Search in sources :

Example 6 with ScoreAccounting

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;
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) AssessableResultsVO(org.olat.restapi.support.vo.AssessableResultsVO) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ScoreAccounting(org.olat.course.run.scoring.ScoreAccounting) IdentityEnvironment(org.olat.core.id.IdentityEnvironment)

Example 7 with ScoreAccounting

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);
}
Also used : CourseEditorEnv(org.olat.course.editor.CourseEditorEnv) STCourseNode(org.olat.course.nodes.STCourseNode) ArgumentParseException(org.olat.course.condition.interpreter.ArgumentParseException) ScoreAccounting(org.olat.course.run.scoring.ScoreAccounting)

Example 8 with ScoreAccounting

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);
}
Also used : CourseEditorEnv(org.olat.course.editor.CourseEditorEnv) STCourseNode(org.olat.course.nodes.STCourseNode) ArgumentParseException(org.olat.course.condition.interpreter.ArgumentParseException) ScoreAccounting(org.olat.course.run.scoring.ScoreAccounting)

Example 9 with ScoreAccounting

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;
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) AssessableResultsVO(org.olat.restapi.support.vo.AssessableResultsVO) ScoreEvaluation(org.olat.course.run.scoring.ScoreEvaluation) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ScoreAccounting(org.olat.course.run.scoring.ScoreAccounting) IdentityEnvironment(org.olat.core.id.IdentityEnvironment)

Example 10 with ScoreAccounting

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;
}
Also used : ArrayList(java.util.ArrayList) ScoreAccounting(org.olat.course.run.scoring.ScoreAccounting) AssessmentNodeData(org.olat.course.assessment.model.AssessmentNodeData)

Aggregations

ScoreAccounting (org.olat.course.run.scoring.ScoreAccounting)18 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)12 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)8 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)8 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)6 STCourseNode (org.olat.course.nodes.STCourseNode)6 UserCourseEnvironmentImpl (org.olat.course.run.userview.UserCourseEnvironmentImpl)6 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 ICourse (org.olat.course.ICourse)4 AssessmentManager (org.olat.course.assessment.AssessmentManager)4 AssessmentNodeData (org.olat.course.assessment.model.AssessmentNodeData)4 CertificateTemplate (org.olat.course.certificate.CertificateTemplate)4 CertificateInfos (org.olat.course.certificate.model.CertificateInfos)4 ArgumentParseException (org.olat.course.condition.interpreter.ArgumentParseException)4 CourseEditorEnv (org.olat.course.editor.CourseEditorEnv)4 CourseNode (org.olat.course.nodes.CourseNode)4 CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)4 File (java.io.File)2 IOException (java.io.IOException)2