Search in sources :

Example 11 with TaskDefinition

use of org.olat.course.nodes.gta.model.TaskDefinition in project openolat by klemens.

the class AbstractAssignmentEditController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (addTaskCtrl == source) {
        if (event == Event.DONE_EVENT) {
            TaskDefinition newTask = addTaskCtrl.getTask();
            gtaManager.addTaskDefinition(newTask, courseEnv, gtaNode);
            fireEvent(ureq, Event.DONE_EVENT);
            updateModel();
            notificationsManager.markPublisherNews(subscriptionContext, null, false);
        }
        cmc.deactivate();
        cleanUp();
    // fireEvent(ureq, Event.DONE_EVENT);
    } else if (editTaskCtrl == source) {
        if (event == Event.DONE_EVENT) {
            doFinishReplacementOfTask(editTaskCtrl.getFilenameToReplace(), editTaskCtrl.getTask());
            updateModel();
            // fireEvent(ureq, Event.DONE_EVENT);
            notificationsManager.markPublisherNews(subscriptionContext, null, false);
        }
        cmc.deactivate();
        cleanUp();
    } else if (newTaskCtrl == source) {
        TaskDefinition newTask = newTaskCtrl.getTaskDefinition();
        cmc.deactivate();
        cleanUp();
        if (event == Event.DONE_EVENT) {
            gtaManager.addTaskDefinition(newTask, courseEnv, gtaNode);
            doCreateTaskEditor(ureq, newTask);
            updateModel();
        }
    } else if (newTaskEditorCtrl == source) {
        if (event == Event.DONE_EVENT) {
            updateModel();
            // fireEvent(ureq, Event.DONE_EVENT);
            notificationsManager.markPublisherNews(subscriptionContext, null, false);
        }
        cmc.deactivate();
        cleanUp();
    } else if (editTaskEditorCtrl == source) {
        if (event == Event.DONE_EVENT) {
            gtaManager.updateTaskDefinition(null, editTaskEditorCtrl.getTask(), courseEnv, gtaNode);
            updateModel();
            // fireEvent(ureq, Event.DONE_EVENT);
            notificationsManager.markPublisherNews(subscriptionContext, null, false);
        }
        cmc.deactivate();
        cleanUp();
    } else if (confirmDeleteCtrl == source) {
        if (DialogBoxUIFactory.isOkEvent(event) || DialogBoxUIFactory.isYesEvent(event)) {
            TaskDefinition row = (TaskDefinition) confirmDeleteCtrl.getUserObject();
            doDelete(ureq, row);
        }
        cleanUp();
    } else if (cmc == source) {
        cleanUp();
    }
    super.event(ureq, source, event);
}
Also used : TaskDefinition(org.olat.course.nodes.gta.model.TaskDefinition)

Example 12 with TaskDefinition

use of org.olat.course.nodes.gta.model.TaskDefinition in project openolat by klemens.

the class AbstractAssignmentEditController method doReplaceTask.

private void doReplaceTask(UserRequest ureq, TaskDefinition taskDef) {
    List<TaskDefinition> currentDefinitions = gtaManager.getTaskDefinitions(courseEnv, gtaNode);
    editTaskCtrl = new EditTaskController(ureq, getWindowControl(), taskDef, tasksFolder, currentDefinitions);
    listenTo(editTaskCtrl);
    String title = translate("edit.task");
    cmc = new CloseableModalController(getWindowControl(), null, editTaskCtrl.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 13 with TaskDefinition

use of org.olat.course.nodes.gta.model.TaskDefinition in project openolat by klemens.

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 14 with TaskDefinition

use of org.olat.course.nodes.gta.model.TaskDefinition in project openolat by klemens.

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

Example 15 with TaskDefinition

use of org.olat.course.nodes.gta.model.TaskDefinition in project OpenOLAT by OpenOLAT.

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