use of org.olat.course.editor.CourseEditorEnv in project openolat by klemens.
the class IsAssessmentModeFunction 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();
}
WindowControl wControl = getUserCourseEnv().getWindowControl();
if (wControl == null) {
return ConditionInterpreter.INT_FALSE;
}
ChiefController chiefController = wControl.getWindowBackOffice().getChiefController();
if (chiefController == null) {
return ConditionInterpreter.INT_FALSE;
}
OLATResourceable lockedResource = chiefController.getLockResource();
if (lockedResource == null) {
return ConditionInterpreter.INT_FALSE;
}
Long resourceableId = getUserCourseEnv().getCourseEnvironment().getCourseResourceableId();
if (lockedResource.getResourceableId().equals(resourceableId)) {
RepositoryEntry entry = getUserCourseEnv().getCourseEnvironment().getCourseGroupManager().getCourseEntry();
AssessmentModeManager assessmentModeMgr = CoreSpringFactory.getImpl(AssessmentModeManager.class);
boolean inAssessment = assessmentModeMgr.isInAssessmentMode(entry, new Date());
return inAssessment ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
} else {
return ConditionInterpreter.INT_FALSE;
}
}
use of org.olat.course.editor.CourseEditorEnv in project openolat by klemens.
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 klemens.
the class IsCourseCoachFunction 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 isCourseCoach;
if (inStack != null && inStack.length > 0 && inStack[0] instanceof String && AnyCourseVariable.name.equalsIgnoreCase((String) inStack[0])) {
// administrator of any course
isCourseCoach = getUserCourseEnv().isCoachOfAnyCourse();
} else {
isCourseCoach = getUserCourseEnv().isCoach();
}
if (log.isDebug()) {
Identity ident = getUserCourseEnv().getIdentityEnvironment().getIdentity();
log.debug("identity " + ident.getName() + ", coursecoach:" + isCourseCoach + ", in course " + getUserCourseEnv().getCourseEnvironment().getCourseResourceableId());
}
return isCourseCoach ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
}
use of org.olat.course.editor.CourseEditorEnv in project openolat by klemens.
the class IsGuestFunction method call.
/**
* @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
*/
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 isGuest = getUserCourseEnv().getIdentityEnvironment().getRoles().isGuestOnly();
return isGuest ? ConditionInterpreter.INT_TRUE : ConditionInterpreter.INT_FALSE;
}
use of org.olat.course.editor.CourseEditorEnv in project openolat by klemens.
the class GetCourseBeginDateFunction method call.
/**
* @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
*/
@Override
public Object call(Object[] inStack) {
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
return defaultValue();
}
RepositoryEntryLifecycle lifecycle = getUserCourseEnv().getLifecycle();
if (lifecycle != null && lifecycle.getValidFrom() != null) {
return Double.valueOf(lifecycle.getValidFrom().getTime());
} else {
// what to do in case of no date available??? -> return date in the future
return new Double(Double.POSITIVE_INFINITY);
}
}
Aggregations