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);
}
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);
}
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;
}
Aggregations