use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.
the class ScoreAccounting method evalScoreOfCourseNode.
/**
* Evaluate the score of the course element. The method
* takes the visibility of the results in account and will
* return 0.0 if the results are not visiblity.
*
* @param childId The specified course element ident
* @return A float (never null)
*/
public Float evalScoreOfCourseNode(String childId) {
CourseNode foundNode = findChildByID(childId);
Float score = null;
if (foundNode instanceof AssessableCourseNode) {
AssessableCourseNode acn = (AssessableCourseNode) foundNode;
ScoreEvaluation se = evalCourseNode(acn);
if (se != null) {
// the node could not provide any sensible information on scoring. e.g. a STNode with no calculating rules
if (se.getUserVisible() == null || se.getUserVisible().booleanValue()) {
score = se.getScore();
} else {
score = new Float(0.0f);
}
}
if (score == null) {
// a child has no score yet
// default to 0.0, so that the condition can be evaluated (zero points makes also the most sense for "no results yet", if to be expressed in a number)
score = new Float(0.0f);
}
} else {
error = true;
score = new Float(0.0f);
}
return score;
}
use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.
the class ScoreAccounting method evalPassedOfCourseNode.
/**
* Evaluate the passed / failed state of a course element. The method
* takes the visibility of the results in account and will return false
* if the results are not visible.
*
* @param childId The specified course element ident
* @return true/false never null
*/
public Boolean evalPassedOfCourseNode(String childId) {
CourseNode foundNode = findChildByID(childId);
if (foundNode == null) {
error = true;
return Boolean.FALSE;
}
if (!(foundNode instanceof AssessableCourseNode)) {
error = true;
return Boolean.FALSE;
}
AssessableCourseNode acn = (AssessableCourseNode) foundNode;
ScoreEvaluation se = evalCourseNode(acn);
if (se == null) {
// the node could not provide any sensible information on scoring. e.g. a STNode with no calculating rules
log.error("could not evaluate node '" + acn.getShortTitle() + "' (" + acn.getClass().getName() + "," + childId + ")", null);
return Boolean.FALSE;
}
// check if the results are visible
if (se.getUserVisible() != null && !se.getUserVisible().booleanValue()) {
return Boolean.FALSE;
}
Boolean passed = se.getPassed();
if (passed == null) {
// a child has no "Passed" yet
passed = Boolean.FALSE;
}
return passed;
}
use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.
the class ScoreAccounting method evaluateAll.
public boolean evaluateAll(boolean update) {
Identity identity = userCourseEnvironment.getIdentityEnvironment().getIdentity();
List<AssessmentEntry> entries = userCourseEnvironment.getCourseEnvironment().getAssessmentManager().getAssessmentEntries(identity);
AssessableTreeVisitor visitor = new AssessableTreeVisitor(entries, update);
// collect all assessable nodes and eval 'em
CourseNode root = userCourseEnvironment.getCourseEnvironment().getRunStructure().getRootNode();
// breadth first traversal gives an easier order of evaluation for debugging
// however, for live it is absolutely mandatory to use depth first since using breadth first
// the score accoutings local cache hash map will never be used. this can slow down things like
// crazy (course with 10 tests, 300 users and some crazy score and passed calculations will have
// 10 time performance differences)
cachedScoreEvals.clear();
for (AssessmentEntry entry : entries) {
String nodeIdent = entry.getSubIdent();
CourseNode courseNode = userCourseEnvironment.getCourseEnvironment().getRunStructure().getNode(nodeIdent);
if (courseNode instanceof AssessableCourseNode) {
AssessableCourseNode acn = (AssessableCourseNode) courseNode;
AssessmentEvaluation se = AssessmentEvaluation.toAssessmentEvalutation(entry, acn);
cachedScoreEvals.put(acn, se);
}
}
// true=depth first
TreeVisitor tv = new TreeVisitor(visitor, root, true);
tv.visitAll();
return visitor.hasChanges();
}
use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.
the class ScoreRuleEditor method searchScoreableNodes.
private void searchScoreableNodes(CourseNode courseNode, List<CourseNode> nodes) {
if (courseNode instanceof AssessableCourseNode) {
AssessableCourseNode assessableCourseNode = (AssessableCourseNode) courseNode;
if (assessableCourseNode.hasScoreConfigured()) {
nodes.add(courseNode);
}
}
for (int i = 0; i < courseNode.getChildCount(); i++) {
CourseNode child = (CourseNode) courseNode.getChildAt(i);
searchScoreableNodes(child, nodes);
}
}
use of org.olat.course.nodes.AssessableCourseNode in project OpenOLAT by OpenOLAT.
the class IdentityAssessmentOverviewController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (tableEl == source) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
String cmd = se.getCommand();
AssessmentNodeData nodeData = tableModel.getObject(se.getIndex());
if (CMD_SELECT_NODE.equals(cmd)) {
CourseNode node = runStructure.getNode(nodeData.getIdent());
selectedCourseNode = (AssessableCourseNode) node;
fireEvent(ureq, EVENT_NODE_SELECTED);
}
}
}
super.formInnerEvent(ureq, source, event);
}
Aggregations