Search in sources :

Example 21 with TaskImpl

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

the class GTAManagerImpl method selectTask.

private AssignmentResponse selectTask(Identity identity, BusinessGroup businessGroup, TaskList tasks, GTACourseNode cNode, File taskFile) {
    Task currentTask;
    if (businessGroup != null) {
        currentTask = getTask(businessGroup, tasks);
    } else {
        currentTask = getTask(identity, tasks);
    }
    AssignmentResponse response;
    if (currentTask == null) {
        String taskName = taskFile.getName();
        TaskList reloadedTasks = loadForUpdate(tasks);
        String sampling = cNode.getModuleConfiguration().getStringValue(GTACourseNode.GTASK_SAMPLING);
        if (GTACourseNode.GTASK_SAMPLING_UNIQUE.equals(sampling) && isTaskAssigned(reloadedTasks, taskName)) {
            response = new AssignmentResponse(null, Status.alreadyAssigned);
        } else {
            TaskProcess nextStep = nextStep(TaskProcess.assignment, cNode);
            TaskImpl task = createTask(taskName, reloadedTasks, nextStep, businessGroup, identity, cNode);
            task.setAssignmentDate(new Date());
            dbInstance.getCurrentEntityManager().persist(task);
            syncAssessmentEntry(task, cNode, Role.user);
            response = new AssignmentResponse(task, Status.ok);
        }
        dbInstance.commit();
    } else {
        if (currentTask.getTaskStatus() == TaskProcess.assignment) {
            TaskProcess nextStep = nextStep(currentTask.getTaskStatus(), cNode);
            ((TaskImpl) currentTask).setTaskStatus(nextStep);
            if (taskFile != null) {
                ((TaskImpl) currentTask).setTaskName(taskFile.getName());
            }
        }
        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) 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 22 with TaskImpl

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

the class GTAManagerImpl method submitTask.

@Override
public Task submitTask(Task task, GTACourseNode cNode, int numOfDocs, Role by) {
    TaskProcess review = nextStep(TaskProcess.submit, cNode);
    TaskImpl taskImpl = (TaskImpl) task;
    taskImpl.setSubmissionDate(new Date());
    taskImpl.setSubmissionNumOfDocs(numOfDocs);
    return updateTask(task, review, cNode, by);
}
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 23 with TaskImpl

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

the class GTAManagerImpl method createTask.

@Override
public TaskImpl createTask(String taskName, TaskList taskList, TaskProcess status, BusinessGroup assessedGroup, Identity assessedIdentity, GTACourseNode cNode) {
    TaskImpl task = new TaskImpl();
    Date creationDate = new Date();
    task.setCreationDate(creationDate);
    task.setLastModified(creationDate);
    task.setTaskList(taskList);
    task.setTaskName(taskName);
    // assignment is ok -> go to submit step
    task.setTaskStatus(status);
    task.setRevisionLoop(0);
    if (status == TaskProcess.graded) {
        task.setGraduationDate(new Date());
    }
    if (GTAType.group.name().equals(cNode.getModuleConfiguration().getStringValue(GTACourseNode.GTASK_TYPE))) {
        task.setBusinessGroup(assessedGroup);
    } else {
        task.setIdentity(assessedIdentity);
    }
    return task;
}
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 24 with TaskImpl

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

the class GTAManagerImpl method updateTask.

@Override
public Task updateTask(Task task, TaskProcess newStatus, int iteration, GTACourseNode cNode, Role by) {
    TaskImpl taskImpl = (TaskImpl) task;
    taskImpl.setTaskStatus(newStatus);
    taskImpl.setRevisionLoop(iteration);
    taskImpl = dbInstance.getCurrentEntityManager().merge(taskImpl);
    // log date
    createAndPersistTaskRevisionDate(taskImpl, iteration, newStatus);
    syncAssessmentEntry(taskImpl, cNode, by);
    return taskImpl;
}
Also used : TaskImpl(org.olat.course.nodes.gta.model.TaskImpl)

Example 25 with TaskImpl

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

the class GTAManagerImpl method reviewedTask.

@Override
public Task reviewedTask(Task task, GTACourseNode cNode) {
    TaskProcess solution = nextStep(TaskProcess.correction, cNode);
    TaskImpl taskImpl = (TaskImpl) task;
    taskImpl.setAcceptationDate(new Date());
    return updateTask(taskImpl, solution, 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)

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