use of org.olat.course.run.scoring.ScoreAccounting in project OpenOLAT by OpenOLAT.
the class CourseAssessmentWebService method getRootResult.
private AssessableResultsVO getRootResult(Identity identity, ICourse course, CourseNode courseNode) {
AssessableResultsVO results = new AssessableResultsVO();
results.setIdentityKey(identity.getKey());
// create an identenv with no roles, no attributes, no locale
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(identity);
UserCourseEnvironment userCourseEnvironment = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
// Fetch all score and passed and calculate score accounting for the entire course
ScoreAccounting scoreAccounting = userCourseEnvironment.getScoreAccounting();
scoreAccounting.evaluateAll();
if (courseNode instanceof AssessableCourseNode) {
AssessableCourseNode assessableRootNode = (AssessableCourseNode) courseNode;
ScoreEvaluation scoreEval = scoreAccounting.evalCourseNode(assessableRootNode);
results.setScore(scoreEval.getScore());
results.setPassed(scoreEval.getPassed());
results.setLastModifiedDate(getLastModificationDate(identity, course, courseNode));
}
return results;
}
use of org.olat.course.run.scoring.ScoreAccounting in project openolat by klemens.
the class GetScoreFunction method call.
/**
* @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
*/
public Object call(Object[] inStack) {
/*
* argument check
*/
if (inStack.length > 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_FEWER_ARGUMENTS, name, "", "error.fewerargs", "solution.provideone.nodereference"));
} else if (inStack.length < 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_MORE_ARGUMENTS, name, "", "error.moreargs", "solution.provideone.nodereference"));
}
/*
* argument type check
*/
if (!(inStack[0] instanceof String))
return handleException(new ArgumentParseException(ArgumentParseException.WRONG_ARGUMENT_FORMAT, name, "", "error.argtype.coursnodeidexpeted", "solution.example.node.infunction"));
String childId = (String) inStack[0];
/*
* check reference integrity
*/
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
if (!cev.existsNode(childId)) {
return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, childId, "error.notfound.coursenodeid", "solution.copypastenodeid"));
}
if (!cev.isAssessable(childId)) {
return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, childId, "error.notassessable.coursenodid", "solution.takeassessablenode"));
}
// dependencies to parents as they create cycles.
if (!childId.equals(cev.getCurrentCourseNodeId()) || cev.getNode(cev.getCurrentCourseNodeId()) instanceof STCourseNode) {
cev.addSoftReference("courseNodeId", childId, true);
}
// return a valid value to continue with condition evaluation test
return defaultValue();
}
/*
* the real function evaluation which is used during run time
*/
ScoreAccounting sa = getUserCourseEnv().getScoreAccounting();
Float score = sa.evalScoreOfCourseNode(childId);
return new Double(score);
}
use of org.olat.course.run.scoring.ScoreAccounting in project openolat by klemens.
the class GetPassedFunction method call.
/**
* @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
*/
public Object call(Object[] inStack) {
/*
* argument check
*/
if (inStack.length > 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_FEWER_ARGUMENTS, name, "", "error.fewerargs", "solution.provideone.nodereference"));
} else if (inStack.length < 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_MORE_ARGUMENTS, name, "", "error.moreargs", "solution.provideone.nodereference"));
}
/*
* argument type check
*/
if (!(inStack[0] instanceof String))
return handleException(new ArgumentParseException(ArgumentParseException.WRONG_ARGUMENT_FORMAT, name, "", "error.argtype.coursnodeidexpeted", "solution.example.node.infunction"));
String childId = (String) inStack[0];
/*
* check reference integrity
*/
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
if (!cev.existsNode(childId)) {
return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, childId, "error.notfound.coursenodeid", "solution.copypastenodeid"));
}
if (!cev.isAssessable(childId)) {
return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, childId, "error.notassessable.coursenodid", "solution.takeassessablenode"));
}
// dependencies to parents as they create cycles.
if (!childId.equals(cev.getCurrentCourseNodeId()) || cev.getNode(cev.getCurrentCourseNodeId()) instanceof STCourseNode) {
cev.addSoftReference("courseNodeId", childId, true);
}
// return a valid value to continue with condition evaluation test
return defaultValue();
}
/*
* the real function evaluation which is used during run time
*/
ScoreAccounting sa = getUserCourseEnv().getScoreAccounting();
Boolean passed = sa.evalPassedOfCourseNode(childId);
return (passed.booleanValue() ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE);
}
use of org.olat.course.run.scoring.ScoreAccounting in project openolat by klemens.
the class CourseAssessmentWebService method getRootResult.
private AssessableResultsVO getRootResult(Identity identity, ICourse course, CourseNode courseNode) {
AssessableResultsVO results = new AssessableResultsVO();
results.setIdentityKey(identity.getKey());
// create an identenv with no roles, no attributes, no locale
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(identity);
UserCourseEnvironment userCourseEnvironment = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
// Fetch all score and passed and calculate score accounting for the entire course
ScoreAccounting scoreAccounting = userCourseEnvironment.getScoreAccounting();
scoreAccounting.evaluateAll();
if (courseNode instanceof AssessableCourseNode) {
AssessableCourseNode assessableRootNode = (AssessableCourseNode) courseNode;
ScoreEvaluation scoreEval = scoreAccounting.evalCourseNode(assessableRootNode);
results.setScore(scoreEval.getScore());
results.setPassed(scoreEval.getPassed());
results.setLastModifiedDate(getLastModificationDate(identity, course, courseNode));
}
return results;
}
use of org.olat.course.run.scoring.ScoreAccounting in project openolat by klemens.
the class AssessmentHelper method getAssessmentNodeDataList.
/**
* Add all assessable nodes and the scoring data to a list. Each item in the list is an object array
* that has the following data:
* @param recursionLevel
* @param courseNode
* @param userCourseEnv
* @param discardEmptyNodes
* @param discardComments
* @return list of object arrays or null if empty
*/
public static List<AssessmentNodeData> getAssessmentNodeDataList(UserCourseEnvironment userCourseEnv, AssessmentNodesLastModified lastModifications, boolean followUserVisibility, boolean discardEmptyNodes, boolean discardComments) {
List<AssessmentNodeData> data = new ArrayList<AssessmentNodeData>(50);
ScoreAccounting scoreAccounting = userCourseEnv.getScoreAccounting();
scoreAccounting.evaluateAll();
getAssessmentNodeDataList(0, userCourseEnv.getCourseEnvironment().getRunStructure().getRootNode(), scoreAccounting, userCourseEnv, followUserVisibility, discardEmptyNodes, discardComments, data, lastModifications);
return data;
}
Aggregations