Search in sources :

Example 11 with Checklist

use of de.bps.olat.modules.cl.Checklist 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 12 with Checklist

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

the class ChecklistCourseNode method cleanupOnDelete.

@Override
public void cleanupOnDelete(ICourse course) {
    super.cleanupOnDelete(course);
    // delete checklist in db
    Checklist checklist = loadOrCreateChecklist(course.getCourseEnvironment().getCoursePropertyManager());
    ChecklistManager.getInstance().deleteChecklist(checklist);
    checklist = null;
    // delete node configuration
    deleteChecklistKeyConf(course.getCourseEnvironment().getCoursePropertyManager());
}
Also used : Checklist(de.bps.olat.modules.cl.Checklist)

Example 13 with Checklist

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

the class ChecklistCourseNode method archiveNodeData.

@Override
public boolean archiveNodeData(Locale locale, ICourse course, ArchiveOptions options, ZipOutputStream exportStream, String charset) {
    String filename = "checklist_" + StringHelper.transformDisplayNameToFileSystemName(getShortName()) + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis()));
    Checklist checklist = loadOrCreateChecklist(course.getCourseEnvironment().getCoursePropertyManager());
    String exportContent = XStreamHelper.createXStreamInstance().toXML(checklist);
    try {
        exportStream.putNextEntry(new ZipEntry(filename));
        IOUtils.write(exportContent, exportStream);
        exportStream.closeEntry();
    } catch (IOException e) {
        log.error("", e);
    }
    return true;
}
Also used : ZipEntry(java.util.zip.ZipEntry) Checklist(de.bps.olat.modules.cl.Checklist) IOException(java.io.IOException) Date(java.util.Date)

Example 14 with Checklist

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

the class ChecklistCourseNode method createNodeRunConstructionResult.

@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
    ICourse course = CourseFactory.loadCourse(userCourseEnv.getCourseEnvironment().getCourseResourceableId());
    CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
    boolean canEdit = ureq.getUserSession().getRoles().isOLATAdmin() || cgm.isIdentityCourseAdministrator(ureq.getIdentity());
    boolean canManage;
    if (canEdit) {
        canManage = true;
    } else {
        canManage = cgm.isIdentityCourseCoach(ureq.getIdentity()) || cgm.hasRight(ureq.getIdentity(), CourseRights.RIGHT_GROUPMANAGEMENT);
    }
    Checklist checklist = loadOrCreateChecklist(userCourseEnv.getCourseEnvironment().getCoursePropertyManager());
    ChecklistDisplayController checkController = new ChecklistDisplayController(ureq, wControl, checklist, canEdit, canManage, userCourseEnv.isCourseReadOnly(), course);
    checkController.addLoggingResourceable(LoggingResourceable.wrap(this));
    // Add title and descrition
    Controller controller = TitledWrapperHelper.getWrapper(ureq, wControl, checkController, this, "o_cl_icon");
    return new NodeRunConstructionResult(controller);
}
Also used : ChecklistDisplayController(de.bps.olat.modules.cl.ChecklistDisplayController) CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) Checklist(de.bps.olat.modules.cl.Checklist) ICourse(org.olat.course.ICourse) NodeEditController(org.olat.course.editor.NodeEditController) ConditionEditController(org.olat.course.condition.ConditionEditController) TabbableController(org.olat.core.gui.control.generic.tabbable.TabbableController) ChecklistDisplayController(de.bps.olat.modules.cl.ChecklistDisplayController) ChecklistEditController(de.bps.course.nodes.cl.ChecklistEditController) Controller(org.olat.core.gui.control.Controller) NodeRunConstructionResult(org.olat.course.run.navigation.NodeRunConstructionResult)

Example 15 with Checklist

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

the class ChecklistCourseNode method importNode.

@Override
public void importNode(File importDirectory, ICourse course, Identity owner, Locale locale, boolean withReferences) {
    CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
    if (getChecklistKey(cpm) != null)
        deleteChecklistKeyConf(cpm);
    File importFile = new File(importDirectory, getExportFilename());
    String importContent = FileUtils.load(importFile, WebappHelper.getDefaultCharset());
    if (importContent == null || importContent.isEmpty()) {
        return;
    }
    XStream xstream = XStreamHelper.createXStreamInstance();
    Checklist checklist = (Checklist) xstream.fromXML(importContent);
    if (checklist != null) {
        checklist = ChecklistManager.getInstance().copyChecklist(checklist);
        setChecklistKey(cpm, checklist.getKey());
    }
}
Also used : XStream(com.thoughtworks.xstream.XStream) Checklist(de.bps.olat.modules.cl.Checklist) File(java.io.File) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager)

Aggregations

Checklist (de.bps.olat.modules.cl.Checklist)20 XStream (com.thoughtworks.xstream.XStream)4 ChecklistEditController (de.bps.course.nodes.cl.ChecklistEditController)4 ChecklistManager (de.bps.olat.modules.cl.ChecklistManager)4 Condition (org.olat.course.condition.Condition)4 ChecklistDisplayController (de.bps.olat.modules.cl.ChecklistDisplayController)2 Checkpoint (de.bps.olat.modules.cl.Checkpoint)2 File (java.io.File)2 IOException (java.io.IOException)2 Date (java.util.Date)2 ZipEntry (java.util.zip.ZipEntry)2 Controller (org.olat.core.gui.control.Controller)2 TabbableController (org.olat.core.gui.control.generic.tabbable.TabbableController)2 ICourse (org.olat.course.ICourse)2 ConditionEditController (org.olat.course.condition.ConditionEditController)2 NodeEditController (org.olat.course.editor.NodeEditController)2 StatusDescription (org.olat.course.editor.StatusDescription)2 CourseGroupManager (org.olat.course.groupsandrights.CourseGroupManager)2 AbstractAccessableCourseNode (org.olat.course.nodes.AbstractAccessableCourseNode)2 CourseNode (org.olat.course.nodes.CourseNode)2