Search in sources :

Example 16 with TaskDefinition

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

the class GTACoachController 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 17 with TaskDefinition

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

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

Example 18 with TaskDefinition

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

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)

Example 19 with TaskDefinition

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

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;
}
Also used : Path(java.nio.file.Path) TaskDefinition(org.olat.course.nodes.gta.model.TaskDefinition) ModuleConfiguration(org.olat.modules.ModuleConfiguration) ArrayList(java.util.ArrayList) TaskDefinitionList(org.olat.course.nodes.gta.model.TaskDefinitionList)

Example 20 with TaskDefinition

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

the class ConvertToGTACourseNode method convertTasks.

private void convertTasks(TaskList taskList, TACourseNode sourceNode, GTACourseNode gtaNode, ICourse course) {
    File taskFolder = new File(FolderConfig.getCanonicalRoot(), TACourseNode.getTaskFolderPathRelToFolderRoot(course, sourceNode));
    OlatRootFolderImpl taskContainer = new OlatRootFolderImpl(TACourseNode.getTaskFolderPathRelToFolderRoot(course, sourceNode), null);
    CourseEnvironment courseEnv = course.getCourseEnvironment();
    File gtaskDirectory = gtaManager.getTasksDirectory(courseEnv, gtaNode);
    VFSContainer gtaskContainer = gtaManager.getTasksContainer(courseEnv, gtaNode);
    // make the task
    TaskDefinitionList taskDefs = new TaskDefinitionList();
    for (File task : taskFolder.listFiles(SystemFileFilter.FILES_ONLY)) {
        TaskDefinition taskDef = new TaskDefinition();
        taskDef.setDescription("");
        taskDef.setFilename(task.getName());
        taskDef.setTitle(task.getName());
        taskDefs.getTasks().add(taskDef);
        try {
            File target = new File(gtaskDirectory, task.getName());
            Files.copy(task.toPath(), target.toPath(), StandardCopyOption.REPLACE_EXISTING);
            convertMetada(taskContainer, gtaskContainer, task.getName(), taskDef, null);
        } catch (Exception ex) {
            log.error("", ex);
        }
        List<Property> samples = courseEnv.getCoursePropertyManager().listCourseNodeProperties(sourceNode, null, null, TaskController.PROP_ASSIGNED);
        for (Property sample : samples) {
            File taskFile = new File(gtaskDirectory, sample.getStringValue());
            Identity id = securityManager.loadIdentityByKey(sample.getIdentity().getKey());
            gtaManager.selectTask(id, taskList, gtaNode, taskFile);
        }
    }
    gtaNode.getModuleConfiguration().set(GTACourseNode.GTASK_TASKS, taskDefs);
}
Also used : TaskDefinition(org.olat.course.nodes.gta.model.TaskDefinition) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) VFSContainer(org.olat.core.util.vfs.VFSContainer) TaskDefinitionList(org.olat.course.nodes.gta.model.TaskDefinitionList) Identity(org.olat.core.id.Identity) File(java.io.File) Property(org.olat.properties.Property)

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