Search in sources :

Example 1 with AssignmentResponse

use of org.olat.course.nodes.gta.AssignmentResponse in project OpenOLAT by OpenOLAT.

the class GTAAvailableTaskController method doSelect.

private void doSelect(UserRequest ureq, AvailableTask row) {
    String taskName = row.getTaskDef().getFilename();
    File tasksFolder = gtaManager.getTasksDirectory(courseEnv, gtaNode);
    File task = new File(tasksFolder, taskName);
    AssignmentResponse response;
    if (businessGroupTask) {
        response = gtaManager.selectTask(assessedGroup, taskList, gtaNode, task);
    } else {
        response = gtaManager.selectTask(assessedIdentity, taskList, gtaNode, task);
    }
    if (response == null || response.getStatus() == AssignmentResponse.Status.error) {
        showError("task.assignment.error");
    } else if (response.getStatus() == AssignmentResponse.Status.alreadyAssigned) {
        showWarning("task.alreadyChosen");
    } else if (response == null || response.getStatus() == AssignmentResponse.Status.ok) {
        showInfo("task.successfully.assigned");
        fireEvent(ureq, Event.DONE_EVENT);
        gtaManager.log("Assignment", "task assigned", response.getTask(), getIdentity(), assessedIdentity, assessedGroup, courseEnv, gtaNode);
        doSendConfirmationEmail(response.getTask());
    }
}
Also used : AssignmentResponse(org.olat.course.nodes.gta.AssignmentResponse) File(java.io.File)

Example 2 with AssignmentResponse

use of org.olat.course.nodes.gta.AssignmentResponse in project OpenOLAT by OpenOLAT.

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)

Example 3 with AssignmentResponse

use of org.olat.course.nodes.gta.AssignmentResponse in project OpenOLAT by OpenOLAT.

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 4 with AssignmentResponse

use of org.olat.course.nodes.gta.AssignmentResponse in project OpenOLAT by OpenOLAT.

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 5 with AssignmentResponse

use of org.olat.course.nodes.gta.AssignmentResponse in project OpenOLAT by OpenOLAT.

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)

Aggregations

AssignmentResponse (org.olat.course.nodes.gta.AssignmentResponse)36 File (java.io.File)32 TaskList (org.olat.course.nodes.gta.TaskList)32 Test (org.junit.Test)28 Identity (org.olat.core.id.Identity)28 GTACourseNode (org.olat.course.nodes.GTACourseNode)28 RepositoryEntry (org.olat.repository.RepositoryEntry)28 Task (org.olat.course.nodes.gta.Task)20 BusinessGroup (org.olat.group.BusinessGroup)12 ArrayList (java.util.ArrayList)6 Date (java.util.Date)6 List (java.util.List)6 TaskRevisionDate (org.olat.course.nodes.gta.TaskRevisionDate)6 DueDate (org.olat.course.nodes.gta.model.DueDate)6 Calendar (java.util.Calendar)4 TaskDueDate (org.olat.course.nodes.gta.TaskDueDate)4 TaskProcess (org.olat.course.nodes.gta.TaskProcess)4 TaskImpl (org.olat.course.nodes.gta.model.TaskImpl)4 ReminderRuleImpl (org.olat.modules.reminder.model.ReminderRuleImpl)4