Exercise Question Types Expansion PRD
Status
- In progress (remaining question-type work; exercise question sections and video recording are tracked as separate shipped PRDs — see PRD-TRACKER DONE)
Date
- February 24, 2026
Implementation Plan
- See implementation-plan.md for ticket breakdown and delivery sequencing.
Purpose
Expand ClassroomIO exercise questions beyond single answer, multiple answers, and paragraph, so instructors can run stronger assessments, reduce manual grading where possible, and collect richer assignment submissions inside the LMS.
Problem Statement
Current exercise functionality is constrained by three legacy question types and a grading/answer model tuned for those types. This creates four product issues:
- Limited assessment design for instructors.
- Lower auto-grading coverage.
- Weak first-class support for assignment-style submissions.
- Increased instructor grading overhead and external-tool leakage.
Current-State Audit
| Area | Current State | Gaps |
|---|---|---|
| Question types | RADIO, CHECKBOX, TEXTAREA only |
No true/false, numeric, fill-blank, matching, ordering, file-upload, hotspot |
DB question_type |
Seeded from packages/db/src/utils/seed/questionType.ts |
Typename coverage too narrow |
| Validation constants | QUESTION_TYPE in packages/utils/src/validation/constants.ts contains only 3 numeric IDs |
Hardcoded numeric assumptions are fragile as type set grows |
| Exercise validation | packages/utils/src/validation/exercise/exercise.ts has option rules for radio/checkbox + textarea |
No schema-per-type authoring or submission validation |
| Exercise authoring UI | edit-mode.svelte renders only radio, checkbox, textarea |
No renderer registry or extensibility contract |
| Exercise taking UI | view-mode.svelte answer flow assumes options or open text |
No type-specific interaction patterns for new formats |
| Submission model | question_answer stores answers[] + open_answer |
No structured payload for richer responses (fill blanks, ordering, matching, uploads) |
| Attempt controls | No max-attempt rule or attempt scoring strategy on exercise |
Cannot configure highest/latest/average grading behavior |
| Test controls | No persisted timer/randomization/availability settings on exercise | Missing in-schema support for test-mode controls |
| File response support | No exercise-question-level upload config | Cannot do per-question file constraints |
Data Sources Checked
packages/db/src/schema.tspackages/db/src/utils/seed/questionType.tspackages/db/src/queries/exercise/exercise.tspackages/utils/src/validation/constants.tspackages/utils/src/validation/exercise/exercise.tsapps/api/src/routes/course/exercise.tsapps/api/src/services/exercise/exercise.tsapps/api/src/services/exercise/utils.tsapps/api/src/services/submission/submission.tsapps/api/src/services/course/clone.tsapps/dashboard/src/lib/features/ui/question/constants.tsapps/dashboard/src/lib/features/course/components/exercise/edit-mode.svelteapps/dashboard/src/lib/features/course/components/exercise/view-mode.svelteapps/dashboard/src/lib/features/course/components/exercise/functions.tsapps/dashboard/src/lib/features/course/components/exercise/store.tsapps/dashboard/src/lib/features/course/api/exercise.svelte.ts
Primary Users
- Instructors creating tests and assignments.
- Students answering exercises on desktop and mobile.
- Admins and tutors grading and reviewing progress.
Goals
- Support additional objective and subjective question types.
- Increase auto-grading coverage for objective formats.
- Add first-class assignment upload support at question level.
- Keep authoring UX consistent across question types.
- Add explicit exercise-level controls for attempts, scoring rule, answer reveal, and test behavior.
Non-Goals (v1)
- Online proctoring.
- AI-generated grading feedback.
- Code execution/judging sandboxes.
- LTI/QTI export.
- Negative marking.
- Audio/video response question type.
Confirmed Decisions
- Code execution is out of scope.
- Upload size limits are plan-based: Free
2MB, Paid10MB. - Resubmission policy is exercise-level, not per question.
- Rollout phases remain
P0,P1,P2. - If an exercise contains
short answerorparagraph, final grading is manual. - Numeric-answer grading mode is configurable.
- Fill-in-the-blank does not support multiple accepted answers per blank in v1.
- Partial credit is enabled by default where supported.
- Partial credit settings are question-level with exercise-level override.
- File upload configuration is per question.
- Exercise settings include max attempts.
- Correct-answer visibility is exercise-level configurable.
- Test-only controls are in scope.
- Allowed upload file types in v1:
PDF,DOCX,PPTX,XLSX,ZIP, and images. - Attempt grading rule is exercise-level configurable:
highest,latest,average. - Upload question accepts exactly one file in v1.
Proposed Question Types
| Type | Auto-gradable | Partial Credit | Assignment Fit | Test Fit | Phase |
|---|---|---|---|---|---|
| True/False | Yes | No | Medium | High | P0 |
| Short Answer (single-line) | No | N/A | High | High | P0 |
| Numeric Answer | Yes | Optional | Medium | High | P0 |
| Fill in the Blank | Yes | Yes | Medium | High | P0 |
| File Upload | No | N/A | High | Low | P0 |
| Matching | Yes | Yes | Medium | High | P1 |
| Ordering/Sequence | Yes | Yes | Medium | High | P1 |
| Hotspot/Image Labeling | Yes | Optional | Medium | Medium | P2 |
Functional Requirements
Authoring
- Instructor can choose question type from a type picker.
- Instructor can configure:
- prompt
- points
- required/optional
- per-question instructions
- type-specific settings
- Instructor can define answer key for auto-graded types.
- Instructor can configure scoring mode (
all_or_nothingorpartial) where supported. - Instructor can preview question behavior before publish.
Student Experience
- Students can answer all released types on desktop and mobile.
- Answers autosave while taking exercise.
- One exercise can contain mixed question types.
- File upload question enforces allowed MIME/extensions and plan-based limits.
- File upload question accepts one file in v1.
Grading
- Objective types auto-grade immediately unless exercise is in manual-only mode.
- Manual types route to grading queue with teacher feedback.
- Instructors can override auto-graded scores.
- Gradebook stores per-question points and final exercise score.
- Exercise-level
auto-gradetoggle can only be enabled when all active question types are auto-gradable; otherwise it must be disabled with a hint message.
Attempts and Test Controls
- Exercise-level settings:
maxAttemptsattemptScoringRule(highest,latest,average)showCorrectAnswerspolicytimerSeconds(optional)randomizeQuestionOrderrandomizeOptionOrder- availability window (
availableFrom,availableTo)
Technical Design
1. Canonical Question Type Registry
Keep one canonical source for question type metadata used by API and dashboard.
Target package:
packages/question-types/src/(new, published as@cio/question-types)
Registry includes:
- stable key (
TRUE_FALSE,SHORT_ANSWER, etc.) - DB typename
- DB id (resolved at startup/seed, not hardcoded in scattered files)
- auto-gradable flag
- partial-credit support
- submission payload schema key
- rollout phase
1.1 Canonical Renderer Components
Keep question renderer components in @cio/ui and keep all shared logic/contracts in @cio/question-types.
Target package:
packages/ui/src/custom/exercise-question/(new)- exports via
packages/ui/src/index.ts
Rules:
- renderer registry/contracts live in
@cio/question-types. - answer serialization and shared form-state utilities live in
@cio/question-types. - render contract object lives in
@cio/question-types(ExerciseQuestionRenderContract/ExerciseQuestionListRenderContract) and is deterministic for the same inputs. - question type renderer components live in
@cio/ui/custom/exercise-question. @cio/ui/custom/exercise-questionis components-only and does not own shared exercise logic.- dashboard screens consume type keys/contracts from
@cio/question-typesand renderers from@cio/ui/custom/exercise-question.
1.2 Cross-App File Contract
- The complete individual file list for reusable shared packages is defined in
implementation-plan.mdunderShared Package File Contract (Cross-App Reuse). - Shared package code must stay app-agnostic so any app can consume it to build an exercise/forms product.
2. Data Model Changes
question table
Add:
settings(jsonb, default{}, not null)scoring_mode(varchar, defaultall_or_nothing)manual_grading_required(boolean, defaultfalse)
settings examples:
- numeric:
{ "mode": "exact" | "tolerance_abs" | "tolerance_pct", "tolerance": number } - upload:
{ "maxFiles": 1, "allowedTypes": [...], "maxSizeMb": 2|10 } - matching:
{ "shuffleLeft": true, "shuffleRight": true }
question_answer table
Add:
payload(jsonb, default{}, not null)
Keep existing answers[] and open_answer for backward compatibility during migration; new types write to payload.
exercise table
Add:
max_attempts(integer, default1)attempt_scoring_rule(varchar, defaultlatest)show_correct_answers(varchar, defaultafter_grading)timer_seconds(integer, nullable)randomize_question_order(boolean, defaultfalse)randomize_option_order(boolean, defaultfalse)available_from(timestamptz, nullable)available_to(timestamptz, nullable)
submission table
Add:
attempt_number(integer, default1)finalized_score(double precision, nullable)grading_mode(varchar, defaultauto_or_manual)
3. Validation Layer
Update/expand packages/utils/src/validation/exercise/:
question-base.ts(shared prompt/points/rules)question-true-false.tsquestion-short-answer.tsquestion-numeric.tsquestion-fill-blank.tsquestion-file-upload.tsquestion-matching.tsquestion-ordering.tsquestion-hotspot.ts- compose into:
ZExerciseCreateZExerciseUpdateZExerciseSubmissionCreate
Validation must run:
- in API routes
- in dashboard before submit/update
- in grading service for defensive checks
4. API Layer Changes
Primary touchpoints:
apps/api/src/routes/course/exercise.tsapps/api/src/services/exercise/exercise.tsapps/api/src/services/exercise/utils.tsapps/api/src/services/submission/submission.tspackages/db/src/queries/exercise/exercise.ts
Key changes:
- Accept/store question
settingsandscoringMode. - Support typed answer payload writes to
question_answer.payload. - Enforce attempt limits before creating a submission.
- Compute final grade using
attemptScoringRule. - Auto/manual grading decision based on question mix.
- Support file-response references through existing assets model.
5. Dashboard Layer Changes
Primary touchpoints:
packages/ui/src/custom/exercise-question/*(new shared UI component set; components only)packages/ui/src/index.tsapps/dashboard/src/lib/features/course/components/exercise/edit-mode.svelteapps/dashboard/src/lib/features/course/components/exercise/view-mode.svelteapps/dashboard/src/lib/features/course/components/exercise/functions.tsapps/dashboard/src/lib/features/course/components/exercise/store.tsapps/dashboard/src/lib/features/course/api/exercise.svelte.tsapps/dashboard/src/lib/features/course/utils/types.ts- translations in
apps/dashboard/src/lib/utils/translations/en.json
Refactor plan:
- Introduce registry/contracts in
@cio/question-typesand map question type keys to shared UI renderers. - Keep existing mode structure (
edit,view,preview) but remove hardcodedif RADIO/CHECKBOX/TEXTAREAbranching. - Add type-specific renderer components under
packages/ui/src/custom/exercise-question. - Add translation keys for new types and setting labels.
- Add exercise-level
auto-gradetoggle with eligibility guard and hint message when blocked by manual-only question types.
6. Legacy Compatibility and Migration
- Existing exercises keep working without migration rewrite of question data.
- New columns default safely (
{}/ false / null / default enums). question_typeseed extends with new typenames.- Replace hardcoded numeric assumptions where present.
Known cleanup item discovered during audit:
apps/api/src/services/course/clone.tsusesQUESTION_TYPE_TEXTAREA = 2, while shared constant mapsTEXTAREA = 3.- This must be corrected before rollout to avoid option-cloning regressions for paragraph questions.
Progress Update (Feb 26, 2026)
Completed in branch:
- Shared package contracts/registry implemented in
@cio/question-types. - Dashboard renderer logic centralized via shared render contracts and shared
@cio/ui/custom/exercise-questioncomponents. - Shared question renderer component files implemented for legacy and expanded question types.
- Clone service question-type ID mismatch fixed to use shared constants.
Still pending for grading engine milestone:
- End-to-end server auto-grading engine across non-legacy types.
- Exercise-level
auto-gradetoggle + disabled-state hint behavior. - Full per-type validation/attempt-rule enforcement rollout in API.
Rollout Plan
Phase 1 (P0)
Question types:
- True/False
- Short Answer
- Numeric
- Fill in the Blank
- File Upload
Required deliverables:
- DB columns for settings/payload/attempt controls.
- Validation and API support for P0 types.
- Dashboard renderer registry + P0 components.
- Attempt scoring rule support.
- Migration + seed updates.
Phase 2 (P1)
Question types:
- Matching
- Ordering/Sequence
Required deliverables:
- Partial-credit grading helpers.
- Enhanced analytics aggregation for pair/order correctness.
- UX polish for drag/drop and accessibility.
Phase 3 (P2)
Question types:
- Hotspot/Image Labeling
Required deliverables:
- Image coordinate mapping schema.
- Responsive touch/mobile interaction hardening.
- Additional grading explainability in teacher UI.
Testing Requirements
API
- Schema validation tests for each type (create/update/submit).
- Grading tests:
- all-or-nothing
- partial-credit
- manual-required fallback
- Attempt rule tests (
highest,latest,average). - Upload constraint tests by plan limit.
Dashboard
- Component tests for each type renderer in edit/take modes.
- Store tests for autosave and answer serialization.
- Integration tests for submission payload generation.
Regression
- Existing three types must pass unchanged behavior tests.
- Exercise cloning must preserve all supported question types correctly.
Build and Verification Commands
pnpm --filter @cio/db buildpnpm --filter @cio/utils buildpnpm --filter @cio/api buildpnpm --filter @cio/dashboard build
Success Metrics (90 Days Post-Launch)
- 40% of newly created exercises include at least one new type.
- 25% reduction in average grading time per exercise.
- 20% increase in completion for assignment-heavy exercises.
- 30% increase in auto-graded question share in test exercises.
Risks and Mitigations
- Hardcoded question-type IDs may cause logic drift.
- Mitigation: canonical registry + typename-based mapping.
- Rich payload types can increase complexity in submission parsing.
- Mitigation: strict per-type schema and shared serializer/deserializer utilities.
- File uploads can introduce abuse/security risk.
- Mitigation: MIME/size validation, one-file v1 cap, server-side checks, existing asset safeguards.
Open Questions
- Should
short answersupport optional case-insensitive exact-match auto-grading in v1.1? - For fill-in-the-blank, should punctuation normalization be strict or relaxed by default?
- Should hotspot remain P2 or shift post-P2 depending on demand?