Repository navigation
[QTI] Restoring a published channel loses the questions of its units #6261
Description
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
restore_channel recreates assessment items only for exercise nodes. A unit (a topic with UNIT modality) publishes its questions as a QTI package, so a restored unit has no questions and is no longer a unit.
Complexity: Medium
Target branch: unstable
Context
- Publish treats a
UNITtopic with assessment items as having assessments and writes its QTI package:studio/contentcuration/contentcuration/utils/publish.py
Lines 277 to 290 in f65cb93
def has_assessments(node): """Check if a node should have its assessment items published. Returns True for EXERCISE nodes and TOPIC nodes with UNIT modality that have assessment items. """ if node.kind_id == content_kinds.EXERCISE: return True if node.kind_id == content_kinds.TOPIC: options = node.extra_fields.get("options", {}) if node.extra_fields else {} if options.get("modality") == modalities.UNIT: # Only return True if the UNIT has assessment items return node.assessment_items.filter(deleted=False).exists() return False - Restore calls
create_assessment_itemsonly forcontent_kinds.EXERCISE:studio/contentcuration/contentcuration/utils/import_tools.py
Lines 284 to 292 in f65cb93
if kind == content_kinds.TOPIC: create_nodes( cursor, target_id, node, indent=indent + 1, download_url=download_url ) elif kind == content_kinds.EXERCISE: create_assessment_items( cursor, node, indent=indent + 1, download_url=download_url ) create_files(cursor, node, indent=indent + 1, download_url=download_url) - On
f65cb9388, a published unit with one QTI item, restored withimport_channel: zero assessment items,extra_fieldsis{}, and the node keeps the publishedqti_zipfile.
The Change
- Restore should recreate a unit's questions from its QTI package and keep it a unit.
How to Get There
- Publish a channel holding a unit with at least one question.
- Run
manage.py restore_channel <channel_id> --download-url <studio url>. - Open the restored unit in the editor.
Acceptance Criteria
- A restored unit has the same questions, in the same order, as the published unit.
- A restored unit has
UNITmodality and its completion criteria. - Republishing the restored channel publishes the unit's QTI package built from the restored questions.
-
import_toolstests cover restoring a unit.
AI usage
Claude Code found this during an automated self-review of the #6211 branch, reproduced it by publishing and restoring a channel in a scratch test, and drafted this issue.

Activity