Affects Version/s: 3.8.2
Fix Version/s: None
The lesson_attempts table has a "retry" column to indicate to which retry/retake does an answer belong. However, lesson_timer and lesson_grades don't have this column, and this causes a weird behaviour in one of our testing sites.
We have a lesson with questions and grades. However, there is a way to reach the end of the lesson without answering any question, only with content pages (branch). In this case, there are entries in the lesson_attempts table because the content pages button clicks are also stored in there, but there is no entry in the lesson_grades table.
The function lesson_get_overview_report_table_and_data assumes that, if a lesson has grades, each retry will have an entry in the lesson_grades table, so the first entry found will belong to the first retry and so on. But in this case we have more retries than entries in the lesson_grades table. So at first when a teacher sees the list of retries he can see that the last attempt has no grade. But if the user retries the lesson again, the grade of this last retry will be assigned to the previous retry, not to the last one, because the lesson cannot know to which retry does each grade belong, it assigns them by order.
So for example:
- Student starts a new retry (retry number 1) and finishes the lesson without answering any question.
- The teacher can see retry number 1 without grade.
- The student starts a new retry (retry number 2) and finishes it with a grade of 50%.
- The teacher can see retry number 1 with a grade of 50% and retry 2 without grade.
The same happens with the lesson_timer table. I don't know how it happened, but we have more retries than entries in the lesson_timer table so the last 3 retries don't have a start or end time. Every time the student starts a new retry, the last retry without a start/end time gets the timers from the current attempt.
Both cases aren't usual cases, but I think it would be better to identify to which retry does each grade/timer belong.