diff --git a/src/main/java/org/wise/portal/dao/run/impl/HibernateRunDao.java b/src/main/java/org/wise/portal/dao/run/impl/HibernateRunDao.java index e546ae2a3..4462ae01d 100644 --- a/src/main/java/org/wise/portal/dao/run/impl/HibernateRunDao.java +++ b/src/main/java/org/wise/portal/dao/run/impl/HibernateRunDao.java @@ -176,7 +176,9 @@ public List getRunsRunWithinTimePeriod(String timePeriod) { Calendar c = Calendar.getInstance(); c.add(Calendar.DAY_OF_YEAR, -days); Date compareDate = c.getTime(); - cq.select(runRoot).where(cb.greaterThanOrEqualTo(runRoot.get("lastRun"), compareDate)); + cq.select(runRoot) + .where(cb.greaterThanOrEqualTo(runRoot.get("lastRun"), compareDate)) + .orderBy(cb.desc(runRoot.get("id"))); TypedQuery query = entityManager.createQuery(cq); List runResultList = query.getResultList(); return (List) (Object) runResultList; diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/admin/RunStatisticsController.java b/src/main/java/org/wise/portal/presentation/web/controllers/admin/RunStatisticsController.java index 1a84d0611..4b4ea38a3 100644 --- a/src/main/java/org/wise/portal/presentation/web/controllers/admin/RunStatisticsController.java +++ b/src/main/java/org/wise/portal/presentation/web/controllers/admin/RunStatisticsController.java @@ -34,7 +34,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.servlet.ModelAndView; import org.wise.portal.domain.attendance.StudentAttendance; import org.wise.portal.domain.run.Run; import org.wise.portal.service.attendance.StudentAttendanceService; @@ -79,13 +78,29 @@ protected String showRunStatistics( } modelMap.put("runs", runs); modelMap.put("period", period); + modelMap.put("totalAttendanceWithinLookBackPeriod", getTotalAttendanceWithinPeriod(runs)); + modelMap.put("totalAttendance", getTotalAttendance(runs)); return "admin/run/stats"; } @RequestMapping(value = "/admin/run/stats-by-activity", method = RequestMethod.GET) protected String showRunStatisticsByActivity(HttpServletRequest request, ModelMap modelMap) throws Exception { - modelMap.put("runs", runService.getRunsByActivity()); + List runs = runService.getRunsByActivity(); + modelMap.put("runs", runs); + modelMap.put("totalAttendance", getTotalAttendance(runs)); return "admin/run/stats"; } -} + + private int getTotalAttendanceWithinPeriod(List runs) { + return runs.stream() + .map(run -> run.getStudentAttendance().size()) + .reduce(0, (acc, timesRun) -> acc += timesRun); + } + + private int getTotalAttendance(List runs) { + return runs.stream() + .map(run -> run.getTimesRun()) + .reduce(0, (acc, timesRun) -> acc += timesRun); + } +} \ No newline at end of file diff --git a/src/main/resources/i18n/i18n.properties b/src/main/resources/i18n/i18n.properties index 92d0bd5d2..fa378a33d 100644 --- a/src/main/resources/i18n/i18n.properties +++ b/src/main/resources/i18n/i18n.properties @@ -628,6 +628,10 @@ admin.run.manageSharedTeachers=Manage shared teachers admin.run.manageSharedTeachers.description=Text for 'Manage shared teachers' to allow admins to manage shared teachers of a run admin.run.manageStudents=Manage students admin.run.manageStudents.description=Text for 'Manage students' to allow admins to manage students in a run +admin.run.accessCountWithinPeriodAllListed=Total access count of these runs +admin.run.accessCountWithinPeriodAllListed.description=Text for total access count of all listed runs within the given timeframe +admin.run.totalAccessCountAllListed=Total access count of these runs +admin.run.totalAccessCountAllListed.description=Text for total access count of all listed runs admin.news.newsItems=News Items admin.news.newsItems.description=Text for 'News Items' in admin portal admin.news.addNewsItem=Add News Item diff --git a/src/main/webapp/portal/admin/run/stats.jsp b/src/main/webapp/portal/admin/run/stats.jsp index 202a7b7a5..552c5f2d6 100644 --- a/src/main/webapp/portal/admin/run/stats.jsp +++ b/src/main/webapp/portal/admin/run/stats.jsp @@ -33,21 +33,33 @@ th {

${period} (${fn:length(runs)} )

+
+ + +

+ + ${period}: ${totalAttendanceWithinLookBackPeriod} +

+
+

: ${totalAttendance}

+
+
- + + - + - + -
()
() () ${period}
${run.id} (${run.runcode})${run.id} (${run.runcode}) ${run.name} (${run.project.wiseVersion}) ${run.owner.userDetails.username}
@@ -57,8 +69,6 @@ th {
${fn:length(run.studentAttendance)} ${run.timesRun} -