Search in sources :

Example 21 with TaskDefinition

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

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

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

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

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

the class EditTaskController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    task.setTitle(titleEl.getValue());
    task.setDescription(descriptionEl.getValue());
    if (fileEl.getUploadFile() != null) {
        if (replaceFile && StringHelper.containsNonWhitespace(task.getFilename())) {
            int usage = 0;
            if (currentDefinitions != null) {
                for (TaskDefinition definition : currentDefinitions) {
                    if (task.getFilename().equals(definition.getFilename())) {
                        usage++;
                    }
                }
            }
            if (usage == 1) {
                File currentFile = new File(taskContainer, task.getFilename());
                if (currentFile.exists()) {
                    currentFile.delete();
                }
            }
        }
        String filename = fileEl.getUploadFileName();
        task.setFilename(filename);
        try {
            Path upload = fileEl.getUploadFile().toPath();
            File target = new File(taskContainer, filename);
            Files.move(upload, target.toPath(), StandardCopyOption.REPLACE_EXISTING);
        } catch (Exception ex) {
            logError("", ex);
        }
    }
    fireEvent(ureq, Event.DONE_EVENT);
}
Also used : Path(java.nio.file.Path) TaskDefinition(org.olat.course.nodes.gta.model.TaskDefinition) File(java.io.File)

Example 24 with TaskDefinition

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

the class GTACourseNode method validateInternalConfiguration.

