use of org.olat.course.nodes.cl.CheckboxManager in project openolat by klemens.
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 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");
}
}
}
}
use of org.olat.course.nodes.cl.CheckboxManager in project openolat by klemens.
the class CheckListCourseNode method updateOnPublish.
@Override
public void updateOnPublish(Locale locale, ICourse course, Identity publisher, PublishEvents publishEvents) {
ModuleConfiguration config = getModuleConfiguration();
// sync the checkbox with the database
CheckboxList list = (CheckboxList) config.get(CONFIG_KEY_CHECKBOX);
CheckboxManager checkboxManager = CoreSpringFactory.getImpl(CheckboxManager.class);
checkboxManager.syncCheckbox(list, course, getIdent());
CoursePropertyManager pm = course.getCourseEnvironment().getCoursePropertyManager();
List<Identity> assessedUsers = pm.getAllIdentitiesWithCourseAssessmentData(null);
int count = 0;
for (Identity assessedIdentity : assessedUsers) {
updateScorePassedOnPublish(assessedIdentity, publisher, checkboxManager, course);
if (++count % 10 == 0) {
DBFactory.getInstance().commitAndCloseSession();
}
}
DBFactory.getInstance().commitAndCloseSession();
super.updateOnPublish(locale, course, publisher, publishEvents);
}
use of org.olat.course.nodes.cl.CheckboxManager in project openolat by klemens.
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.CheckboxManager in project OpenOLAT by OpenOLAT.
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