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());
}
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);
}
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;
}
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;
}
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;
}
Aggregations