-
Bug
-
Resolution: Fixed
-
Critical
-
4.0.8, 4.1.3, 4.2
-
MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE
-
MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE
-
MDL-78025_401 -
The logic in quiz_questions_in_use is wrong.
Quizzes can use questions in two ways:
- Because that question appears in a quiz attempt. That bit of the logic, computed via question_engine::questions_in_use, is right.
- Because a quiz_slot refers to the question, via question_references. This bit is wrong.
The reference is relevant if:
- The reference is to a specific question_version, and the questionid is that exact version.
- The reference is to 'always latest' and the questionid is the latest non-draft version of that question.
In fact, this logic should not be in the quiz callback at all. Instead, question_references should be handled in core questionlib.php.
While working on this, I found some other issues in the code:
- Some of the unit tests were asserting the wrong delete behaviour for unused versions. I fixed that.
- The logic about hiding versions, rather than deleting them, if they are in use, was split between the delete script and the back-end function. I consolidated all that logic in the question_delete_question API function.
- I fixed some surprising behaviour in core_question_generator, which confused me while working on this.
- I fixed the poor PHPdoc comment on question_require_capability_on.
- blocks
-
MDL-76757 Cannot easily delete all versions of a question
- Closed