-
Bug
-
Resolution: Fixed
-
Major
-
4.0.3, 4.0.6, 4.1.1, 4.1.2
-
MOODLE_400_STABLE, MOODLE_401_STABLE
-
MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE
-
MDL-75576_401 -
-
When the question bank is displayed, there is a loop over the questions (rows) in the display.
For each row, there is a loop over the columns. Typically three colums display stats-related data.
So, for each question x 3, we call calculate_average_question_stats_item. This:
- does a DB query to find in which (component, contextid) combinations the question is used it.
- Loops over that, and for each combinations, calls the calls a callaback in the component to load the entire blob of statistics (e.g. the stats for all questions in all attempts at a particular quiz) out of that we pick the one statistic for the one question we are interested in using in our average.
This code is clearly a long way from optimal.
To fix this, I have done the following:
- (Cleaned up some incorrect PHPdoc comments.)
- There is now a new mechanism where
- Question bank columns can declare which statistics they need.
- core_question\local\bank\view then loads all the statistics required by all columns in one go.
- and there is a method to then access those bulk-loaded values.
- Also, I have changed the policy, we no longer try to compute statistics on-the-fly when a user tries to view the question bank. Now, we only show satistics if quiz_statistics\task\recalculate (or another equivalent task) has already computed them.
- Related to this, an old task, deleting statistics data was removed. Instead, now, before computing new data, we delete the previous data with the same settings.
- Also, previously computed statistics were previously only used for up to 15 minutes, then ignored. That is no longer the case.
- Some of the old code has been deprecated, master-only.
- caused a regression
-
MDL-78488 Question bank statistics still being pulled/loaded when associated columns disabled
- Closed
-
MDL-78327 Random PHPUnit failures related to question statistics after MDL-75576
- Closed
-
MDL-78580 Add locking to quiz statistics calculation to prevent database deadlocks
- Closed
-
MDL-78588 Question bank statistics: computing something, when it should only be using cached values
- Closed
-
MDL-78608 Question bank must be robust if question_usages are not cleaned up when a context is deleted
- Closed
- Discovered while testing
-
MDL-74762 Statistics in the Moodle 4.0 question bank use many DB queries causing performance problems
- Closed
- has a non-specific relationship to
-
MDL-78336 'Needs checking?', 'Facility index' and 'Discriminative efficiency' columns are still showing no data
- Closed
- has been marked as being related by
-
MDL-77080 Exceptions when running Recalculate question statistics scheduled task
- Closed
-
MDL-77094 Quiz statistics scheduled task: fix more obvious inefficiencies
- Closed
-
MDL-78090 Moodle 5.0 core_question final deprecations
- Open
-
MDL-78091 Moodle 5.0 quiz final deprecations
- Open
- is a regression caused by
-
MDL-74762 Statistics in the Moodle 4.0 question bank use many DB queries causing performance problems
- Closed
- is duplicated by
-
MDL-77836 Duplicated records with question bank statistics
- Open
-
MDL-76832 Timeout when toggling between question bank categories
- Closed
-
MDL-77867 question_stats_cleanup_task fails with "number of parameters must be between 0 and 65535"
- Closed