diff --git a/src/main/java/org/olat/core/commons/modules/glossary/GlossaryMainController.java b/src/main/java/org/olat/core/commons/modules/glossary/GlossaryMainController.java index 899ff328a48d07195eda38ff38c7580f92402e74..d1879e60e1f1fce0bcd5d8809933f787b0a613dd 100644 --- a/src/main/java/org/olat/core/commons/modules/glossary/GlossaryMainController.java +++ b/src/main/java/org/olat/core/commons/modules/glossary/GlossaryMainController.java @@ -58,6 +58,7 @@ import org.olat.core.util.StringHelper; import org.olat.core.util.coordinate.CoordinatorManager; import org.olat.core.util.coordinate.LockResult; import org.olat.core.util.vfs.VFSContainer; +import org.olat.resource.OLATResource; import org.olat.user.UserInfoMainController; import org.olat.user.UserManager; import org.springframework.beans.factory.annotation.Autowired; @@ -102,7 +103,7 @@ public class GlossaryMainController extends BasicController implements Activatea @Autowired private BaseSecurity securityManager; - public GlossaryMainController(WindowControl control, UserRequest ureq, VFSContainer glossaryFolder, OLATResourceable res, + public GlossaryMainController(WindowControl control, UserRequest ureq, VFSContainer glossaryFolder, OLATResource res, GlossarySecurityCallback glossarySecCallback, boolean eventProfil) { super(ureq, control); this.glossarySecCallback = glossarySecCallback; diff --git a/src/main/java/org/olat/course/archiver/ScoreAccountingHelper.java b/src/main/java/org/olat/course/archiver/ScoreAccountingHelper.java index c9eed9a88e0b137604b989ae6384c189509d9981..bacc0efeedea99211894a128924f8a0a51fc2a94 100644 --- a/src/main/java/org/olat/course/archiver/ScoreAccountingHelper.java +++ b/src/main/java/org/olat/course/archiver/ScoreAccountingHelper.java @@ -64,6 +64,7 @@ import org.olat.group.BusinessGroupService; import org.olat.repository.RepositoryEntry; import org.olat.repository.RepositoryManager; import org.olat.repository.RepositoryService; +import org.olat.resource.OLATResource; import org.olat.user.UserManager; import org.olat.user.propertyhandlers.UserPropertyHandler; @@ -137,7 +138,8 @@ public class ScoreAccountingHelper { int rowNumber = 1; UserCourseInformationsManager mgr = CoreSpringFactory.getImpl(UserCourseInformationsManager.class); - Map<Long,Date> firstTimes = mgr.getInitialLaunchDates(courseEnvironment.getCourseResourceableId(), identities); + OLATResource courseResource = courseEnvironment.getCourseGroupManager().getCourseResource(); + Map<Long,Date> firstTimes = mgr.getInitialLaunchDates(courseResource, identities); Formatter formatter = Formatter.getInstance(locale); for (Identity identity:identities) { diff --git a/src/main/java/org/olat/course/assessment/AssessmentMainController.java b/src/main/java/org/olat/course/assessment/AssessmentMainController.java index f85956c50ae6a0b141f1454aa6877798a9f2d5bd..b6e3b3f90b502ae689ec719e3684119d4c18ca9f 100644 --- a/src/main/java/org/olat/course/assessment/AssessmentMainController.java +++ b/src/main/java/org/olat/course/assessment/AssessmentMainController.java @@ -710,7 +710,7 @@ public class AssessmentMainController extends MainLayoutBasicController implemen initialLaunchDate = initialLaunchDates.get(identityKeyFromEvent); } else { UserCourseInformationsManager userCourseInformationsManager = CoreSpringFactory.getImpl(UserCourseInformationsManager.class); - initialLaunchDate = userCourseInformationsManager.getInitialLaunchDate(ores.getResourceableId(), uce.getIdentityEnvironment().getIdentity()); + initialLaunchDate = userCourseInformationsManager.getInitialLaunchDate(re.getOlatResource(), uce.getIdentityEnvironment().getIdentity()); } AssessedIdentityWrapper wrappedIdFromModel = AssessmentHelper.wrapIdentity(uce, initialLaunchDate, currentCourseNode); wrappersToUpdate.add(wrappedIdFromModel); @@ -1403,7 +1403,7 @@ public class AssessmentMainController extends MainLayoutBasicController implemen course.getCourseEnvironment().getAssessmentManager().preloadCache(identities); UserCourseInformationsManager mgr = CoreSpringFactory.getImpl(UserCourseInformationsManager.class); - initialLaunchDates.putAll(mgr.getInitialLaunchDates(course.getResourceableId(), identities)); + initialLaunchDates.putAll(mgr.getInitialLaunchDates(re.getOlatResource(), identities)); for (Identity identity : identities) { AssessmentHelper.wrapIdentity(identity, localUserCourseEnvironmentCache, initialLaunchDates, course, null); diff --git a/src/main/java/org/olat/course/assessment/IdentityAssessmentEditController.java b/src/main/java/org/olat/course/assessment/IdentityAssessmentEditController.java index 77f13d21e31e3adda73b9db7c503aa67663de5b5..9345401325614c2d18ff3b194e38bb1b46e4d465 100644 --- a/src/main/java/org/olat/course/assessment/IdentityAssessmentEditController.java +++ b/src/main/java/org/olat/course/assessment/IdentityAssessmentEditController.java @@ -190,7 +190,8 @@ public class IdentityAssessmentEditController extends BasicController { if (mayEdit) { ICourse course = CourseFactory.loadCourse(ores); UserCourseInformationsManager userCourseInformationsManager = CoreSpringFactory.getImpl(UserCourseInformationsManager.class); - Date initialLaunchDate = userCourseInformationsManager.getInitialLaunchDate(ores.getResourceableId(), assessedUserCourseEnvironment.getIdentityEnvironment().getIdentity()); + Date initialLaunchDate = userCourseInformationsManager.getInitialLaunchDate(course.getCourseEnvironment().getCourseGroupManager().getCourseResource(), + assessedUserCourseEnvironment.getIdentityEnvironment().getIdentity()); AssessedIdentityWrapper assessedIdentityWrapper = AssessmentHelper.wrapIdentity(assessedUserCourseEnvironment, initialLaunchDate, courseNode); assessmentEditCtr = new AssessmentEditController(ureq, getWindowControl(), stackPanel, course, courseNode, assessedIdentityWrapper, true, false, !pushToStackPanel); diff --git a/src/main/java/org/olat/course/assessment/manager/UserCourseInformationsManager.java b/src/main/java/org/olat/course/assessment/manager/UserCourseInformationsManager.java index 5bb9b1c1111bf8187c128628aab5dd3f3e77f542..315a00a152cc4307b01dadc5ba7ea3d2cbdf34c1 100644 --- a/src/main/java/org/olat/course/assessment/manager/UserCourseInformationsManager.java +++ b/src/main/java/org/olat/course/assessment/manager/UserCourseInformationsManager.java @@ -35,21 +35,24 @@ import org.olat.resource.OLATResource; */ public interface UserCourseInformationsManager { - public UserCourseInformations getUserCourseInformations(Long courseResourceId, IdentityRef identity); + public UserCourseInformations getUserCourseInformations(OLATResource resource, IdentityRef identity); public List<UserCourseInformations> getUserCourseInformations(IdentityRef identity, List<OLATResource> resources); - public List<UserCourseInformations> getUserCourseInformations(List<Long> keys); - - public void updateUserCourseInformations(OLATResource courseResource, Identity identity); - public Date getInitialLaunchDate(Long courseResourceId, IdentityRef identity); + public Date getInitialLaunchDate(OLATResource resource, IdentityRef identity); - public Date getRecentLaunchDate(Long courseResourceId, IdentityRef identity); + public Date getRecentLaunchDate(OLATResource resource, IdentityRef identity); - - public Map<Long,Date> getRecentLaunchDates(Long courseResourceId, List<Identity> identities); + /** + * Get all last launch date for all visitors. + * @param resource + * @return + */ + public Map<Long,Date> getRecentLaunchDates(OLATResource resource); + + public Map<Long,Date> getRecentLaunchDates(OLATResource resource, List<Identity> identities); /** * Return the initial launch dates of a list of users. @@ -57,7 +60,7 @@ public interface UserCourseInformationsManager { * @param identities * @return */ - public Map<Long,Date> getInitialLaunchDates(Long courseResourceId, List<Identity> identities); + public Map<Long,Date> getInitialLaunchDates(OLATResource resource, List<Identity> identities); /** * Return all initial launch dates of a course. diff --git a/src/main/java/org/olat/course/assessment/manager/UserCourseInformationsManagerImpl.java b/src/main/java/org/olat/course/assessment/manager/UserCourseInformationsManagerImpl.java index e4895524bd23681e7e48391828807a7c42ecf2f1..76569e8a220294416f95c173fa2a5fa5a355ef9a 100644 --- a/src/main/java/org/olat/course/assessment/manager/UserCourseInformationsManagerImpl.java +++ b/src/main/java/org/olat/course/assessment/manager/UserCourseInformationsManagerImpl.java @@ -62,18 +62,18 @@ public class UserCourseInformationsManagerImpl implements UserCourseInformations private DB dbInstance; @Override - public UserCourseInfosImpl getUserCourseInformations(Long courseResourceId, IdentityRef identity) { + public UserCourseInfosImpl getUserCourseInformations(OLATResource resource, IdentityRef identity) { try { StringBuilder sb = new StringBuilder(); sb.append("select infos from ").append(UserCourseInfosImpl.class.getName()).append(" as infos ") .append(" inner join fetch infos.resource as resource") .append(" inner join infos.identity as identity") - .append(" where identity.key=:identityKey and resource.resId=:resId and resource.resName='CourseModule'"); + .append(" where identity.key=:identityKey and resource.key=:resKey and resource.resName='CourseModule'"); List<UserCourseInfosImpl> infoList = dbInstance.getCurrentEntityManager() .createQuery(sb.toString(), UserCourseInfosImpl.class) .setParameter("identityKey", identity.getKey()) - .setParameter("resId", courseResourceId) + .setParameter("resKey", resource.getKey()) .getResultList(); if(infoList.isEmpty()) { @@ -113,24 +113,6 @@ public class UserCourseInformationsManagerImpl implements UserCourseInformations } } - @Override - public List<UserCourseInformations> getUserCourseInformations(List<Long> keys) { - if(keys == null || keys.isEmpty()) { - return Collections.emptyList(); - } - - StringBuilder sb = new StringBuilder(); - sb.append("select infos from ").append(UserCourseInfosImpl.class.getName()).append(" as infos ") - .append(" inner join fetch infos.resource as resource") - .append(" inner join infos.identity as identity") - .append(" where infos.key in (:keys)"); - - return dbInstance.getCurrentEntityManager() - .createQuery(sb.toString(), UserCourseInformations.class) - .setParameter("keys", keys) - .getResultList(); - } - /** * Execute the update statement * @param courseResource @@ -181,16 +163,16 @@ public class UserCourseInformationsManagerImpl implements UserCourseInformations } @Override - public Date getRecentLaunchDate(Long courseResourceId, IdentityRef identity) { + public Date getRecentLaunchDate(OLATResource resource, IdentityRef identity) { StringBuilder sb = new StringBuilder(); sb.append("select infos.recentLaunch from usercourseinfos as infos ") .append(" inner join infos.resource as resource") - .append(" where infos.identity.key=:identityKey and resource.resId=:resId and resource.resName='CourseModule'"); + .append(" where infos.identity.key=:identityKey and resource.key=:resKey and resource.resName='CourseModule'"); List<Date> infoList = dbInstance.getCurrentEntityManager() .createQuery(sb.toString(), Date.class) .setParameter("identityKey", identity.getKey()) - .setParameter("resId", courseResourceId) + .setParameter("resKey", resource.getKey()) .getResultList(); if(infoList.isEmpty()) { @@ -200,21 +182,21 @@ public class UserCourseInformationsManagerImpl implements UserCourseInformations } @Override - public Date getInitialLaunchDate(Long courseResourceId, IdentityRef identity) { - return getInitialLaunchDate(courseResourceId, identity.getKey()); + public Date getInitialLaunchDate(OLATResource resource, IdentityRef identity) { + return getInitialLaunchDate(resource, identity.getKey()); } - public Date getInitialLaunchDate(Long courseResourceId, Long identityKey) { + public Date getInitialLaunchDate(OLATResource resource, Long identityKey) { try { StringBuilder sb = new StringBuilder(); sb.append("select infos.initialLaunch from ").append(UserCourseInfosImpl.class.getName()).append(" as infos ") .append(" inner join infos.resource as resource") - .append(" where infos.identity.key=:identityKey and resource.resId=:resId and resource.resName='CourseModule'"); + .append(" where infos.identity.key=:identityKey and resource.key=:resKey and resource.resName='CourseModule'"); List<Date> infoList = dbInstance.getCurrentEntityManager() .createQuery(sb.toString(), Date.class) .setParameter("identityKey", identityKey) - .setParameter("resId", courseResourceId) + .setParameter("resKey", resource.getKey()) .getResultList(); if(infoList.isEmpty()) { @@ -222,7 +204,7 @@ public class UserCourseInformationsManagerImpl implements UserCourseInformations } return infoList.get(0); } catch (Exception e) { - log.error("Cannot retrieve course informations for: " + courseResourceId, e); + log.error("Cannot retrieve course informations for: " + resource.getResourceableId(), e); return null; } } @@ -234,7 +216,7 @@ public class UserCourseInformationsManagerImpl implements UserCourseInformations * @return */ @Override - public Map<Long,Date> getInitialLaunchDates(Long courseResourceId, List<Identity> identities) { + public Map<Long,Date> getInitialLaunchDates(OLATResource resource, List<Identity> identities) { if(identities == null || identities.isEmpty()) { return new HashMap<Long,Date>(); } @@ -244,7 +226,7 @@ public class UserCourseInformationsManagerImpl implements UserCourseInformations StringBuilder sb = new StringBuilder(); sb.append("select infos.identity.key, infos.initialLaunch from ").append(UserCourseInfosImpl.class.getName()).append(" as infos ") .append(" inner join infos.resource as resource") - .append(" where resource.resId=:resId and resource.resName='CourseModule'"); + .append(" where resource.key=:resKey and resource.resName='CourseModule'"); Set<Long> identityKeySet = null; if(identityKeys.size() < 100) { @@ -252,8 +234,9 @@ public class UserCourseInformationsManagerImpl implements UserCourseInformations identityKeySet = new HashSet<Long>(identityKeys); } - TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class) - .setParameter("resId", courseResourceId); + TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager() + .createQuery(sb.toString(), Object[].class) + .setParameter("resKey", resource.getKey()); if(identityKeys.size() < 100) { query.setParameter("identityKeys", identityKeys); } @@ -269,7 +252,7 @@ public class UserCourseInformationsManagerImpl implements UserCourseInformations } return dateMap; } catch (Exception e) { - log.error("Cannot retrieve course informations for: " + courseResourceId, e); + log.error("Cannot retrieve course informations for: " + resource.getResourceableId(), e); return Collections.emptyMap(); } } @@ -308,13 +291,36 @@ public class UserCourseInformationsManagerImpl implements UserCourseInformations } } + @Override + public Map<Long, Date> getRecentLaunchDates(OLATResource resource) { + try { + StringBuilder sb = new StringBuilder(); + sb.append("select infos.identity.key, infos.recentLaunch from usercourseinfos as infos where infos.resource.key=:resKey"); + + List<Object[]> infoList = dbInstance.getCurrentEntityManager() + .createQuery(sb.toString(), Object[].class) + .setParameter("resKey", resource.getKey()) + .getResultList(); + Map<Long, Date> dateMap = new HashMap<>(); + for(Object[] infos:infoList) { + Long identityKey = (Long)infos[0]; + Date recentLaunch = (Date)infos[1]; + dateMap.put(identityKey, recentLaunch); + } + return dateMap; + } catch (Exception e) { + log.error("Cannot retrieve course informations for: " + resource.getResourceableId(), e); + return Collections.emptyMap(); + } + } + /** * Return a map of identity keys to initial launch date. * @param courseEnv * @return */ @Override - public Map<Long,Date> getRecentLaunchDates(Long courseResourceId, List<Identity> identities) { + public Map<Long,Date> getRecentLaunchDates(OLATResource resource, List<Identity> identities) { if(identities == null || identities.isEmpty()) { return new HashMap<Long,Date>(); } @@ -324,7 +330,7 @@ public class UserCourseInformationsManagerImpl implements UserCourseInformations StringBuilder sb = new StringBuilder(); sb.append("select infos.identity.key, infos.recentLaunch from ").append(UserCourseInfosImpl.class.getName()).append(" as infos ") .append(" inner join infos.resource as resource") - .append(" where resource.resId=:resId and resource.resName='CourseModule'"); + .append(" where resource.key=:resKey and resource.resName='CourseModule'"); Set<Long> identityKeySet = null; if(identityKeys.size() < 100) { @@ -333,7 +339,7 @@ public class UserCourseInformationsManagerImpl implements UserCourseInformations } TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class) - .setParameter("resId", courseResourceId); + .setParameter("resKey", resource.getKey()); if(identityKeys.size() < 100) { query.setParameter("identityKeys", identityKeys); } @@ -349,7 +355,7 @@ public class UserCourseInformationsManagerImpl implements UserCourseInformations } return dateMap; } catch (Exception e) { - log.error("Cannot retrieve course informations for: " + courseResourceId, e); + log.error("Cannot retrieve course informations for: " + resource.getResourceableId(), e); return Collections.emptyMap(); } } diff --git a/src/main/java/org/olat/course/condition/interpreter/GetInitialCourseLaunchDateFunction.java b/src/main/java/org/olat/course/condition/interpreter/GetInitialCourseLaunchDateFunction.java index b06c8f35972033afa3dc74aa57be9be682a935ab..e1babb775e7ded137d7bf6041631480eabde3949 100644 --- a/src/main/java/org/olat/course/condition/interpreter/GetInitialCourseLaunchDateFunction.java +++ b/src/main/java/org/olat/course/condition/interpreter/GetInitialCourseLaunchDateFunction.java @@ -60,7 +60,7 @@ public class GetInitialCourseLaunchDateFunction extends AbstractFunction { //the real function evaluation which is used during run time UserCourseInformationsManager mgr = CoreSpringFactory.getImpl(UserCourseInformationsManager.class); - UserCourseInformations infos = mgr.getUserCourseInformations(getUserCourseEnv().getCourseEnvironment().getCourseResourceableId(), getUserCourseEnv().getIdentityEnvironment().getIdentity()); + UserCourseInformations infos = mgr.getUserCourseInformations(getUserCourseEnv().getCourseEnvironment().getCourseGroupManager().getCourseResource(), getUserCourseEnv().getIdentityEnvironment().getIdentity()); if (infos != null) { return Double.valueOf(infos.getInitialLaunch().getTime()); } else { diff --git a/src/main/java/org/olat/course/condition/interpreter/GetRecentCourseLaunchDateFunction.java b/src/main/java/org/olat/course/condition/interpreter/GetRecentCourseLaunchDateFunction.java index 5f98ae78c850d3c8aed9aea0d152100eb5198635..482f7b055d800fc10ba337306ac6a355f6a5e636 100644 --- a/src/main/java/org/olat/course/condition/interpreter/GetRecentCourseLaunchDateFunction.java +++ b/src/main/java/org/olat/course/condition/interpreter/GetRecentCourseLaunchDateFunction.java @@ -58,7 +58,7 @@ public class GetRecentCourseLaunchDateFunction extends AbstractFunction { } UserCourseInformationsManager mgr = CoreSpringFactory.getImpl(UserCourseInformationsManager.class); - UserCourseInformations infos = mgr.getUserCourseInformations(getUserCourseEnv().getCourseEnvironment().getCourseResourceableId(), getUserCourseEnv().getIdentityEnvironment().getIdentity()); + UserCourseInformations infos = mgr.getUserCourseInformations(getUserCourseEnv().getCourseEnvironment().getCourseGroupManager().getCourseResource(), getUserCourseEnv().getIdentityEnvironment().getIdentity()); if (infos != null) { return Double.valueOf(infos.getRecentLaunch().getTime()); } else { diff --git a/src/main/java/org/olat/course/nodes/gta/ui/GTAAbstractController.java b/src/main/java/org/olat/course/nodes/gta/ui/GTAAbstractController.java index c5542c3b8271a5682b9320448779f257ffa233a7..9f63c2ba76648f59df6eda8925fa61ab42259060 100644 --- a/src/main/java/org/olat/course/nodes/gta/ui/GTAAbstractController.java +++ b/src/main/java/org/olat/course/nodes/gta/ui/GTAAbstractController.java @@ -344,7 +344,7 @@ public abstract class GTAAbstractController extends BasicController { } case courseLaunch: { referenceDate = userCourseInformationsManager - .getInitialLaunchDate(courseEnv.getCourseResourceableId(), assessedIdentity); + .getInitialLaunchDate(courseEnv.getCourseGroupManager().getCourseResource(), assessedIdentity); break; } case enrollment: { diff --git a/src/main/java/org/olat/group/ui/main/AbstractMemberListController.java b/src/main/java/org/olat/group/ui/main/AbstractMemberListController.java index 49d806dd6035b131dba24dc1b70b10dd2a282aeb..7dd48dca43ea36f991125a2f8a2afcac4c691f99 100644 --- a/src/main/java/org/olat/group/ui/main/AbstractMemberListController.java +++ b/src/main/java/org/olat/group/ui/main/AbstractMemberListController.java @@ -22,6 +22,7 @@ package org.olat.group.ui.main; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -84,6 +85,7 @@ import org.olat.core.util.mail.ContactMessage; import org.olat.core.util.mail.MailPackage; import org.olat.core.util.resource.OresHelper; import org.olat.core.util.session.UserSessionManager; +import org.olat.course.assessment.manager.UserCourseInformationsManager; import org.olat.course.member.MemberListController; import org.olat.group.BusinessGroup; import org.olat.group.BusinessGroupManagedFlag; @@ -169,6 +171,8 @@ public abstract class AbstractMemberListController extends FormBasicController i @Autowired private BusinessGroupService businessGroupService; @Autowired + private UserCourseInformationsManager userInfosMgr; + @Autowired private BusinessGroupModule groupModule; @Autowired private ACService acService; @@ -736,7 +740,7 @@ public abstract class AbstractMemberListController extends FormBasicController i : businessGroupService.findBusinessGroups(null, repoEntry, 0, -1); List<Long> groupKeys = new ArrayList<Long>(); - Map<Long,BusinessGroupShort> keyToGroupMap = new HashMap<Long,BusinessGroupShort>(); + Map<Long,BusinessGroupShort> keyToGroupMap = new HashMap<>(); for(BusinessGroup group:groups) { groupKeys.add(group.getKey()); keyToGroupMap.put(group.getKey(), group); @@ -746,7 +750,7 @@ public abstract class AbstractMemberListController extends FormBasicController i businessGroupService.getBusinessGroupsMembership(groups); //get identities - Set<Long> identityKeys = new HashSet<Long>(); + Set<Long> identityKeys = new HashSet<>(); for(RepositoryEntryMembership membership: repoMemberships) { identityKeys.add(membership.getIdentityKey()); } @@ -756,18 +760,18 @@ public abstract class AbstractMemberListController extends FormBasicController i List<Identity> identities; if(identityKeys.isEmpty()) { - identities = new ArrayList<Identity>(0); + identities = new ArrayList<>(0); } else { identities = filterIdentities(params, identityKeys); } - Map<Long,MemberView> keyToMemberMap = new HashMap<Long,MemberView>(); - List<MemberView> memberList = new ArrayList<MemberView>(); + Map<Long,MemberView> keyToMemberMap = new HashMap<>(); + List<MemberView> memberList = new ArrayList<>(); Locale locale = getLocale(); //reservations if(params.isPending()) { - List<OLATResource> resourcesForReservations = new ArrayList<OLATResource>(); + List<OLATResource> resourcesForReservations = new ArrayList<>(); if(repoEntry != null) { resourcesForReservations.add(repoEntry.getOlatResource()); } @@ -801,7 +805,7 @@ public abstract class AbstractMemberListController extends FormBasicController i } Long me = getIdentity().getKey(); - Set<Long> loadStatus = new HashSet<Long>(); + Set<Long> loadStatus = new HashSet<>(); for(Identity identity:identities) { MemberView member = new MemberView(identity, userPropertyHandlers, locale); if(chatEnabled) { @@ -819,7 +823,7 @@ public abstract class AbstractMemberListController extends FormBasicController i } if(loadStatus.size() > 0) { - List<Long> statusToLoadList = new ArrayList<Long>(loadStatus); + List<Long> statusToLoadList = new ArrayList<>(loadStatus); Map<Long,String> statusMap = imService.getBuddyStatus(statusToLoadList); for(Long toLoad:statusToLoadList) { String status = statusMap.get(toLoad); @@ -873,6 +877,15 @@ public abstract class AbstractMemberListController extends FormBasicController i } } + if(repoEntry != null) { + Map<Long,Date> lastLaunchDates = userInfosMgr.getRecentLaunchDates(repoEntry.getOlatResource()); + for(MemberView memberView:keyToMemberMap.values()) { + Long identityKey = memberView.getIdentityKey(); + Date date = lastLaunchDates.get(identityKey); + memberView.setLastTime(date); + } + } + //the order of the filter is important filterByRoles(memberList, params); filterByOrigin(memberList, params); diff --git a/src/main/java/org/olat/group/ui/main/MemberInfoController.java b/src/main/java/org/olat/group/ui/main/MemberInfoController.java index e37cbd8643aecda0c4e7c7c68a7cf36875899116..2f61a36e2110e025aeadc64ceb8024dd4fdb3ffe 100644 --- a/src/main/java/org/olat/group/ui/main/MemberInfoController.java +++ b/src/main/java/org/olat/group/ui/main/MemberInfoController.java @@ -79,7 +79,7 @@ public class MemberInfoController extends FormBasicController { if(repoEntry != null){ repoEntryKey = repoEntry.getKey(); - courseInfos = userCourseInfosMgr.getUserCourseInformations(repoEntry.getOlatResource().getResourceableId(), identity); + courseInfos = userCourseInfosMgr.getUserCourseInformations(repoEntry.getOlatResource(), identity); } initForm(ureq); } diff --git a/src/main/java/org/olat/ims/qti/repository/handlers/QTISurveyHandler.java b/src/main/java/org/olat/ims/qti/repository/handlers/QTISurveyHandler.java index 60be4423ee60d9b9d11ac5ccea6375d3ad36f217..b2b148a413c927505436b1f5b269b9d0f1e6c3af 100644 --- a/src/main/java/org/olat/ims/qti/repository/handlers/QTISurveyHandler.java +++ b/src/main/java/org/olat/ims/qti/repository/handlers/QTISurveyHandler.java @@ -41,6 +41,7 @@ import org.olat.core.id.Identity; import org.olat.core.id.OLATResourceable; import org.olat.core.logging.AssertException; import org.olat.course.assessment.AssessmentMode; +import org.olat.course.assessment.manager.UserCourseInformationsManager; import org.olat.fileresource.FileResourceManager; import org.olat.fileresource.types.ResourceEvaluation; import org.olat.ims.qti.QTIRuntimeController; @@ -148,6 +149,8 @@ public class QTISurveyHandler extends QTIHandler { RepositoryEntry entry, RepositoryEntrySecurity security, AssessmentMode assessmentMode) { Controller runController; OLATResource res = entry.getOlatResource(); + CoreSpringFactory.getImpl(UserCourseInformationsManager.class) + .updateUserCourseInformations(entry.getOlatResource(), ureq.getIdentity()); if (OnyxModule.isOnyxTest(res)) { runController = new OnyxRunController(uureq, wwControl, entry, false); } else { diff --git a/src/main/java/org/olat/ims/qti/repository/handlers/QTITestHandler.java b/src/main/java/org/olat/ims/qti/repository/handlers/QTITestHandler.java index 727168de5ad4c808c8ed357aad970ec107d585d6..3e23327f321f161a0125e86c0df19d27c166b221 100644 --- a/src/main/java/org/olat/ims/qti/repository/handlers/QTITestHandler.java +++ b/src/main/java/org/olat/ims/qti/repository/handlers/QTITestHandler.java @@ -41,6 +41,7 @@ import org.olat.core.id.Identity; import org.olat.core.id.OLATResourceable; import org.olat.core.logging.AssertException; import org.olat.course.assessment.AssessmentMode; +import org.olat.course.assessment.manager.UserCourseInformationsManager; import org.olat.fileresource.FileResourceManager; import org.olat.fileresource.types.ResourceEvaluation; import org.olat.ims.qti.QTIRuntimeController; @@ -148,6 +149,8 @@ public class QTITestHandler extends QTIHandler { RepositoryEntry entry, RepositoryEntrySecurity security, AssessmentMode assessmentMode) { Controller runController; OLATResource res = entry.getOlatResource(); + CoreSpringFactory.getImpl(UserCourseInformationsManager.class) + .updateUserCourseInformations(entry.getOlatResource(), ureq.getIdentity()); if (OnyxModule.isOnyxTest(res)) { // <OLATCE-1054> runController = new OnyxRunController(uureq, wwControl, entry, false); diff --git a/src/main/java/org/olat/modules/cp/CPDisplayController.java b/src/main/java/org/olat/modules/cp/CPDisplayController.java index 0b37c0f7322b0455ca7345e0ebb06757eb0110b9..cd9ef1010aa62c4b84fc8e5f13625ed208a8a965 100644 --- a/src/main/java/org/olat/modules/cp/CPDisplayController.java +++ b/src/main/java/org/olat/modules/cp/CPDisplayController.java @@ -99,7 +99,7 @@ public class CPDisplayController extends BasicController implements Activateable private CPSelectPrintPagesController printController; private CloseableModalController printPopup; - + /** * @param ureq * @param cpRoot diff --git a/src/main/java/org/olat/modules/reminder/rule/InitialCourseLaunchRuleSPI.java b/src/main/java/org/olat/modules/reminder/rule/InitialCourseLaunchRuleSPI.java index 49c7ae721495ca2e258deab013b2466b87f72845..ecbc71ce66d34e232debf7644bee0b1850355f53 100644 --- a/src/main/java/org/olat/modules/reminder/rule/InitialCourseLaunchRuleSPI.java +++ b/src/main/java/org/olat/modules/reminder/rule/InitialCourseLaunchRuleSPI.java @@ -55,7 +55,6 @@ public class InitialCourseLaunchRuleSPI extends AbstractLaunchDateRuleSPI { @Override protected Map<Long, Date> getLaunchDates(ReminderRule rule, RepositoryEntry entry, List<Identity> identities) { - Long courseResourceId = entry.getOlatResource().getResourceableId(); - return userCourseInformationsManager.getInitialLaunchDates(courseResourceId, identities); + return userCourseInformationsManager.getInitialLaunchDates(entry.getOlatResource(), identities); } } \ No newline at end of file diff --git a/src/main/java/org/olat/modules/reminder/rule/RecentCourseLaunchRuleSPI.java b/src/main/java/org/olat/modules/reminder/rule/RecentCourseLaunchRuleSPI.java index ac2944ef155be7ee74c19dfe44ebc51d203d3e49..e7779a6e8f6178c6d8b2c9480b721127ba56d6c3 100644 --- a/src/main/java/org/olat/modules/reminder/rule/RecentCourseLaunchRuleSPI.java +++ b/src/main/java/org/olat/modules/reminder/rule/RecentCourseLaunchRuleSPI.java @@ -60,7 +60,6 @@ public class RecentCourseLaunchRuleSPI extends AbstractLaunchDateRuleSPI { @Override protected Map<Long, Date> getLaunchDates(ReminderRule rule, RepositoryEntry entry, List<Identity> identities) { - Long courseResourceId = entry.getOlatResource().getResourceableId(); - return userCourseInformationsManager.getRecentLaunchDates(courseResourceId, identities); + return userCourseInformationsManager.getRecentLaunchDates(entry.getOlatResource(), identities); } } diff --git a/src/main/java/org/olat/modules/wiki/WikiMainController.java b/src/main/java/org/olat/modules/wiki/WikiMainController.java index 4ac6f0846142640e225054b50dae30d5731bf8e8..7d7d94773d1f780f495b1d0601f6bd32d5937ac5 100644 --- a/src/main/java/org/olat/modules/wiki/WikiMainController.java +++ b/src/main/java/org/olat/modules/wiki/WikiMainController.java @@ -178,7 +178,7 @@ public class WikiMainController extends BasicController implements CloneableCont private CloseableModalController cmc; - WikiMainController(UserRequest ureq, WindowControl wControl, OLATResourceable ores, + public WikiMainController(UserRequest ureq, WindowControl wControl, OLATResourceable ores, WikiSecurityCallback securityCallback, String initialPageName) { super(ureq, wControl); diff --git a/src/main/java/org/olat/modules/wiki/WikiManager.java b/src/main/java/org/olat/modules/wiki/WikiManager.java index 51daa64fd4ca4f1fa74bd3f13ff9a7354aa280ae..ca4e71644da6cd4ffc663ce79e5535b131daf7e6 100644 --- a/src/main/java/org/olat/modules/wiki/WikiManager.java +++ b/src/main/java/org/olat/modules/wiki/WikiManager.java @@ -44,7 +44,6 @@ import org.apache.commons.codec.binary.Base64; import org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl; import org.olat.core.commons.services.notifications.SubscriptionContext; import org.olat.core.gui.UserRequest; -import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.WindowControl; import org.olat.core.id.OLATResourceable; import org.olat.core.logging.AssertException; @@ -55,7 +54,6 @@ import org.olat.core.logging.activity.LearningResourceLoggingAction; import org.olat.core.logging.activity.ThreadLocalUserActivityLogger; import org.olat.core.util.FileUtils; import org.olat.core.util.cache.CacheWrapper; -import org.olat.core.util.controller.OLATResourceableListeningWrapperController; import org.olat.core.util.coordinate.CoordinatorManager; import org.olat.core.util.coordinate.SyncerExecutor; import org.olat.core.util.resource.OresHelper; @@ -139,19 +137,6 @@ public class WikiManager { public WikiMainController createWikiMainController(UserRequest ureq, WindowControl wControl, OLATResourceable ores, WikiSecurityCallback securityCallback, String initialPageName) { return new WikiMainController(ureq, wControl, ores, securityCallback, initialPageName); } - - /** - * brasato:::: to discuss, are two methods needed at all? probably not, unless there are cases to launch this controller without an ores known. - * such as contentPackacking which requires only a fileroot (but this file directory depends on a ores in the end) - * - * create a wikiMaincontroller which disposes itself when the associated olatresourceable is disposed. - */ - public Controller createWikiMainControllerDisposeOnOres(UserRequest ureq, WindowControl wControl, OLATResourceable ores, WikiSecurityCallback securityCallback, String initialPageName) { - Controller controller = new WikiMainController(ureq, wControl, ores, securityCallback, initialPageName); - //fxdiff BAKS-7 Resume function - OLATResourceableListeningWrapperController dwc = new OLATResourceableListeningWrapperController(ureq, wControl, ores, controller, null, ureq.getIdentity()); - return dwc; - } // ---- end controller factory ----- diff --git a/src/main/java/org/olat/repository/handlers/BlogHandler.java b/src/main/java/org/olat/repository/handlers/BlogHandler.java index 70b19e49ad7c383bf90ac0cf5f7b4999953c9c30..91044aca9d26df583bc06b2ca442b8e2d94d05cd 100644 --- a/src/main/java/org/olat/repository/handlers/BlogHandler.java +++ b/src/main/java/org/olat/repository/handlers/BlogHandler.java @@ -42,6 +42,7 @@ import org.olat.core.util.coordinate.LockResult; import org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent; import org.olat.core.util.vfs.VFSContainer; import org.olat.course.assessment.AssessmentMode; +import org.olat.course.assessment.manager.UserCourseInformationsManager; import org.olat.fileresource.FileResourceManager; import org.olat.fileresource.types.BlogFileResource; import org.olat.fileresource.types.FileResource; @@ -173,6 +174,8 @@ public class BlogHandler implements RepositoryHandler { @Override public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry entry, RepositoryEntrySecurity security, AssessmentMode assessmentMode) { + CoreSpringFactory.getImpl(UserCourseInformationsManager.class) + .updateUserCourseInformations(entry.getOlatResource(), ureq.getIdentity()); return new FeedMainController(entry.getOlatResource(), uureq, wwControl, null, null, BlogUIFactory.getInstance(uureq.getLocale()), callback, null); } diff --git a/src/main/java/org/olat/repository/handlers/GlossaryHandler.java b/src/main/java/org/olat/repository/handlers/GlossaryHandler.java index a0b69f8fa48d11ff6e43dbc44a1edc8f98e430db..e51c2d718553aac671a7a9ea88f028c8c01128a0 100644 --- a/src/main/java/org/olat/repository/handlers/GlossaryHandler.java +++ b/src/main/java/org/olat/repository/handlers/GlossaryHandler.java @@ -56,6 +56,7 @@ import org.olat.core.util.coordinate.LockResult; import org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent; import org.olat.core.util.vfs.VFSContainer; import org.olat.course.assessment.AssessmentMode; +import org.olat.course.assessment.manager.UserCourseInformationsManager; import org.olat.fileresource.FileResourceManager; import org.olat.fileresource.types.FileResource; import org.olat.fileresource.types.GlossaryResource; @@ -174,6 +175,8 @@ public class GlossaryHandler implements RepositoryHandler { */ @Override public MainLayoutController createLaunchController(RepositoryEntry re, RepositoryEntrySecurity reSecurity, UserRequest ureq, WindowControl wControl) { + + return new GlossaryRuntimeController(ureq, wControl, re, reSecurity, new RuntimeControllerCreator() { @Override @@ -191,6 +194,9 @@ public class GlossaryHandler implements RepositoryHandler { } else { secCallback = new GlossarySecurityCallbackImpl(false, owner, editableByUser, uureq.getIdentity().getKey()); } + + CoreSpringFactory.getImpl(UserCourseInformationsManager.class) + .updateUserCourseInformations(entry.getOlatResource(), ureq.getIdentity()); return new GlossaryMainController(wwControl, uureq, glossaryFolder, entry.getOlatResource(), secCallback, false); } }); diff --git a/src/main/java/org/olat/repository/handlers/ImsCPHandler.java b/src/main/java/org/olat/repository/handlers/ImsCPHandler.java index 952e8cc76401b606cc0e3d1814788d8ad4b9f224..37fb52c897ad2b603309ef62df7118543e3983e4 100644 --- a/src/main/java/org/olat/repository/handlers/ImsCPHandler.java +++ b/src/main/java/org/olat/repository/handlers/ImsCPHandler.java @@ -55,6 +55,7 @@ import org.olat.core.util.vfs.QuotaManager; import org.olat.core.util.vfs.callbacks.FullAccessWithQuotaCallback; import org.olat.core.util.vfs.callbacks.VFSSecurityCallback; import org.olat.course.assessment.AssessmentMode; +import org.olat.course.assessment.manager.UserCourseInformationsManager; import org.olat.fileresource.FileResourceManager; import org.olat.fileresource.ZippedDirectoryMediaResource; import org.olat.fileresource.types.FileResource; @@ -201,6 +202,9 @@ public class ImsCPHandler extends FileHandler { RepositoryEntry entry, RepositoryEntrySecurity security, AssessmentMode assessmentMode) { boolean activateFirstPage = true; String initialUri = null; + + CoreSpringFactory.getImpl(UserCourseInformationsManager.class) + .updateUserCourseInformations(entry.getOlatResource(), ureq.getIdentity()); CPDisplayController cpCtr = new CPDisplayController(uureq, wwControl, vfsWrapper, true, true, activateFirstPage, true, deliveryOptions, initialUri, entry.getOlatResource(), ""); MainLayout3ColumnsController ctr = new LayoutMain3ColsController(uureq, wwControl, cpCtr.getMenuComponent(), cpCtr.getInitialComponent(), vfsWrapper.getName()); diff --git a/src/main/java/org/olat/repository/handlers/PodcastHandler.java b/src/main/java/org/olat/repository/handlers/PodcastHandler.java index 32dc081eeef4bb0267c94004db71f7d74db12b5e..ef92e2141ad09b8d66c38f462a6b77efcad7d1db 100644 --- a/src/main/java/org/olat/repository/handlers/PodcastHandler.java +++ b/src/main/java/org/olat/repository/handlers/PodcastHandler.java @@ -42,6 +42,7 @@ import org.olat.core.util.coordinate.LockResult; import org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent; import org.olat.core.util.vfs.VFSContainer; import org.olat.course.assessment.AssessmentMode; +import org.olat.course.assessment.manager.UserCourseInformationsManager; import org.olat.fileresource.FileResourceManager; import org.olat.fileresource.types.FileResource; import org.olat.fileresource.types.PodcastFileResource; @@ -167,6 +168,8 @@ public class PodcastHandler implements RepositoryHandler { @Override public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry entry, RepositoryEntrySecurity security, AssessmentMode assessmentMode) { + CoreSpringFactory.getImpl(UserCourseInformationsManager.class) + .updateUserCourseInformations(entry.getOlatResource(), ureq.getIdentity()); return new FeedMainController(entry.getOlatResource(), uureq, wwControl, null, null, PodcastUIFactory.getInstance(uureq.getLocale()), callback, null); } diff --git a/src/main/java/org/olat/repository/handlers/PortfolioHandler.java b/src/main/java/org/olat/repository/handlers/PortfolioHandler.java index feec8099319bb84c6c5a400ace73bb8d912605ee..03588f6f582258d09ed2aaf679ebb9c3ef661d7a 100644 --- a/src/main/java/org/olat/repository/handlers/PortfolioHandler.java +++ b/src/main/java/org/olat/repository/handlers/PortfolioHandler.java @@ -46,6 +46,7 @@ import org.olat.core.util.coordinate.CoordinatorManager; import org.olat.core.util.coordinate.LockResult; import org.olat.core.util.vfs.VFSContainer; import org.olat.course.assessment.AssessmentMode; +import org.olat.course.assessment.manager.UserCourseInformationsManager; import org.olat.fileresource.FileResourceManager; import org.olat.fileresource.types.ResourceEvaluation; import org.olat.portfolio.EPSecurityCallback; @@ -226,7 +227,10 @@ public class PortfolioHandler implements RepositoryHandler { public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry entry, RepositoryEntrySecurity security, AssessmentMode assessmentMode) { EPFrontendManager ePFMgr = CoreSpringFactory.getImpl(EPFrontendManager.class); - PortfolioStructureMap map = (PortfolioStructureMap)ePFMgr.loadPortfolioStructure(entry.getOlatResource()); + PortfolioStructureMap map = (PortfolioStructureMap)ePFMgr + .loadPortfolioStructure(entry.getOlatResource()); + CoreSpringFactory.getImpl(UserCourseInformationsManager.class) + .updateUserCourseInformations(entry.getOlatResource(), ureq.getIdentity()); EPSecurityCallback secCallback = EPSecurityCallbackFactory.getSecurityCallback(uureq, map, ePFMgr); return new EPMapViewController(uureq, wwControl, map, false, false, secCallback); } diff --git a/src/main/java/org/olat/repository/handlers/SCORMCPHandler.java b/src/main/java/org/olat/repository/handlers/SCORMCPHandler.java index 2db8c9c36e4fce711b92feeceb013c97c4bf075d..fb59a823abe0077d958bc587bac3ce69d674477c 100644 --- a/src/main/java/org/olat/repository/handlers/SCORMCPHandler.java +++ b/src/main/java/org/olat/repository/handlers/SCORMCPHandler.java @@ -44,6 +44,7 @@ import org.olat.core.logging.activity.ThreadLocalUserActivityLogger; import org.olat.core.util.FileUtils; import org.olat.core.util.coordinate.LockResult; import org.olat.course.assessment.AssessmentMode; +import org.olat.course.assessment.manager.UserCourseInformationsManager; import org.olat.fileresource.FileResourceManager; import org.olat.fileresource.ZippedDirectoryMediaResource; import org.olat.fileresource.types.FileResource; @@ -173,6 +174,8 @@ public class SCORMCPHandler extends FileHandler { public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry entry, RepositoryEntrySecurity security, AssessmentMode assessmentMode) { OLATResource res = entry.getOlatResource(); + CoreSpringFactory.getImpl(UserCourseInformationsManager.class) + .updateUserCourseInformations(res, ureq.getIdentity()); File cpRoot = FileResourceManager.getInstance().unzipFileResource(res); MainLayoutController realController = ScormMainManager.getInstance().createScormAPIandDisplayController(uureq, wwControl, true, null, cpRoot, res.getResourceableId(), null, ScormConstants.SCORM_MODE_BROWSE, ScormConstants.SCORM_MODE_NOCREDIT, false, null, false, false, false, null); diff --git a/src/main/java/org/olat/repository/handlers/SharedFolderHandler.java b/src/main/java/org/olat/repository/handlers/SharedFolderHandler.java index 61433267fb00a0d84ca8c8db4180369c76936621..0c0b8067ea550dab32794480ab76ff06551a8365 100644 --- a/src/main/java/org/olat/repository/handlers/SharedFolderHandler.java +++ b/src/main/java/org/olat/repository/handlers/SharedFolderHandler.java @@ -50,6 +50,7 @@ import org.olat.core.util.coordinate.LockResult; import org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent; import org.olat.core.util.vfs.VFSContainer; import org.olat.course.assessment.AssessmentMode; +import org.olat.course.assessment.manager.UserCourseInformationsManager; import org.olat.fileresource.FileResourceManager; import org.olat.fileresource.types.ResourceEvaluation; import org.olat.fileresource.types.SharedFolderFileResource; @@ -172,6 +173,8 @@ public class SharedFolderHandler implements RepositoryHandler { RepositoryEntry entry, RepositoryEntrySecurity security, AssessmentMode assessmentMode) { OLATResource res = entry.getOlatResource(); VFSContainer sfContainer = SharedFolderManager.getInstance().getSharedFolder(res); + CoreSpringFactory.getImpl(UserCourseInformationsManager.class) + .updateUserCourseInformations(res, ureq.getIdentity()); Controller sfdCtr; if(sfContainer == null || !sfContainer.exists()) { diff --git a/src/main/java/org/olat/repository/handlers/WebDocumentHandler.java b/src/main/java/org/olat/repository/handlers/WebDocumentHandler.java index f211701ca366056a67b2f109ca2844c3bddbed8a..d95fe6d7f5c762d77740580798b648738402105d 100644 --- a/src/main/java/org/olat/repository/handlers/WebDocumentHandler.java +++ b/src/main/java/org/olat/repository/handlers/WebDocumentHandler.java @@ -49,6 +49,7 @@ import org.olat.core.util.FileUtils; import org.olat.core.util.StringHelper; import org.olat.core.util.coordinate.LockResult; import org.olat.course.assessment.AssessmentMode; +import org.olat.course.assessment.manager.UserCourseInformationsManager; import org.olat.fileresource.FileResourceManager; import org.olat.fileresource.types.AnimationFileResource; import org.olat.fileresource.types.DocFileResource; @@ -219,6 +220,8 @@ public class WebDocumentHandler extends FileHandler { @Override public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry entry, RepositoryEntrySecurity rereSecurity, AssessmentMode assessmentMode) { + CoreSpringFactory.getImpl(UserCourseInformationsManager.class) + .updateUserCourseInformations(entry.getOlatResource(), ureq.getIdentity()); return new WebDocumentRunController(uureq, wwControl, entry); } }); diff --git a/src/main/java/org/olat/repository/handlers/WikiHandler.java b/src/main/java/org/olat/repository/handlers/WikiHandler.java index 6e6292a81c3868bc28f67fcadc4919c6f7ae1a61..b9a3164dee025b72408402cba06f4aae57c35e14 100644 --- a/src/main/java/org/olat/repository/handlers/WikiHandler.java +++ b/src/main/java/org/olat/repository/handlers/WikiHandler.java @@ -49,6 +49,7 @@ import org.olat.core.id.context.BusinessControl; import org.olat.core.id.context.ContextEntry; import org.olat.core.logging.AssertException; import org.olat.core.util.Util; +import org.olat.core.util.controller.OLATResourceableListeningWrapperController; import org.olat.core.util.coordinate.CoordinatorManager; import org.olat.core.util.coordinate.LockResult; import org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent; @@ -59,11 +60,13 @@ import org.olat.core.util.vfs.VFSManager; import org.olat.core.util.vfs.VFSMediaResource; import org.olat.core.util.vfs.filters.VFSItemSuffixFilter; import org.olat.course.assessment.AssessmentMode; +import org.olat.course.assessment.manager.UserCourseInformationsManager; import org.olat.fileresource.FileResourceManager; import org.olat.fileresource.types.ResourceEvaluation; import org.olat.fileresource.types.WikiResource; import org.olat.modules.wiki.Wiki; import org.olat.modules.wiki.WikiContainer; +import org.olat.modules.wiki.WikiMainController; import org.olat.modules.wiki.WikiManager; import org.olat.modules.wiki.WikiPage; import org.olat.modules.wiki.WikiSecurityCallback; @@ -237,17 +240,18 @@ public class WikiHandler implements RepositoryHandler { @Override public Controller create(UserRequest uureq, WindowControl wwControl, TooledStackedPanel toolbarPanel, RepositoryEntry entry, RepositoryEntrySecurity security, AssessmentMode assessmentMode) { + CoreSpringFactory.getImpl(UserCourseInformationsManager.class) + .updateUserCourseInformations(entry.getOlatResource(), ureq.getIdentity()); Controller controller; - if ( ce != null ) { //jump to a certain context + if (ce != null ) { //jump to a certain context OLATResourceable ores = ce.getOLATResourceable(); String typeName = ores.getResourceableTypeName(); String page = typeName.substring("page=".length()); - controller = WikiManager.getInstance().createWikiMainControllerDisposeOnOres(uureq, wwControl, entry.getOlatResource(), callback, page); + controller = new WikiMainController(uureq, wwControl, entry.getOlatResource(), callback, page); } else { - controller = WikiManager.getInstance().createWikiMainControllerDisposeOnOres(uureq, wwControl, entry.getOlatResource(), callback, null); + controller = new WikiMainController(uureq, wwControl, entry.getOlatResource(), callback, null); } - - return controller; + return new OLATResourceableListeningWrapperController(ureq, wControl, entry.getOlatResource(), controller, null, ureq.getIdentity()); } }); diff --git a/src/main/java/org/olat/repository/ui/list/RepositoryEntryDetailsController.java b/src/main/java/org/olat/repository/ui/list/RepositoryEntryDetailsController.java index f513f140990bb90ca758cf215c267f26d3b355a4..08ffb7d7b09b1d600ad0eb89401f1f7b2be0e9ec 100644 --- a/src/main/java/org/olat/repository/ui/list/RepositoryEntryDetailsController.java +++ b/src/main/java/org/olat/repository/ui/list/RepositoryEntryDetailsController.java @@ -88,6 +88,7 @@ import org.olat.repository.manager.CatalogManager; import org.olat.repository.model.RepositoryEntryStatistics; import org.olat.repository.ui.PriceMethod; import org.olat.repository.ui.RepositoyUIFactory; +import org.olat.resource.OLATResource; import org.olat.resource.accesscontrol.ACService; import org.olat.resource.accesscontrol.AccessControlModule; import org.olat.resource.accesscontrol.AccessResult; @@ -429,14 +430,14 @@ public class RepositoryEntryDetailsController extends FormBasicController { layoutCont.contextPut("failed", failed); layoutCont.contextPut("score", score); - Long courseResId = entry.getOlatResource().getResourceableId(); - Date recentLaunch = userCourseInfosManager.getRecentLaunchDate(courseResId, getIdentity()); + OLATResource ores = entry.getOlatResource(); + Date recentLaunch = userCourseInfosManager.getRecentLaunchDate(ores, getIdentity()); layoutCont.contextPut("recentLaunch", recentLaunch); // show how many users are currently using this resource String numUsers; - OLATResourceable ores = entry.getOlatResource(); int cnt = 0; + Long courseResId = entry.getOlatResource().getResourceableId(); OLATResourceable courseRunOres = OresHelper.createOLATResourceableInstance(RunMainController.ORES_TYPE_COURSE_RUN, courseResId); if (ores != null) cnt = coordinatorManager.getCoordinator().getEventBus().getListeningIdentityCntFor(courseRunOres); numUsers = String.valueOf(cnt); diff --git a/src/main/java/org/olat/upgrade/OLATUpgrade_8_1_0.java b/src/main/java/org/olat/upgrade/OLATUpgrade_8_1_0.java index 950584bb3e5fb5cb4442ba2211b757fa2a9a674c..5d977bef9f75ef5ee4c99f16369006ca1cdc85c6 100644 --- a/src/main/java/org/olat/upgrade/OLATUpgrade_8_1_0.java +++ b/src/main/java/org/olat/upgrade/OLATUpgrade_8_1_0.java @@ -34,8 +34,6 @@ import org.olat.core.id.Identity; import org.olat.core.util.xml.XStreamHelper; import org.olat.course.assessment.EfficiencyStatement; import org.olat.course.assessment.EfficiencyStatementManager; -import org.olat.course.assessment.manager.UserCourseInformationsManager; -import org.olat.course.assessment.manager.UserCourseInformationsManagerImpl; import org.olat.course.assessment.model.UserCourseInfosImpl; import org.olat.course.assessment.model.UserEfficiencyStatementImpl; import org.olat.properties.Property; @@ -74,8 +72,6 @@ public class OLATUpgrade_8_1_0 extends OLATUpgrade { @Autowired private EfficiencyStatementManager efficiencyStatementManager; @Autowired - private UserCourseInformationsManager userCourseInformationsManager; - @Autowired private OLATResourceManager resourceManager; @Autowired private BaseSecurity securityManager; @@ -206,7 +202,7 @@ public class OLATUpgrade_8_1_0 extends OLATUpgrade { uhd.setBooleanDataValue(TASK_LAUNCH_DATES, false); } else { for(SimpleProp prop:props) { - Date d = ((UserCourseInformationsManagerImpl)userCourseInformationsManager).getInitialLaunchDate(prop.resourceId, prop.identityKey); + Date d = getInitialLaunchDate(prop.resourceId, prop.identityKey); if(d == null) { createUserCourseInformation(prop); } @@ -222,6 +218,29 @@ public class OLATUpgrade_8_1_0 extends OLATUpgrade { } } + private Date getInitialLaunchDate(Long courseResourceId, Long identityKey) { + try { + StringBuilder sb = new StringBuilder(); + sb.append("select infos.initialLaunch from ").append(UserCourseInfosImpl.class.getName()).append(" as infos ") + .append(" inner join infos.resource as resource") + .append(" where infos.identity.key=:identityKey and resource.resId=:resId and resource.resName='CourseModule'"); + + List<Date> infoList = dbInstance.getCurrentEntityManager() + .createQuery(sb.toString(), Date.class) + .setParameter("identityKey", identityKey) + .setParameter("resId", courseResourceId) + .getResultList(); + + if(infoList.isEmpty()) { + return null; + } + return infoList.get(0); + } catch (Exception e) { + log.error("Cannot retrieve course informations for: " + courseResourceId, e); + return null; + } + } + private void createUserCourseInformation(SimpleProp prop) { Identity identity = securityManager.loadIdentityByKey(prop.identityKey); OLATResource resource = resourceManager.findResourceable(prop.resourceId, "CourseModule"); diff --git a/src/test/java/org/olat/course/assessment/manager/UserCourseInformationsManagerTest.java b/src/test/java/org/olat/course/assessment/manager/UserCourseInformationsManagerTest.java index be1cd32a270d3200c0231a85bf2d6dbc70121122..867acde6abc1adc5059b619e41b70cbff0adaf71 100644 --- a/src/test/java/org/olat/course/assessment/manager/UserCourseInformationsManagerTest.java +++ b/src/test/java/org/olat/course/assessment/manager/UserCourseInformationsManagerTest.java @@ -67,7 +67,7 @@ public class UserCourseInformationsManagerTest extends OlatTestCase { userCourseInformationsManager.updateUserCourseInformations(courseResource, user); dbInstance.commitAndCloseSession(); - UserCourseInformations infos = userCourseInformationsManager.getUserCourseInformations(course.getResourceableId(), user); + UserCourseInformations infos = userCourseInformationsManager.getUserCourseInformations(courseResource, user); Assert.assertNotNull(infos); Assert.assertNotNull(infos.getIdentity()); Assert.assertNotNull(infos.getResource()); @@ -93,7 +93,7 @@ public class UserCourseInformationsManagerTest extends OlatTestCase { userCourseInformationsManager.updateUserCourseInformations(courseResource, user); dbInstance.commitAndCloseSession(); - UserCourseInformations infos = userCourseInformationsManager.getUserCourseInformations(course.getResourceableId(), user); + UserCourseInformations infos = userCourseInformationsManager.getUserCourseInformations(courseResource, user); Assert.assertNotNull(infos); Assert.assertNotNull(infos.getIdentity()); Assert.assertEquals(2, infos.getVisit()); @@ -121,7 +121,7 @@ public class UserCourseInformationsManagerTest extends OlatTestCase { dbInstance.commitAndCloseSession(); Assert.assertEquals(1, updated2); - UserCourseInformations infos = userCourseInformationsManager.getUserCourseInformations(course.getResourceableId(), user); + UserCourseInformations infos = userCourseInformationsManager.getUserCourseInformations(courseResource, user); Assert.assertNotNull(infos); Assert.assertNotNull(infos.getIdentity()); Assert.assertEquals(3, infos.getVisit()); @@ -137,7 +137,7 @@ public class UserCourseInformationsManagerTest extends OlatTestCase { userCourseInformationsManager.updateUserCourseInformations(courseResource, user); dbInstance.commitAndCloseSession(); - Date launchDate = userCourseInformationsManager.getRecentLaunchDate(course.getResourceableId(), user); + Date launchDate = userCourseInformationsManager.getRecentLaunchDate(courseResource, user); Assert.assertNotNull(launchDate); } @@ -151,7 +151,7 @@ public class UserCourseInformationsManagerTest extends OlatTestCase { userCourseInformationsManager.updateUserCourseInformations(courseResource, user); dbInstance.commitAndCloseSession(); - Date launchDate = userCourseInformationsManager.getInitialLaunchDate(course.getResourceableId(), user); + Date launchDate = userCourseInformationsManager.getInitialLaunchDate(courseResource, user); Assert.assertNotNull(launchDate); } @@ -171,7 +171,7 @@ public class UserCourseInformationsManagerTest extends OlatTestCase { users.add(user1); users.add(user2); - Map<Long,Date> launchDates = userCourseInformationsManager.getInitialLaunchDates(course.getResourceableId(), users); + Map<Long,Date> launchDates = userCourseInformationsManager.getInitialLaunchDates(courseResource, users); Assert.assertNotNull(launchDates); Assert.assertEquals(2, launchDates.size()); Assert.assertTrue(launchDates.containsKey(user1.getKey())); @@ -224,7 +224,8 @@ public class UserCourseInformationsManagerTest extends OlatTestCase { dbInstance.commitAndCloseSession(); List<Identity> users = Collections.singletonList(user); - Map<Long,Date> launchDates = userCourseInformationsManager.getInitialLaunchDates(course.getResourceableId(), users); + OLATResource courseResource = course.getCourseEnvironment().getCourseGroupManager().getCourseResource(); + Map<Long,Date> launchDates = userCourseInformationsManager.getInitialLaunchDates(courseResource, users); Assert.assertNotNull(launchDates); Assert.assertEquals(1, launchDates.size()); Assert.assertTrue(launchDates.containsKey(user.getKey())); @@ -324,7 +325,7 @@ public class UserCourseInformationsManagerTest extends OlatTestCase { Thread.sleep(10); for(int i=0; i<25;i++) { uciManager.updateUserCourseInformations(courseResource, user); - uciManager.getUserCourseInformations(courseResource.getResourceableId(), user); + uciManager.getUserCourseInformations(courseResource, user); uciManager.updateUserCourseInformations(courseResource, user); db.commitAndCloseSession(); } diff --git a/src/test/java/org/olat/course/nodes/gta/rule/GTAReminderRuleTest.java b/src/test/java/org/olat/course/nodes/gta/rule/GTAReminderRuleTest.java index c35f39c1abd902364ca8043e1f3d2599365e069d..aa88c554cad581ca7f4c88ee86224a72fda9119a 100644 --- a/src/test/java/org/olat/course/nodes/gta/rule/GTAReminderRuleTest.java +++ b/src/test/java/org/olat/course/nodes/gta/rule/GTAReminderRuleTest.java @@ -52,6 +52,7 @@ import org.olat.repository.manager.RepositoryEntryLifecycleDAO; import org.olat.repository.manager.RepositoryEntryRelationDAO; import org.olat.repository.model.RepositoryEntryLifecycle; import org.olat.repository.model.RepositoryEntryToGroupRelation; +import org.olat.resource.OLATResource; import org.olat.restapi.repository.course.CoursesWebService; import org.olat.test.JunitTestHelper; import org.olat.test.OlatTestCase; @@ -317,16 +318,15 @@ public class GTAReminderRuleTest extends OlatTestCase { dbInstance.commit(); //create user course infos - Long courseResId = course.getCourseEnvironment().getCourseResourceableId(); userCourseInformationsManager.updateUserCourseInformations(re.getOlatResource(), id1); userCourseInformationsManager.updateUserCourseInformations(re.getOlatResource(), id2); userCourseInformationsManager.updateUserCourseInformations(re.getOlatResource(), id3); dbInstance.commit(); //fake the date - updateInitialLaunchDate(courseResId, id1, -5, Calendar.DATE); - updateInitialLaunchDate(courseResId, id2, -35, Calendar.DATE); - updateInitialLaunchDate(courseResId, id3, -75, Calendar.DATE); + updateInitialLaunchDate(re.getOlatResource(), id1, -5, Calendar.DATE); + updateInitialLaunchDate(re.getOlatResource(), id2, -35, Calendar.DATE); + updateInitialLaunchDate(re.getOlatResource(), id3, -75, Calendar.DATE); dbInstance.commitAndCloseSession(); // create a fake node @@ -388,8 +388,8 @@ public class GTAReminderRuleTest extends OlatTestCase { } - private void updateInitialLaunchDate(Long courseResId, Identity id, int amount, int field) { - UserCourseInfosImpl userCourseInfos = (UserCourseInfosImpl)userCourseInformationsManager.getUserCourseInformations(courseResId, id); + 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); diff --git a/src/test/java/org/olat/modules/reminder/manager/ReminderRuleEngineTest.java b/src/test/java/org/olat/modules/reminder/manager/ReminderRuleEngineTest.java index 5cb8e7fb644fb7c5650fe1c183f83775c70da7f4..55a6408ca7044c2b59ff9e31dfb976f1f5fbf00f 100644 --- a/src/test/java/org/olat/modules/reminder/manager/ReminderRuleEngineTest.java +++ b/src/test/java/org/olat/modules/reminder/manager/ReminderRuleEngineTest.java @@ -67,6 +67,7 @@ import org.olat.repository.manager.RepositoryEntryLifecycleDAO; import org.olat.repository.manager.RepositoryEntryRelationDAO; import org.olat.repository.model.RepositoryEntryLifecycle; import org.olat.repository.model.RepositoryEntryToGroupRelation; +import org.olat.resource.OLATResource; import org.olat.restapi.repository.course.CoursesWebService; import org.olat.test.JunitTestHelper; import org.olat.test.OlatTestCase; @@ -321,16 +322,15 @@ public class ReminderRuleEngineTest extends OlatTestCase { dbInstance.commit(); //create user course infos - Long courseResId = course.getCourseEnvironment().getCourseResourceableId(); userCourseInformationsManager.updateUserCourseInformations(re.getOlatResource(), id1); userCourseInformationsManager.updateUserCourseInformations(re.getOlatResource(), id2); userCourseInformationsManager.updateUserCourseInformations(re.getOlatResource(), id3); dbInstance.commit(); //fake the date - updateInitialLaunchDate(courseResId, id1, -5, Calendar.DATE); - updateInitialLaunchDate(courseResId, id2, -35, Calendar.DATE); - updateInitialLaunchDate(courseResId, id3, -75, Calendar.DATE); + updateInitialLaunchDate(re.getOlatResource(), id1, -5, Calendar.DATE); + updateInitialLaunchDate(re.getOlatResource(), id2, -35, Calendar.DATE); + updateInitialLaunchDate(re.getOlatResource(), id3, -75, Calendar.DATE); dbInstance.commitAndCloseSession(); List<Identity> identities = new ArrayList<>(); @@ -403,8 +403,8 @@ public class ReminderRuleEngineTest extends OlatTestCase { } } - private void updateInitialLaunchDate(Long courseResId, Identity id, int amount, int field) { - UserCourseInfosImpl userCourseInfos = (UserCourseInfosImpl)userCourseInformationsManager.getUserCourseInformations(courseResId, id); + 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); @@ -442,16 +442,15 @@ public class ReminderRuleEngineTest extends OlatTestCase { dbInstance.commit(); //create user course infos - Long courseResId = course.getCourseEnvironment().getCourseResourceableId(); userCourseInformationsManager.updateUserCourseInformations(re.getOlatResource(), id1); userCourseInformationsManager.updateUserCourseInformations(re.getOlatResource(), id2); userCourseInformationsManager.updateUserCourseInformations(re.getOlatResource(), id3); dbInstance.commit(); //fake the date - updateRecentLaunchDate(courseResId, id1, -5, Calendar.DATE); - updateRecentLaunchDate(courseResId, id2, -35, Calendar.DATE); - updateRecentLaunchDate(courseResId, id3, -75, Calendar.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<>(); @@ -524,8 +523,8 @@ public class ReminderRuleEngineTest extends OlatTestCase { } } - private void updateRecentLaunchDate(Long courseResId, Identity id, int amount, int field) { - UserCourseInfosImpl userCourseInfos = (UserCourseInfosImpl)userCourseInformationsManager.getUserCourseInformations(courseResId, id); + 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);