Skip to content

feat: land ricecooker assessment items as QTI#6032

Open
rtibblesbot wants to merge 1 commit into
learningequality:unstablefrom
rtibblesbot:issue-6002-6c5913
Open

feat: land ricecooker assessment items as QTI#6032
rtibblesbot wants to merge 1 commit into
learningequality:unstablefrom
rtibblesbot:issue-6002-6c5913

Conversation

@rtibblesbot

@rtibblesbot rtibblesbot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Ricecooker's internal ingest endpoint built AssessmentItems directly and validated only assessment_id uniqueness, so malformed QTI, unconverted legacy question types, and Perseus content wrapped for republishing could all land in Studio unchecked. create_exercises now delegates item construction and schema validation to AssessmentItemSerializer: native QTI is validated and persisted as-is, legacy/structured questions are converted to schema-valid QTI on ingest, raw Perseus passes through unchanged, and a Perseus custom interaction is unwrapped back into a raw perseus_question by reading its declared payload file. Referenced media is mapped for every resulting item.

References

Fixes #6002.

Reviewer guidance

  • views/internal.py:987-996set_files() auto-creates a stray File row per QTI media reference during serializer.save(); the watermark-then-delete cleanup removes it before the real attach. Check this can't race a concurrent upload from the same user landing in the same window.
  • views/internal.py:972-976 — DRF's ValidationError is caught and re-raised as NodeValidationError; confirm the wrapped message (e.detail) still gives ricecooker callers an actionable error rather than a generic DRF error dict.
  • viewsets/assessmentitem.py:147 — widened the raw_data validation to also accept PERSEUS_QUESTION, not just QTI. Confirm this can't be used to smuggle raw_data edits into a PERSEUS_QUESTION item through the browser-editor sync API in a way that wasn't intended.

AI usage

Used Claude Code to implement the refactor from an existing task plan and write the accompanying tests. Verified with the full affected test suite and the repo's pre-commit hooks.


@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?
  • Ran pre-flight CI checks (lint, format, tests) and verified all pass
  • Rebased onto the target branch and resolved any conflicts
  • Reorganized commit history into clean, logical commits
  • Audited the diff to ensure only issue-relevant files are changed
  • Built PR body from the repository's PR template with evidence blocks
@rtibblesbot

🟡 Waiting for feedback

Last updated: 2026-07-05 05:21 UTC

Refactor create_exercises to delegate item construction and schema
validation to AssessmentItemSerializer instead of duplicating that
logic. Native QTI (editor-shaped or arbitrary) is persisted and
schema-validated directly; legacy/structured questions are converted
to QTI on ingest; raw Perseus passes through unchanged; a Perseus
custom interaction is unwrapped back to its raw perseus_question by
reading its data-perseus-path payload. Referenced media is mapped via
the existing map_files_to_assessment_item helper.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@rtibblesbot rtibblesbot marked this pull request as ready for review July 5, 2026 05:21
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.

[QTI] Accept QTI items through the internal API for ricecooker import

1 participant