Search in sources :

Example 1 with TaskDefinition

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;
}
Also used : TaskDefinition(org.olat.course.nodes.gta.model.TaskDefinition)

Example 2 with TaskDefinition

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;
}
Also used : TaskDefinition(org.olat.course.nodes.gta.model.TaskDefinition)

Example 3 with TaskDefinition

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();
}
Also used : DownloadLink(org.olat.core.gui.components.form.flexible.elements.DownloadLink) VFSLeaf(org.olat.core.util.vfs.VFSLeaf) TaskDefinition(org.olat.course.nodes.gta.model.TaskDefinition) ArrayList(java.util.ArrayList) VFSItem(org.olat.core.util.vfs.VFSItem)

Example 4 with TaskDefinition

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();
}
Also used : TaskDefinition(org.olat.course.nodes.gta.model.TaskDefinition) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)

Example 5 with TaskDefinition

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);
}
Also used : TaskDefinition(org.olat.course.nodes.gta.model.TaskDefinition) File(java.io.File)

Aggregations

TaskDefinition (org.olat.course.nodes.gta.model.TaskDefinition)32 File (java.io.File)10 ArrayList (java.util.ArrayList)8 Path (java.nio.file.Path)4 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)4 TaskDefinitionList (org.olat.course.nodes.gta.model.TaskDefinitionList)4 ModuleConfiguration (org.olat.modules.ModuleConfiguration)4 IdentityRef (org.olat.basesecurity.IdentityRef)2 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)2 FormItem (org.olat.core.gui.components.form.flexible.FormItem)2 DownloadLink (org.olat.core.gui.components.form.flexible.elements.DownloadLink)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 Identity (org.olat.core.id.Identity)2 VFSContainer (org.olat.core.util.vfs.VFSContainer)2 VFSItem (org.olat.core.util.vfs.VFSItem)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 ICourse (org.olat.course.ICourse)2 StatusDescription (org.olat.course.editor.StatusDescription)2 GTAManager (org.olat.course.nodes.gta.GTAManager)2 CourseEnvironment (org.olat.course.run.environment.CourseEnvironment)2