kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Changing a saved quiz answer records the wrong time spent

Open rtibblesbot opened this issue 1 week ago • 0 comments

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Target branch: develop

Observed behavior

  • saveAnswer computes time_spent as ((this.currentAttempt.time_spent || 0) + Date.now() - this.startTime) / 1000.
  • currentAttempt.time_spent is the saved value in seconds; Date.now() - this.startTime is milliseconds. The sum is divided by 1000 as a whole.
  • The server stores the value as sent: https://github.com/learningequality/kolibri/blob/758605b764b04d41d5270165cab714ddd441b78a/kolibri/core/logger/viewsets/progress_tracking.py#L758
  • Sites:
    • https://github.com/learningequality/kolibri/blob/758605b764b04d41d5270165cab714ddd441b78a/kolibri/plugins/learn/frontend/views/ExamPage/index.vue#L659
    • https://github.com/learningequality/kolibri/blob/758605b764b04d41d5270165cab714ddd441b78a/kolibri/plugins/learn/frontend/views/QuizRenderer/index.vue#L434
    • https://github.com/learningequality/kolibri/blob/758605b764b04d41d5270165cab714ddd441b78a/kolibri/plugins/learn/frontend/views/courses/QuizRenderer/index.vue#L379
    • https://github.com/learningequality/kolibri/blob/758605b764b04d41d5270165cab714ddd441b78a/kolibri/plugins/learn/frontend/views/courses/PrePostTestRenderer/index.vue#L415

Expected behavior

  • The time spent on a question is the total across every visit to it, in seconds.

Steps to reproduce

  1. Answer a quiz question after 60 seconds and press Next. The PUT sends time_spent: 60.
  2. Press Previous, wait 5 seconds, change the answer and press Next.
  3. The PUT sends time_spent: 5.06, not 65.

Context

  • develop at 758605b764.
  • #15980 changes the same four components and their specs, and creates ExamPage.spec.js.

Acceptance Criteria

  • [ ] In class quizzes, practice quizzes, surveys, course quizzes and course pre/post tests, a changed answer sends the earlier time_spent plus the seconds since the question was opened.
  • [ ] Specs cover a changed answer in each of the four components.

AI usage

Claude Code found this while working on #15980 and drafted the issue; rtibbles kept #15980 to focus handling.

rtibblesbot avatar Nov 25 '26 07:11 rtibblesbot