Search in sources :

Example 86 with TaskList

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

the class GTAManagerTest method getTasks.

@Test
public void getTasks() {
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-3");
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-4");
    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);
    List<Task> assignedTasks = gtaManager.getTasks(participant, re, node);
    Assert.assertNotNull(assignedTasks);
    Assert.assertEquals(1, assignedTasks.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 87 with TaskList

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

the class GTAManagerTest method updateTaskName.

@Test
public void updateTaskName() {
    // 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"));
    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());
}
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 88 with TaskList

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

the class GTAManagerTest method getTaskRevisions.

@Test
public void getTaskRevisions() {
    // prepare
    Identity participant = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-21");
    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 a task
    Task task = gtaManager.createAndPersistTask(null, tasks, TaskProcess.assignment, null, participant, node);
    dbInstance.commitAndCloseSession();
    // add the revision log
    TaskRevisionDate taskRevision = gtaManager.createAndPersistTaskRevisionDate(task, 2, TaskProcess.correction);
    Assert.assertNotNull(taskRevision);
    dbInstance.commitAndCloseSession();
    // load the revisions
    List<TaskRevisionDate> taskRevisions = gtaManager.getTaskRevisions(task);
    Assert.assertNotNull(taskRevisions);
    Assert.assertEquals(1, taskRevisions.size());
    TaskRevisionDate loadedTaskRevision = taskRevisions.get(0);
    Assert.assertNotNull(loadedTaskRevision.getKey());
    Assert.assertNotNull(loadedTaskRevision.getDate());
    Assert.assertEquals(task, loadedTaskRevision.getTask());
    Assert.assertEquals(2, loadedTaskRevision.getRevisionLoop());
    Assert.assertEquals(TaskProcess.correction, loadedTaskRevision.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)

Example 89 with TaskList

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

the class GTAReminderRuleTest method assignTask_businessGroup.

@Test
public void assignTask_businessGroup() {
    // prepare
    Identity coach = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-2");
    Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-3");
    Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-4");
    Identity participant3 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-5");
    Identity participant4 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-6");
    BusinessGroup businessGroup1 = businessGroupDao.createAndPersist(coach, "gdao", "gdao-desc", -1, -1, false, false, false, false, false);
    BusinessGroup businessGroup2 = businessGroupDao.createAndPersist(coach, "gdao", "gdao-desc", -1, -1, false, false, false, false, false);
    businessGroupRelationDao.addRole(participant1, businessGroup1, GroupRole.participant.name());
    businessGroupRelationDao.addRole(participant2, businessGroup1, GroupRole.participant.name());
    businessGroupRelationDao.addRole(participant3, businessGroup2, GroupRole.participant.name());
    businessGroupRelationDao.addRole(participant4, businessGroup2, GroupRole.participant.name());
    dbInstance.commit();
    RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry("", false);
    businessGroupRelationDao.addRelationToResource(businessGroup1, re);
    businessGroupRelationDao.addRelationToResource(businessGroup2, re);
    GTACourseNode node = new GTACourseNode();
    node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.group.name());
    List<Long> groupKeys = new ArrayList<>(2);
    groupKeys.add(businessGroup1.getKey());
    groupKeys.add(businessGroup2.getKey());
    node.getModuleConfiguration().setList(GTACourseNode.GTASK_GROUPS, groupKeys);
    TaskList tasks = gtaManager.createIfNotExists(re, node);
    File taskFile = new File("bg.txt");
    Assert.assertNotNull(tasks);
    dbInstance.commit();
    // group 1 select a task
    AssignmentResponse response = gtaManager.selectTask(businessGroup1, tasks, node, taskFile);
    dbInstance.commitAndCloseSession();
    Assert.assertEquals(AssignmentResponse.Status.ok, response.getStatus());
    // only remind group 2
    List<Identity> toRemind = assignTaskRuleSPI.getPeopleToRemind(re, node);
    Assert.assertEquals(2, toRemind.size());
    Assert.assertTrue(toRemind.contains(participant3));
    Assert.assertTrue(toRemind.contains(participant4));
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) TaskList(org.olat.course.nodes.gta.TaskList) ArrayList(java.util.ArrayList) 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 90 with TaskList

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

the class GTAReminderRuleTest method assignTask_individual.

