Search in sources :

Example 26 with GTACourseNode

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

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());
}
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)

Example 27 with GTACourseNode

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

the class GTAManagerTest method isTasksInProcess_yes.

@Test
public void isTasksInProcess_yes() {
    // prepare
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-12");
    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.isTasksInProcess(re, node);
    Assert.assertTrue(inProcess);
}
Also used : 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)

Example 28 with GTACourseNode

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

the class GTAManagerTest method deleteAllTaskLists_parano.

/**
 * Create 2 pseudo courses in a course, and delete the task of the first course
 * and check that the task of second are always there.
 */
@Test
public void deleteAllTaskLists_parano() {
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-20");
    Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-21");
    Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-22");
    RepositoryEntry re1 = deployGTACourse();
    repositoryEntryRelationDao.addRole(coach, re1, GroupRoles.coach.name());
    repositoryEntryRelationDao.addRole(participant1, re1, GroupRoles.participant.name());
    repositoryEntryRelationDao.addRole(participant2, re1, GroupRoles.participant.name());
    // course 1
    GTACourseNode node1 = getGTACourseNode(re1);
    node1.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
    TaskList tasks1 = gtaManager.createIfNotExists(re1, node1);
    File taskFile = new File("bg.txt");
    Assert.assertNotNull(tasks1);
    dbInstance.commit();
    RepositoryEntry re2 = deployGTACourse();
    repositoryEntryRelationDao.addRole(coach, re2, GroupRoles.coach.name());
    repositoryEntryRelationDao.addRole(participant1, re2, GroupRoles.participant.name());
    // participant 2 course 2
    GTACourseNode node2 = getGTACourseNode(re2);
    node2.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
    TaskList tasks2 = gtaManager.createIfNotExists(re2, node2);
    Assert.assertNotNull(tasks2);
    dbInstance.commit();
    // participant 1 and 2 select course 1
    AssignmentResponse response1_1 = gtaManager.selectTask(participant1, tasks1, node1, taskFile);
    AssignmentResponse response1_2 = gtaManager.selectTask(participant2, tasks1, node1, taskFile);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(response1_1);
    Assert.assertNotNull(response1_2);
    // participant 2 select node 2
    AssignmentResponse response2_2 = gtaManager.selectTask(participant2, tasks2, node2, taskFile);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(response2_2);
    // check that there is tasks
    List<Task> assignedTasks1_1 = gtaManager.getTasks(participant1, re1, node1);
    Assert.assertNotNull(assignedTasks1_1);
    Assert.assertEquals(1, assignedTasks1_1.size());
    List<Task> assignedTasks1_2 = gtaManager.getTasks(participant2, re1, node1);
    Assert.assertNotNull(assignedTasks1_2);
    Assert.assertEquals(1, assignedTasks1_2.size());
    List<Task> assignedTasks2_2 = gtaManager.getTasks(participant2, re2, node2);
    Assert.assertNotNull(assignedTasks2_2);
    Assert.assertEquals(1, assignedTasks2_2.size());
    // delete
    int numOfDeletedObjects = gtaManager.deleteAllTaskLists(re1);
    Assert.assertEquals(3, numOfDeletedObjects);
    dbInstance.commitAndCloseSession();
    // check that there isn't any tasks in node 1
    List<Task> deletedAssignedTasks1_1 = gtaManager.getTasks(participant1, re1, node1);
    Assert.assertNotNull(deletedAssignedTasks1_1);
    Assert.assertEquals(0, deletedAssignedTasks1_1.size());
    List<Task> deletedAssignedTasks1_2 = gtaManager.getTasks(participant2, re1, node1);
    Assert.assertNotNull(deletedAssignedTasks1_2);
    Assert.assertEquals(0, deletedAssignedTasks1_2.size());
    // but always in node 2
    List<Task> notDeletedAssignedTasks2_2 = gtaManager.getTasks(participant2, re2, node2);
    Assert.assertNotNull(notDeletedAssignedTasks2_2);
    Assert.assertEquals(1, notDeletedAssignedTasks2_2.size());
}
Also used : Task(org.olat.course.nodes.gta.Task) 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)

Example 29 with GTACourseNode

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

the class GTAManagerTest method selectTask_businessGroup.

@Test
public void selectTask_businessGroup() {
    // prepare
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-2");
    BusinessGroup businessGroup = businessGroupDao.createAndPersist(coach, "gdao", "gdao-desc", -1, -1, false, false, false, false, false);
    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();
    // 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.getIdentity());
    Assert.assertNotNull(task.getCreationDate());
    Assert.assertNotNull(task.getLastModified());
    Assert.assertEquals(tasks, task.getTaskList());
    Assert.assertEquals("bg.txt", task.getTaskName());
    Assert.assertEquals(businessGroup, task.getBusinessGroup());
}
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)

Example 30 with GTACourseNode

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

the class GTAManagerTest method createTaskRevisionDate.

@Test
public void createTaskRevisionDate() {
    // prepare
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-20");
    RepositoryEntry re = deployGTACourse();
    GTACourseNode node = getGTACourseNode(re);
    node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
    TaskList tasks = gtaManager.createIfNotExists(re, node);
    dbInstance.commit();
    // create task
    Task task = gtaManager.createAndPersistTask(null, tasks, TaskProcess.assignment, null, participant, node);
    dbInstance.commitAndCloseSession();
    // create the revision log
    TaskRevisionDate taskRevision = gtaManager.createAndPersistTaskRevisionDate(task, 2, TaskProcess.correction);
    Assert.assertNotNull(taskRevision);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(taskRevision.getKey());
    Assert.assertNotNull(taskRevision.getDate());
    Assert.assertEquals(task, taskRevision.getTask());
    Assert.assertEquals(2, taskRevision.getRevisionLoop());
    Assert.assertEquals(TaskProcess.correction, taskRevision.getTaskStatus());
}
Also used : Task(org.olat.course.nodes.gta.Task) TaskList(org.olat.course.nodes.gta.TaskList) GTACourseNode(org.olat.course.nodes.GTACourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) TaskRevisionDate(org.olat.course.nodes.gta.TaskRevisionDate) 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