use of org.olat.course.nodes.GTACourseNode 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.GTACourseNode in project OpenOLAT by OpenOLAT.
the class GTAManagerTest method createIfNotExists.
@Test
public void createIfNotExists() {
RepositoryEntry re = deployGTACourse();
GTACourseNode node = getGTACourseNode(re);
Assert.assertNotNull(node.getIdent());
TaskList tasks = gtaManager.createIfNotExists(re, node);
Assert.assertNotNull(tasks);
dbInstance.commit();
// reload and check
TaskList reloadedTasks = gtaManager.getTaskList(re, node);
Assert.assertNotNull(reloadedTasks);
Assert.assertEquals(tasks, reloadedTasks);
Assert.assertTrue(reloadedTasks instanceof TaskListImpl);
TaskListImpl tasksImpl = (TaskListImpl) reloadedTasks;
Assert.assertNotNull(tasksImpl.getCreationDate());
Assert.assertNotNull(tasksImpl.getLastModified());
Assert.assertEquals(re, tasksImpl.getEntry());
Assert.assertEquals(node.getIdent(), tasksImpl.getCourseNodeIdent());
dbInstance.commit();
// check that a second call doesn't create a new task list
TaskList secondTasks = gtaManager.createIfNotExists(re, node);
Assert.assertNotNull(secondTasks);
dbInstance.commit();
Assert.assertEquals(tasks, secondTasks);
}
use of org.olat.course.nodes.GTACourseNode in project OpenOLAT by OpenOLAT.
the class GTAManagerTest method isTasksInProcess_no.
@Test
public void isTasksInProcess_no() {
// prepare
RepositoryEntry re = deployGTACourse();
GTACourseNode node = getGTACourseNode(re);
node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
TaskList tasks = gtaManager.createIfNotExists(re, node);
Assert.assertNotNull(tasks);
dbInstance.commit();
// check
boolean inProcess = gtaManager.isTasksInProcess(re, node);
Assert.assertFalse(inProcess);
}
use of org.olat.course.nodes.GTACourseNode in project OpenOLAT by OpenOLAT.
the class GTAManagerTest method updateTaskName_paranoia.
@Test
public void updateTaskName_paranoia() {
// create an individual task
Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-7");
Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-8");
RepositoryEntry re = deployGTACourse();
GTACourseNode node = getGTACourseNode(re);
node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
TaskList taskList = gtaManager.createIfNotExists(re, node);
dbInstance.commit();
Assert.assertNotNull(taskList);
// create a reference individual task
GTACourseNode nodeRef = new GTACourseNode();
nodeRef.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
TaskList taskListRef = gtaManager.createIfNotExists(re, nodeRef);
dbInstance.commit();
Assert.assertNotNull(taskListRef);
// select
gtaManager.selectTask(id1, taskList, node, new File("work_1.txt"));
gtaManager.selectTask(id1, taskListRef, nodeRef, new File("work_1.txt"));
gtaManager.selectTask(id2, taskList, node, new File("work_2.txt"));
dbInstance.commit();
// change a name
int rowUpdated = gtaManager.updateTaskName(taskList, "work_1.txt", "changed_work.txt");
dbInstance.commitAndCloseSession();
Assert.assertEquals(1, rowUpdated);
// check
Task assignedTaskToId1 = gtaManager.getTask(id1, taskList);
Assert.assertNotNull(assignedTaskToId1);
Assert.assertEquals("changed_work.txt", assignedTaskToId1.getTaskName());
List<Task> assignedTaskToId2 = gtaManager.getTasks(id2, re, node);
Assert.assertNotNull(assignedTaskToId2);
Assert.assertEquals(1, assignedTaskToId2.size());
Assert.assertEquals("work_2.txt", assignedTaskToId2.get(0).getTaskName());
Task assignedTaskRefToId1 = gtaManager.getTask(id1, taskListRef);
Assert.assertNotNull(assignedTaskRefToId1);
Assert.assertEquals("work_1.txt", assignedTaskRefToId1.getTaskName());
}
use of org.olat.course.nodes.GTACourseNode in project OpenOLAT by OpenOLAT.
the class GTAManagerTest method getAssignedTasks.
@Test
public void getAssignedTasks() {
// create an individual task
Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-7");
Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-8");
RepositoryEntry re = deployGTACourse();
GTACourseNode node = getGTACourseNode(re);
node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
TaskList taskList = gtaManager.createIfNotExists(re, node);
dbInstance.commit();
Assert.assertNotNull(taskList);
// select
gtaManager.selectTask(id1, taskList, node, new File("work_1.txt"));
gtaManager.selectTask(id2, taskList, node, new File("work_2.txt"));
// get assigned tasks
List<String> assigned = gtaManager.getAssignedTasks(taskList);
Assert.assertNotNull(assigned);
Assert.assertEquals(2, assigned.size());
Assert.assertTrue(assigned.contains("work_1.txt"));
Assert.assertTrue(assigned.contains("work_2.txt"));
}
Aggregations