-
-
Notifications
You must be signed in to change notification settings - Fork 69
feat: display reading speed on analytics dashboard #2220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -143,6 +143,38 @@ public String handleRequest(@PathVariable Long studentId, Model model) { | |||||||
| } | ||||||||
| model.addAttribute("wordAssessmentEventCorrectCountList", wordAssessmentEventCorrectCountList); | ||||||||
| model.addAttribute("wordAssessmentEventIncorrectCountList", wordAssessmentEventIncorrectCountList); | ||||||||
|
|
||||||||
| // Prepare chart data - Reading speed (words per minute) | ||||||||
| List<Double> readingSpeedAvgList = new ArrayList<>(); | ||||||||
| if (!wordAssessmentEvents.isEmpty()) { | ||||||||
| Map<String, Integer> eventCountByWeekMap = new HashMap<>(); | ||||||||
| Map<String, Long> timeSpentMsSumByWeekMap = new HashMap<>(); | ||||||||
| for (WordAssessmentEvent event : wordAssessmentEvents) { | ||||||||
| String eventWeek = simpleDateFormat.format(event.getTimestamp().getTime()); | ||||||||
| if (event.getMasteryScore() >= 0.5) { | ||||||||
| eventCountByWeekMap.put(eventWeek, eventCountByWeekMap.getOrDefault(eventWeek, 0) + 1); | ||||||||
| timeSpentMsSumByWeekMap.put(eventWeek, eventCountByWeekMap.getOrDefault(eventWeek, 0) + event.getTimeSpentMs()); | ||||||||
| } | ||||||||
| } | ||||||||
| week = (Calendar) calendar6MonthsAgo.clone(); | ||||||||
| while (!week.after(calendarNow)) { | ||||||||
| String weekAsString = simpleDateFormat.format(week.getTime()); | ||||||||
| Integer wordsReadCount = eventCountByWeekMap.getOrDefault(weekAsString, 0); | ||||||||
| log.info("wordsReadCount: " + wordsReadCount); | ||||||||
| Long timeSpentMsSum = timeSpentMsSumByWeekMap.getOrDefault(weekAsString, 0L); | ||||||||
| log.info("timeSpentMsSum: " + timeSpentMsSum); | ||||||||
| Double timeSpentInMinutes = (double) (timeSpentMsSum / 1_000); | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct the milliseconds to minutes conversion. Line 166 incorrectly converts milliseconds to minutes by dividing by 1,000. The correct conversion should divide by 60,000 (1000ms × 60s = 60,000ms per minute). Apply this diff to fix the conversion: - Double timeSpentInMinutes = (double) (timeSpentMsSum / 1_000);
+ Double timeSpentInMinutes = (double) timeSpentMsSum / 60_000.0;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||
| log.info("timeSpentInMinutes: " + timeSpentInMinutes); | ||||||||
| Double wordsPerMinute = 0.00; | ||||||||
| if (timeSpentInMinutes > 0) { | ||||||||
| wordsPerMinute = wordsReadCount / timeSpentInMinutes; | ||||||||
| log.info("wordsPerMinute: " + wordsPerMinute); | ||||||||
| } | ||||||||
| readingSpeedAvgList.add(wordsPerMinute); | ||||||||
| week.add(Calendar.WEEK_OF_YEAR, 1); | ||||||||
| } | ||||||||
| } | ||||||||
| model.addAttribute("readingSpeedAvgList", readingSpeedAvgList); | ||||||||
|
|
||||||||
| // Prepare chart data - WordLearningEvents | ||||||||
| List<WordLearningEvent> wordLearningEvents = wordLearningEventDao.readAll(student.getAndroidId()); | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the time sum calculation bug.
Line 156 incorrectly uses
eventCountByWeekMap.getOrDefault(eventWeek, 0)instead of the time sum map.Apply this diff to fix the bug:
📝 Committable suggestion
🤖 Prompt for AI Agents