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

Incorrect SQL snippet in qubaids_for_quiz constructor

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.7.19, 2.9.9, 3.0.9, 3.1.5, 3.2.2
    • Fix Version/s: 3.1.6, 3.2.3
    • Component/s: Quiz
    • Labels:
    • Testing Instructions:
      Hide

      To tester: For bonus points you can write a unit testcase for this fix and i'll integrate it (Dan)

      Testing difficulty: Hard(requires writing code to test)

      With a quiz that has completed attempts:

      Construct a query usings the qubaids_for_quiz object with $finishedonly set to true, below is an included snippet that led to finding this bug:

      $qubaids = new qubaids_for_quiz($quizid, false, true);
      $questionids = $DB->get_fieldset_select('question_attempts', 'questionid', 'questionusageid ' . $qubaids->usage_id_in(), $qubaids->usage_id_in_params());

       

      Without the patch it should exhibit a dml exception with the patch you should get a list of question ids.

      Show
      To tester: For bonus points you can write a unit testcase for this fix and i'll integrate it (Dan) Testing difficulty: Hard(requires writing code to test) With a quiz that has completed attempts: Construct a query usings the qubaids_for_quiz object with $finishedonly set to true, below is an included snippet that led to finding this bug: $qubaids = new qubaids_for_quiz($quizid, false, true); $questionids = $DB->get_fieldset_select('question_attempts', 'questionid', 'questionusageid ' . $qubaids->usage_id_in(), $qubaids->usage_id_in_params());   Without the patch it should exhibit a dml exception with the patch you should get a list of question ids.
    • Affected Branches:
      MOODLE_27_STABLE, MOODLE_29_STABLE, MOODLE_30_STABLE, MOODLE_31_STABLE, MOODLE_32_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE, MOODLE_32_STABLE
    • Pull Master Branch:

      Description

      When calling new qubaids_for_quiz(int, bool, true) it causes a dml exception when the constructed SQL query is used.

      This has probably never been picked up because core does not seem to call it with $onlyfinished set to true.

        Attachments

          Activity

            People

            Assignee:
            dcocco Darren Cocco
            Reporter:
            dcocco Darren Cocco
            Peer reviewer:
            Tim Hunt
            Integrator:
            Dan Poltawski
            Tester:
            Marina Glancy
            Participants:
            Component watchers:
            Tim Hunt, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              8/May/17