Search in sources :

Example 6 with Checklist

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

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

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

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

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

the class ChecklistCourseNode method loadOrCreateChecklist.

/**
 * Load referenced checklist or create a new one
 * @param cpm
 * @return Checklist
 */
public Checklist loadOrCreateChecklist(final CoursePropertyManager cpm) {
    Checklist checklist;
    if (getChecklistKey(cpm) == null) {
        // this is a copied node, the checklist is referenced by createInstanceForCopy()
        if (getModuleConfiguration().get(CONF_CHECKLIST_COPY) != null) {
            checklist = ChecklistManager.getInstance().loadChecklist((Checklist) getModuleConfiguration().get(ChecklistCourseNode.CONF_CHECKLIST_COPY));
            getModuleConfiguration().remove(CONF_CHECKLIST_COPY);
        } else // this is part of a copied course, the original checklist will be copied
        if (getModuleConfiguration().get(CONF_CHECKLIST) != null) {
            Checklist confChecklist = (Checklist) getModuleConfiguration().get(ChecklistCourseNode.CONF_CHECKLIST);
            Checklist orgChecklist = ChecklistManager.getInstance().loadChecklist(confChecklist);
            checklist = ChecklistManager.getInstance().copyChecklist(orgChecklist);
        } else {
            // no checklist available, create new one
            checklist = new Checklist();
            ChecklistManager.getInstance().saveChecklist(checklist);
        }
        // set referenced checklist in configuration
        setChecklistKey(cpm, checklist.getKey());
    } else {
        checklist = ChecklistManager.getInstance().loadChecklist(getChecklistKey(cpm));
    }
    return checklist;
}
Also used : Checklist(de.bps.olat.modules.cl.Checklist)

Example 9 with Checklist

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

the class ChecklistEditController method event.

/**
 * {@inheritDoc}
 */
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == accessibilityCondContr) {
        if (event == Event.CHANGED_EVENT) {
            Condition cond = accessibilityCondContr.getCondition();
            courseNode.setPreConditionAccess(cond);
            fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
        }
    } else if (source == checklistFormContr && event == Event.CHANGED_EVENT) {
        // checklist = ChecklistManager.getInstance().saveChecklist(checklist);
        fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
    } else if (source == manageController && event == Event.DONE_EVENT) {
        cmcManage.deactivate();
    } else if (event == NodeEditController.NODECONFIG_CHANGED_EVENT) {
        // update title and description according to the course node
        Checklist cl = ChecklistManager.getInstance().loadChecklist(checklist);
        cl.setTitle(courseNode.getShortTitle());
        cl.setDescription(courseNode.getLongTitle());
        checklist = ChecklistManager.getInstance().saveChecklist(cl);
    }
}
Also used : Condition(org.olat.course.condition.Condition) Checklist(de.bps.olat.modules.cl.Checklist)

Example 10 with Checklist

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

the class ChecklistCourseNode method loadOrCreateChecklist.

/**
 * Load referenced checklist or create a new one
 * @param cpm
 * @return Checklist
 */
public Checklist loadOrCreateChecklist(final CoursePropertyManager cpm) {
    Checklist checklist;
    if (getChecklistKey(cpm) == null) {
        // this is a copied node, the checklist is referenced by createInstanceForCopy()
        if (getModuleConfiguration().get(CONF_CHECKLIST_COPY) != null) {
            checklist = ChecklistManager.getInstance().loadChecklist((Checklist) getModuleConfiguration().get(ChecklistCourseNode.CONF_CHECKLIST_COPY));
            getModuleConfiguration().remove(CONF_CHECKLIST_COPY);
        } else // this is part of a copied course, the original checklist will be copied
        if (getModuleConfiguration().get(CONF_CHECKLIST) != null) {
            Checklist confChecklist = (Checklist) getModuleConfiguration().get(ChecklistCourseNode.CONF_CHECKLIST);
            Checklist orgChecklist = ChecklistManager.getInstance().loadChecklist(confChecklist);
            checklist = ChecklistManager.getInstance().copyChecklist(orgChecklist);
        } else {
            // no checklist available, create new one
            checklist = new Checklist();
            ChecklistManager.getInstance().saveChecklist(checklist);
        }
        // set referenced checklist in configuration
        setChecklistKey(cpm, checklist.getKey());
    } else {
        checklist = ChecklistManager.getInstance().loadChecklist(getChecklistKey(cpm));
    }
    return checklist;
}
Also used : Checklist(de.bps.olat.modules.cl.Checklist)

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