private List<StatusDescription> validateInternalConfiguration(CourseEditorEnv cev) {
    List<StatusDescription> sdList = new ArrayList<>(5);
    ModuleConfiguration config = getModuleConfiguration();
    boolean hasScoring = config.getBooleanSafe(GTASK_GRADING);
    if (hasScoring) {
        if (!config.getBooleanSafe(MSCourseNode.CONFIG_KEY_HAS_SCORE_FIELD) && !config.getBooleanSafe(MSCourseNode.CONFIG_KEY_HAS_PASSED_FIELD) && !config.getBooleanSafe(MSCourseNode.CONFIG_KEY_HAS_COMMENT_FIELD)) {
            addStatusErrorDescription("error.missing.score.config", GTAEditController.PANE_TAB_GRADING, sdList);
        }
    }
    if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
        List<Long> groupKeys = config.getList(GTACourseNode.GTASK_GROUPS, Long.class);
        List<Long> areaKeys = config.getList(GTACourseNode.GTASK_AREAS, Long.class);
        if (groupKeys.isEmpty() && areaKeys.isEmpty()) {
            addStatusErrorDescription("error.missing.group", GTAEditController.PANE_TAB_GRADING, sdList);
        }
    }
    // at least one step
    if (!config.getBooleanSafe(GTACourseNode.GTASK_ASSIGNMENT) && !config.getBooleanSafe(GTACourseNode.GTASK_SUBMIT) && !config.getBooleanSafe(GTACourseNode.GTASK_REVIEW_AND_CORRECTION) && !config.getBooleanSafe(GTACourseNode.GTASK_REVISION_PERIOD) && !config.getBooleanSafe(GTACourseNode.GTASK_SAMPLE_SOLUTION) && !config.getBooleanSafe(GTACourseNode.GTASK_GRADING)) {
        addStatusErrorDescription("error.select.atleastonestep", GTAEditController.PANE_TAB_WORKLOW, sdList);
    }
    if (cev != null) {
        // check assignment
        GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
        RepositoryEntry courseRe = cev.getCourseGroupManager().getCourseEntry();
        ICourse course = CourseFactory.loadCourse(courseRe);
        if (config.getBooleanSafe(GTACourseNode.GTASK_ASSIGNMENT)) {
            File taskDirectory = gtaManager.getTasksDirectory(course.getCourseEnvironment(), this);
            if (!TaskHelper.hasDocuments(taskDirectory)) {
                if (config.getBooleanSafe(GTACourseNode.GTASK_COACH_ALLOWED_UPLOAD_TASKS, false)) {
                    addStatusWarningDescription("error.missing.tasks", GTAEditController.PANE_TAB_ASSIGNMENT, sdList);
                } else {
                    addStatusErrorDescription("error.missing.tasks", GTAEditController.PANE_TAB_ASSIGNMENT, sdList);
                }
            } else {
                List<TaskDefinition> taskList = gtaManager.getTaskDefinitions(course.getCourseEnvironment(), this);
                if (taskList == null || taskList.isEmpty()) {
                    if (config.getBooleanSafe(GTACourseNode.GTASK_COACH_ALLOWED_UPLOAD_TASKS, false)) {
                        addStatusWarningDescription("error.missing.tasks", GTAEditController.PANE_TAB_ASSIGNMENT, sdList);
                    } else {
                        addStatusErrorDescription("error.missing.tasks", GTAEditController.PANE_TAB_ASSIGNMENT, sdList);
                    }
                } else {
                    String[] filenames = taskDirectory.list();
                    for (TaskDefinition taskDef : taskList) {
                        boolean found = false;
                        for (String filename : filenames) {
                            if (filename.equals(taskDef.getFilename())) {
                                found = true;
                                break;
                            }
                        }
                        if (!found) {
                            addStatusWarningDescription("error.missing.file", GTAEditController.PANE_TAB_ASSIGNMENT, sdList);
                        }
                    }
                }
            }
        }
        // check solutions
        if (config.getBooleanSafe(GTACourseNode.GTASK_SAMPLE_SOLUTION)) {
            File solutionDirectory = gtaManager.getSolutionsDirectory(course.getCourseEnvironment(), this);
            if (!TaskHelper.hasDocuments(solutionDirectory)) {
                if (config.getBooleanSafe(GTACourseNode.GTASK_COACH_ALLOWED_UPLOAD_TASKS, false)) {
                    addStatusWarningDescription("error.missing.solutions", GTAEditController.PANE_TAB_SOLUTIONS, sdList);
                } else {
                    addStatusErrorDescription("error.missing.solutions", GTAEditController.PANE_TAB_SOLUTIONS, sdList);
                }
            }
        }
        List<IdentityRef> participants = gtaManager.getDuplicatedMemberships(this);
        if (participants.size() > 0) {
            UserManager um = CoreSpringFactory.getImpl(UserManager.class);
            StringBuilder sb = new StringBuilder();
            for (IdentityRef participant : participants) {
                String fullname = um.getUserDisplayName(participant.getKey());
                if (sb.length() > 0)
                    sb.append(", ");
                sb.append(fullname);
            }
            String[] params = new String[] { getShortTitle(), sb.toString() };
            StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.duplicate.memberships", "error.duplicate.memberships", params, PACKAGE_GTA);
            sd.setDescriptionForUnit(getIdent());
            sd.setActivateableViewIdentifier(GTAEditController.PANE_TAB_WORKLOW);
            sdList.add(sd);
        }
    }
    return sdList;
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) TaskDefinition(org.olat.course.nodes.gta.model.TaskDefinition) StatusDescription(org.olat.course.editor.StatusDescription) UserManager(org.olat.user.UserManager) IdentityRef(org.olat.basesecurity.IdentityRef) GTAManager(org.olat.course.nodes.gta.GTAManager) File(java.io.File)

Example 25 with TaskDefinition

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

the class GTAParticipantController method showAssignedTask.

private void showAssignedTask(UserRequest ureq, Task assignedTask) {
    String message = gtaNode.getModuleConfiguration().getStringValue(GTACourseNode.GTASK_USERS_TEXT);
    TaskDefinition taskDef = getTaskDefinition(assignedTask);
    assignedTaskCtrl = new GTAAssignedTaskController(ureq, getWindowControl(), assignedTask, taskDef, courseEnv, gtaNode, "task.assigned.description", "warning.no.task.choosed", message);
    listenTo(assignedTaskCtrl);
    mainVC.put("myAssignedTask", assignedTaskCtrl.getInitialComponent());
}
Also used : TaskDefinition(org.olat.course.nodes.gta.model.TaskDefinition)

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