Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ public List<Run> 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<RunImpl> query = entityManager.createQuery(cq);
List<RunImpl> runResultList = query.getResultList();
return (List<Run>) (Object) runResultList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Run> runs = runService.getRunsByActivity();
modelMap.put("runs", runs);
modelMap.put("totalAttendance", getTotalAttendance(runs));
return "admin/run/stats";
}
}

private int getTotalAttendanceWithinPeriod(List<Run> runs) {
return runs.stream()
.map(run -> run.getStudentAttendance().size())
.reduce(0, (acc, timesRun) -> acc += timesRun);
}

private int getTotalAttendance(List<Run> runs) {
return runs.stream()
.map(run -> run.getTimesRun())
.reduce(0, (acc, timesRun) -> acc += timesRun);
}
}
4 changes: 4 additions & 0 deletions src/main/resources/i18n/i18n.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 15 additions & 5 deletions src/main/webapp/portal/admin/run/stats.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,33 @@ th {
<h5 style="color:#0000CC;"><a href="${contextPath}/admin"><spring:message code="returnToMainAdminPage" /></a></h5>

<h3><spring:message code="run_plural" /> ${period} (${fn:length(runs)} <spring:message code="run_plural" />)</h3>
<br />
<c:if test="${fn:length(runs) > 0}">
<c:if test="${period!=null}">
<h4>
<spring:message code="admin.run.accessCountWithinPeriodAllListed" />
${period}: ${totalAttendanceWithinLookBackPeriod}
</h4>
</c:if>
<h4><spring:message code="admin.run.totalAccessCountAllListed" />: ${totalAttendance}</h4>
<br />
</c:if>
<table id="runStatsTable" border="1">
<thead>
<tr><th><spring:message code="run_id" /> (<spring:message code="run_accessCode" />)</th>
<tr>
<th><spring:message code="run_id" /> (<spring:message code="run_accessCode" />)</th>
<th><spring:message code="run_name" /> (<spring:message code="wiseVersion" />)</th>
<th><spring:message code="admin.run.owners" /></th>
<c:if test="${period!=null}">
<th><spring:message code="admin.run.accessCount" /> ${period}</th>
</c:if>
<th><spring:message code="admin.run.totalAccessCount" /></th>
<th><spring:message code="available_actions" /></th></tr>
</tr>
</thead>
<tbody>
<c:forEach var="run" items="${runs}">
<tr>
<td>${run.id} (${run.runcode})</td>
<td><a href="${contextPath}/preview/unit/${run.id}" target="_blank">${run.id} (${run.runcode})</a></td>
<td>${run.name} (${run.project.wiseVersion})</td>
<td>
<a onclick='impersonateUser("${run.owner.userDetails.username}", "teacher")'>${run.owner.userDetails.username}</a><br/>
Expand All @@ -57,8 +69,6 @@ th {
<td>${fn:length(run.studentAttendance)}</td>
</c:if>
<td>${run.timesRun}</td>
<td>
</td>
</tr>
</c:forEach>
</tbody>
Expand Down
Loading