use of org.olat.course.nodes.gta.model.TaskDefinition in project OpenOLAT by OpenOLAT.
the class GTAParticipantController method getTaskDefinition.
private TaskDefinition getTaskDefinition(Task task) {
if (task == null)
return null;
TaskDefinition taskDef = null;
List<TaskDefinition> availableTasks = gtaManager.getTaskDefinitions(courseEnv, gtaNode);
for (TaskDefinition availableTask : availableTasks) {
if (availableTask.getFilename() != null && availableTask.getFilename().equals(task.getTaskName())) {
taskDef = availableTask;
break;
}
}
return taskDef;
}
use of org.olat.course.nodes.gta.model.TaskDefinition in project OpenOLAT by OpenOLAT.
the class NewTaskController method getTaskDefinition.
public TaskDefinition getTaskDefinition() {
TaskDefinition taskDef = new TaskDefinition();
taskDef.setTitle(titleEl.getValue());
taskDef.setFilename(getFilename());
taskDef.setDescription(descriptionEl.getValue());
return taskDef;
}
use of org.olat.course.nodes.gta.model.TaskDefinition in project OpenOLAT by OpenOLAT.
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();
}
use of org.olat.course.nodes.gta.model.TaskDefinition in project OpenOLAT by OpenOLAT.
the class AbstractAssignmentEditController method doAddTask.
private void doAddTask(UserRequest ureq) {
List<TaskDefinition> currentDefinitions = gtaManager.getTaskDefinitions(courseEnv, gtaNode);
addTaskCtrl = new EditTaskController(ureq, getWindowControl(), tasksFolder, currentDefinitions);
listenTo(addTaskCtrl);
String title = translate("add.task");
cmc = new CloseableModalController(getWindowControl(), null, addTaskCtrl.getInitialComponent(), true, title, false);
listenTo(cmc);
cmc.activate();
}
use of org.olat.course.nodes.gta.model.TaskDefinition in project OpenOLAT by OpenOLAT.
the class EditTaskController method validateFormLogic.
@Override
protected boolean validateFormLogic(UserRequest ureq) {
boolean allOk = true;
titleEl.clearError();
if (!StringHelper.containsNonWhitespace(titleEl.getValue())) {
titleEl.setErrorKey("form.mandatory.hover", null);
allOk &= false;
}
fileEl.clearError();
if (fileEl.getInitialFile() == null && fileEl.getUploadFile() == null) {
fileEl.setErrorKey("form.mandatory.hover", null);
allOk &= false;
} else if (!FileUtils.validateFilename(fileEl.getUploadFileName())) {
fileEl.setErrorKey("error.file.invalid", null);
allOk = false;
} else if (!replaceFile && fileEl.getUploadFile() != null) {
String filename = fileEl.getUploadFileName();
File target = new File(taskContainer, filename);
if (target.exists()) {
fileEl.setErrorKey("error.file.exists", new String[] { filename });
allOk &= false;
}
} else if (replaceFile && fileEl.getUploadFile() != null) {
String filename = fileEl.getUploadFileName();
if (currentDefinitions != null) {
for (TaskDefinition definition : currentDefinitions) {
if (filename.equals(definition.getFilename()) && !task.getTitle().equals(definition.getTitle())) {
fileEl.setErrorKey("error.file.exists", new String[] { filename });
allOk &= false;
}
}
}
}
return allOk & super.validateFormLogic(ureq);
}
Aggregations