use of org.olat.course.nodes.gta.model.TaskDefinition in project OpenOLAT by OpenOLAT.
the class TaskDefinitionTableModel method getValueAt.
@Override
public Object getValueAt(int row, int col) {
TaskDefinitionRow taskDefRow = getObject(row);
TaskDefinition taskDef = taskDefRow.getTaskDefinition();
switch(TDCols.values()[col]) {
case title:
return taskDef.getTitle();
case file:
return taskDefRow.getDownloadLink() == null ? taskDef.getFilename() : taskDefRow.getDownloadLink();
case edit:
return taskDef.getFilename().endsWith(".html");
default:
return "ERROR";
}
}
use of org.olat.course.nodes.gta.model.TaskDefinition in project openolat by klemens.
the class GTAManagerImpl method getTaskDefinitions.
@Override
public List<TaskDefinition> getTaskDefinitions(CourseEnvironment courseEnv, GTACourseNode cNode) {
Path taskDefinitionsPath = Paths.get(FolderConfig.getCanonicalRoot(), courseEnv.getCourseBaseContainer().getRelPath(), "gtasks", cNode.getIdent(), TASKS_DEFINITIONS);
List<TaskDefinition> taskDefinitions = new ArrayList<>();
if (Files.exists(taskDefinitionsPath)) {
TaskDefinitionList taskDefinitionsList = (TaskDefinitionList) taskDefinitionsXstream.fromXML(taskDefinitionsPath.toFile());
if (taskDefinitionsList != null && taskDefinitionsList.getTasks() != null) {
taskDefinitions.addAll(taskDefinitionsList.getTasks());
}
} else {
syncWithTaskList(courseEnv, cNode, new TaskListSynched() {
@Override
public void sync() {
ModuleConfiguration config = cNode.getModuleConfiguration();
TaskDefinitionList tasks = (TaskDefinitionList) config.get(GTACourseNode.GTASK_TASKS);
if (tasks != null) {
taskDefinitions.addAll(tasks.getTasks());
}
storeTaskDefinitions(taskDefinitions, courseEnv, cNode);
}
});
}
return taskDefinitions;
}
use of org.olat.course.nodes.gta.model.TaskDefinition in project openolat by klemens.
the class GTAAvailableTaskController method loadModel.
private void loadModel() {
File taskFolder = gtaManager.getTasksDirectory(courseEnv, gtaNode);
List<AvailableTask> availableTasks = new ArrayList<>(taskDefs.size());
List<String> usedSlotes;
if (GTACourseNode.GTASK_SAMPLING_UNIQUE.equals(gtaNode.getModuleConfiguration().getStringValue(GTACourseNode.GTASK_SAMPLING))) {
usedSlotes = gtaManager.getAssignedTasks(taskList);
} else {
usedSlotes = Collections.emptyList();
}
for (TaskDefinition taskDef : taskDefs) {
String filename = taskDef.getFilename();
if (usedSlotes.contains(filename)) {
continue;
}
FormLink descriptionLink = null;
if (StringHelper.containsNonWhitespace(taskDef.getDescription())) {
descriptionLink = uifactory.addFormLink("preview-" + CodeHelper.getRAMUniqueID(), "description", "task.description", null, flc, Link.LINK);
descriptionLink.setIconLeftCSS("o_icon o_icon_description");
}
FormItem download = null;
boolean preview = gtaNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_PREVIEW);
if (preview) {
if (taskDef.getFilename().endsWith(".html")) {
download = uifactory.addFormLink("prev-html-" + CodeHelper.getRAMUniqueID(), "preview-html", filename, null, flc, Link.LINK | Link.NONTRANSLATED);
download.setUserObject(filename);
} else {
File taskFile = new File(taskFolder, filename);
download = uifactory.addDownloadLink("prev-" + CodeHelper.getRAMUniqueID(), filename, null, taskFile, tableEl);
}
}
AvailableTask wrapper = new AvailableTask(taskDef, descriptionLink, download);
availableTasks.add(wrapper);
if (descriptionLink != null) {
descriptionLink.setUserObject(wrapper);
}
}
taskModel.setObjects(availableTasks);
tableEl.reset();
if (availableTasks.isEmpty()) {
flc.contextPut("noMoreTasks", Boolean.TRUE);
} else {
flc.contextPut("noMoreTasks", Boolean.FALSE);
}
}
use of org.olat.course.nodes.gta.model.TaskDefinition in project openolat by klemens.
the class GTACoachController method stepAssignment.
@Override
protected Task stepAssignment(UserRequest ureq, Task assignedTask) {
assignedTask = super.stepAssignment(ureq, assignedTask);
if (assignedTask == null || assignedTask.getTaskStatus() == TaskProcess.assignment) {
mainVC.contextPut("assignmentCssClass", "o_active");
} else {
mainVC.contextPut("assignmentCssClass", "o_done");
TaskDefinition taskDef = getTaskDefinition(assignedTask);
assignedTaskCtrl = new GTAAssignedTaskController(ureq, getWindowControl(), assignedTask, taskDef, courseEnv, gtaNode, "coach.task.assigned.description", "warning.no.task.choosed.coach", null);
listenTo(assignedTaskCtrl);
mainVC.put("assignedTask", assignedTaskCtrl.getInitialComponent());
}
return assignedTask;
}
use of org.olat.course.nodes.gta.model.TaskDefinition in project openolat by klemens.
the class AbstractAssignmentEditController method updateModel.
protected void updateModel() {
fileExistsRenderer.setFilenames(tasksFolder.list());
List<TaskDefinition> taskDefinitions = gtaManager.getTaskDefinitions(courseEnv, gtaNode);
List<TaskDefinitionRow> rows = new ArrayList<>(taskDefinitions.size());
for (TaskDefinition def : taskDefinitions) {
DownloadLink downloadLink = null;
VFSItem item = tasksContainer.resolve(def.getFilename());
if (item instanceof VFSLeaf) {
downloadLink = uifactory.addDownloadLink("file_" + (++linkCounter), def.getFilename(), null, (VFSLeaf) item, taskDefTableEl);
}
rows.add(new TaskDefinitionRow(def, downloadLink));
}
taskModel.setObjects(rows);
taskDefTableEl.reset();
}
Aggregations