Index: lams_common/src/java/org/lamsfoundation/lams/events/EventNotificationService.java =================================================================== diff -u -rb8e54021b464f3abf023581e819cee4d4a54f26e -r0b789ab29e5a14f005e0978cdcad6add8606c83f --- lams_common/src/java/org/lamsfoundation/lams/events/EventNotificationService.java (.../EventNotificationService.java) (revision b8e54021b464f3abf023581e819cee4d4a54f26e) +++ lams_common/src/java/org/lamsfoundation/lams/events/EventNotificationService.java (.../EventNotificationService.java) (revision 0b789ab29e5a14f005e0978cdcad6add8606c83f) @@ -120,7 +120,7 @@ @Override public void notifyLessonMonitors(Long lessonId, String subject, String message, boolean isHtmlFormat) { Map monitoringUsers = lessonService.getUsersWithLessonParticipation(lessonId, "MONITOR", null, - null, null, true); + null, null, true, true); if (monitoringUsers.isEmpty()) { return; } Index: lams_common/src/java/org/lamsfoundation/lams/lesson/dao/ILessonDAO.java =================================================================== diff -u -r1ba40605c8e5fff683288c9c72f5ab2a981ba98a -r0b789ab29e5a14f005e0978cdcad6add8606c83f --- lams_common/src/java/org/lamsfoundation/lams/lesson/dao/ILessonDAO.java (.../ILessonDAO.java) (revision 1ba40605c8e5fff683288c9c72f5ab2a981ba98a) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/dao/ILessonDAO.java (.../ILessonDAO.java) (revision 0b789ab29e5a14f005e0978cdcad6add8606c83f) @@ -125,7 +125,7 @@ * given lesson. */ Map getUsersWithLessonParticipation(Long lessonId, String role, String searchPhrase, Integer limit, - Integer offset, boolean orderAscending); + Integer offset, boolean orderByLastName, boolean orderAscending); /** * Get all the preview lessons more with the creation date before the given date. @@ -142,11 +142,11 @@ Lesson getLessonForActivity(long activityId); /** - * Get the lesson and activity ids that apply to the tool activity associated with this tool content id. + * Get the lesson and activity ids that apply to the tool activity associated with this tool content id. * Returns an array of two longs. */ Long[] getLessonActivityIdsForToolContentId(long toolContentId); - + /** * Gets all non-removed lessons for a user in an org; set userRole parameter to learner if you want lessons where * user is in the learner list, or to monitor if in the staff list. @@ -208,10 +208,11 @@ * Finds IDs of preview lessons. */ List getPreviewLessons(Integer limit); - + /** - * Finds IDs of all lessons in an organisation. When calling MonitoringService.removeLessonPermanently() you cannot load the Lessons + * Finds IDs of all lessons in an organisation. When calling MonitoringService.removeLessonPermanently() you cannot + * load the Lessons * or a Hibernate error occurs. So we need a way to get the ids withouth calling Organisation.getLessons() */ - List getOrganisationLessons(Integer organisationId) ; + List getOrganisationLessons(Integer organisationId); } \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/lesson/dao/hibernate/LessonDAO.java =================================================================== diff -u -r0b0204c5d68cb94fbcdae15199580c7a78e42d52 -r0b789ab29e5a14f005e0978cdcad6add8606c83f --- lams_common/src/java/org/lamsfoundation/lams/lesson/dao/hibernate/LessonDAO.java (.../LessonDAO.java) (revision 0b0204c5d68cb94fbcdae15199580c7a78e42d52) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/dao/hibernate/LessonDAO.java (.../LessonDAO.java) (revision 0b789ab29e5a14f005e0978cdcad6add8606c83f) @@ -354,7 +354,8 @@ @SuppressWarnings("unchecked") @Override public Map getUsersWithLessonParticipation(final Long lessonId, final String role, - String searchPhrase, final Integer limit, final Integer offset, boolean orderAscending) { + String searchPhrase, final Integer limit, final Integer offset, boolean orderByLastName, + boolean orderAscending) { String queryTextBase = LessonDAO.LOAD_USERS_WITH_LESSON_PARTICIPATION; // whether to exclude staff group or make it the only group that counts queryTextBase = queryTextBase.replace("", role.equals(Role.MONITOR) ? "=" : "<>"); @@ -372,12 +373,18 @@ queryTextBuilder.delete(queryTextBuilder.length() - 4, queryTextBuilder.length()); } String order = orderAscending ? "ASC" : "DESC"; - queryTextBuilder.append(" ORDER BY users.first_name ").append(order).append(", users.last_name ").append(order) - .append(", users.login ").append(order); + if (orderByLastName) { + queryTextBuilder.append(" ORDER BY users.last_name ").append(order).append(", users.first_name ") + .append(order); + } else { + queryTextBuilder.append(" ORDER BY users.first_name ").append(order).append(", users.last_name ") + .append(order); + } + queryTextBuilder.append(", users.login ").append(order); Query query = getSession().createSQLQuery(queryTextBuilder.toString()).addEntity(User.class) - .addScalar("participant").setLong("lessonId", lessonId) - .setInteger("roleId", role.equals(Role.MONITOR) ? Role.ROLE_MONITOR : Role.ROLE_LEARNER); + .addScalar("participant").setParameter("lessonId", lessonId) + .setParameter("roleId", role.equals(Role.MONITOR) ? Role.ROLE_MONITOR : Role.ROLE_LEARNER); if (limit != null) { query.setMaxResults(limit); } Index: lams_common/src/java/org/lamsfoundation/lams/lesson/service/ILessonService.java =================================================================== diff -u -rb8e54021b464f3abf023581e819cee4d4a54f26e -r0b789ab29e5a14f005e0978cdcad6add8606c83f --- lams_common/src/java/org/lamsfoundation/lams/lesson/service/ILessonService.java (.../ILessonService.java) (revision b8e54021b464f3abf023581e819cee4d4a54f26e) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/service/ILessonService.java (.../ILessonService.java) (revision 0b789ab29e5a14f005e0978cdcad6add8606c83f) @@ -78,7 +78,7 @@ * given lesson. */ Map getUsersWithLessonParticipation(Long lessonId, String role, String searchPhrase, Integer limit, - Integer offset, boolean orderAscending); + Integer offset, boolean orderByLastName, boolean orderAscending); /** * Get the count of all the learners who are a part of the lesson class. Index: lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java =================================================================== diff -u -rb8e54021b464f3abf023581e819cee4d4a54f26e -r0b789ab29e5a14f005e0978cdcad6add8606c83f --- lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java (.../LessonService.java) (revision b8e54021b464f3abf023581e819cee4d4a54f26e) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java (.../LessonService.java) (revision 0b789ab29e5a14f005e0978cdcad6add8606c83f) @@ -123,8 +123,9 @@ @Override public Map getUsersWithLessonParticipation(Long lessonId, String role, String searchPhrase, - Integer limit, Integer offset, boolean orderAscending) { - return lessonDAO.getUsersWithLessonParticipation(lessonId, role, searchPhrase, limit, offset, orderAscending); + Integer limit, Integer offset, boolean orderByLastName, boolean orderAscending) { + return lessonDAO.getUsersWithLessonParticipation(lessonId, role, searchPhrase, limit, offset, orderByLastName, + orderAscending); } @Override @@ -149,6 +150,7 @@ return lessonDAO.getLesson(lessonId); } + @Override public Lesson getLessonByToolContentId(long toolContentId) { ToolActivity toolActivity = baseDAO.findByProperty(ToolActivity.class, "toolContentId", toolContentId).get(0); return toolActivity.getLearningDesign().getLessons().iterator().next(); Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringController.java =================================================================== diff -u -r1c7084d36b0332efa632440c93c18308adc27c71 -r0b789ab29e5a14f005e0978cdcad6add8606c83f --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringController.java (.../MonitoringController.java) (revision 1c7084d36b0332efa632440c93c18308adc27c71) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringController.java (.../MonitoringController.java) (revision 0b789ab29e5a14f005e0978cdcad6add8606c83f) @@ -714,7 +714,7 @@ // find organisation users and whether they participate in the current lesson Map users = lessonService.getUsersWithLessonParticipation(lessonId, role, searchPhrase, - MonitoringController.USER_PAGE_SIZE, (pageNumber - 1) * MonitoringController.USER_PAGE_SIZE, + MonitoringController.USER_PAGE_SIZE, (pageNumber - 1) * MonitoringController.USER_PAGE_SIZE, true, orderAscending); // if the result is less then page size, then no need for full check of user count @@ -1401,7 +1401,7 @@ if (isOrganisationSearch) { // search for Learners in the organisation Map result = lessonService.getUsersWithLessonParticipation(lessonId, Role.LEARNER, - searchPhrase, MonitoringController.USER_PAGE_SIZE, null, true); + searchPhrase, MonitoringController.USER_PAGE_SIZE, null, false, true); users = result.keySet(); } else { // search for Learners in the lesson