Skip to content

Use quiz attempts for completion state#7

Open
aiko-gh wants to merge 2 commits into
mainfrom
aiko/fix-quiz-completion-signal
Open

Use quiz attempts for completion state#7
aiko-gh wants to merge 2 commits into
mainfrom
aiko/fix-quiz-completion-signal

Conversation

@aiko-gh

@aiko-gh aiko-gh commented Mar 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • fetch quiz attempt data with mod_quiz_get_user_attempts during Moodle contents sync
  • mark quizzes completed when the user has a non-preview attempt in finished state, falling back to module completion only when attempt data is unavailable
  • add collector tests for finished, in-progress, and fallback quiz completion behavior

Live investigation

  • core_course_get_contents returned completiondata.state = 0 for Thermo quizzes 100064 and 100067, which kept them incorrectly incomplete
  • mod_quiz_get_user_attempts for those same quiz instance IDs returned one attempt each with state: "finished"
  • other Thermo quizzes checked (100061, 100070, 100073, 100076, 100079, 100082, 100085, 100100) returned zero attempts

Verification

  • PYTHONPATH=/tmp/moodle-tracker-codex-kjvtTb/src MOODLE_BASE_URL=https://example.invalid MOODLE_USERNAME=test MOODLE_PASSWORD=test pytest -q tests/test_collectors.py
  • rebuilt and restarted live api and worker containers from /home/sam/projects/moodle-tracker
  • ran POST /sync/run/moodle_contents against the live app
  • confirmed /items/78 and /items/80 now return completion_state: completed
  • confirmed those quizzes no longer appear in GET /risks

Notes

  • the broader local suite still has two unrelated failures in tests/test_persistence_notifications.py around change classification (refresh_only / deadline_changed), not touched by this patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant