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