use of org.olat.course.nodes.cl.CheckboxManager in project OpenOLAT by OpenOLAT.
the class CheckListCourseNode method createInstanceForCopy.
@Override
public CourseNode createInstanceForCopy(boolean isNewTitle, ICourse course, Identity author) {
CheckListCourseNode cNode = (CheckListCourseNode) super.createInstanceForCopy(isNewTitle, course, author);
CheckboxManager checkboxManager = CoreSpringFactory.getImpl(CheckboxManager.class);
CheckboxList list = (CheckboxList) cNode.getModuleConfiguration().get(CONFIG_KEY_CHECKBOX);
if (list != null) {
for (Checkbox checkbox : list.getList()) {
checkbox.setCheckboxId(UUID.randomUUID().toString());
}
}
// the ident of the course node is the same
File sourceDir = checkboxManager.getFileDirectory(course.getCourseEnvironment(), this);
if (sourceDir.exists()) {
File targetDir = checkboxManager.getFileDirectory(course.getCourseEnvironment(), cNode);
if (!targetDir.exists()) {
targetDir.mkdirs();
FileUtils.copyDirContentsToDir(sourceDir, targetDir, false, "copy files of checkbox");
}
}
return cNode;
}
use of org.olat.course.nodes.cl.CheckboxManager in project openolat by klemens.
the class CheckListCourseNode method exportNode.
@Override
public void exportNode(File fExportDirectory, ICourse course) {
// export the files
CheckboxManager checkboxManager = CoreSpringFactory.getImpl(CheckboxManager.class);
ModuleConfiguration config = getModuleConfiguration();
CheckboxList list = (CheckboxList) config.get(CONFIG_KEY_CHECKBOX);
if (list != null && list.getList() != null) {
for (Checkbox checkbox : list.getList()) {
File dir = checkboxManager.getFileDirectory(course.getCourseEnvironment(), this);
if (dir.exists()) {
File fFileExportDir = new File(fExportDirectory, "checklistfiles/" + getIdent() + "/" + checkbox.getCheckboxId());
fFileExportDir.mkdirs();
FileUtils.copyDirContentsToDir(dir, fFileExportDir, false, "export files of checkbox");
}
}
}
}
use of org.olat.course.nodes.cl.CheckboxManager in project openolat by klemens.
the class CheckListCourseNode method archiveNodeData.
/**
* Make an archive of all datas.
*/
@Override
public boolean archiveNodeData(Locale locale, ICourse course, ArchiveOptions options, ZipOutputStream exportStream, String charset) {
String dirName = "cl_" + StringHelper.transformDisplayNameToFileSystemName(getShortName()) + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis()));
ModuleConfiguration config = getModuleConfiguration();
CheckboxList list = (CheckboxList) config.get(CONFIG_KEY_CHECKBOX);
CheckboxManager checkboxManager = CoreSpringFactory.getImpl(CheckboxManager.class);
if (list != null && list.getList() != null) {
Set<String> usedNames = new HashSet<>();
for (Checkbox checkbox : list.getList()) {
VFSContainer dir = checkboxManager.getFileContainer(course.getCourseEnvironment(), this);
if (dir != null) {
VFSItem item = dir.resolve(checkbox.getFilename());
if (item instanceof VFSLeaf) {
String path = dirName + "/" + Formatter.makeStringFilesystemSave(checkbox.getTitle());
if (usedNames.contains(checkbox.getTitle())) {
path += "_" + checkbox.getCheckboxId();
} else {
usedNames.add(checkbox.getTitle());
}
ZipUtil.addToZip(item, path, exportStream);
}
}
}
}
String filename = dirName + "/" + StringHelper.transformDisplayNameToFileSystemName(getShortName());
new CheckListExcelExport(this, course, locale).exportAll(filename, exportStream);
// assessment documents
if (hasIndividualAsssessmentDocuments()) {
List<AssessmentEntry> assessmentEntries = course.getCourseEnvironment().getAssessmentManager().getAssessmentEntries(this);
if (assessmentEntries != null && !assessmentEntries.isEmpty()) {
String assessmentDirName = dirName + "/Assessment_documents";
for (AssessmentEntry assessmentEntry : assessmentEntries) {
Identity assessedIdentity = assessmentEntry.getIdentity();
List<File> assessmentDocuments = course.getCourseEnvironment().getAssessmentManager().getIndividualAssessmentDocuments(this, assessedIdentity);
String name = assessedIdentity.getUser().getLastName() + "_" + assessedIdentity.getUser().getFirstName() + "_" + assessedIdentity.getName();
String userDirName = assessmentDirName + "/" + StringHelper.transformDisplayNameToFileSystemName(name);
if (assessmentDocuments != null && !assessmentDocuments.isEmpty()) {
for (File document : assessmentDocuments) {
String path = userDirName + "/" + document.getName();
ZipUtil.addFileToZip(path, document, exportStream);
}
}
}
}
}
return super.archiveNodeData(locale, course, options, exportStream, charset);
}
use of org.olat.course.nodes.cl.CheckboxManager in project openolat by klemens.
the class CheckListCourseNode method doUpdateAssessment.
private void doUpdateAssessment(Float cutValue, Float maxScore, Identity identity, UserCourseEnvironment assessedUserCourseEnv, Identity assessedIdentity, Role by) {
OLATResourceable courseOres = OresHelper.createOLATResourceableInstance("CourseModule", assessedUserCourseEnv.getCourseEnvironment().getCourseResourceableId());
CheckboxManager checkboxManager = CoreSpringFactory.getImpl(CheckboxManager.class);
float score = checkboxManager.calculateScore(assessedIdentity, courseOres, getIdent());
if (maxScore != null && maxScore.floatValue() < score) {
score = maxScore.floatValue();
}
Boolean passed = null;
if (cutValue != null) {
boolean aboveCutValue = score >= cutValue.floatValue();
passed = Boolean.valueOf(aboveCutValue);
}
ScoreEvaluation sceval = new ScoreEvaluation(Float.valueOf(score), passed);
AssessmentManager am = assessedUserCourseEnv.getCourseEnvironment().getAssessmentManager();
am.saveScoreEvaluation(this, identity, assessedIdentity, sceval, assessedUserCourseEnv, false, by);
}
use of org.olat.course.nodes.cl.CheckboxManager in project openolat by klemens.
the class CheckListStepRunnerCallback method execute.
@Override
public Step execute(UserRequest ureq, WindowControl wControl, StepsRunContext runContext) {
GeneratorData data = (GeneratorData) runContext.get("data");
List<Checkbox> templateCheckbox = data.getCheckboxList();
ModuleConfiguration templateConfig = data.getModuleConfiguration();
ICourse course = CourseFactory.getCourseEditSession(courseOres.getResourceableId());
CourseEnvironment courseEnv = course.getCourseEnvironment();
CheckboxManager checkboxManager = CoreSpringFactory.getImpl(CheckboxManager.class);
CourseNode structureNode = createCourseNode(data.getStructureShortTitle(), data.getStructureTitle(), data.getStructureObjectives(), "st");
CourseEditorTreeNode parentNode = (CourseEditorTreeNode) course.getEditorTreeModel().getRootNode();
course.getEditorTreeModel().addCourseNode(structureNode, parentNode.getCourseNode());
List<CheckListNode> nodes = data.getNodes();
List<String> nodesIdent = new ArrayList<>();
for (CheckListNode node : nodes) {
String title = node.getTitle();
CheckListCourseNode checkNode = (CheckListCourseNode) createCourseNode(title, title, null, "checklist");
nodesIdent.add(checkNode.getIdent());
ModuleConfiguration config = checkNode.getModuleConfiguration();
config.putAll(templateConfig);
CheckboxList checkboxList = new CheckboxList();
List<Checkbox> boxes = new ArrayList<>();
for (Checkbox templateBox : templateCheckbox) {
Checkbox checkbox = templateBox.clone();
boxes.add(checkbox);
if (StringHelper.containsNonWhitespace(templateBox.getFilename())) {
File path = new File(FolderConfig.getCanonicalTmpDir(), templateBox.getCheckboxId());
VFSContainer tmpContainer = new LocalFolderImpl(path);
VFSItem item = tmpContainer.resolve(templateBox.getFilename());
if (item instanceof VFSLeaf) {
VFSContainer container = checkboxManager.getFileContainer(courseEnv, checkNode);
VFSManager.copyContent(tmpContainer, container);
tmpContainer.deleteSilently();
}
}
}
checkboxList.setList(boxes);
config.set(CheckListCourseNode.CONFIG_KEY_CHECKBOX, checkboxList);
boolean dueDate = node.getDueDate() != null;
if (dueDate) {
config.set(CheckListCourseNode.CONFIG_KEY_DUE_DATE, node.getDueDate());
}
config.set(CheckListCourseNode.CONFIG_KEY_CLOSE_AFTER_DUE_DATE, new Boolean(dueDate));
course.getEditorTreeModel().addCourseNode(checkNode, structureNode);
}
setScoreCalculation(data, (STCourseNode) structureNode, nodesIdent);
return StepsMainRunController.DONE_MODIFIED;
}
Aggregations