use of org.olat.course.nodes.gta.AssignmentResponse in project OpenOLAT by OpenOLAT.
the class GTAParticipantController method stepAssignment.
@Override
protected Task stepAssignment(UserRequest ureq, Task assignedTask) {
assignedTask = super.stepAssignment(ureq, assignedTask);
if (TaskHelper.inOrNull(assignedTask, TaskProcess.assignment)) {
mainVC.contextPut("assignmentCssClass", "o_active");
if (stepPreferences != null) {
// assignment is very important, open it always
stepPreferences.setAssignement(Boolean.TRUE);
}
// assignment open?
DueDate dueDate = getAssignementDueDate(assignedTask);
if (dueDate != null && dueDate.getDueDate() != null && dueDate.getDueDate().compareTo(new Date()) < 0) {
// assignment is closed
mainVC.contextPut("assignmentClosed", Boolean.TRUE);
} else if (userCourseEnv.isCourseReadOnly()) {
showAssignedTask(ureq, assignedTask);
} else {
List<TaskDefinition> availableTasks = gtaManager.getTaskDefinitions(courseEnv, gtaNode);
// assignment auto or manual
String assignmentType = config.getStringValue(GTACourseNode.GTASK_ASSIGNEMENT_TYPE);
if (GTACourseNode.GTASK_ASSIGNEMENT_TYPE_AUTO.equals(assignmentType)) {
AssignmentResponse response;
if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
response = gtaManager.assignTaskAutomatically(taskList, assessedGroup, courseEnv, gtaNode);
} else {
response = gtaManager.assignTaskAutomatically(taskList, assessedIdentity, courseEnv, gtaNode);
}
if (response == null || response.getStatus() == AssignmentResponse.Status.error) {
showError("task.assignment.error");
} else if (response == null || response.getStatus() == AssignmentResponse.Status.noMoreTasks) {
showError("error.nomoretasks");
} else if (response == null || response.getStatus() == AssignmentResponse.Status.ok) {
if (response != null) {
assignedTask = response.getTask();
}
showInfo("task.successfully.assigned");
showAssignedTask(ureq, assignedTask);
}
} else if (GTACourseNode.GTASK_ASSIGNEMENT_TYPE_MANUAL.equals(assignmentType)) {
availableTaskCtrl = new GTAAvailableTaskController(ureq, getWindowControl(), availableTasks, taskList, assessedGroup, assessedIdentity, courseEnv, gtaNode);
listenTo(availableTaskCtrl);
mainVC.put("availableTasks", availableTaskCtrl.getInitialComponent());
}
}
} else {
mainVC.contextPut("assignmentCssClass", "o_done");
showAssignedTask(ureq, assignedTask);
}
return assignedTask;
}
use of org.olat.course.nodes.gta.AssignmentResponse in project OpenOLAT by OpenOLAT.
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.AssignmentResponse in project openolat by klemens.
the class GTAManagerTest method isTaskInProcess.
@Test
public void isTaskInProcess() {
// prepare
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-11");
RepositoryEntry re = deployGTACourse();
GTACourseNode node = getGTACourseNode(re);
node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
TaskList tasks = gtaManager.createIfNotExists(re, node);
File taskFile = new File("solo.txt");
Assert.assertNotNull(tasks);
dbInstance.commit();
// select
AssignmentResponse response = gtaManager.selectTask(participant, tasks, node, taskFile);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(response);
Assert.assertNotNull(response.getTask());
// check
boolean inProcess = gtaManager.isTaskInProcess(re, node, taskFile.getName());
Assert.assertTrue(inProcess);
// check dummy file name which cannot be in process
boolean notInProcess = gtaManager.isTaskInProcess(re, node, "qwertz");
Assert.assertFalse(notInProcess);
}
use of org.olat.course.nodes.gta.AssignmentResponse in project openolat by klemens.
the class GTAManagerTest method deleteAllTaskLists.
@Test
public void deleteAllTaskLists() {
Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-9");
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-10");
dbInstance.commit();
RepositoryEntry re = deployGTACourse();
repositoryEntryRelationDao.addRole(coach, re, GroupRoles.coach.name());
repositoryEntryRelationDao.addRole(participant, re, GroupRoles.participant.name());
GTACourseNode node = getGTACourseNode(re);
node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
TaskList tasks = gtaManager.createIfNotExists(re, node);
File taskFile = new File("bg.txt");
Assert.assertNotNull(tasks);
dbInstance.commit();
// select
AssignmentResponse response = gtaManager.selectTask(participant, tasks, node, taskFile);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(response);
// check that there is tasks
List<Task> assignedTasks = gtaManager.getTasks(participant, re, node);
Assert.assertNotNull(assignedTasks);
Assert.assertEquals(1, assignedTasks.size());
// delete
int numOfDeletedObjects = gtaManager.deleteAllTaskLists(re);
Assert.assertEquals(2, numOfDeletedObjects);
dbInstance.commitAndCloseSession();
// check that there isn't any tasks
List<Task> deletedAssignedTasks = gtaManager.getTasks(participant, re, node);
Assert.assertNotNull(deletedAssignedTasks);
Assert.assertEquals(0, deletedAssignedTasks.size());
}
use of org.olat.course.nodes.gta.AssignmentResponse in project openolat by klemens.
the class GTAManagerTest method selectTask_identity.
@Test
public void selectTask_identity() {
// prepare
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-1");
RepositoryEntry re = deployGTACourse();
GTACourseNode node = getGTACourseNode(re);
node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
TaskList tasks = gtaManager.createIfNotExists(re, node);
File taskFile = new File("solo.txt");
Assert.assertNotNull(tasks);
dbInstance.commit();
// select
AssignmentResponse response = gtaManager.selectTask(participant, tasks, node, taskFile);
dbInstance.commitAndCloseSession();
// check
Assert.assertNotNull(response);
Assert.assertNotNull(response.getTask());
Assert.assertEquals(AssignmentResponse.Status.ok, response.getStatus());
Task task = response.getTask();
Assert.assertNotNull(task.getKey());
Assert.assertNull(task.getBusinessGroup());
Assert.assertNotNull(task.getCreationDate());
Assert.assertNotNull(task.getLastModified());
Assert.assertEquals(tasks, task.getTaskList());
Assert.assertEquals("solo.txt", task.getTaskName());
Assert.assertEquals(participant, task.getIdentity());
}
Aggregations