Search in sources :

Example 66 with CourseEditorEnv

use of org.olat.course.editor.CourseEditorEnv in project openolat by klemens.

the class NowVariable method getValue.

/**
 * @see com.neemsoft.jmep.VariableCB#getValue()
 */
public Object getValue() {
    CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
    if (cev != null) {
        return new Double(0);
    }
    CourseEnvironment ce = getUserCourseEnv().getCourseEnvironment();
    long time = ce.getCurrentTimeMillis();
    return new Double(time);
}
Also used : CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) CourseEditorEnv(org.olat.course.editor.CourseEditorEnv)

Example 67 with CourseEditorEnv

use of org.olat.course.editor.CourseEditorEnv in project openolat by klemens.

the class GetAttemptsFunction method call.

/**
 * @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
 */
@Override
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 nodeId = (String) inStack[0];
    /*
		 * check reference integrity
		 */
    CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
    if (cev != null) {
        if (!cev.existsNode(nodeId)) {
            return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, nodeId, "error.notfound.coursenodeid", "solution.copypastenodeid"));
        }
        // Allow self-referencing but do not allow dependencies to parents as they create cycles.
        if (!nodeId.equals(cev.getCurrentCourseNodeId())) {
            cev.addSoftReference("courseNodeId", nodeId, false);
        }
        // return a valid value to continue with condition evaluation test
        return defaultValue();
    }
    /*
		 * the real function evaluation which is used during run time
		 */
    CourseNode node = getUserCourseEnv().getCourseEnvironment().getRunStructure().getNode(nodeId);
    AssessmentManager am = getUserCourseEnv().getCourseEnvironment().getAssessmentManager();
    Identity identity = getUserCourseEnv().getIdentityEnvironment().getIdentity();
    return am.getNodeAttempts(node, identity);
}
Also used : CourseEditorEnv(org.olat.course.editor.CourseEditorEnv) AssessmentManager(org.olat.course.assessment.AssessmentManager) CourseNode(org.olat.course.nodes.CourseNode) Identity(org.olat.core.id.Identity)

Example 68 with CourseEditorEnv

use of org.olat.course.editor.CourseEditorEnv in project openolat by klemens.

the class EditScoreCalculationExpertForm method validateFormLogic.

@Override
public boolean validateFormLogic(UserRequest ureq) {
    String scoreExp = tscoreexpr.getValue().trim();
    if (StringHelper.containsNonWhitespace(scoreExp)) {
        CourseEditorEnv cev = euce.getCourseEditorEnv();
        ConditionExpression ce = new ConditionExpression("score", scoreExp);
        ConditionErrorMessage[] cerrmsgs = cev.validateConditionExpression(ce);
        if (cerrmsgs != null && cerrmsgs.length > 0) {
            setKeys(ureq, tscoreexpr, cerrmsgs);
            return false;
        }
        testElemWithNoResource = getInvalidNodeDescriptions(ce);
    }
    String passedExp = tpassedexpr.getValue().trim();
    if (StringHelper.containsNonWhitespace(passedExp)) {
        CourseEditorEnv cev = euce.getCourseEditorEnv();
        ConditionExpression ce = new ConditionExpression("passed", passedExp);
        ConditionErrorMessage[] cerrmsgs = cev.validateConditionExpression(ce);
        if (cerrmsgs != null && cerrmsgs.length > 0) {
            setKeys(ureq, tpassedexpr, cerrmsgs);
            return false;
        }
    }
    // reset HINTS
    tscoreexpr.setExampleKey("rules.example", EXAMPLE_SCORE);
    tpassedexpr.setExampleKey("rules.example", EXAMPLE_PASSED);
    return true;
}
Also used : CourseEditorEnv(org.olat.course.editor.CourseEditorEnv) ConditionExpression(org.olat.course.condition.interpreter.ConditionExpression) ConditionErrorMessage(org.olat.course.condition.interpreter.ConditionErrorMessage)

Aggregations

CourseEditorEnv (org.olat.course.editor.CourseEditorEnv)68 Identity (org.olat.core.id.Identity)32 ArgumentParseException (org.olat.course.condition.interpreter.ArgumentParseException)10 CourseGroupManager (org.olat.course.groupsandrights.CourseGroupManager)8 CourseNode (org.olat.course.nodes.CourseNode)8 Date (java.util.Date)6 BusinessGroupService (org.olat.group.BusinessGroupService)6 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)4 User (org.olat.core.id.User)4 AssessmentManager (org.olat.course.assessment.AssessmentManager)4 UserCourseInformations (org.olat.course.assessment.UserCourseInformations)4 UserEfficiencyStatement (org.olat.course.assessment.UserEfficiencyStatement)4 EfficiencyStatementManager (org.olat.course.assessment.manager.EfficiencyStatementManager)4 UserCourseInformationsManager (org.olat.course.assessment.manager.UserCourseInformationsManager)4 ConditionErrorMessage (org.olat.course.condition.interpreter.ConditionErrorMessage)4 ConditionExpression (org.olat.course.condition.interpreter.ConditionExpression)4 ENCourseNode (org.olat.course.nodes.ENCourseNode)4 STCourseNode (org.olat.course.nodes.STCourseNode)4 CoursePropertyManager (org.olat.course.properties.CoursePropertyManager)4 CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)4