Skip to content

Add visual quiz editor for instructors + fix KnockoutJS bugs + comprehensive tests#98

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/add-quiz-editor-feature
Draft

Add visual quiz editor for instructors + fix KnockoutJS bugs + comprehensive tests#98
Copilot wants to merge 2 commits intomasterfrom
copilot/add-quiz-editor-feature

Conversation

Copy link
Copy Markdown

Copilot AI commented May 5, 2026

Summary

Implements a full visual quiz editor so instructors can edit quiz questions through a form UI instead of editing raw JSON. Also fixes several KnockoutJS bugs found in the existing quiz system and adds comprehensive Python tests for the grading logic.

Changes

New: Visual Quiz Editor

  • frontend/components/quizzes/quiz_editor_state.ts — Observable ViewModel classes for the quiz editor. Parses existing instructions + checks JSON into KnockoutJS observables and serialises them back. Supports all 10 question types.
  • frontend/components/quizzes/quiz_editor_ui.html — HTML template for the editor. Renders type-appropriate form fields for every question type, plus quiz settings and pool management.
  • frontend/components/quizzes/quizzer.ts — Wires in the editor: new quizEditor observable, saveQuizEditor() method, and a subscription that rebuilds the editor state whenever the "Quiz Editor" tab is selected.
  • frontend/components/quizzes/quiz_ui.ts — Replaces the "Quiz Editor is not yet ready" placeholder with the real editor template.

The editor is accessed via the existing "Quiz Editor" tab in the instructor toolbar. It supports:

  • All question types: true/false, multiple choice, multiple answers, matching, multiple dropdowns, fill-in-multiple-blanks, short answer, numerical, essay, text-only
  • All check/feedback fields: correct answers, per-answer feedback, fallback feedback, regex patterns
  • Quiz settings: feedback type, attempt limit, cool-down, pool randomness, reading ID
  • Question pools: add/remove pools, set amount, assign question IDs
  • Add/remove questions of any type with auto-generated IDs
  • Expand/collapse individual questions for a clean overview

Bug Fixes (KnockoutJS)

  • quizzer.ts: isReadOnly computed now null-guards this.quiz() (was throwing before a quiz was loaded). Subscription callback now correctly uses the quiz parameter instead of re-calling this.quiz(). New editorMode subscription is properly disposed.
  • quizzer_question_status.ts: Fixed a runtime crash: the quiz parameter was typed as ko.Observable<Quiz> but the template passed a plain Quiz value. this.quiz() would throw "not a function" as soon as any feedback was shown. Fixed by correcting the type to Quiz and accessing .feedbackType() directly.
  • questions_ui.html: Fixed the matching question's answer dropdown — $parent.answers.sort(...) was mutating the original array in place and re-randomising on every re-render. Fixed with [...$parent.answers].sort(...).

Tests

  • tests/test_quiz_grading.py — 70 new passing tests covering every question type and feature of the Python quiz grading system (process_quiz, process_quiz_str, check_quiz_question), including partial credit, weighted scoring, regex checking, feedback, edge cases, and error handling.

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.

2 participants