use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class PFNotifications method getItems.
public List<SubscriptionListItem> getItems() throws Exception {
Publisher p = subscriber.getPublisher();
Identity identity = subscriber.getIdentity();
ICourse course = CourseFactory.loadCourse(p.getResId());
CourseEnvironment courseEnv = course.getCourseEnvironment();
CourseGroupManager groupManager = courseEnv.getCourseGroupManager();
CourseNode node = course.getRunStructure().getNode(p.getSubidentifier());
RepositoryEntry entry = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
Date latestNews = p.getLatestNewsDate();
if (notificationsManager.isPublisherValid(p) && compareDate.before(latestNews)) {
this.displayname = entry.getDisplayname();
if (groupManager.isIdentityCourseCoach(identity) || groupManager.isIdentityCourseAdministrator(identity)) {
List<Identity> participants = pfManager.getParticipants(identity, courseEnv, groupManager.isIdentityCourseAdministrator(identity));
for (Identity participant : participants) {
gatherItems(participant, p, courseEnv, node);
}
} else {
gatherItems(identity, p, courseEnv, node);
}
}
return items;
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class GTAManagerImpl method syncAssessmentEntry.
private void syncAssessmentEntry(TaskImpl taskImpl, GTACourseNode cNode, Role by) {
if (taskImpl == null || taskImpl.getTaskStatus() == null || cNode == null)
return;
RepositoryEntry courseRepoEntry = taskImpl.getTaskList().getEntry();
AssessmentEntryStatus assessmentStatus = convertToAssessmentEntrystatus(taskImpl, cNode);
if (GTAType.group.name().equals(cNode.getModuleConfiguration().getStringValue(GTACourseNode.GTASK_TYPE))) {
// update whole group
assessmentService.updateAssessmentEntries(taskImpl.getBusinessGroup(), courseRepoEntry, cNode.getIdent(), null, assessmentStatus);
} else {
Identity assessedIdentity = taskImpl.getIdentity();
assessmentService.updateAssessmentEntry(assessedIdentity, courseRepoEntry, cNode.getIdent(), null, assessmentStatus);
dbInstance.commit();
ICourse course = CourseFactory.loadCourse(courseRepoEntry);
UserCourseEnvironment userCourseEnv = AssessmentHelper.createAndInitUserCourseEnvironment(assessedIdentity, course);
cNode.updateLastModifications(userCourseEnv, taskImpl.getIdentity(), by);
}
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class ScormAPIMapper method checkForLms.
private final void checkForLms() {
check();
if (scormNode == null) {
int sep = courseIdNodeId.indexOf('-');
String courseId = courseIdNodeId.substring(0, sep);
String nodeId = courseIdNodeId.substring(sep + 1);
ICourse course = CourseFactory.loadCourse(Long.parseLong(courseId));
scormNode = (ScormCourseNode) course.getRunStructure().getNode(nodeId);
IdentityEnvironment identityEnvironment = new IdentityEnvironment();
identityEnvironment.setIdentity(identity);
userCourseEnv = new UserCourseEnvironmentImpl(identityEnvironment, course.getCourseEnvironment());
}
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class ReminderRuleEngineTest method afterEndDate.
@Test
public void afterEndDate() {
// create a course with 3 members
Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("after-end-1");
Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("after-end-2");
Identity id3 = JunitTestHelper.createAndPersistIdentityAsRndUser("after-end-3");
ICourse course = CoursesWebService.createEmptyCourse(null, "initial-launch-dates", "course long name", null);
RepositoryEntry re = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
Calendar cal = Calendar.getInstance();
// now
cal.setTime(new Date());
cal.add(Calendar.DATE, -25);
Date validFrom = cal.getTime();
// - 3weeks
cal.add(Calendar.DATE, 4);
Date validTo = cal.getTime();
RepositoryEntryLifecycle cycle = lifecycleDao.create("Cycle 2", "Cycle soft 2", false, validFrom, validTo);
re = repositoryManager.setDescriptionAndName(re, null, null, null, null, null, null, null, cycle);
repositoryEntryRelationDao.addRole(id1, re, GroupRoles.owner.name());
repositoryEntryRelationDao.addRole(id2, re, GroupRoles.coach.name());
repositoryEntryRelationDao.addRole(id3, re, GroupRoles.participant.name());
dbInstance.commit();
{
// check after 2 days
List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidToRule(2, LaunchUnit.day);
boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
Assert.assertTrue(match);
}
{
// check after 7 days (between begin and and date)
List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidToRule(7, LaunchUnit.day);
boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
Assert.assertTrue(match);
}
{
// check after 2 week s
List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidToRule(1, LaunchUnit.week);
boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
Assert.assertTrue(match);
}
{
// check after 21 days
List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidToRule(21, LaunchUnit.day);
boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
Assert.assertTrue(match);
}
{
// check after 3 weeks
List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidToRule(3, LaunchUnit.week);
boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
Assert.assertTrue(match);
}
{
// check after 22 days
List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidToRule(22, LaunchUnit.day);
boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
Assert.assertFalse(match);
}
{
// check after 4 weeks
List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidToRule(4, LaunchUnit.week);
boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
Assert.assertFalse(match);
}
{
// check after 1 month
List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidToRule(1, LaunchUnit.month);
boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
Assert.assertFalse(match);
}
}
use of org.olat.course.ICourse in project OpenOLAT by OpenOLAT.
the class ReminderRuleEngineTest method recentLaunchDate.
@Test
public void recentLaunchDate() {
// 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.owner.name());
repositoryEntryRelationDao.addRole(id2, re, GroupRoles.coach.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
updateRecentLaunchDate(re.getOlatResource(), id1, -5, Calendar.DATE);
updateRecentLaunchDate(re.getOlatResource(), id2, -35, Calendar.DATE);
updateRecentLaunchDate(re.getOlatResource(), id3, -75, Calendar.DATE);
dbInstance.commitAndCloseSession();
List<Identity> identities = new ArrayList<>();
identities.add(id1);
identities.add(id2);
identities.add(id3);
{
// check after 3 days
List<ReminderRule> rules = getRecentLaunchRules(3, LaunchUnit.day);
List<Identity> all = new ArrayList<>(identities);
ruleEngine.filterByRules(re, all, rules);
Assert.assertEquals(3, all.size());
}
{
// check after 7 days
List<ReminderRule> rules = getRecentLaunchRules(7, LaunchUnit.day);
List<Identity> all = new ArrayList<>(identities);
ruleEngine.filterByRules(re, all, rules);
Assert.assertEquals(2, all.size());
Assert.assertTrue(all.contains(id2));
Assert.assertTrue(all.contains(id3));
}
{
// check after 1 week
List<ReminderRule> rules = getRecentLaunchRules(1, LaunchUnit.week);
List<Identity> all = new ArrayList<>(identities);
ruleEngine.filterByRules(re, all, rules);
Assert.assertEquals(2, all.size());
Assert.assertTrue(all.contains(id2));
Assert.assertTrue(all.contains(id3));
}
{
// check after 1 month
List<ReminderRule> rules = getRecentLaunchRules(1, LaunchUnit.month);
List<Identity> all = new ArrayList<>(identities);
ruleEngine.filterByRules(re, all, rules);
Assert.assertEquals(2, all.size());
Assert.assertTrue(all.contains(id2));
Assert.assertTrue(all.contains(id3));
}
{
// check after 6 weeks
List<ReminderRule> rules = getRecentLaunchRules(6, LaunchUnit.week);
List<Identity> all = new ArrayList<>(identities);
ruleEngine.filterByRules(re, all, rules);
Assert.assertEquals(1, all.size());
Assert.assertTrue(all.contains(id3));
}
{
// check after 1 year
List<ReminderRule> rules = getRecentLaunchRules(2, LaunchUnit.month);
List<Identity> all = new ArrayList<>(identities);
ruleEngine.filterByRules(re, all, rules);
Assert.assertEquals(1, all.size());
Assert.assertTrue(all.contains(id3));
}
{
// check after 1 year
List<ReminderRule> rules = getRecentLaunchRules(1, LaunchUnit.year);
List<Identity> all = new ArrayList<>(identities);
ruleEngine.filterByRules(re, all, rules);
Assert.assertEquals(0, all.size());
}
}
Aggregations