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

transfer_question_categories task deletes all questions where there are no question usages in a category.

XMLWordPrintable

    • MOODLE_500_STABLE
    • MOODLE_500_STABLE
    • MDL-83977_main
    • Hide
      1. Install Moodle 4.5.
      2. Create 2 courses, "Usage course" and "No usage course"
      3. In each course, go to the Question bank and create 2 questions.
      4. On "Usage course", create a quiz, and add one of the questions from the question bank to the quiz.
      5. Upgrade to Moodle 5.0 with the patch applied.
      6. Run the mod_qbank\task\transfer_question_categories ad-hoc task (directly, or via the cron.
      7. Go to "Usage course" and navigate to "More > Question banks" then "Usage course shared question bank".
      8. Confirm that the two questions for this course were successfully migrated.
      9. Go to "No usage course" and navigate to "More > Question banks" then "No usage course shared question bank".
      10. Confirm that the two questions for this course were successfully migrated.
      Show
      Install Moodle 4.5. Create 2 courses, "Usage course" and "No usage course" In each course, go to the Question bank and create 2 questions. On "Usage course", create a quiz, and add one of the questions from the question bank to the quiz. Upgrade to Moodle 5.0 with the patch applied. Run the mod_qbank\task\transfer_question_categories ad-hoc task (directly, or via the cron. Go to "Usage course" and navigate to "More > Question banks" then "Usage course shared question bank". Confirm that the two questions for this course were successfully migrated. Go to "No usage course" and navigate to "More > Question banks" then "No usage course shared question bank". Confirm that the two questions for this course were successfully migrated.
    • Hide

      Code verified against automated checks.

      Checked MDL-83977 using repository: https://github.com/marxjohnson/moodle.git

      More information about this report

      Built on: Mon Dec 16 08:26:12 AM UTC 2024

      Show
      Code verified against automated checks. Checked MDL-83977 using repository: https://github.com/marxjohnson/moodle.git main (0 errors / 0 warnings) [branch: MDL-83977_main | CI Job ] More information about this report Built on: Mon Dec 16 08:26:12 AM UTC 2024
    • Show
      Launching automatic jobs for branch MDL-83977 _main https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/17709/ PHPUnit (sqlsrv) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/60309/ Behat (NonJS - boost and classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/60310/ Behat (Firefox - boost) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/60311/ Behat (Firefox - classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/60312/ App tests (stable app version) Built on: Wed Dec 11 16:25:42 UTC 2024

      Steps to reproduce:

      1. Install Moodle 4.5.
      2. Create 2 courses, "Usage course" and "No usage course"
      3. In each course, go to the Question bank and create 2 questions.
      4. On "Usage course", create a quiz, and add one of the questions from the question bank to the quiz.
      5. Upgrade to Moodle 5.0.
      6. Run the mod_qbank\task\transfer_question_categories ad-hoc task (directly, or via the cron.
      7. Go to "Usage course" and navigate to "More > Question banks" then "Usage course shared question bank".
        • Confirm that the two questions for this course were successfully migrated.
      8. Go to "No usage course" and navigate to "More > Question banks" then "No usage course shared question bank".
        • Expected: The two questions for this course were successfully migrated.
        • Actual: The two questions for this course have been deleted.

      It seems the following code in the ad-hoc task is responsible for these deletions:

      $subcategories = array_reverse(\sort_categories_by_tree($subcategories, $oldtopcategory->id));
      foreach ($subcategories as $subcategory) {
           \qbank_managecategories\helper::question_remove_stale_questions_from_category($subcategory->id);
           if (!question_category_in_use($subcategory->id)) {
               question_category_delete_safe($subcategory);
           }
      }
      

            marxjohnson Mark Johnson
            marxjohnson Mark Johnson
            Mark Webster Mark Webster
            Mihail Geshoski Mihail Geshoski
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour
                1h

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