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