* feat(ui): add THUMBS question type renderer - Add seven new renderer files under renderers/thumbs/: thumbs-correct.ts, take.svelte, edit.svelte, preview.svelte, thumbs-review-toggle.svelte, review.svelte, submission.svelte - Register THUMBS in renderer-contract.ts with edit/take/preview/submission/review - Export ThumbsEdit, ThumbsTake, ThumbsPreview, ThumbsSubmission, ThumbsReview from exercise-question/index.ts - Add THUMBS_FIXTURE, four thumbs label keys, and Thumbs story in storybook exercise-question files - Add THUMBS case to question-type-modes.svelte submission builder Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com> * feat(question-types): add THUMBS contracts, scoring, and seed Introduce the THUMBS question type (id 14) with boolean answer data, codec, auto-grading, Zod validation, DB seed/schema docs, and binary normalize support shared with TRUE_FALSE. Dashboard wiring is deferred. Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com> * feat(dashboard): wire THUMBS question type into exercise UI Connect THUMBS option sync in edit/view modes, labels, picker icon, and locale strings so the existing contracts surface in the dashboard. Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com> * fix(ui): polish thumbs question UI and move premium upgrade icon Widen thumbs Yes/No toggles, inherit selected icon color via custom class, replace badge-based review correctness with solid fill states and bare Check/X icons, add a success pill in preview, and place the premium upgrade icon at the end of the question type select row. Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com> * fix(ui): align thumbs review colors with prototypes Tune correct/incorrect selected states so review buttons use dark emerald/red content colors on solid fills, matching the design comps. Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com> * fix(ui): address remaining PR review comments Use a shared timestamp local in thumbs edit fallback options. Move border-beam animation-delay after the animation shorthand. Alias --spacing to --ui-spacing for tw-animate compatibility. Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com> * fix(db): sync question_type sequence before seeding new types Avoid duplicate key errors when question_type_id_seq lags behind rows inserted via restore or explicit ids (e.g. THUMBS on restored databases). Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com> * fix(exercise): resolve thumbs review label ICU crash Remove {value} ICU placeholder from thumbs.review.correct_answer_label since labels are resolved at map-build time without context. Append the dynamic yes/no label in thumbs-review-toggle instead. Also bind question points through the questionnaire store index to avoid the Svelte non-reactive property binding warning in edit-mode. Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com> * docs(agent): add THUMBS guidance and sync question type docs Add shared agent question-type guide helpers in @cio/question-types and use them across the teacher prompt, add/update_questions tool schemas, legacy ai-assistant schemas, and MCP exercise tools. - Document when to use THUMBS (Yes/No sentiment) vs TRUE_FALSE (factual) - Fix stale MCP question type ids and add THUMBS=14 - Exclude disabled MATCHING/HOTSPOT from enabled type lists Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com> * fix(thumbs): clarify auto-grading and add editable option labels THUMBS is auto-graded like TRUE_FALSE; the difference is thumbs UI with customizable Yes/No-style labels and the teacher selecting the correct option. Render take/preview/review from question.options labels and add label inputs in the thumbs edit renderer. Update agent and MCP docs to stop implying THUMBS is manual or non-gradable. Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com> * chore(mcp): bump version to 0.0.10 Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com> * fix(question-types): make THUMBS open-ended with no correct answer THUMBS is a sentiment/poll question type, not an auto-graded binary like TRUE_FALSE. Remove correct-answer UI, scoring, and validation; update agent and MCP docs accordingly. Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com> * fix(dashboard): stop treating THUMBS as auto-graded in editor validation Normalize thumbs questions on load/save, show an Open-ended badge instead of Auto, and only enforce points/correct-answer rules on auto-gradable types. Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com> * revert(dashboard): remove unsolicited open-ended grading badge THUMBS uses the existing Manual badge like other non-auto-gradable types. Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com> * fix(exercise): show question title validation errors in editor Display mapped title errors beneath the question title input instead of only highlighting the question card border. Pass the exercise entity to mapZodErrorsToTranslations so messages resolve to validations.exercise.* keys, and use a translated snackbar key for save validation failures. Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com> * fix(mcp): build workspace deps before MCP publish bundle The MCP esbuild step imports @cio/question-types and @cio/utils dist outputs. CI failed on a clean checkout because mcp:build only built the MCP package itself. Build those dependencies first so 0.0.10 can publish. Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Rotimi Best <rotimi-best@users.noreply.github.com>
@cio/question-types
Shared, framework-agnostic question type contracts for ClassroomIO exercise products.
This package is the source of truth for:
- Question type keys and DB id mappings
- Type metadata and capability flags
- Stable render contracts and list contracts
- Answer payload and serialization helpers
- Renderer registry helpers (without UI implementation)
- Form state primitives for question flows
It is intentionally pure TypeScript and contains no UI components.
Why this package exists
@cio/question-types centralizes exercise domain contracts so every app/package can use the same behavior:
apps/dashboarduses the same question keys/types as API and DB consumersapps/apican rely on stable question type IDs@cio/uican implement renderers against one shared contract- Future products (for example, forms/assessments) can reuse the same domain model
Package boundary
What belongs here:
- Domain constants and type-level contracts
- Pure mapping/lookup helpers
- Deterministic utilities (same input => same output)
- Serialization rules for answer payloads
What does not belong here:
- Svelte/React/Vue components
- Package-specific UI behavior
- Network calls
- DB query implementations
Architecture
flowchart LR
subgraph Product Apps
DASH[apps/dashboard]
API[apps/api]
FUTURE[future app e.g. forms]
end
subgraph Shared Packages
QT[@cio/question-types\ncontracts + registry + serializer]
UI[@cio/ui/custom/exercise-question\nrendering implementation]
DB[(DB question_types ids)]
end
DASH -->|question models, keys, lookups| QT
FUTURE -->|same contracts| QT
UI -->|imports types + registry helpers| QT
DASH -->|renders via props/contracts| UI
API -->|imports QUESTION_TYPE_IDS| QT
QT -->|stable id <-> key mapping| DB
DASH -->|answersByKey| QT
QT -->|serializeExerciseAnswerMap| API
Source layout
packages/question-types/src/
answer-serializer.ts
exercise-types.ts
form-state.ts
index.ts
question-answer-payload.ts
question-scoring-rules.ts
question-type-capabilities.ts
question-type-keys.ts
question-type-lookup.ts
question-type-registry.ts
question-type-types.ts
render-contract.ts
renderer-registry.ts
Supported question types
Registry source: src/question-type-registry.ts
| key | id | label | autoGradable | supportsPartialCredit | manualGradingRequired |
|---|---|---|---|---|---|
RADIO |
1 | Single answer | yes | no | no |
CHECKBOX |
2 | Multiple answers | yes | yes | no |
TEXTAREA |
3 | Paragraph | no | no | yes |
TRUE_FALSE |
4 | True/False | yes | no | no |
SHORT_ANSWER |
5 | Short answer | no | no | yes |
NUMERIC |
6 | Numeric answer | yes | yes | no |
FILL_BLANK |
7 | Fill in the blank | yes | yes | no |
FILE_UPLOAD |
8 | File upload | no | no | yes |
MATCHING |
9 | Matching | yes | yes | no |
ORDERING |
10 | Ordering | yes | yes | no |
HOTSPOT |
11 | Hotspot | yes | yes | no |
LINK |
12 | Links | no | no | yes |
Public API overview
1) Keys and metadata
QUESTION_TYPE_KEYQuestionTypeKeyQUESTION_TYPE_REGISTRYQUESTION_TYPE_IDSQUESTION_TYPE_BY_KEYQUESTION_TYPE_TYPENAME_TO_KEYQUESTION_TYPE_ID_TO_KEY
Lookup helpers:
getQuestionTypeByKey(key)getQuestionTypeByTypename(typename)getQuestionTypeById(id)getQuestionTypeId(key)
Capability helpers:
isAutoGradableQuestionType(key)supportsPartialCredit(key)requiresManualGrading(key)
2) Exercise rendering contracts
Core types (src/exercise-types.ts):
ExerciseQuestionModelExerciseQuestionOptionExerciseAnswerValueExerciseRendererMode(edit | take | preview | view)ExerciseRendererDefinition<TRenderer>ExerciseQuestionRendererProps
Render contracts (src/render-contract.ts):
ExerciseQuestionRenderContractExerciseQuestionListRenderContractExerciseQuestionImageUploadergetExerciseQuestionContractKey(question, fallbackIndex)
3) Renderer registry helpers (UI-agnostic)
From src/renderer-registry.ts:
ExerciseRendererRegistry<TRenderer>getRendererDefinition(registry, questionType, fallback)getRendererForMode(registry, questionType, mode, fallback)
Important behavior:
mode: 'view'resolves to'take'internally ingetRendererForMode.
4) Answer payload and serialization
Answer payload union (src/question-answer-payload.ts):
QuestionAnswerPayloadand per-type payload interfaces (RadioAnswerPayload,CheckboxAnswerPayload, etc.)
Serializer (src/answer-serializer.ts):
serializeExerciseAnswer(question, answer)serializeExerciseAnswerMap(questions, answersByKey)SerializedExerciseAnswer
5) Form state and scoring constants
Form state (src/form-state.ts):
ExerciseQuestionFormStatecreateExerciseQuestionFormState(initialQuestions)getQuestionStateKey(question, fallbackIndex)
Scoring constants (src/question-scoring-rules.ts):
QUESTION_SCORING_MODEATTEMPT_SCORING_RULESHOW_CORRECT_ANSWERS_POLICY
Deterministic contract guarantees
The following helpers are deterministic and should be treated as stable contracts:
getExerciseQuestionContractKeygetQuestionStateKeygetQuestionTypeById/getQuestionTypeIdgetRendererForModeserializeExerciseAnswer/serializeExerciseAnswerMap
If given the same inputs, they always return the same outputs.
Usage examples
Resolve question type from id
import { getQuestionTypeById } from '@cio/question-types';
const metadata = getQuestionTypeById(10);
// => { key: 'ORDERING', label: 'Ordering', ... }
Build a renderer registry in another package
import {
QUESTION_TYPE_KEY,
getRendererForMode,
type ExerciseRendererRegistry,
type ExerciseRendererDefinition
} from '@cio/question-types';
type Renderer = unknown;
const registry: ExerciseRendererRegistry<Renderer> = {
[QUESTION_TYPE_KEY.RADIO]: {
edit: 'RadioEditRenderer',
take: 'RadioTakeRenderer',
preview: 'RadioPreviewRenderer'
}
};
const fallback: ExerciseRendererDefinition<Renderer> = {
edit: 'FallbackEdit',
take: 'FallbackTake',
preview: 'FallbackPreview'
};
const renderer = getRendererForMode(registry, QUESTION_TYPE_KEY.RADIO, 'view', fallback);
// 'view' resolves to 'take'
Serialize answers for API submission
import { serializeExerciseAnswerMap } from '@cio/question-types';
const payload = serializeExerciseAnswerMap(questions, answersByKey);
// => Array<{ questionId, optionId?, answer?, payload? }>
Create question form state
import { createExerciseQuestionFormState } from '@cio/question-types';
const state = createExerciseQuestionFormState(initialQuestions);
Adding a new question type
See ADDING_A_QUESTION_TYPE.md for a step-by-step guide. At a high level:
Build
pnpm -C packages/question-types build
Notes for consumers
- Prefer importing keys/lookup helpers from this package instead of duplicating constants.
- Use
getExerciseQuestionContractKeyconsistently for stable answer maps. - Keep UI implementation in
@cio/ui; keep domain contracts in@cio/question-types.