Search in sources :

Example 16 with Checklist

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

the class ChecklistCourseNode method exportNode.

@Override
public void exportNode(File exportDirectory, ICourse course) {
    XStream xstream = XStreamHelper.createXStreamInstance();
    ChecklistManager cm = ChecklistManager.getInstance();
    Checklist checklist = loadOrCreateChecklist(course.getCourseEnvironment().getCoursePropertyManager());
    Checklist copy = cm.copyChecklistInRAM(checklist);
    String exportContent = xstream.toXML(copy);
    ExportUtil.writeContentToFile(getExportFilename(), exportContent, exportDirectory, WebappHelper.getDefaultCharset());
}
Also used : XStream(com.thoughtworks.xstream.XStream) ChecklistManager(de.bps.olat.modules.cl.ChecklistManager) Checklist(de.bps.olat.modules.cl.Checklist)

Example 17 with Checklist

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

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 18 with Checklist

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

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 19 with Checklist

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

Example 20 with Checklist

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

the class ChecklistCourseNode method createInstanceForCopy.

@Override
public CourseNode createInstanceForCopy(boolean isNewTitle, ICourse course, Identity author) {
    CourseNode copyInstance = super.createInstanceForCopy(isNewTitle, course, author);
    ChecklistManager cm = ChecklistManager.getInstance();
    // load checklist
    Checklist checklist = cm.loadChecklist((Checklist) getModuleConfiguration().get(ChecklistCourseNode.CONF_CHECKLIST));
    // remove old config
    copyInstance.getModuleConfiguration().remove(ChecklistCourseNode.CONF_CHECKLIST);
    // create new checklist with same settings and save to db
    Checklist initialChecklist = cm.copyChecklist(checklist);
    // set to config
    copyInstance.getModuleConfiguration().set(CONF_CHECKLIST_COPY, initialChecklist);
    return copyInstance;
}
Also used : ChecklistManager(de.bps.olat.modules.cl.ChecklistManager) Checklist(de.bps.olat.modules.cl.Checklist) CourseNode(org.olat.course.nodes.CourseNode) AbstractAccessableCourseNode(org.olat.course.nodes.AbstractAccessableCourseNode)

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