use of org.olat.course.nodes.GTACourseNode in project openolat by klemens.
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 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.GTACourseNode 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.GTACourseNode 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());
}
use of org.olat.course.nodes.GTACourseNode in project openolat by klemens.
the class GTAManagerTest method isTaskAssigned.
@Test
public void isTaskAssigned() {
// create an individual task
Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-6");
RepositoryEntry re = deployGTACourse();
GTACourseNode node = getGTACourseNode(re);
node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
TaskList tasks = gtaManager.createIfNotExists(re, node);
dbInstance.commit();
Assert.assertNotNull(tasks);
// select
File taskFile = new File("bg.txt");
AssignmentResponse response = gtaManager.selectTask(participant, tasks, node, taskFile);
Assert.assertNotNull(response);
Assert.assertEquals(Status.ok, response.getStatus());
// check is assigned
boolean assigned = gtaManager.isTaskAssigned(tasks, taskFile.getName());
Assert.assertTrue(assigned);
boolean notAssigned = gtaManager.isTaskAssigned(tasks, "noise.txt");
Assert.assertFalse(notAssigned);
}
Aggregations