use of org.olat.course.editor.CourseEditorEnv in project OpenOLAT by OpenOLAT.
the class InLearningAreaFunction 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.areaname"));
} else if (inStack.length < 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_MORE_ARGUMENTS, name, "", "error.moreargs", "solution.provideone.areaname"));
}
/*
* argument type check
*/
if (!(inStack[0] instanceof String))
return handleException(new ArgumentParseException(ArgumentParseException.WRONG_ARGUMENT_FORMAT, name, "", "error.argtype.areanameexpected", "solution.example.name.infunction"));
String areaName = (String) inStack[0];
areaName = areaName != null ? areaName.trim() : areaName;
/*
* check reference integrity
*/
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
if (!cev.existsArea(areaName)) {
return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, areaName, "error.notfound.name", "solution.checkgroupmanagement"));
}
// remember the reference to the node id for this condtion
cev.addSoftReference("areaId", areaName, false);
// return a valid value to continue with condition evaluation test
return defaultValue();
}
// The real function evaluation which is used during run time
Identity ident = getUserCourseEnv().getIdentityEnvironment().getIdentity();
CourseGroupManager cgm = getUserCourseEnv().getCourseEnvironment().getCourseGroupManager();
if (StringHelper.isLong(areaName)) {
Long areaKey = new Long(areaName);
return cgm.isIdentityInLearningArea(ident, areaKey) ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
}
List<Long> areaKeys = CoreSpringFactory.getImpl(BGAreaManager.class).toAreaKeys(areaName, cgm.getCourseResource());
if (!areaKeys.isEmpty()) {
return cgm.isIdentityInLearningArea(ident, areaKeys.get(0)) ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
}
return ConditionInterpreter.INT_FALSE;
}
use of org.olat.course.editor.CourseEditorEnv in project OpenOLAT by OpenOLAT.
the class IsCourseAdministratorFunction method call.
/**
* @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
*/
@Override
public Object call(Object[] inStack) {
/*
* expression check only if cev != null
*/
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
// return a valid value to continue with condition evaluation test
return defaultValue();
}
boolean isCourseAdmin;
if (inStack != null && inStack.length > 0 && inStack[0] instanceof String && AnyCourseVariable.name.equalsIgnoreCase((String) inStack[0])) {
// administrator of any course
isCourseAdmin = getUserCourseEnv().isAdminOfAnyCourse();
} else {
isCourseAdmin = getUserCourseEnv().isAdmin();
}
if (log.isDebug()) {
Identity ident = getUserCourseEnv().getIdentityEnvironment().getIdentity();
log.debug("identity " + ident.getName() + ", courseadministrator:" + isCourseAdmin + ", in course " + getUserCourseEnv().getCourseEnvironment().getCourseResourceableId());
}
return isCourseAdmin ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
}
use of org.olat.course.editor.CourseEditorEnv in project OpenOLAT by OpenOLAT.
the class IsCourseParticipantFunction method call.
/**
* @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
*/
@Override
public Object call(Object[] inStack) {
/*
* expression check only if cev != null
*/
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
// return a valid value to continue with condition evaluation test
return defaultValue();
}
boolean isParticipant;
if (inStack != null && inStack.length > 0 && inStack[0] instanceof String && AnyCourseVariable.name.equalsIgnoreCase((String) inStack[0])) {
// administrator of any course
isParticipant = getUserCourseEnv().isParticipantOfAnyCourse();
} else {
isParticipant = getUserCourseEnv().isParticipant();
}
if (log.isDebug()) {
Identity ident = getUserCourseEnv().getIdentityEnvironment().getIdentity();
log.debug("identity " + ident.getName() + ", coursecoach:" + isParticipant + ", in course " + getUserCourseEnv().getCourseEnvironment().getCourseResourceableId());
}
return isParticipant ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
}
use of org.olat.course.editor.CourseEditorEnv in project OpenOLAT by OpenOLAT.
the class IsLearningGroupFullFunction 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.groupname"));
} else if (inStack.length < 1) {
return handleException(new ArgumentParseException(ArgumentParseException.NEEDS_MORE_ARGUMENTS, name, "", "error.moreargs", "solution.provideone.groupname"));
}
/*
* argument type check
*/
if (!(inStack[0] instanceof String))
return handleException(new ArgumentParseException(ArgumentParseException.WRONG_ARGUMENT_FORMAT, name, "", "error.argtype.groupnameexpected", "solution.example.name.infunction"));
String groupName = (String) inStack[0];
groupName = groupName != null ? groupName.trim() : null;
/*
* check reference integrity
*/
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
if (!cev.existsGroup(groupName)) {
return handleException(new ArgumentParseException(ArgumentParseException.REFERENCE_NOT_FOUND, name, groupName, "error.notfound.name", "solution.checkgroupmanagement"));
}
// remember the reference to the node id for this condition
cev.addSoftReference("groupId", groupName, false);
// return a valid value to continue with condition evaluation test
return defaultValue();
}
/*
* the real function evaluation which is used during run time
*/
CourseGroupManager cgm = getUserCourseEnv().getCourseEnvironment().getCourseGroupManager();
if (StringHelper.isLong(groupName)) {
Long groupKey = new Long(groupName);
return cgm.isBusinessGroupFull(groupKey) ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
}
List<Long> groupKeys = CoreSpringFactory.getImpl(BusinessGroupService.class).toGroupKeys(groupName, cgm.getCourseEntry());
if (!groupKeys.isEmpty()) {
return cgm.isBusinessGroupFull(groupKeys.get(0)) ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
}
return ConditionInterpreter.INT_FALSE;
}
use of org.olat.course.editor.CourseEditorEnv in project OpenOLAT by OpenOLAT.
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;
}
Aggregations