use of org.olat.course.nodes.gta.model.TaskDefinitionList in project openolat by klemens.
the class ConvertToGTACourseNode method convertTasks.
private void convertTasks(TaskList taskList, TACourseNode sourceNode, GTACourseNode gtaNode, ICourse course) {
File taskFolder = new File(FolderConfig.getCanonicalRoot(), TACourseNode.getTaskFolderPathRelToFolderRoot(course, sourceNode));
OlatRootFolderImpl taskContainer = new OlatRootFolderImpl(TACourseNode.getTaskFolderPathRelToFolderRoot(course, sourceNode), null);
CourseEnvironment courseEnv = course.getCourseEnvironment();
File gtaskDirectory = gtaManager.getTasksDirectory(courseEnv, gtaNode);
VFSContainer gtaskContainer = gtaManager.getTasksContainer(courseEnv, gtaNode);
// make the task
TaskDefinitionList taskDefs = new TaskDefinitionList();
for (File task : taskFolder.listFiles(SystemFileFilter.FILES_ONLY)) {
TaskDefinition taskDef = new TaskDefinition();
taskDef.setDescription("");
taskDef.setFilename(task.getName());
taskDef.setTitle(task.getName());
taskDefs.getTasks().add(taskDef);
try {
File target = new File(gtaskDirectory, task.getName());
Files.copy(task.toPath(), target.toPath(), StandardCopyOption.REPLACE_EXISTING);
convertMetada(taskContainer, gtaskContainer, task.getName(), taskDef, null);
} catch (Exception ex) {
log.error("", ex);
}
List<Property> samples = courseEnv.getCoursePropertyManager().listCourseNodeProperties(sourceNode, null, null, TaskController.PROP_ASSIGNED);
for (Property sample : samples) {
File taskFile = new File(gtaskDirectory, sample.getStringValue());
Identity id = securityManager.loadIdentityByKey(sample.getIdentity().getKey());
gtaManager.selectTask(id, taskList, gtaNode, taskFile);
}
}
gtaNode.getModuleConfiguration().set(GTACourseNode.GTASK_TASKS, taskDefs);
}
Aggregations