Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-78025

quiz_questions_in_use logic is wrong

    XMLWordPrintable

Details

    Description

      The logic in quiz_questions_in_use is wrong.

      Quizzes can use questions in two ways:

      1. Because that question appears in a quiz attempt. That bit of the logic, computed via question_engine::questions_in_use, is right.
      2. 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:

      1. Some of the unit tests were asserting the wrong delete behaviour for unused versions. I fixed that.
      2. 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.
      3. I fixed some surprising behaviour in core_question_generator, which confused me while working on this.
      4. I fixed the poor PHPdoc comment on question_require_capability_on.

      Attachments

        Issue Links

          Activity

            People

              timhunt Tim Hunt
              timhunt Tim Hunt
              Mark Johnson Mark Johnson
              Ilya Tregubov Ilya Tregubov
              CiBoT CiBoT
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 6 hours
                  6h

                  Clockify

                    Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.