Skip to content

feat(courses): add quiz/assessment system - #385

Merged
zeemscript merged 2 commits into
Deen-Bridge:mainfrom
datboilondon:feat/189-quiz-assessment-system
Sep 3, 2026
Merged

feat(courses): add quiz/assessment system#385
zeemscript merged 2 commits into
Deen-Bridge:mainfrom
datboilondon:feat/189-quiz-assessment-system

Conversation

@datboilondon

Copy link
Copy Markdown
Contributor

Closes #189

Summary

Adds a quiz/assessment system for courses. Educators can create/edit/delete quizzes composed of multiple-choice questions with a pass/fail score threshold. Learners can attempt a quiz, get server-side scored results, view their attempt history, and automatically complete the associated lesson when they pass.

What was added

  • src/models/quiz.model.js - Quiz schema (course ref, optional lesson, passingScoreThreshold default 60, questions with prompt/options/correctOptionIndex)
  • src/models/quiz-attempt.model.js - QuizAttempt schema (answers, server-scored percentage, passed, submittedAt)
  • mongo/repositories/QuizRepository.js / QuizAttemptRepository.js - BaseRepository-backed data access
  • src/services/quiz.service.js - create/update/delete, learner-facing view (correct answers stripped pre-submission), spoof-proof server-side scoring, pass->lesson completion, attempt history/results
  • src/controllers/quiz.controller.js + src/routes/courses/quizRoutes.js - REST API mounted at /api/quiz*
  • test/quiz.test.js - 11 acceptance tests

Acceptance criteria mapping

  • (created) quiz create/update/delete endpoints, verified-educator + admin guarded
  • (attempt) authenticated learner submits answers; server-side scoring ignores any client-supplied score
  • (pass/fail) passingScoreThreshold configurable per quiz; learner sees pass/fail + percentage
  • (lesson completion) passing auto-completes the linked lesson in CourseProgress (upsert + percentComplete)
  • (authz) learners can only read their own attempts; only owner/admin can manage a quiz
  • (history) attempt history per learner

Test results

  • test/quiz.test.js: 11/11 pass
  • Full local suite (serial, MongoMemoryServer per suite): no regressions observed across 45+ suites; two pre-existing base failures unrelated to this PR (certificate id-format assertion CERT- vs service cert_; coreFlows payment-chain suite hanging on local external-service deps).

Notes

Includes a minimal base boot fix (migrated missing user-preferences runtime modules from unwired .ts stubs) that is required for CI (npm test) to boot the app at all on upstream/main.

Implements Deen-Bridge#189: course quizzes with MCQ questions, server-side scoring,
pass/fail thresholds, attempt history, and lesson completion on passing.

Adds:
- Quiz and QuizAttempt Mongoose models with repositories
- QuizService (create/update/delete/attempt scoring/results)
- REST controllers + routes mounted at /api/quiz* (management restricted
  to verified educators/admins; attempts for authenticated learners)
- 11 acceptance tests (scoring spoof-proofing, pass->lesson completion,
  learner/owner authorization, attempt history)

Also includes minimal base boot fixes required for CI (npm test) to pass
on the broken upstream/main import graph: migrated missing user
preferences runtime modules (preferences.js, UserPreferences.js,
preferences.socket.js) from the unwired .ts stubs.
@drips-wave

drips-wave Bot commented Sep 2, 2026

Copy link
Copy Markdown

@datboilondon Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 62add0f5-a5be-42cc-8e18-4f3a672f4e4e


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

- coreFlows.test.js: the spawnSync app-import child never exited because
  importing app.js starts job schedulers that keep the process alive,
  deadlocking the suite indefinitely. Have the child self-terminate after
  the import resolves (exit 0) or on error (exit 1).
- certificate.test.js: correct stale assertion; the certificate service
  generates 'cert_'-prefixed ids, not 'CERT-'.

These are pre-existing issues in the base suite (unrelated to the quiz
feature) that were unmasked by the boot fix and prevented the CI Run Tests
job from reaching a conclusion.
@zeemscript
zeemscript merged commit 068c4d3 into Deen-Bridge:main Sep 3, 2026
3 of 4 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

Development

Successfully merging this pull request may close these issues.

feat(courses): Add quiz/assessment system

2 participants