use of org.olat.course.nodes.cl.model.Checkbox in project OpenOLAT by OpenOLAT.
the class CheckboxListStepController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (addLink == source) {
Checkbox checkbox = new Checkbox();
checkbox.setCheckboxId(UUID.randomUUID().toString());
String title = translate("add.checkbox");
doOpenEdit(ureq, checkbox, true, title);
} else if (boxTable == source) {
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
String cmd = se.getCommand();
if ("edit".equals(cmd)) {
CheckboxConfigRow row = model.getObject(se.getIndex());
doOpenEdit(ureq, row.getCheckbox(), false, translate("edit.checkbox"));
}
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.course.nodes.cl.model.Checkbox in project OpenOLAT by OpenOLAT.
the class CheckboxManagerImpl method syncCheckbox.
@Override
public void syncCheckbox(CheckboxList checkboxList, OLATResourceable ores, String resSubPath) {
List<DBCheckbox> dbCheckboxList = loadCheckbox(ores, resSubPath);
Map<String, DBCheckbox> uuids = new HashMap<String, DBCheckbox>();
for (DBCheckbox dbCheckbox : dbCheckboxList) {
uuids.put(dbCheckbox.getCheckboxId(), dbCheckbox);
}
if (checkboxList != null && checkboxList.getList() != null) {
List<Checkbox> resCheckboxList = checkboxList.getList();
for (Checkbox resCheckbox : resCheckboxList) {
String resUuid = resCheckbox.getCheckboxId();
if (uuids.containsKey(resUuid)) {
// already synched
uuids.remove(resUuid);
} else {
createDBCheckbox(resUuid, ores, resSubPath);
}
}
}
for (DBCheckbox dbCheckbox : uuids.values()) {
System.out.println("Remove them??? " + dbCheckbox.getCheckboxId());
}
}
use of org.olat.course.nodes.cl.model.Checkbox in project OpenOLAT by OpenOLAT.
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.model.Checkbox in project OpenOLAT by OpenOLAT.
the class CheckListCourseNode method postCopy.
@Override
public void postCopy(CourseEnvironmentMapper envMapper, Processing processType, ICourse course, ICourse sourceCourse) {
ModuleConfiguration config = getModuleConfiguration();
CheckboxManager checkboxManager = CoreSpringFactory.getImpl(CheckboxManager.class);
CheckboxList list = (CheckboxList) config.get(CONFIG_KEY_CHECKBOX);
if (list != null && list.getList().size() > 0) {
for (Checkbox checkbox : list.getList()) {
String sourceId = checkbox.getCheckboxId();
String targetId = envMapper.getTargetUniqueKey(getIdent(), sourceId);
if (targetId == null) {
targetId = UUID.randomUUID().toString();
envMapper.addUniqueKeyPair(getIdent(), sourceId, targetId);
}
checkbox.setCheckboxId(targetId);
}
}
// the ident of the course node is the same
File sourceDir = checkboxManager.getFileDirectory(sourceCourse.getCourseEnvironment(), this);
if (sourceDir.exists()) {
File targetDir = checkboxManager.getFileDirectory(course.getCourseEnvironment(), this);
if (!targetDir.exists()) {
targetDir.mkdirs();
FileUtils.copyDirContentsToDir(sourceDir, targetDir, false, "copy files of checkbox");
}
}
checkboxManager.syncCheckbox(list, course, getIdent());
super.postCopy(envMapper, processType, course, sourceCourse);
}
use of org.olat.course.nodes.cl.model.Checkbox in project OpenOLAT by OpenOLAT.
the class CheckListCourseNode method importNode.
@Override
public void importNode(File importDirectory, ICourse course, Identity owner, Locale locale, boolean withReferences) {
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 fFileImportDir = new File(importDirectory, "checklistfiles/" + getIdent() + "/" + checkbox.getCheckboxId());
String newCheckboxId = UUID.randomUUID().toString();
checkbox.setCheckboxId(newCheckboxId);
if (fFileImportDir.exists()) {
File dir = checkboxManager.getFileDirectory(course.getCourseEnvironment(), this);
dir.mkdirs();
FileUtils.copyDirContentsToDir(fFileImportDir, dir, false, "import file of checkbox");
}
}
}
}
Aggregations