Skip to content

[QTI] A QTI item with a comment quoting its root tag is published without the node's language #6235

Description

@rtibblesbot

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Target branch: unstable

Observed behavior

  • set_qti_item_language (utils/assessment/qti/media.py) rewrites the first <qti-assessment-item …> match in the raw text.
  • A comment before the root that quotes that tag takes the match.
  • xml:lang is written inside the comment; the real root keeps its own language.
  • The item passes validate_qti_item.

Steps to reproduce

  1. Insert <!-- <qti-assessment-item foo="1"> --> before the root of VALID_CHOICE_ITEM (tests/utils/qti/test_validation.py).
  2. Call set_qti_item_language(xml, "fr").
  3. The real root still has xml:lang="en-US".

Acceptance Criteria

  • set_qti_item_language sets the language on the real root regardless of comments before it.
  • A test covers a comment quoting the root start tag.

Activity

  1. added theissue type on Sep 30, 2026
  2. self-assigned this
    on Sep 30, 2026
  3. rtibblesbot commented on Sep 30, 2026

    @rtibblesbot
    ContributorAuthor

    Plan: set_qti_item_language stamps xml:lang on the real <qti-assessment-item> root even when a comment (or other prolog markup) quotes that start tag before it.

    • Match the root start tag after the prolog
    • /simplify pass

    Assumptions — the issue did not settle these; say so if one is wrong.

    • PIs and DOCTYPE are skipped as well as comments; if unwanted, the pattern is wider than the issue asks but no test breaks.
    • A > inside a root attribute value still ends the tag match early ([^>]*); not in scope, and serializers escape it as &gt;. If items carry a raw >, xml:lang lands mid-value.
    • No match after the prolog returns raw_data unchanged, as today; if a caller expects an error, it needs a separate change.

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

    How was this generated?
    • Implemented code following the pre-approved plan using test-driven development (red-green-refactor)
    • Ran the project's full test suite and linter before committing
    • For UI changes: captured live screenshots to verify rendering
    • For backend changes: verified with example API/CLI output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions