Search in sources :

Example 1 with UserCourseInformations

use of org.olat.course.assessment.UserCourseInformations in project OpenOLAT by OpenOLAT.

the class UserCourseInformationsManagerTest method createUpdateCourseInfos_create.

@Test
public void createUpdateCourseInfos_create() {
    Identity user = JunitTestHelper.createAndPersistIdentityAsUser("user-launch-1-" + UUID.randomUUID().toString());
    ICourse course = CoursesWebService.createEmptyCourse(user, "course-launch-dates", "course long name", null);
    dbInstance.commitAndCloseSession();
    OLATResource courseResource = course.getCourseEnvironment().getCourseGroupManager().getCourseResource();
    userCourseInformationsManager.updateUserCourseInformations(courseResource, user);
    dbInstance.commitAndCloseSession();
    UserCourseInformations infos = userCourseInformationsManager.getUserCourseInformations(courseResource, user);
    Assert.assertNotNull(infos);
    Assert.assertNotNull(infos.getIdentity());
    Assert.assertNotNull(infos.getResource());
    Assert.assertNotNull(infos.getInitialLaunch());
    Assert.assertNotNull(infos.getRecentLaunch());
    Assert.assertEquals(1, infos.getVisit());
    Assert.assertEquals(infos.getIdentity(), user);
    Assert.assertEquals(course.getResourceableId(), infos.getResource().getResourceableId());
    Assert.assertEquals(course.getResourceableTypeName(), infos.getResource().getResourceableTypeName());
}
Also used : OLATResource(org.olat.resource.OLATResource) ICourse(org.olat.course.ICourse) Identity(org.olat.core.id.Identity) UserCourseInformations(org.olat.course.assessment.UserCourseInformations) Test(org.junit.Test)

Example 2 with UserCourseInformations

use of org.olat.course.assessment.UserCourseInformations in project OpenOLAT by OpenOLAT.

the class UserCourseInformationsManagerTest method createUpdateCourseInfos_updateToo_implementationDetails.

/**
 * Check the low level update statement, it's the critical part of the
 * method which update the user course informations.
 */
@Test
public void createUpdateCourseInfos_updateToo_implementationDetails() {
    Identity user = JunitTestHelper.createAndPersistIdentityAsUser("user-launch-1-" + UUID.randomUUID().toString());
    ICourse course = CoursesWebService.createEmptyCourse(user, "course-launch-dates", "course long name", null);
    dbInstance.commitAndCloseSession();
    OLATResource courseResource = course.getCourseEnvironment().getCourseGroupManager().getCourseResource();
    userCourseInformationsManager.updateUserCourseInformations(courseResource, user);
    dbInstance.commitAndCloseSession();
    int updated1 = ((UserCourseInformationsManagerImpl) userCourseInformationsManager).lowLevelUpdate(courseResource, user);
    dbInstance.commitAndCloseSession();
    Assert.assertEquals(1, updated1);
    int updated2 = ((UserCourseInformationsManagerImpl) userCourseInformationsManager).lowLevelUpdate(courseResource, user);
    dbInstance.commitAndCloseSession();
    Assert.assertEquals(1, updated2);
    UserCourseInformations infos = userCourseInformationsManager.getUserCourseInformations(courseResource, user);
    Assert.assertNotNull(infos);
    Assert.assertNotNull(infos.getIdentity());
    Assert.assertEquals(3, infos.getVisit());
}
Also used : OLATResource(org.olat.resource.OLATResource) ICourse(org.olat.course.ICourse) Identity(org.olat.core.id.Identity) UserCourseInformations(org.olat.course.assessment.UserCourseInformations) Test(org.junit.Test)

Example 3 with UserCourseInformations

use of org.olat.course.assessment.UserCourseInformations in project OpenOLAT by OpenOLAT.

the class GetInitialCourseLaunchDateFunction method call.

/**
 * @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
 */
public Object call(Object[] inStack) {
    CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
    if (cev != null) {
        return defaultValue();
    }
    // the real function evaluation which is used during run time
    UserCourseInformationsManager mgr = CoreSpringFactory.getImpl(UserCourseInformationsManager.class);
    UserCourseInformations infos = mgr.getUserCourseInformations(getUserCourseEnv().getCourseEnvironment().getCourseGroupManager().getCourseResource(), getUserCourseEnv().getIdentityEnvironment().getIdentity());
    if (infos != null) {
        return Double.valueOf(infos.getInitialLaunch().getTime());
    } else {
        // what to do in case of no date available??? -> return date in the future
        return new Double(Double.POSITIVE_INFINITY);
    }
}
Also used : CourseEditorEnv(org.olat.course.editor.CourseEditorEnv) UserCourseInformationsManager(org.olat.course.assessment.manager.UserCourseInformationsManager) UserCourseInformations(org.olat.course.assessment.UserCourseInformations)

Example 4 with UserCourseInformations

use of org.olat.course.assessment.UserCourseInformations in project openolat by klemens.

the class GetInitialCourseLaunchDateFunction method call.

/**
 * @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
 */
public Object call(Object[] inStack) {
    CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
    if (cev != null) {
        return defaultValue();
    }
    // the real function evaluation which is used during run time
    UserCourseInformationsManager mgr = CoreSpringFactory.getImpl(UserCourseInformationsManager.class);
    UserCourseInformations infos = mgr.getUserCourseInformations(getUserCourseEnv().getCourseEnvironment().getCourseGroupManager().getCourseResource(), getUserCourseEnv().getIdentityEnvironment().getIdentity());
    if (infos != null) {
        return Double.valueOf(infos.getInitialLaunch().getTime());
    } else {
        // what to do in case of no date available??? -> return date in the future
        return new Double(Double.POSITIVE_INFINITY);
    }
}
Also used : CourseEditorEnv(org.olat.course.editor.CourseEditorEnv) UserCourseInformationsManager(org.olat.course.assessment.manager.UserCourseInformationsManager) UserCourseInformations(org.olat.course.assessment.UserCourseInformations)

Example 5 with UserCourseInformations

use of org.olat.course.assessment.UserCourseInformations in project openolat by klemens.

the class UserCourseInformationsManagerTest method createUpdateCourseInfos_create.

@Test
public void createUpdateCourseInfos_create() {
    Identity user = JunitTestHelper.createAndPersistIdentityAsUser("user-launch-1-" + UUID.randomUUID().toString());
    ICourse course = CoursesWebService.createEmptyCourse(user, "course-launch-dates", "course long name", null);
    dbInstance.commitAndCloseSession();
    OLATResource courseResource = course.getCourseEnvironment().getCourseGroupManager().getCourseResource();
    userCourseInformationsManager.updateUserCourseInformations(courseResource, user);
    dbInstance.commitAndCloseSession();
    UserCourseInformations infos = userCourseInformationsManager.getUserCourseInformations(courseResource, user);
    Assert.assertNotNull(infos);
    Assert.assertNotNull(infos.getIdentity());
    Assert.assertNotNull(infos.getResource());
    Assert.assertNotNull(infos.getInitialLaunch());
    Assert.assertNotNull(infos.getRecentLaunch());
    Assert.assertEquals(1, infos.getVisit());
    Assert.assertEquals(infos.getIdentity(), user);
    Assert.assertEquals(course.getResourceableId(), infos.getResource().getResourceableId());
    Assert.assertEquals(course.getResourceableTypeName(), infos.getResource().getResourceableTypeName());
}
Also used : OLATResource(org.olat.resource.OLATResource) ICourse(org.olat.course.ICourse) Identity(org.olat.core.id.Identity) UserCourseInformations(org.olat.course.assessment.UserCourseInformations) Test(org.junit.Test)

Aggregations

UserCourseInformations (org.olat.course.assessment.UserCourseInformations)10 Test (org.junit.Test)6 Identity (org.olat.core.id.Identity)6 ICourse (org.olat.course.ICourse)6 OLATResource (org.olat.resource.OLATResource)6 UserCourseInformationsManager (org.olat.course.assessment.manager.UserCourseInformationsManager)4 CourseEditorEnv (org.olat.course.editor.CourseEditorEnv)4