use of org.olat.course.assessment.model.UserCourseInfosImpl in project OpenOLAT by OpenOLAT.
the class GTAReminderRuleTest method updateInitialLaunchDate.
private void updateInitialLaunchDate(OLATResource courseRes, Identity id, int amount, int field) {
UserCourseInfosImpl userCourseInfos = (UserCourseInfosImpl) userCourseInformationsManager.getUserCourseInformations(courseRes, id);
Date initialLaunch = userCourseInfos.getInitialLaunch();
Calendar cal = Calendar.getInstance();
cal.setTime(initialLaunch);
cal.add(field, amount);
userCourseInfos.setInitialLaunch(cal.getTime());
dbInstance.getCurrentEntityManager().merge(userCourseInfos);
dbInstance.commit();
}
use of org.olat.course.assessment.model.UserCourseInfosImpl in project OpenOLAT by OpenOLAT.
the class ReminderRuleEngineTest method updateRecentLaunchDate.
private void updateRecentLaunchDate(OLATResource courseRes, Identity id, int amount, int field) {
UserCourseInfosImpl userCourseInfos = (UserCourseInfosImpl) userCourseInformationsManager.getUserCourseInformations(courseRes, id);
Date recentLaunch = userCourseInfos.getRecentLaunch();
Calendar cal = Calendar.getInstance();
cal.setTime(recentLaunch);
cal.add(field, amount);
userCourseInfos.setRecentLaunch(cal.getTime());
dbInstance.getCurrentEntityManager().merge(userCourseInfos);
dbInstance.commit();
}
use of org.olat.course.assessment.model.UserCourseInfosImpl in project openolat by klemens.
the class OLATUpgrade_8_1_0 method createUserCourseInformation.
private void createUserCourseInformation(SimpleProp prop) {
Identity identity = securityManager.loadIdentityByKey(prop.identityKey);
OLATResource resource = resourceManager.findResourceable(prop.resourceId, "CourseModule");
UserCourseInfosImpl infos = new UserCourseInfosImpl();
infos.setIdentity(identity);
infos.setCreationDate(new Date());
infos.setLastModified(new Date());
infos.setInitialLaunch(prop.initialLaunch);
infos.setRecentLaunch(prop.recentLaunch);
infos.setVisit(1);
infos.setResource(resource);
dbInstance.saveObject(infos);
}
use of org.olat.course.assessment.model.UserCourseInfosImpl in project openolat by klemens.
the class UserCourseInformationsManagerImpl method updateUserCourseInformations.
/**
* Update (or create if not exists) the course informations for a user
* @param userCourseEnv
* @return
*/
@Override
public void updateUserCourseInformations(final OLATResource courseResource, final Identity identity) {
int updatedRows = lowLevelUpdate(courseResource, identity);
// to make it quick
dbInstance.commit();
if (updatedRows == 0) {
OLATResourceable lockRes = OresHelper.createOLATResourceableInstance("CourseLaunchDate::Identity", identity.getKey());
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(lockRes, new SyncerExecutor() {
@Override
public void execute() {
try {
int retryUpdatedRows = lowLevelUpdate(courseResource, identity);
if (retryUpdatedRows == 0) {
UserCourseInfosImpl infos = new UserCourseInfosImpl();
infos.setIdentity(identity);
infos.setCreationDate(new Date());
infos.setInitialLaunch(new Date());
infos.setLastModified(new Date());
infos.setRecentLaunch(new Date());
infos.setVisit(1);
infos.setResource(courseResource);
dbInstance.getCurrentEntityManager().persist(infos);
}
} catch (Exception e) {
log.error("Cannot update course informations for: " + identity + " from " + identity, e);
}
}
});
}
}
use of org.olat.course.assessment.model.UserCourseInfosImpl in project OpenOLAT by OpenOLAT.
the class ReminderRuleEngineTest method updateInitialLaunchDate.
private void updateInitialLaunchDate(OLATResource courseRes, Identity id, int amount, int field) {
UserCourseInfosImpl userCourseInfos = (UserCourseInfosImpl) userCourseInformationsManager.getUserCourseInformations(courseRes, id);
Date initialLaunch = userCourseInfos.getInitialLaunch();
Calendar cal = Calendar.getInstance();
cal.setTime(initialLaunch);
cal.add(field, amount);
userCourseInfos.setInitialLaunch(cal.getTime());
dbInstance.getCurrentEntityManager().merge(userCourseInfos);
dbInstance.commit();
}
Aggregations