Repository navigation
Exercise: Export exact combination questions to QTI2 - refs #2263 - #9482
Merged
christianbeeznest merged 1 commit intoNov 17, 2026
Merged
christianbeeznest merged 1 commit into
christianbeeznest merged 1 commit into
Conversation
This was referenced Nov 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2263
What
Exact combination questions (type 9) were left out of the QTI 2 export. Both exporters now include them, and both importers read them back as Exact combination.
Export (legacy
export_question_qti()andExerciseQti2ExportService). Both use the new sharedQti2ExactCombinationWriter:choiceInteractionwithmaxChoices="0", so any number of choices can be ticked (the QTI default is 1);responseDeclarationwithcardinality="multiple"and acorrectResponseholding the correct choices. There is no<mapping>, so no partial credit;responseProcessingthat setsSCOREto the question score when<match>compares the response with the correct response, and 0 otherwise.matchcompares multiple containers as sets, so this is all or nothing, as inExercise::manage_answer(). The SCORM exporter uses the same logic;Import (legacy
exercise_import.inc.phpandExerciseQti2ImportService):responseProcessingis that exact-match condition settingSCORE.Type 12 (Exact combination True/False/Don't know) is not exported. In QTI it would need a statement × True/False/Don't know
matchInteraction. Those three options are interface strings, not stored data, and both importers read anymatchInteractionas Matching (scored per pair). So it would not come back as type 12 without inventing an identifier convention. Type 12 extends the Exact combination class, so the legacy exporter now checks type 9 by its number, not by class, to keep type 12 out.Tests
tests/CoreBundle/Service/Exercise/ExerciseQti2ExactCombinationTest.php: 8 tests, 86 assertions.maxChoices="0", multiple cardinality, the correct response holds only the correct choices, no mapping, and the score and 0 branches.ImsAssessmentItemexport: the same XML checks, plus the round trip through both importers.<script>and]]>still gives well-formed XML.map_responsetemplate is still imported as Multiple answer.readScore(): it only accepts the exact-match processing, and a negative score is read as 0.The existing QTI tests still pass:
ExerciseQti2FillBlanksExportTest,ExerciseQti2ImportServiceTestandLegacyQti2ImportMatchingTest, 36 tests across the QTI filter.ExerciseAccessControlTestpasses too (14).Linters:
php -lis clean on the legacy files.Security (OWASP)
readScore()only walks the DOM that is already parsed.formatExerciseQtiText()/CDATA path on export, and through the same HTML sanitising as Multiple answer on import.htmlspecialchars(ENT_QUOTES | ENT_SUBSTITUTE | ENT_XML1). The identifiers are built from integer ids.Notes for review
maxChoices, so strict QTI players may limit it to one choice. I didn't change it here, to keep this PR to type 9.correctResponseand scores 0. In Chamilo, ticking nothing would get the full score. This is an edge case I left as it is.answer_1) and the API exporter by answer iid. This was already the case for the other choice types.match_correcttemplate are not mapped to Exact combination. Only the processing written by this exporter is recognised.Release note
QTI 2 export now includes Exact combination questions, scored all or nothing, and importing that export brings them back as Exact combination questions.