Skip to content

feat(quizzes): module quiz history, archive endpoint, and quiz analytics - #505

Merged
DeFiVC merged 2 commits into
ChainLearnOfficial:mainfrom
davedumto:feat/quiz-history-archive-analytics-cleanup-batch
Sep 30, 2026
Merged

DeFiVC merged 2 commits into
ChainLearnOfficial:mainfrom
davedumto:feat/quiz-history-archive-analytics-cleanup-batch

Conversation

@davedumto

Copy link
Copy Markdown
Contributor

Summary

  • GET /courses/:id/modules/:moduleId/quiz-history: aggregate stats across every quiz in a module (average score, pass rate, total attempts, score distribution), admin-only, cached 5 minutes.
  • POST /admin/courses/:id/modules/:moduleId/quizzes/:quizId/archive: a dedicated route delegating to the existing 0. Add POST /api/v1/admin/courses/:id/modules/:moduleId/quizzes/:quizId endpoint #413 update-quiz path with { archived: true/false }, same atomic transaction and audit log, added purely for discoverability over the generic update endpoint.
  • GET /admin/courses/:id/modules/:moduleId/quizzes/:quizId/analytics: per-question correct rate and most common wrong answer, score distribution, and current-vs-superseded attempt counts. Per-question timing isn't tracked anywhere in the submission data (only questionId + selectedIndex), so it's explicitly reported as unavailable rather than fabricated.

Both aggregate endpoints are cached 5 minutes via the existing cacheGetOrSet helper and invalidated on every quiz write path.

Issue #468 (duplicate imports in course.service.ts) was already fixed on main before this branch was created; verified and made no changes for it.

closes #415
closes #416
closes #417
closes #468

Test plan

  • New test file (tests/unit/quizzes/admin-quiz-analytics.test.ts, 16 cases): aggregate shape correctness, zero-submission edge cases, 5-minute cache-hit behavior, score bucketing, common-wrong-answer aggregation, superseded-vs-current counting, archive/unarchive delegation + audit log, 404s for mismatched course/module/quiz
  • Full suite: 254 passed / 10 failed, all 10 failures pre-existing on main and unrelated to any file this PR touches (confirmed by diffing failure lists before/after)
  • npx tsc --noEmit: clean on every file this PR touches
  • eslint: 0 errors on changed files

davedumto and others added 2 commits September 29, 2026 15:49
Adds three admin/course-creator endpoints:
- GET /courses/:id/modules/:moduleId/quiz-history: aggregate stats
  across every quiz in a module (average score, pass rate, total
  attempts, score distribution), scoped to the module rather than the
  whole course.
- POST /admin/courses/:id/modules/:moduleId/quizzes/:quizId/archive:
  a dedicated route delegating to the existing ChainLearnOfficial#413 update-quiz path
  with { archived: true/false }, for discoverability.
- GET /admin/courses/:id/modules/:moduleId/quizzes/:quizId/analytics:
  per-question correct rate and common wrong answer, score
  distribution, and current-vs-superseded attempt counts. Per-question
  timing is not tracked anywhere in the submission data, so it's
  reported as explicitly unavailable rather than fabricated.

Both aggregate endpoints are cached 5 minutes and invalidated on every
quiz write path. ChainLearnOfficial#468 (duplicate imports in course.service.ts) was
already fixed on main; no changes needed for it.
@DeFiVC
DeFiVC merged commit 5851eee into ChainLearnOfficial:main Sep 30, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants