Search in sources :

Example 61 with GTACourseNode

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());
}
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) File(java.io.File) Test(org.junit.Test)

Example 62 with GTACourseNode

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);
}
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 63 with GTACourseNode

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

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

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

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