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