public StatisticResult generateStatisticResult(UserRequest ureq, ICourse course, long courseRepositoryEntryKey) {
DBQuery dbQuery = DBFactory.getInstance().createQuery("select businessPath,day,value from org.olat.course.statistic.dayofweek.DayOfWeekStat sv "
+ "where sv.resId=:resId");
dbQuery.setLong("resId", courseRepositoryEntryKey);
StatisticResult result = new StatisticResult(course, dbQuery.list());
// now sort by user's preferred firstDayOfWeek
Calendar c = Calendar.getInstance(ureq.getLocale());
int firstDayOfWeek = c.getFirstDayOfWeek();
List<String> columnHeaders = new ArrayList<String>(7);
for(int i=firstDayOfWeek; i<firstDayOfWeek+7; i++) {
int mod = i%7;
if (mod==0) {
// jdk calendar calculations don't start at 0 - they start at 1
mod = 7;
}
columnHeaders.add(String.valueOf(mod));
}
result.setColumnHeaders(columnHeaders);
return result;
}