use of org.olat.course.nodes.gta.AssignmentResponse in project OpenOLAT by OpenOLAT.
the class GTAManagerTest method deleteTaskList.
@Test
public void deleteTaskList() {
Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-9");
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-10");
BusinessGroup businessGroup = businessGroupDao.createAndPersist(coach, "gdao", "gdao-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRole(participant, businessGroup, GroupRole.participant.name());
dbInstance.commit();
RepositoryEntry re = deployGTACourse();
GTACourseNode node = getGTACourseNode(re);
node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.group.name());
TaskList tasks = gtaManager.createIfNotExists(re, node);
File taskFile = new File("bg.txt");
Assert.assertNotNull(tasks);
dbInstance.commit();
// select
AssignmentResponse response = gtaManager.selectTask(businessGroup, 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.deleteTaskList(re, node);
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 OpenOLAT.
the class GTAManagerTest method deleteTaskList_withRevisionDates.
@Test
public void deleteTaskList_withRevisionDates() {
Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-9");
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-10");
BusinessGroup businessGroup = businessGroupDao.createAndPersist(coach, "gdao", "gdao-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRole(participant, businessGroup, GroupRole.participant.name());
dbInstance.commit();
RepositoryEntry re = deployGTACourse();
GTACourseNode node = getGTACourseNode(re);
node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.group.name());
TaskList tasks = gtaManager.createIfNotExists(re, node);
File taskFile = new File("bg.txt");
Assert.assertNotNull(tasks);
dbInstance.commit();
// select
AssignmentResponse response = gtaManager.selectTask(businessGroup, 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());
// create a revision date
gtaManager.createAndPersistTaskRevisionDate(assignedTasks.get(0), 2, TaskProcess.correction);
dbInstance.commitAndCloseSession();
// delete
int numOfDeletedObjects = gtaManager.deleteTaskList(re, node);
Assert.assertEquals(3, 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 OpenOLAT.
the class GTAManagerTest method getTasks.
@Test
public void getTasks() {
Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-3");
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-4");
BusinessGroup businessGroup = businessGroupDao.createAndPersist(coach, "gdao", "gdao-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRole(participant, businessGroup, GroupRole.participant.name());
dbInstance.commit();
RepositoryEntry re = deployGTACourse();
GTACourseNode node = getGTACourseNode(re);
node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.group.name());
TaskList tasks = gtaManager.createIfNotExists(re, node);
File taskFile = new File("bg.txt");
Assert.assertNotNull(tasks);
dbInstance.commit();
// select
AssignmentResponse response = gtaManager.selectTask(businessGroup, tasks, node, taskFile);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(response);
List<Task> assignedTasks = gtaManager.getTasks(participant, re, node);
Assert.assertNotNull(assignedTasks);
Assert.assertEquals(1, assignedTasks.size());
}
use of org.olat.course.nodes.gta.AssignmentResponse 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;
}
use of org.olat.course.nodes.gta.AssignmentResponse in project openolat by klemens.
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;
}
Aggregations