Search in sources :

Example 1 with UserCourseInfosImpl

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();
}
Also used : Calendar(java.util.Calendar) UserCourseInfosImpl(org.olat.course.assessment.model.UserCourseInfosImpl) Date(java.util.Date)

Example 2 with UserCourseInfosImpl

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();
}
Also used : Calendar(java.util.Calendar) UserCourseInfosImpl(org.olat.course.assessment.model.UserCourseInfosImpl) Date(java.util.Date)

Example 3 with UserCourseInfosImpl

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);
}
Also used : OLATResource(org.olat.resource.OLATResource) Identity(org.olat.core.id.Identity) UserCourseInfosImpl(org.olat.course.assessment.model.UserCourseInfosImpl) Date(java.util.Date)

Example 4 with UserCourseInfosImpl

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);
                }
            }
        });
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor) UserCourseInfosImpl(org.olat.course.assessment.model.UserCourseInfosImpl) Date(java.util.Date)

Example 5 with UserCourseInfosImpl

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();
}
Also used : Calendar(java.util.Calendar) UserCourseInfosImpl(org.olat.course.assessment.model.UserCourseInfosImpl) Date(java.util.Date)

Aggregations

Date (java.util.Date)10 UserCourseInfosImpl (org.olat.course.assessment.model.UserCourseInfosImpl)10 Calendar (java.util.Calendar)6 Identity (org.olat.core.id.Identity)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 SyncerExecutor (org.olat.core.util.coordinate.SyncerExecutor)2 OLATResource (org.olat.resource.OLATResource)2