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

Question bank sub-category fetching does not handle bad data

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 4.2.6, 4.3.3
    • 4.2.2
    • Questions

      After restore course with many top question categories gets {question_categories}.parent = some number which can be and from other course.

      It will not make big deal but in questionlib.php 

      $subcategories = $DB->get_records_select_menu('question_categories', "parent $in", $params,
                                                          null, 'id,id AS id2');

      when collecting questions from sub categories it not use contextid and if in other course question bank category.parent are same id as selecting it will take this category too. This problem are not only in question bank view, but exist in quiz preview/attempt.

       

      DB select to get all categories which parent and contextid are not same.

      SELECT *
      FROM {question_categories} c1
      WHERE EXISTS (
          SELECT 1
          FROM {question_categories} c2
          WHERE c2.id = c1.parent
          AND c2.contextid <> c1.contextid
      )

      Quick and boring fix are go to course question bank and move category to other level.

       

      Couldn't reproduce on test system, but teacher some how made parent duplicates to other courses. It could be restore problem when setting wrong parent in question top categories, but select question sub categories can have contexid too.

            timhunt Tim Hunt
            slq Tomas
            Luca Bösch Luca Bösch
            Ilya Tregubov Ilya Tregubov
            CiBoT CiBoT
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 15 minutes
                3h 15m

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