use of org.olat.course.editor.CourseEditorEnv in project openolat by klemens.
the class GetPassedWithCourseIdFunction method call.
/**
* @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
*/
public Object call(Object[] inStack) {
/*
* argument check
*/
if (inStack.length > 2) {
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
*/
Long courseRepoEntryKey;
try {
Object arg = inStack[0];
if (arg instanceof Number) {
courseRepoEntryKey = new Long(((Number) arg).longValue());
} else if (arg instanceof String) {
courseRepoEntryKey = Long.decode((String) arg);
} else {
courseRepoEntryKey = null;
}
} catch (NumberFormatException nfe) {
return handleException(new ArgumentParseException(ArgumentParseException.WRONG_ARGUMENT_FORMAT, name, "", "error.argtype.coursnodeidexpeted", "solution.example.node.infunction"));
}
/*
* no integrity check can be done - other course might not exist anymore
*/
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
return defaultValue();
}
/*
* the real function evaluation which is used during run time
*/
EfficiencyStatementManager esm = CoreSpringFactory.getImpl(EfficiencyStatementManager.class);
RepositoryEntryRef courseRef = new RepositoryEntryRefImpl(courseRepoEntryKey);
UserEfficiencyStatement es = esm.getUserEfficiencyStatementLightByRepositoryEntry(courseRef, getUserCourseEnv().getIdentityEnvironment().getIdentity());
if (es == null)
return defaultValue();
Boolean passed = es.getPassed();
if (passed == null) {
return defaultValue();
}
// finally check existing value
return passed.booleanValue() ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
}
use of org.olat.course.editor.CourseEditorEnv 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.editor.CourseEditorEnv in project openolat by klemens.
the class Sleep method call.
/**
* @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
*/
public Object call(Object[] inStack) {
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
// return a valid value to continue with condition evaluation test
return defaultValue();
} else if (Settings.isDebuging()) {
long sleep = 30000;
if (inStack == null || inStack.length == 0) {
// stay with default
} else if (inStack[0] instanceof String) {
String sleepStr = (String) inStack[0];
sleep = Long.parseLong(sleepStr);
}
try {
Thread.sleep(sleep);
} catch (InterruptedException e) {
log.error("", e);
}
}
return ConditionInterpreter.INT_TRUE;
}
use of org.olat.course.editor.CourseEditorEnv in project openolat by klemens.
the class TodayVariable 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();
Date date = new Date(time);
Date day = DateUtils.truncate(date, Calendar.DATE);
Double dDay = new Double(day.getTime());
return dDay;
}
use of org.olat.course.editor.CourseEditorEnv 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);
}
Aggregations