Search in sources :

Example 6 with TaskImpl

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

the class GTAManagerImpl method assignTaskAutomatically.

private AssignmentResponse assignTaskAutomatically(TaskList tasks, BusinessGroup businessGroup, Identity identity, CourseEnvironment courseEnv, GTACourseNode cNode) {
    Task currentTask;
    if (businessGroup != null) {
        currentTask = getTask(businessGroup, tasks);
    } else {
        currentTask = getTask(identity, tasks);
    }
    AssignmentResponse response;
    if (currentTask == null) {
        TaskList reloadedTasks = loadForUpdate(tasks);
        File tasksFolder = getTasksDirectory(courseEnv, cNode);
        String[] taskFiles = tasksFolder.list(SystemFilenameFilter.FILES_ONLY);
        List<String> assignedFilenames = getAssignedTasks(reloadedTasks);
        String taskName;
        if (GTACourseNode.GTASK_SAMPLING_UNIQUE.equals(cNode.getModuleConfiguration().get(GTACourseNode.GTASK_SAMPLING))) {
            taskName = nextUnique(taskFiles, assignedFilenames);
        } else {
            taskName = nextSlotRoundRobin(taskFiles, assignedFilenames);
        }
        if (taskName == null) {
            response = AssignmentResponse.NO_MORE_TASKS;
        } else {
            TaskProcess nextStep = nextStep(TaskProcess.assignment, cNode);
            TaskImpl task = createTask(taskName, reloadedTasks, nextStep, businessGroup, identity, cNode);
            task.setAssignmentDate(new Date());
            dbInstance.getCurrentEntityManager().persist(task);
            dbInstance.commit();
            syncAssessmentEntry((TaskImpl) currentTask, cNode, Role.user);
            response = new AssignmentResponse(task, Status.ok);
        }
    } else {
        if (currentTask.getTaskStatus() == TaskProcess.assignment) {
            ((TaskImpl) currentTask).setTaskStatus(TaskProcess.submit);
        }
        currentTask = dbInstance.getCurrentEntityManager().merge(currentTask);
        syncAssessmentEntry((TaskImpl) currentTask, cNode, Role.user);
        response = new AssignmentResponse(currentTask, Status.ok);
    }
    return response;
}
Also used : Task(org.olat.course.nodes.gta.Task) TaskProcess(org.olat.course.nodes.gta.TaskProcess) TaskImpl(org.olat.course.nodes.gta.model.TaskImpl) TaskList(org.olat.course.nodes.gta.TaskList) AssignmentResponse(org.olat.course.nodes.gta.AssignmentResponse) File(java.io.File) Date(java.util.Date) TaskDueDate(org.olat.course.nodes.gta.TaskDueDate) TaskRevisionDate(org.olat.course.nodes.gta.TaskRevisionDate) DueDate(org.olat.course.nodes.gta.model.DueDate)

Example 7 with TaskImpl

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

the class GTAManagerImpl method allowResetTask.

@Override
public Task allowResetTask(Task task, Identity allower, GTACourseNode cNode) {
    TaskImpl taskImpl = (TaskImpl) task;
    taskImpl.setAllowResetDate(new Date());
    taskImpl.setAllowResetIdentity(allower);
    return updateTask(task, task.getTaskStatus(), cNode, Role.coach);
}
Also used : TaskImpl(org.olat.course.nodes.gta.model.TaskImpl) Date(java.util.Date) TaskDueDate(org.olat.course.nodes.gta.TaskDueDate) TaskRevisionDate(org.olat.course.nodes.gta.TaskRevisionDate) DueDate(org.olat.course.nodes.gta.model.DueDate)

Example 8 with TaskImpl

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

the class GTAManagerImpl method collectTask.

@Override
public Task collectTask(Task task, GTACourseNode cNode, int numOfDocs) {
    TaskProcess review = nextStep(TaskProcess.submit, cNode);
    TaskImpl taskImpl = (TaskImpl) task;
    taskImpl.setCollectionDate(new Date());
    taskImpl.setCollectionNumOfDocs(numOfDocs);
    return updateTask(task, review, cNode, Role.coach);
}
Also used : TaskProcess(org.olat.course.nodes.gta.TaskProcess) TaskImpl(org.olat.course.nodes.gta.model.TaskImpl) Date(java.util.Date) TaskDueDate(org.olat.course.nodes.gta.TaskDueDate) TaskRevisionDate(org.olat.course.nodes.gta.TaskRevisionDate) DueDate(org.olat.course.nodes.gta.model.DueDate)

Example 9 with TaskImpl

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

the class GTAManagerImpl method nextStep.

@Override
public Task nextStep(Task task, GTACourseNode cNode, Role by) {
    TaskImpl taskImpl = (TaskImpl) task;
    TaskProcess currentStep = taskImpl.getTaskStatus();
    // cascade through the possible steps
    TaskProcess nextStep = nextStep(currentStep, cNode);
    taskImpl.setTaskStatus(nextStep);
    TaskImpl mergedTask = dbInstance.getCurrentEntityManager().merge(taskImpl);
    // make the thing definitiv
    dbInstance.commit();
    syncAssessmentEntry(mergedTask, cNode, by);
    return mergedTask;
}
Also used : TaskProcess(org.olat.course.nodes.gta.TaskProcess) TaskImpl(org.olat.course.nodes.gta.model.TaskImpl)

Example 10 with TaskImpl

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

the class GTAManagerImpl method resetTask.

@Override
public Task resetTask(Task task, GTACourseNode cNode, CourseEnvironment courseEnv) {
    TaskImpl taskImpl = (TaskImpl) task;
    taskImpl.setTaskName(null);
    taskImpl.setAllowResetDate(null);
    Task updatedTask = updateTask(task, TaskProcess.assignment, cNode, Role.user);
    File submissionDir = null;
    if (updatedTask.getBusinessGroup() != null) {
        submissionDir = getSubmitDirectory(courseEnv, cNode, updatedTask.getBusinessGroup());
    } else if (updatedTask.getIdentity() != null) {
        submissionDir = getSubmitDirectory(courseEnv, cNode, updatedTask.getIdentity());
    }
    if (submissionDir != null) {
        FileUtils.deleteDirsAndFiles(submissionDir, true, false);
    }
    return updatedTask;
}
Also used : Task(org.olat.course.nodes.gta.Task) TaskImpl(org.olat.course.nodes.gta.model.TaskImpl) File(java.io.File)

Aggregations

TaskImpl (org.olat.course.nodes.gta.model.TaskImpl)26 Date (java.util.Date)16 TaskDueDate (org.olat.course.nodes.gta.TaskDueDate)16 TaskRevisionDate (org.olat.course.nodes.gta.TaskRevisionDate)16 DueDate (org.olat.course.nodes.gta.model.DueDate)16 TaskProcess (org.olat.course.nodes.gta.TaskProcess)12 Task (org.olat.course.nodes.gta.Task)6 File (java.io.File)4 AssignmentResponse (org.olat.course.nodes.gta.AssignmentResponse)4 TaskList (org.olat.course.nodes.gta.TaskList)4 OLATResource (org.olat.resource.OLATResource)2