Search in sources :

Example 56 with CourseEditorEnv

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;
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) CourseEditorEnv(org.olat.course.editor.CourseEditorEnv) ChiefController(org.olat.core.gui.control.ChiefController) RepositoryEntry(org.olat.repository.RepositoryEntry) WindowControl(org.olat.core.gui.control.WindowControl) AssessmentModeManager(org.olat.course.assessment.AssessmentModeManager) Date(java.util.Date)

Example 57 with CourseEditorEnv

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;
}
Also used : CourseEditorEnv(org.olat.course.editor.CourseEditorEnv) Identity(org.olat.core.id.Identity)

Example 58 with CourseEditorEnv

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;
}
Also used : CourseEditorEnv(org.olat.course.editor.CourseEditorEnv) Identity(org.olat.core.id.Identity)

Example 59 with CourseEditorEnv

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;
}
Also used : CourseEditorEnv(org.olat.course.editor.CourseEditorEnv)

Example 60 with CourseEditorEnv

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);
    }
}
Also used : CourseEditorEnv(org.olat.course.editor.CourseEditorEnv) RepositoryEntryLifecycle(org.olat.repository.model.RepositoryEntryLifecycle)

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