MDL-78025 questions: questions_in_use should check question_references

This avoids the needs for plugins to do separate queries, which is
easier for them, and better performing.
This commit is contained in:
Tim Hunt
2023-04-26 15:29:38 +01:00
parent 9775be13e9
commit 25596a50e5
3 changed files with 205 additions and 0 deletions
+5
View File
@@ -29,6 +29,7 @@
*/
use core_question\local\bank\question_version_status;
use core_question\question_reference_manager;
defined('MOODLE_INTERNAL') || die();
@@ -123,6 +124,10 @@ function questions_in_use($questionids): bool {
return true;
}
if (question_reference_manager::questions_with_references($questionids)) {
return true;
}
// Check if any plugins are using these questions.
$callbacksbytype = get_plugins_with_function('questions_in_use');
foreach ($callbacksbytype as $callbacks) {