@Test
public void assignTask_individual() {
    // prepare a course with a volatile task
    Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-1");
    Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-2");
    RepositoryEntry re = deployGTACourse();
    repositoryEntryRelationDao.addRole(participant1, re, GroupRoles.participant.name());
    repositoryEntryRelationDao.addRole(participant2, re, GroupRoles.participant.name());
    dbInstance.commit();
    GTACourseNode node = getGTACourseNode(re);
    node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
    Calendar cal = Calendar.getInstance();
    cal.add(2, Calendar.MONTH);
    node.getModuleConfiguration().setDateValue(GTACourseNode.GTASK_ASSIGNMENT_DEADLINE, cal.getTime());
    TaskList tasks = gtaManager.createIfNotExists(re, node);
    File taskFile = new File("solo.txt");
    Assert.assertNotNull(tasks);
    dbInstance.commit();
    // select a task
    AssignmentResponse response = gtaManager.selectTask(participant1, tasks, node, taskFile);
    dbInstance.commitAndCloseSession();
    Assert.assertEquals(AssignmentResponse.Status.ok, response.getStatus());
    // only remind participant 2
    List<Identity> toRemind = assignTaskRuleSPI.getPeopleToRemind(re, node);
    Assert.assertEquals(1, toRemind.size());
    Assert.assertTrue(toRemind.contains(participant2));
    {
        // check before 30 days
        ReminderRuleImpl rule = getAssignedTaskRules(30, LaunchUnit.day);
        List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);
        Assert.assertEquals(0, all.size());
    }
    {
        // check before 5 weeks
        ReminderRuleImpl rule = getAssignedTaskRules(5, LaunchUnit.week);
        List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);
        Assert.assertEquals(0, all.size());
    }
    {
        // check before 1 month
        ReminderRuleImpl rule = getAssignedTaskRules(1, LaunchUnit.month);
        List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);
        Assert.assertEquals(0, all.size());
    }
    {
        // check before  90 days
        ReminderRuleImpl rule = getAssignedTaskRules(90, LaunchUnit.day);
        List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);
        Assert.assertEquals(1, all.size());
        Assert.assertTrue(toRemind.contains(participant2));
    }
    {
        // check before  12 weeks
        ReminderRuleImpl rule = getAssignedTaskRules(12, LaunchUnit.week);
        List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);
        Assert.assertEquals(1, all.size());
        Assert.assertTrue(toRemind.contains(participant2));
    }
    {
        // check before  3 month
        ReminderRuleImpl rule = getAssignedTaskRules(3, LaunchUnit.month);
        List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);
        Assert.assertEquals(1, all.size());
        Assert.assertTrue(toRemind.contains(participant2));
    }
    {
        // check before 1 year
        ReminderRuleImpl rule = getAssignedTaskRules(1, LaunchUnit.year);
        List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);
        Assert.assertEquals(1, all.size());
        Assert.assertTrue(toRemind.contains(participant2));
    }
}
Also used : ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) Calendar(java.util.Calendar) TaskList(org.olat.course.nodes.gta.TaskList) GTACourseNode(org.olat.course.nodes.GTACourseNode) AssignmentResponse(org.olat.course.nodes.gta.AssignmentResponse) ArrayList(java.util.ArrayList) TaskList(org.olat.course.nodes.gta.TaskList) List(java.util.List) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) File(java.io.File) Test(org.junit.Test)

Aggregations

TaskList (org.olat.course.nodes.gta.TaskList)102 Identity (org.olat.core.id.Identity)68 Test (org.junit.Test)64 RepositoryEntry (org.olat.repository.RepositoryEntry)60 GTACourseNode (org.olat.course.nodes.GTACourseNode)48 File (java.io.File)36 Task (org.olat.course.nodes.gta.Task)36 AssignmentResponse (org.olat.course.nodes.gta.AssignmentResponse)32 BusinessGroup (org.olat.group.BusinessGroup)20 ArrayList (java.util.ArrayList)16 Date (java.util.Date)12 List (java.util.List)12 TaskRevisionDate (org.olat.course.nodes.gta.TaskRevisionDate)12 TaskProcess (org.olat.course.nodes.gta.TaskProcess)10 ReminderRuleImpl (org.olat.modules.reminder.model.ReminderRuleImpl)10 IdentityMark (org.olat.course.nodes.gta.IdentityMark)8 ModuleConfiguration (org.olat.modules.ModuleConfiguration)8 Calendar (java.util.Calendar)6 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)6 GTAManager (org.olat.course.nodes.gta.GTAManager)6