kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Help notification missing after a LOD sync when the learner completed the exercise before syncing

Open rtibblesbot opened this issue 1 month ago • 2 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

  • On a learn-only device (LOD), a learner fails an exercise in a lesson 3+ times, then completes it, then syncs.
  • Class activity on the server shows Started, Answered and Completed rows for the exercise, but no "needs help" row.
  • The same activity on a full device produces the "needs help" row.
  • Applies to classic lessons and course lessons alike.

User-facing consequences

Coaches of LOD learners never see that a learner struggled on an exercise they eventually completed.

Steps to reproduce

  1. On a server, create a class with a learner and assign a lesson containing an exercise.
  2. Set up a LOD for that learner and sync it.
  3. On the LOD, as the learner, answer 3 questions wrong in the exercise, then complete it.
  4. Sync the LOD.
  5. On the server, open Coach > <class> > Class activity.

Context

  • Synced attempt logs reach parse_attemptslog through batch_process_attemptlogs, after the summary log has already synced in its final, complete state.
  • parse_attemptslog only writes the Help row while _is_summary_log_incompleted(summarylog) is true: https://github.com/learningequality/kolibri/blob/19bae3c9e10ac4270720437734826f2ba2c9e98c/kolibri/core/notifications/api.py#L883-L885
  • Found while fixing #15514, which reuses this path for course resources.

Acceptance Criteria

  • [ ] After a LOD sync, an exercise failed 3+ times and then completed before the sync produces the same "needs help" row a full device produces, in classic and course lessons.
  • [ ] An exercise completed without reaching the help threshold still produces no "needs help" row after a sync.
  • [ ] Re-syncing adds no duplicate "needs help" rows.

AI usage

Claude Code found this gap while comparing full-device and synced notification rows for #15514, and drafted this issue.

rtibblesbot avatar Oct 06 '26 03:10 rtibblesbot

A second cause the fix must also handle:

  • _get_user_needs_help counts every attempt in the mastery log, including attempts made after the one being processed: https://github.com/learningequality/kolibri/blob/19bae3c9e10ac4270720437734826f2ba2c9e98c/kolibri/core/notifications/api.py#L520-L529
  • So once the completion check is relaxed, a synced batch can flag an earlier attempt using failures that came later — a row a full device would not create.
  • Extra criterion: after a LOD sync, attempts a full device would not flag create no "needs help" row, including attempts made after the summary log was completed.

Written by rtibblesbot, an LLM-based coding agent.

rtibblesbot avatar Oct 06 '26 04:10 rtibblesbot

Plan: A synced exercise that was failed past the help threshold and then completed produces the same Help row a full device does (#15523).

  • [ ] Gate Help on the summary log's state at the attempt
  • [ ] Only a failed attempt creates or moves the Help row
  • [ ] Self-review the produced code

Assumptions — the issue did not settle these; say so if one is wrong.

  • Failures are counted from attempts that had ended by the current attempt; if a learner interleaves items, the synced Help timestamp lands on a later attempt.
  • Only failed attempts create the Help row; on a full device, a lesson assigned after the failures now gets its row on the next failure, not the next correct answer.

Written by rtibblesbot, an LLM-based coding agent.

rtibblesbot avatar Oct 22 '26 10:10 rtibblesbot