Search in sources :

Example 46 with ICourse

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;
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) ICourse(org.olat.course.ICourse) Publisher(org.olat.core.commons.services.notifications.Publisher) CourseNode(org.olat.course.nodes.CourseNode) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Date(java.util.Date)

Example 47 with ICourse

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);
    }
}
Also used : UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) AssessmentEntryStatus(org.olat.modules.assessment.model.AssessmentEntryStatus)

Example 48 with ICourse

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());
    }
}
Also used : UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) ICourse(org.olat.course.ICourse) IdentityEnvironment(org.olat.core.id.IdentityEnvironment)

Example 49 with ICourse

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);
    }
}
Also used : RepositoryEntryLifecycle(org.olat.repository.model.RepositoryEntryLifecycle) Calendar(java.util.Calendar) ICourse(org.olat.course.ICourse) List(java.util.List) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test)

Example 50 with ICourse

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());
    }
}
Also used : ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) List(java.util.List) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Aggregations

ICourse (org.olat.course.ICourse)674 Identity (org.olat.core.id.Identity)262 RepositoryEntry (org.olat.repository.RepositoryEntry)246 CourseNode (org.olat.course.nodes.CourseNode)182 Test (org.junit.Test)158 ArrayList (java.util.ArrayList)102 UserCourseEnvironment (org.olat.course.run.userview.UserCourseEnvironment)90 Date (java.util.Date)84 URI (java.net.URI)76 HttpResponse (org.apache.http.HttpResponse)76 OLATResource (org.olat.resource.OLATResource)64 File (java.io.File)62 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)52 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)52 Produces (javax.ws.rs.Produces)48 Roles (org.olat.core.id.Roles)44 Path (javax.ws.rs.Path)42 UserRequest (org.olat.core.gui.UserRequest)42 INode (org.olat.core.util.nodes.INode)40 ScoreEvaluation (org.olat.course.run.scoring.ScoreEvaluation)40