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;
}
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);
}
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;
}
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;
}
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);
}
Aggregations