| Línea 24... |
Línea 24... |
| 24 |
|
24 |
|
| 25 |
use external_function_parameters;
|
25 |
use external_function_parameters;
|
| 26 |
use external_single_structure;
|
26 |
use external_single_structure;
|
| 27 |
use external_value;
|
27 |
use external_value;
|
| - |
|
28 |
use external_api;
|
| 28 |
use external_api;
|
29 |
use core_question\category_manager;
|
| 29 |
use mod_quiz\question\bank\filter\custom_category_condition;
|
30 |
use mod_quiz\question\bank\filter\custom_category_condition;
|
| 30 |
use mod_quiz\quiz_settings;
|
31 |
use mod_quiz\quiz_settings;
|
| Línea 31... |
Línea 32... |
| 31 |
use mod_quiz\structure;
|
32 |
use mod_quiz\structure;
|
| Línea 117... |
Línea 118... |
| 117 |
// If filtercondition is not empty, decode it. Otherwise, set it to empty array.
|
118 |
// If filtercondition is not empty, decode it. Otherwise, set it to empty array.
|
| 118 |
$filtercondition = !empty($filtercondition) ? json_decode($filtercondition, true) : [];
|
119 |
$filtercondition = !empty($filtercondition) ? json_decode($filtercondition, true) : [];
|
| Línea 119... |
Línea 120... |
| 119 |
|
120 |
|
| 120 |
// Create new category.
|
121 |
// Create new category.
|
| 121 |
if (!empty($newcategory)) {
|
- |
|
| 122 |
$contexts = new \core_question\local\bank\question_edit_contexts($thiscontext);
|
- |
|
| 123 |
$defaultcategoryobj = question_make_default_categories($contexts->all());
|
- |
|
| 124 |
$defaultcategory = $defaultcategoryobj->id . ',' . $defaultcategoryobj->contextid;
|
- |
|
| 125 |
$qcobject = new \qbank_managecategories\question_category_object(
|
- |
|
| 126 |
null,
|
- |
|
| 127 |
new \moodle_url('/'),
|
122 |
if (!empty($newcategory)) {
|
| 128 |
$contexts->having_one_edit_tab_cap('categories'),
|
- |
|
| 129 |
$defaultcategoryobj->id,
|
- |
|
| 130 |
$defaultcategory,
|
- |
|
| 131 |
null,
|
- |
|
| 132 |
$contexts->having_cap('moodle/question:add'));
|
123 |
$categorymanager = new category_manager();
|
| 133 |
$categoryid = $qcobject->add_category($parentcategory, $newcategory, '', true);
|
124 |
$categoryid = $categorymanager->add_category($parentcategory, $newcategory, '');
|
| 134 |
$filter = [
|
125 |
$filter = [
|
| 135 |
'category' => [
|
126 |
'category' => [
|
| 136 |
'jointype' => custom_category_condition::JOINTYPE_DEFAULT,
|
127 |
'jointype' => custom_category_condition::JOINTYPE_DEFAULT,
|
| 137 |
'values' => [$categoryid],
|
128 |
'values' => [$categoryid],
|