From 2419bd64de0c1e07dbb2f476efff0776473d321b Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Mon, 29 Jul 2024 15:33:29 +0100 Subject: [PATCH] MDL-72397 mod_quiz: Replace call to qbank plugin When qbank plugins were first introduced, the method to add a question category was put inside qbank_managecategories. This created an invalid call between the mod_quiz and qbank_managecategories plugins. Now that this method has been moved to the core_question namespace, we can update mod_quiz to call the method there instead. --- .../classes/external/add_random_questions.php | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/mod/quiz/classes/external/add_random_questions.php b/mod/quiz/classes/external/add_random_questions.php index c6a5534211f..9f92f6d5e22 100644 --- a/mod/quiz/classes/external/add_random_questions.php +++ b/mod/quiz/classes/external/add_random_questions.php @@ -26,6 +26,7 @@ use external_function_parameters; use external_single_structure; use external_value; use external_api; +use core_question\category_manager; use mod_quiz\question\bank\filter\custom_category_condition; use mod_quiz\quiz_settings; use mod_quiz\structure; @@ -119,18 +120,8 @@ class add_random_questions extends external_api { // Create new category. if (!empty($newcategory)) { - $contexts = new \core_question\local\bank\question_edit_contexts($thiscontext); - $defaultcategoryobj = question_make_default_categories($contexts->all()); - $defaultcategory = $defaultcategoryobj->id . ',' . $defaultcategoryobj->contextid; - $qcobject = new \qbank_managecategories\question_category_object( - null, - new \moodle_url('/'), - $contexts->having_one_edit_tab_cap('categories'), - $defaultcategoryobj->id, - $defaultcategory, - null, - $contexts->having_cap('moodle/question:add')); - $categoryid = $qcobject->add_category($parentcategory, $newcategory, '', true); + $categorymanager = new category_manager(); + $categoryid = $categorymanager->add_category($parentcategory, $newcategory, ''); $filter = [ 'category' => [ 'jointype' => custom_category_condition::JOINTYPE_DEFAULT,