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

Question bank selection runs in memory limit as admin

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 5.0
    • 5.0
    • Questions
    • MOODLE_500_STABLE
    • MOODLE_500_STABLE
    • MDL-84900_main
    • Hide

      1. Create 10 courses, and add 2 question banks to each. Name the question banks like "Bank 1", "Bank 2", "Bank 3", so they all have a common word, and some unique parts. You should have 20 banks in total.
      2. On the first course, add a quiz.
      3. Go to the Questions tab, add a question and select "From question bank".
      4. In the modal, click on "Switch bank"

      • Confirm the "Switch bank" modal loads, displaying the 2 banks from the current course, and an "Other banks" autocomplete at the bottom.

      5. Expand the "Other banks" autocomplete.

      • Confirm it displays 20 banks, with "> 20 results, refine your search." as the last option.

      6. Select the "> 20 results" option.

      • Confirm the suggestions list closes, but the dialogue remains open.

      7. Enter "Bank" in the autocomplete.

      • Confirm a list of 20 banks is displayed again, plus the "> 20 results" message.

      8. Enter "Bank 1" in the autocomplete.

      • Confirm a list containing "Bank 1" and banks 10-19 are displayed, with no "> 20 results" message at the bottom.

      9. Enter "Bank 20" in the autocomplete.

      • Confirm that only "Bank 20" is displayed.

      10. Select "Bank 20"

      • Confirm that the modal switches back to the question bank, with the default category for "Bank 20" selected.
      Show
      1. Create 10 courses, and add 2 question banks to each. Name the question banks like "Bank 1", "Bank 2", "Bank 3", so they all have a common word, and some unique parts. You should have 20 banks in total. 2. On the first course, add a quiz. 3. Go to the Questions tab, add a question and select "From question bank". 4. In the modal, click on "Switch bank" Confirm the "Switch bank" modal loads, displaying the 2 banks from the current course, and an "Other banks" autocomplete at the bottom. 5. Expand the "Other banks" autocomplete. Confirm it displays 20 banks, with "> 20 results, refine your search." as the last option. 6. Select the "> 20 results" option. Confirm the suggestions list closes, but the dialogue remains open. 7. Enter "Bank" in the autocomplete. Confirm a list of 20 banks is displayed again, plus the "> 20 results" message. 8. Enter "Bank 1" in the autocomplete. Confirm a list containing "Bank 1" and banks 10-19 are displayed, with no "> 20 results" message at the bottom. 9. Enter "Bank 20" in the autocomplete. Confirm that only "Bank 20" is displayed. 10. Select "Bank 20" Confirm that the modal switches back to the question bank, with the default category for "Bank 20" selected.
    • Hide

      Code verified against automated checks with warnings.

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

      Should these errors be fixed?

      Built on: Tue Apr 1 12:41:23 UTC 2025

      Show
      Code verified against automated checks with warnings. Checked MDL-84900 using repository: https://github.com/marxjohnson/moodle.git main (0 errors / 1 warnings) [branch: MDL-84900_main | CI Job ] overview (0/0) , phplint (0/0) , phpcs (0/0) , js (0/1) , css (0/0) , phpdoc (0/0) , commit (0/0) , savepoint (0/0) , thirdparty (0/0) , externalbackup (0/0) , grunt (0/0) , shifter (0/0) , mustache (0/0) , gherkin (0/0) , Should these errors be fixed? Built on: Tue Apr 1 12:41:23 UTC 2025
    • Hide

      Launching automatic jobs for branch MDL-84900_main

      Built on: Sun Mar 30 05:33:58 UTC 2025

      Show
      Launching automatic jobs for branch MDL-84900 _main https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/18866/ PHPUnit (sqlsrv / complete) --> unrelated, please ignore. https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/64585/ Behat (NonJS - boost and classic / complete) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/64586/ Behat (Firefox - boost / complete) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/64587/ Behat (Firefox - classic / complete) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/64588/ App tests (stable app version) / complete) Built on: Sun Mar 30 05:33:58 UTC 2025

      Short description

      Question bank selection in quiz not shown for power users.

      Steps to reproduce

      As a "power user" e.g. admin or some course manager that has access to a course area with a lot of courses:

      1. Go to a quiz or create a new quiz
      2. Go to questions and add a new question from the question bank
      3. In the dialogue menu of the quiz question bank click "switch bank"

      Current output: the loading indicator is shown and then another dialogue window appears with the title "undefined".

      Technical background

      The problem is the consumption of memory in the filterlib.php

       

      foreach ($cmcontextids as $contextid) {
              // Copy course list.
              $FILTERLIB_PRIVATE->active[$contextid] = $courseactive;        // Are there any changes to the active list?
              if (array_key_exists($contextid, $remainingactives)) {
       

      This snippet is in lib/filterlib.php line 681ff (in Moodle 4.6)

      The out of memory occurs at the assignment in line 683.

      In our system we usually have a memory limit set to 128MB. We have about 8000 question banks. In my test run as an admin this code snippet is executed about 500 times.

      Increasing the memory to 1GB just extends the runtime and the snippet is executed about 2.5k still at the end there is an error (I didn't check if its the memory limit or max run time).

      Suggestion

      if there are too many question banks to be loaded, show the first 10 only with an option to search for a name of a bank, and load the filters for the displayed question banks only.

            marxjohnson Mark Johnson
            strobotta Stephan Robotta
            Stephan Robotta Stephan Robotta
            Tim Hunt Tim Hunt
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            3 Vote for this issue
            Watchers:
            12 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, 25 minutes
                1h 25m

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