Search in sources :

Example 1 with Checkpoint

use of de.bps.olat.modules.cl.Checkpoint in project OpenOLAT by OpenOLAT.

the class ChecklistCourseNode method isConfigValid.

public StatusDescription isConfigValid() {
    if (oneClickStatusCache != null) {
        return oneClickStatusCache[0];
    }
    StatusDescription sd = StatusDescription.NOERROR;
    String transPackage = ChecklistEditController.class.getPackage().getName();
    // no configuration available hence there is no checklist with checkpoints
    if (getModuleConfiguration().get(ChecklistCourseNode.CONF_CHECKLIST) == null) {
        sd = new StatusDescription(ValidationStatus.ERROR, "config.nocheckpoints.short", "config.nocheckpoints.long", null, transPackage);
        sd.setDescriptionForUnit(getIdent());
        sd.setActivateableViewIdentifier(ChecklistEditController.PANE_TAB_CLCONFIG);
        return sd;
    }
    Checklist checklist = (Checklist) getModuleConfiguration().get(ChecklistCourseNode.CONF_CHECKLIST);
    // checklist without any checkpoints makes no sense
    if (!checklist.hasCheckpoints()) {
        sd = new StatusDescription(ValidationStatus.ERROR, "config.nocheckpoints.short", "config.nocheckpoints.long", null, transPackage);
        sd.setDescriptionForUnit(getIdent());
        sd.setActivateableViewIdentifier(ChecklistEditController.PANE_TAB_CLCONFIG);
        return sd;
    }
    // information, if all checkpoints are invisible
    boolean allUnvisible = true;
    boolean noLearners = false;
    if (checklist.hasCheckpoints()) {
        List<Checkpoint> checkpoints = ((Checklist) getModuleConfiguration().get(ChecklistCourseNode.CONF_CHECKLIST)).getCheckpoints();
        for (Checkpoint checkpoint : checkpoints) {
            if (!checkpoint.getMode().equals(CheckpointMode.MODE_HIDDEN))
                allUnvisible = false;
        }
        if (allUnvisible) {
            Condition cond = getPreConditionVisibility();
            if (cond.isEasyModeCoachesAndAdmins())
                noLearners = true;
            if (!noLearners) {
                sd = new StatusDescription(ValidationStatus.WARNING, "config.allhidden.short", "config.allhidden.long", null, transPackage);
                sd.setDescriptionForUnit(getIdent());
                sd.setActivateableViewIdentifier(ChecklistEditController.PANE_TAB_CLCONFIG);
            }
        }
    }
    return sd;
}
Also used : Condition(org.olat.course.condition.Condition) Checkpoint(de.bps.olat.modules.cl.Checkpoint) StatusDescription(org.olat.course.editor.StatusDescription) Checklist(de.bps.olat.modules.cl.Checklist) ChecklistEditController(de.bps.course.nodes.cl.ChecklistEditController)

Example 2 with Checkpoint

use of de.bps.olat.modules.cl.Checkpoint in project openolat by klemens.

the class ChecklistCourseNode method isConfigValid.

public StatusDescription isConfigValid() {
    if (oneClickStatusCache != null) {
        return oneClickStatusCache[0];
    }
    StatusDescription sd = StatusDescription.NOERROR;
    String transPackage = ChecklistEditController.class.getPackage().getName();
    // no configuration available hence there is no checklist with checkpoints
    if (getModuleConfiguration().get(ChecklistCourseNode.CONF_CHECKLIST) == null) {
        sd = new StatusDescription(ValidationStatus.ERROR, "config.nocheckpoints.short", "config.nocheckpoints.long", null, transPackage);
        sd.setDescriptionForUnit(getIdent());
        sd.setActivateableViewIdentifier(ChecklistEditController.PANE_TAB_CLCONFIG);
        return sd;
    }
    Checklist checklist = (Checklist) getModuleConfiguration().get(ChecklistCourseNode.CONF_CHECKLIST);
    // checklist without any checkpoints makes no sense
    if (!checklist.hasCheckpoints()) {
        sd = new StatusDescription(ValidationStatus.ERROR, "config.nocheckpoints.short", "config.nocheckpoints.long", null, transPackage);
        sd.setDescriptionForUnit(getIdent());
        sd.setActivateableViewIdentifier(ChecklistEditController.PANE_TAB_CLCONFIG);
        return sd;
    }
    // information, if all checkpoints are invisible
    boolean allUnvisible = true;
    boolean noLearners = false;
    if (checklist.hasCheckpoints()) {
        List<Checkpoint> checkpoints = ((Checklist) getModuleConfiguration().get(ChecklistCourseNode.CONF_CHECKLIST)).getCheckpoints();
        for (Checkpoint checkpoint : checkpoints) {
            if (!checkpoint.getMode().equals(CheckpointMode.MODE_HIDDEN))
                allUnvisible = false;
        }
        if (allUnvisible) {
            Condition cond = getPreConditionVisibility();
            if (cond.isEasyModeCoachesAndAdmins())
                noLearners = true;
            if (!noLearners) {
                sd = new StatusDescription(ValidationStatus.WARNING, "config.allhidden.short", "config.allhidden.long", null, transPackage);
                sd.setDescriptionForUnit(getIdent());
                sd.setActivateableViewIdentifier(ChecklistEditController.PANE_TAB_CLCONFIG);
            }
        }
    }
    return sd;
}
Also used : Condition(org.olat.course.condition.Condition) Checkpoint(de.bps.olat.modules.cl.Checkpoint) StatusDescription(org.olat.course.editor.StatusDescription) Checklist(de.bps.olat.modules.cl.Checklist) ChecklistEditController(de.bps.course.nodes.cl.ChecklistEditController)

Aggregations

ChecklistEditController (de.bps.course.nodes.cl.ChecklistEditController)2 Checklist (de.bps.olat.modules.cl.Checklist)2 Checkpoint (de.bps.olat.modules.cl.Checkpoint)2 Condition (org.olat.course.condition.Condition)2 StatusDescription (org.olat.course.editor.StatusDescription)2