Search in sources :

Example 31 with GTACourseNode

use of org.olat.course.nodes.GTACourseNode in project openolat by klemens.

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);
}
Also used : TaskList(org.olat.course.nodes.gta.TaskList) TaskListImpl(org.olat.course.nodes.gta.model.TaskListImpl) GTACourseNode(org.olat.course.nodes.GTACourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Example 32 with GTACourseNode

use of org.olat.course.nodes.GTACourseNode in project openolat by klemens.

the class GTAManagerTest method deleteTaskList_parano.

/**
 * Create 2 pseudo nodes in a course, and delete the task of the first node
 * and check that the task of second are always there.
 */
@Test
public void deleteTaskList_parano() {
    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();
    // node 1
    GTACourseNode node1 = getGTACourseNode(re);
    node1.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.group.name());
    TaskList tasks1 = gtaManager.createIfNotExists(re, node1);
    File taskFile = new File("bg.txt");
    Assert.assertNotNull(tasks1);
    dbInstance.commit();
    // node 2
    GTACourseNode node2 = new GTACourseNode();
    node2.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.group.name());
    TaskList tasks2 = gtaManager.createIfNotExists(re, node2);
    Assert.assertNotNull(tasks2);
    dbInstance.commit();
    // select node 1
    AssignmentResponse response1 = gtaManager.selectTask(businessGroup, tasks1, node1, taskFile);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(response1);
    // select node 2
    AssignmentResponse response2 = gtaManager.selectTask(businessGroup, tasks2, node2, taskFile);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(response2);
    // check that there is tasks
    List<Task> assignedTasks1 = gtaManager.getTasks(participant, re, node1);
    Assert.assertNotNull(assignedTasks1);
    Assert.assertEquals(1, assignedTasks1.size());
    // create a revision date
    gtaManager.createAndPersistTaskRevisionDate(assignedTasks1.get(0), 2, TaskProcess.correction);
    List<Task> assignedTasks2 = gtaManager.getTasks(participant, re, node2);
    Assert.assertNotNull(assignedTasks2);
    Assert.assertEquals(1, assignedTasks2.size());
    // create a revision date
    gtaManager.createAndPersistTaskRevisionDate(assignedTasks2.get(0), 2, TaskProcess.correction);
    dbInstance.commitAndCloseSession();
    // delete
    int numOfDeletedObjects = gtaManager.deleteTaskList(re, node1);
    Assert.assertEquals(3, numOfDeletedObjects);
    dbInstance.commitAndCloseSession();
    // check that there isn't any tasks in node 1
    List<Task> deletedAssignedTasks = gtaManager.getTasks(participant, re, node1);
    Assert.assertNotNull(deletedAssignedTasks);
    Assert.assertEquals(0, deletedAssignedTasks.size());
    List<TaskRevisionDate> revisionsTask1 = gtaManager.getTaskRevisions(assignedTasks1.get(0));
    Assert.assertNotNull(revisionsTask1);
    Assert.assertEquals(0, revisionsTask1.size());
    // but always in node 2
    List<Task> notDeletedAssignedTasks2 = gtaManager.getTasks(participant, re, node2);
    Assert.assertNotNull(notDeletedAssignedTasks2);
    Assert.assertEquals(1, notDeletedAssignedTasks2.size());
    List<TaskRevisionDate> revisionsTask2 = gtaManager.getTaskRevisions(notDeletedAssignedTasks2.get(0));
    Assert.assertNotNull(revisionsTask2);
    Assert.assertEquals(1, revisionsTask2.size());
}
Also used : Task(org.olat.course.nodes.gta.Task) BusinessGroup(org.olat.group.BusinessGroup) TaskList(org.olat.course.nodes.gta.TaskList) GTACourseNode(org.olat.course.nodes.GTACourseNode) AssignmentResponse(org.olat.course.nodes.gta.AssignmentResponse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) File(java.io.File) TaskRevisionDate(org.olat.course.nodes.gta.TaskRevisionDate) Test(org.junit.Test)

Example 33 with GTACourseNode

use of org.olat.course.nodes.GTACourseNode in project openolat by klemens.

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"));
}
Also used : TaskList(org.olat.course.nodes.gta.TaskList) GTACourseNode(org.olat.course.nodes.GTACourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) File(java.io.File) Test(org.junit.Test)

Example 34 with GTACourseNode

use of org.olat.course.nodes.GTACourseNode in project openolat by klemens.

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);
}
Also used : TaskList(org.olat.course.nodes.gta.TaskList) GTACourseNode(org.olat.course.nodes.GTACourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry) Test(org.junit.Test)

Example 35 with GTACourseNode

use of org.olat.course.nodes.GTACourseNode in project openolat by klemens.

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());
}
Also used : Task(org.olat.course.nodes.gta.Task) BusinessGroup(org.olat.group.BusinessGroup) TaskList(org.olat.course.nodes.gta.TaskList) GTACourseNode(org.olat.course.nodes.GTACourseNode) AssignmentResponse(org.olat.course.nodes.gta.AssignmentResponse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) File(java.io.File) Test(org.junit.Test)

Aggregations

GTACourseNode (org.olat.course.nodes.GTACourseNode)74 RepositoryEntry (org.olat.repository.RepositoryEntry)52 Test (org.junit.Test)48 Identity (org.olat.core.id.Identity)48 TaskList (org.olat.course.nodes.gta.TaskList)48 File (java.io.File)36 AssignmentResponse (org.olat.course.nodes.gta.AssignmentResponse)28 Task (org.olat.course.nodes.gta.Task)24 BusinessGroup (org.olat.group.BusinessGroup)16 ArrayList (java.util.ArrayList)14 CourseNode (org.olat.course.nodes.CourseNode)14 List (java.util.List)12 ICourse (org.olat.course.ICourse)12 ReminderRuleImpl (org.olat.modules.reminder.model.ReminderRuleImpl)12 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)10 TACourseNode (org.olat.course.nodes.TACourseNode)8 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)8 Calendar (java.util.Calendar)6 Date (java.util.Date)6 IQTESTCourseNode (org.olat.course.nodes.IQTESTCourseNode)6