use of org.olat.course.nodes.GTACourseNode in project openolat by klemens.
the class GTAReminderRuleTest method submitTask_relativeLifecycle.
@Test
public void submitTask_relativeLifecycle() {
// prepare a course with a volatile task
Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-1");
Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-2");
RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry("", false);
repositoryEntryRelationDao.addRole(participant1, re, GroupRoles.participant.name());
repositoryEntryRelationDao.addRole(participant2, re, GroupRoles.participant.name());
dbInstance.commit();
String label = "Life cycle for relative date";
String softKey = UUID.randomUUID().toString();
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DATE, -5);
Date from = cal.getTime();
cal.add(Calendar.DATE, 20);
Date to = cal.getTime();
RepositoryEntryLifecycle lifecycle = reLifeCycleDao.create(label, softKey, true, from, to);
re.setLifecycle(lifecycle);
re = dbInstance.getCurrentEntityManager().merge(re);
dbInstance.commit();
// create a fake node with a relative submit deadline 15 days after the start of the course
GTACourseNode node = new GTACourseNode();
node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
node.getModuleConfiguration().setBooleanEntry(GTACourseNode.GTASK_RELATIVE_DATES, true);
node.getModuleConfiguration().setIntValue(GTACourseNode.GTASK_SUBMIT_DEADLINE_RELATIVE, 15);
node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_SUBMIT_DEADLINE_RELATIVE_TO, GTARelativeToDates.courseStart.name());
TaskList tasks = gtaManager.createIfNotExists(re, node);
Assert.assertNotNull(tasks);
dbInstance.commitAndCloseSession();
// the course has start 5 days before, deadline is 15 days after it
// conclusion the deadline is 10 days from now
{
// check before 5 days
ReminderRuleImpl rule = getSubmitTaskRules(5, LaunchUnit.day);
List<Identity> all = submissionTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(0, all.size());
}
{
// check before 1 week
ReminderRuleImpl rule = getSubmitTaskRules(1, LaunchUnit.week);
List<Identity> all = submissionTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(0, all.size());
}
{
// check before 10 days
ReminderRuleImpl rule = getSubmitTaskRules(10, LaunchUnit.day);
List<Identity> all = submissionTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(2, all.size());
Assert.assertTrue(all.contains(participant1));
Assert.assertTrue(all.contains(participant2));
}
{
// check before 2 days
ReminderRuleImpl rule = getSubmitTaskRules(10, LaunchUnit.week);
List<Identity> all = submissionTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(2, all.size());
Assert.assertTrue(all.contains(participant1));
Assert.assertTrue(all.contains(participant2));
}
{
// check before 30 days
ReminderRuleImpl rule = getSubmitTaskRules(30, LaunchUnit.day);
List<Identity> all = submissionTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(2, all.size());
Assert.assertTrue(all.contains(participant1));
Assert.assertTrue(all.contains(participant2));
}
{
// check before 1 months
ReminderRuleImpl rule = getSubmitTaskRules(1, LaunchUnit.month);
List<Identity> all = submissionTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(2, all.size());
Assert.assertTrue(all.contains(participant1));
Assert.assertTrue(all.contains(participant2));
}
{
// check before 5 months
ReminderRuleImpl rule = getSubmitTaskRules(5, LaunchUnit.month);
List<Identity> all = submissionTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(2, all.size());
Assert.assertTrue(all.contains(participant1));
Assert.assertTrue(all.contains(participant2));
}
{
// check before 1 year
ReminderRuleImpl rule = getSubmitTaskRules(1, LaunchUnit.year);
List<Identity> all = submissionTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(2, all.size());
Assert.assertTrue(all.contains(participant1));
Assert.assertTrue(all.contains(participant2));
}
}
use of org.olat.course.nodes.GTACourseNode in project openolat by klemens.
the class GTAReminderRuleTest method assignTask_relativeToInitialLaunchDate.
@Test
public void assignTask_relativeToInitialLaunchDate() {
// create a course with 3 members
Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("initial-launch-1");
Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("initial-launch-2");
Identity id3 = JunitTestHelper.createAndPersistIdentityAsRndUser("initial-launch-3");
ICourse course = CoursesWebService.createEmptyCourse(null, "initial-launch-dates", "course long name", null);
RepositoryEntry re = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
repositoryEntryRelationDao.addRole(id1, re, GroupRoles.participant.name());
repositoryEntryRelationDao.addRole(id2, re, GroupRoles.participant.name());
repositoryEntryRelationDao.addRole(id3, re, GroupRoles.participant.name());
dbInstance.commit();
// create user course infos
userCourseInformationsManager.updateUserCourseInformations(re.getOlatResource(), id1);
userCourseInformationsManager.updateUserCourseInformations(re.getOlatResource(), id2);
userCourseInformationsManager.updateUserCourseInformations(re.getOlatResource(), id3);
dbInstance.commit();
// fake the date
updateInitialLaunchDate(re.getOlatResource(), id1, -5, Calendar.DATE);
updateInitialLaunchDate(re.getOlatResource(), id2, -35, Calendar.DATE);
updateInitialLaunchDate(re.getOlatResource(), id3, -75, Calendar.DATE);
dbInstance.commitAndCloseSession();
// create a fake node
GTACourseNode node = new GTACourseNode();
node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
node.getModuleConfiguration().setBooleanEntry(GTACourseNode.GTASK_RELATIVE_DATES, true);
node.getModuleConfiguration().setIntValue(GTACourseNode.GTASK_ASSIGNMENT_DEADLINE_RELATIVE, 40);
node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_ASSIGNMENT_DEADLINE_RELATIVE_TO, GTARelativeToDates.courseLaunch.name());
// need the task list
TaskList tasks = gtaManager.createIfNotExists(re, node);
Assert.assertNotNull(tasks);
dbInstance.commit();
{
// check 3 days
ReminderRuleImpl rule = getAssignedTaskRules(3, LaunchUnit.day);
List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(1, all.size());
Assert.assertTrue(all.contains(id3));
}
{
// check 5 days
ReminderRuleImpl rule = getAssignedTaskRules(5, LaunchUnit.day);
List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(2, all.size());
Assert.assertTrue(all.contains(id2));
Assert.assertTrue(all.contains(id3));
}
{
// check 1 week
ReminderRuleImpl rule = getAssignedTaskRules(1, LaunchUnit.week);
List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(2, all.size());
Assert.assertTrue(all.contains(id2));
Assert.assertTrue(all.contains(id3));
}
{
// check 1 month
ReminderRuleImpl rule = getAssignedTaskRules(1, LaunchUnit.month);
List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(2, all.size());
Assert.assertTrue(all.contains(id2));
Assert.assertTrue(all.contains(id3));
}
{
// check 2 month
ReminderRuleImpl rule = getAssignedTaskRules(2, LaunchUnit.month);
List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(3, all.size());
Assert.assertTrue(all.contains(id1));
Assert.assertTrue(all.contains(id2));
Assert.assertTrue(all.contains(id3));
}
}
use of org.olat.course.nodes.GTACourseNode in project openolat by klemens.
the class GTAReminderRuleTest method assignTask_relativeToDateEnrollment.
@Test
public void assignTask_relativeToDateEnrollment() {
// prepare a course with a volatile task
Identity participant1 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-1");
Identity participant2 = JunitTestHelper.createAndPersistIdentityAsRndUser("gta-user-2");
RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry("", false);
addEnrollmentDate(re, participant1, GroupRoles.participant, -12, Calendar.DATE);
addEnrollmentDate(re, participant2, GroupRoles.participant, -5, Calendar.DATE);
dbInstance.commit();
// create a fake node
GTACourseNode node = new GTACourseNode();
node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
node.getModuleConfiguration().setBooleanEntry(GTACourseNode.GTASK_RELATIVE_DATES, true);
node.getModuleConfiguration().setIntValue(GTACourseNode.GTASK_ASSIGNMENT_DEADLINE_RELATIVE, 15);
node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_ASSIGNMENT_DEADLINE_RELATIVE_TO, GTARelativeToDates.enrollment.name());
// need the task list
TaskList tasks = gtaManager.createIfNotExists(re, node);
Assert.assertNotNull(tasks);
dbInstance.commit();
// participant 1 has still 3 days to choose a task
// participant 2 has still 10 days to choose a task
{
// check before 1 day
ReminderRuleImpl rule = getAssignedTaskRules(1, LaunchUnit.day);
List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(0, all.size());
}
{
// check before 5 days
ReminderRuleImpl rule = getAssignedTaskRules(5, LaunchUnit.day);
List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(1, all.size());
Assert.assertTrue(all.contains(participant1));
}
{
// check before 1 week
ReminderRuleImpl rule = getAssignedTaskRules(1, LaunchUnit.week);
List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(1, all.size());
Assert.assertTrue(all.contains(participant1));
}
{
// check before 1 month
ReminderRuleImpl rule = getAssignedTaskRules(1, LaunchUnit.month);
List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(2, all.size());
Assert.assertTrue(all.contains(participant1));
Assert.assertTrue(all.contains(participant2));
}
}
use of org.olat.course.nodes.GTACourseNode in project openolat by klemens.
the class GTAReminderRuleTest method submitTask_individual.
@Test
public void submitTask_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_SUBMIT_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 = submissionTaskRuleSPI.getPeopleToRemind(re, node);
Assert.assertEquals(1, toRemind.size());
Assert.assertTrue(toRemind.contains(participant2));
{
// check before 30 days
ReminderRuleImpl rule = getSubmitTaskRules(30, LaunchUnit.day);
List<Identity> all = submissionTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(0, all.size());
}
{
// check before 5 weeks
ReminderRuleImpl rule = getSubmitTaskRules(5, LaunchUnit.week);
List<Identity> all = submissionTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(0, all.size());
}
{
// check before 1 month
ReminderRuleImpl rule = getSubmitTaskRules(1, LaunchUnit.month);
List<Identity> all = submissionTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(0, all.size());
}
{
// check before 90 days
ReminderRuleImpl rule = getSubmitTaskRules(90, LaunchUnit.day);
List<Identity> all = submissionTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(1, all.size());
Assert.assertTrue(toRemind.contains(participant2));
}
{
// check before 12 weeks
ReminderRuleImpl rule = getSubmitTaskRules(12, LaunchUnit.week);
List<Identity> all = submissionTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(1, all.size());
Assert.assertTrue(toRemind.contains(participant2));
}
{
// check before 3 month
ReminderRuleImpl rule = getSubmitTaskRules(3, LaunchUnit.month);
List<Identity> all = submissionTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(1, all.size());
Assert.assertTrue(toRemind.contains(participant2));
}
{
// check before 1 year
ReminderRuleImpl rule = getSubmitTaskRules(1, LaunchUnit.year);
List<Identity> all = submissionTaskRuleSPI.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 ArchiverMainController method launchArchiveControllers.
private void launchArchiveControllers(UserRequest ureq, String menuCommand) {
if (menuCommand.equals(CMD_INDEX)) {
main.setContent(intro);
} else {
removeAsListenerAndDispose(contentCtr);
if (menuCommand.equals(CMD_QTISURVRESULTS)) {
contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new IQSURVCourseNode());
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_QTITESTRESULTS)) {
contentCtr = new TestArchiveController(ureq, getWindowControl(), ores, new IQTESTCourseNode(), new IQSELFCourseNode());
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_SCOREACCOUNTING)) {
contentCtr = new ScoreAccountingArchiveController(ureq, getWindowControl(), ores);
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_ARCHIVELOGFILES)) {
contentCtr = new CourseLogsArchiveController(ureq, getWindowControl(), ores);
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_HANDEDINTASKS)) {
// TACourseNode
contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new TACourseNode());
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_GROUPTASKS)) {
contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new GTACourseNode(), new GTACourseNode(GTACourseNode.TYPE_INDIVIDUAL));
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_PROJECTBROKER)) {
contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new ProjectBrokerCourseNode());
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_FORUMS)) {
contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new FOCourseNode());
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_DIALOGS)) {
contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new DialogCourseNode());
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_WIKIS)) {
contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new WikiCourseNode());
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_SCORM)) {
contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new ScormCourseNode());
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_CHECKLIST)) {
contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new CheckListCourseNode());
main.setContent(contentCtr.getInitialComponent());
} else if (menuCommand.equals(CMD_PARTICIPANTFOLDER)) {
contentCtr = new GenericArchiveController(ureq, getWindowControl(), ores, new PFCourseNode());
main.setContent(contentCtr.getInitialComponent());
}
listenTo(contentCtr);
}
}
Aggregations