Search in sources :

Example 71 with GTACourseNode

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

the class GTAReminderRuleTest method getGTACourseNode.

private GTACourseNode getGTACourseNode(RepositoryEntry courseEntry) {
    ICourse course = CourseFactory.loadCourse(courseEntry);
    CourseNode rootNode = course.getRunStructure().getRootNode();
    for (int i = rootNode.getChildCount(); i-- > 0; ) {
        INode child = rootNode.getChildAt(i);
        if (child instanceof GTACourseNode) {
            return ((GTACourseNode) child);
        }
    }
    return null;
}
Also used : INode(org.olat.core.util.nodes.INode) GTACourseNode(org.olat.course.nodes.GTACourseNode) ICourse(org.olat.course.ICourse) CourseNode(org.olat.course.nodes.CourseNode) GTACourseNode(org.olat.course.nodes.GTACourseNode)

Example 72 with GTACourseNode

use of org.olat.course.nodes.GTACourseNode 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)

Example 73 with GTACourseNode

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

the class AssessmentIdentityListCourseTreeController method doSelectCourseNode.

private Controller doSelectCourseNode(UserRequest ureq, CourseNode courseNode) {
    removeAsListenerAndDispose(currentCtrl);
    OLATResourceable ores = OresHelper.createOLATResourceableInstance("Node", new Long(courseNode.getIdent()));
    WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ores, null, getWindowControl());
    if (courseNode instanceof AssessableCourseNode) {
        if (((AssessableCourseNode) courseNode).isAssessedBusinessGroups() && courseNode instanceof GTACourseNode) {
            CourseEnvironment courseEnv = CourseFactory.loadCourse(courseEntry).getCourseEnvironment();
            List<BusinessGroup> coachedGroups;
            if (businessGroup != null) {
                coachedGroups = Collections.singletonList(businessGroup);
            } else if (assessmentCallback.isAdmin()) {
                coachedGroups = courseEnv.getCourseGroupManager().getAllBusinessGroups();
            } else {
                coachedGroups = assessmentCallback.getCoachedGroups();
            }
            currentCtrl = ((GTACourseNode) courseNode).getCoachedGroupListController(ureq, bwControl, stackPanel, coachCourseEnv, assessmentCallback.isAdmin(), coachedGroups);
        } else {
            currentCtrl = ((AssessableCourseNode) courseNode).getIdentityListController(ureq, bwControl, stackPanel, courseEntry, businessGroup, coachCourseEnv, toolContainer, assessmentCallback);
        }
    } else {
        currentCtrl = new IdentityListCourseNodeController(ureq, bwControl, stackPanel, courseEntry, businessGroup, courseNode, coachCourseEnv, toolContainer, assessmentCallback);
    }
    listenTo(currentCtrl);
    mainPanel.setContent(currentCtrl.getInitialComponent());
    addToHistory(ureq, currentCtrl);
    return currentCtrl;
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) OLATResourceable(org.olat.core.id.OLATResourceable) BusinessGroup(org.olat.group.BusinessGroup) GTACourseNode(org.olat.course.nodes.GTACourseNode) WindowControl(org.olat.core.gui.control.WindowControl)

Example 74 with GTACourseNode

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

the class AssessmentCourseTreeController method doSelectCourseNodeBusinessGroupsView.

private Controller doSelectCourseNodeBusinessGroupsView(UserRequest ureq, CourseNode courseNode) {
    OLATResourceable oresGroups = OresHelper.createOLATResourceableInstance("BusinessGroups", 0l);
    WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(oresGroups, null, getWindowControl());
    OLATResourceable oresNode = OresHelper.createOLATResourceableInstance("Node", new Long(courseNode.getIdent()));
    WindowControl bbwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(oresNode, null, bwControl);
    if (courseNode instanceof AssessableCourseNode && ((AssessableCourseNode) courseNode).isAssessedBusinessGroups()) {
        if (courseNode instanceof GTACourseNode) {
            CourseEnvironment courseEnv = CourseFactory.loadCourse(courseEntry).getCourseEnvironment();
            List<BusinessGroup> coachedGroups;
            if (assessmentCallback.isAdmin()) {
                coachedGroups = courseEnv.getCourseGroupManager().getAllBusinessGroups();
            } else {
                coachedGroups = assessmentCallback.getCoachedGroups();
            }
            businessGroupListCtrl = ((GTACourseNode) courseNode).getCoachedGroupListController(ureq, bbwControl, stackPanel, coachCourseEnv, assessmentCallback.isAdmin(), coachedGroups);
        }
    } else {
        businessGroupListCtrl = new AssessedBusinessGroupCourseNodeListController(ureq, bbwControl, stackPanel, courseEntry, courseNode, coachCourseEnv, toolContainer, assessmentCallback);
    }
    return businessGroupListCtrl;
}
Also used : AssessableCourseNode(org.olat.course.nodes.AssessableCourseNode) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) OLATResourceable(org.olat.core.id.OLATResourceable) BusinessGroup(org.olat.group.BusinessGroup) GTACourseNode(org.olat.course.nodes.GTACourseNode) WindowControl(org.olat.core.gui.control.WindowControl)

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