Línea 16... |
Línea 16... |
16 |
|
16 |
|
Línea 17... |
Línea 17... |
17 |
namespace qbank_managecategories;
|
17 |
namespace qbank_managecategories;
|
18 |
|
18 |
|
- |
|
19 |
/**
|
- |
|
20 |
* QUESTION_PAGE_LENGTH - Number of categories to display on page.
|
- |
|
21 |
*
|
19 |
/**
|
22 |
* @deprecated Since Moodle 4.5 MDL-72397. This was only used in moodle_list::display_page_numbers which is now deprecated.
|
20 |
* QUESTION_PAGE_LENGTH - Number of categories to display on page.
|
23 |
* @todo Final removal in Moodle 6.0 MDL-80804.
|
Línea 21... |
Línea 24... |
21 |
*/
|
24 |
*/
|
22 |
define('QUESTION_PAGE_LENGTH', 25);
|
25 |
define('QUESTION_PAGE_LENGTH', 25);
|
Línea 32... |
Línea 35... |
32 |
* Class for performing operations on question categories.
|
35 |
* Class for performing operations on question categories.
|
33 |
*
|
36 |
*
|
34 |
* @package qbank_managecategories
|
37 |
* @package qbank_managecategories
|
35 |
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
38 |
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
36 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
39 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
- |
|
40 |
* @deprecated Since Moodle 4.5 MDL-72397. Use \core_question\category_manager or \qbank_managecategories\question_categories.
|
- |
|
41 |
* @todo Final removal in Moodle 6.0 MDL-80804
|
37 |
*/
|
42 |
*/
|
38 |
class question_category_object {
|
43 |
class question_category_object {
|
Línea 39... |
Línea 44... |
39 |
|
44 |
|
40 |
/**
|
45 |
/**
|
Línea 75... |
Línea 80... |
75 |
* @param context[] $contexts contexts where the current user can edit categories.
|
80 |
* @param context[] $contexts contexts where the current user can edit categories.
|
76 |
* @param int $currentcat id of the category to be edited. 0 if none.
|
81 |
* @param int $currentcat id of the category to be edited. 0 if none.
|
77 |
* @param int|null $defaultcategory id of the current category. null if none.
|
82 |
* @param int|null $defaultcategory id of the current category. null if none.
|
78 |
* @param int $todelete id of the category to delete. 0 if none.
|
83 |
* @param int $todelete id of the category to delete. 0 if none.
|
79 |
* @param context[] $addcontexts contexts where the current user can add questions.
|
84 |
* @param context[] $addcontexts contexts where the current user can add questions.
|
- |
|
85 |
* @deprecated Since Moodle 4.5 MDL-72397. Use \qbank_managecategories\question_categories or \core_question\category_manager.
|
- |
|
86 |
* @todo Final removal in Moodle 6.0 MDL-80804
|
80 |
*/
|
87 |
*/
|
- |
|
88 |
#[\core\attribute\deprecated(
|
- |
|
89 |
'\qbank_managecategories\question_categories or \core_question\category_manager',
|
- |
|
90 |
since: 4.5,
|
- |
|
91 |
reason: 'API properly divided between qbank_managecategories and core_question',
|
- |
|
92 |
mdl: 'MDL-72397',
|
- |
|
93 |
)]
|
81 |
public function __construct($page, $pageurl, $contexts, $currentcat, $defaultcategory, $todelete, $addcontexts) {
|
94 |
public function __construct($page, $pageurl, $contexts, $currentcat, $defaultcategory, $todelete, $addcontexts) {
|
82 |
|
- |
|
- |
|
95 |
\core\deprecation::emit_deprecation([$this, __FUNCTION__]);
|
83 |
$this->tab = str_repeat(' ', $this->tabsize);
|
96 |
$this->tab = str_repeat(' ', $this->tabsize);
|
Línea 84... |
Línea 97... |
84 |
|
97 |
|
85 |
$this->str = new stdClass();
|
98 |
$this->str = new stdClass();
|
86 |
$this->str->course = get_string('course');
|
99 |
$this->str->course = get_string('course');
|
Línea 103... |
Línea 116... |
103 |
$this->str->cancel = get_string('cancel');
|
116 |
$this->str->cancel = get_string('cancel');
|
104 |
$this->str->editcategories = get_string('editcategories', 'question');
|
117 |
$this->str->editcategories = get_string('editcategories', 'question');
|
105 |
$this->str->page = get_string('page');
|
118 |
$this->str->page = get_string('page');
|
Línea 106... |
Línea 119... |
106 |
|
119 |
|
107 |
$this->pageurl = $pageurl;
|
- |
|
108 |
|
- |
|
109 |
$this->initialize($page, $contexts, $currentcat, $defaultcategory, $todelete, $addcontexts);
|
120 |
$this->pageurl = $pageurl;
|
Línea 110... |
Línea 121... |
110 |
}
|
121 |
}
|
111 |
|
122 |
|
112 |
/**
|
123 |
/**
|
Línea 116... |
Línea 127... |
116 |
* @param context[] $contexts contexts where the current user can edit categories.
|
127 |
* @param context[] $contexts contexts where the current user can edit categories.
|
117 |
* @param int $currentcat id of the category to be edited. 0 if none.
|
128 |
* @param int $currentcat id of the category to be edited. 0 if none.
|
118 |
* @param int|null $defaultcategory id of the current category. null if none.
|
129 |
* @param int|null $defaultcategory id of the current category. null if none.
|
119 |
* @param int $todelete id of the category to delete. 0 if none.
|
130 |
* @param int $todelete id of the category to delete. 0 if none.
|
120 |
* @param context[] $addcontexts contexts where the current user can add questions.
|
131 |
* @param context[] $addcontexts contexts where the current user can add questions.
|
- |
|
132 |
* @deprecated Since Moodle 4.5 MDL-72397. Use \qbank_managecategories\question_categories instead.
|
- |
|
133 |
* @todo Final removal in Moodle 6.0 MDL-80804
|
121 |
*/
|
134 |
*/
|
- |
|
135 |
#[\core\attribute\deprecated(
|
- |
|
136 |
'\qbank_managecategories\question_categories',
|
- |
|
137 |
since: 4.5,
|
- |
|
138 |
reason: 'API properly divided between qbank_managecategories and core_question',
|
- |
|
139 |
mdl: 'MDL-72397',
|
- |
|
140 |
)]
|
122 |
public function initialize($page, $contexts, $currentcat, $defaultcategory, $todelete, $addcontexts): void {
|
141 |
public function initialize($page, $contexts, $currentcat, $defaultcategory, $todelete, $addcontexts): void {
|
- |
|
142 |
\core\deprecation::emit_deprecation([$this, __FUNCTION__]);
|
123 |
$lastlist = null;
|
143 |
$lastlist = null;
|
124 |
foreach ($contexts as $context) {
|
144 |
foreach ($contexts as $context) {
|
125 |
$this->editlists[$context->id] =
|
145 |
$this->editlists[$context->id] =
|
126 |
new question_category_list('ul', '', true, $this->pageurl, $page, 'cpage', QUESTION_PAGE_LENGTH, $context);
|
146 |
new question_category_list('ul', '', true, $this->pageurl, $page, 'cpage', QUESTION_PAGE_LENGTH, $context);
|
127 |
$this->editlists[$context->id]->lastlist =& $lastlist;
|
147 |
$this->editlists[$context->id]->lastlist =& $lastlist;
|
Línea 144... |
Línea 164... |
144 |
}
|
164 |
}
|
Línea 145... |
Línea 165... |
145 |
|
165 |
|
146 |
/**
|
166 |
/**
|
147 |
* Displays the user interface.
|
167 |
* Displays the user interface.
|
- |
|
168 |
*
|
- |
|
169 |
* @deprecated Since Moodle 4.5 MDL-72397. No longer used.
|
148 |
*
|
170 |
* @todo Final removal in Moodle 6.0 MDL-80804
|
- |
|
171 |
*/
|
- |
|
172 |
#[\core\attribute\deprecated(
|
- |
|
173 |
'\core_question\category_manager::get_real_question_ids_in_category',
|
- |
|
174 |
since: 4.5,
|
- |
|
175 |
reason: 'No longer used',
|
- |
|
176 |
mdl: 'MDL-72397',
|
149 |
*/
|
177 |
)]
|
- |
|
178 |
public function display_user_interface(): void {
|
150 |
public function display_user_interface(): void {
|
179 |
\core\deprecation::emit_deprecation([$this, __FUNCTION__]);
|
151 |
// Interface for editing existing categories.
|
180 |
// Interface for editing existing categories.
|
152 |
$this->output_edit_lists();
|
181 |
$this->output_edit_lists();
|
Línea 153... |
Línea 182... |
153 |
}
|
182 |
}
|
154 |
|
183 |
|
- |
|
184 |
/**
|
- |
|
185 |
* Outputs a table to allow entry of a new category
|
- |
|
186 |
*
|
155 |
/**
|
187 |
* @deprecated Since Moodle 4.5 MDL-72397. No longer used.
|
- |
|
188 |
* @todo Final removal in Moodle 6.0 MDL-80804
|
- |
|
189 |
*/
|
- |
|
190 |
#[\core\attribute\deprecated(
|
- |
|
191 |
'\core_question\category_manager::get_real_question_ids_in_category',
|
- |
|
192 |
since: 4.5,
|
- |
|
193 |
reason: 'No longer used',
|
156 |
* Outputs a table to allow entry of a new category
|
194 |
mdl: 'MDL-72397',
|
- |
|
195 |
)]
|
157 |
*/
|
196 |
public function output_new_table(): void {
|
158 |
public function output_new_table(): void {
|
197 |
\core\deprecation::emit_deprecation([$this, __FUNCTION__]);
|
Línea 159... |
Línea 198... |
159 |
$this->catform->display();
|
198 |
$this->catform->display();
|
160 |
}
|
199 |
}
|
161 |
|
200 |
|
162 |
/**
|
201 |
/**
|
163 |
* Outputs a list to allow editing/rearranging of existing categories.
|
202 |
* Outputs a list to allow editing/rearranging of existing categories.
|
- |
|
203 |
*
|
- |
|
204 |
* $this->initialize() must have already been called
|
164 |
*
|
205 |
*
|
- |
|
206 |
* @deprecated Since Moodle 4.5 MDL-72397. No longer used.
|
- |
|
207 |
* @todo Final removal in Moodle 6.0 MDL-80804
|
- |
|
208 |
*/
|
- |
|
209 |
#[\core\attribute\deprecated(
|
- |
|
210 |
'\core_question\category_manager::get_real_question_ids_in_category',
|
- |
|
211 |
since: 4.5,
|
165 |
* $this->initialize() must have already been called
|
212 |
reason: 'No longer used',
|
- |
|
213 |
mdl: 'MDL-72397',
|
166 |
*
|
214 |
)]
|
Línea 167... |
Línea 215... |
167 |
*/
|
215 |
public function output_edit_lists(): void {
|
Línea 168... |
Línea 216... |
168 |
public function output_edit_lists(): void {
|
216 |
\core\deprecation::emit_deprecation([$this, __FUNCTION__]);
|
Línea 187... |
Línea 235... |
187 |
/**
|
235 |
/**
|
188 |
* Gets all the courseids for the given categories.
|
236 |
* Gets all the courseids for the given categories.
|
189 |
*
|
237 |
*
|
190 |
* @param array $categories contains category objects in a tree representation
|
238 |
* @param array $categories contains category objects in a tree representation
|
191 |
* @return array courseids flat array in form categoryid=>courseid
|
239 |
* @return array courseids flat array in form categoryid=>courseid
|
- |
|
240 |
* @deprecated Since Moodle 4.5 MDL-72397. No longer used.
|
- |
|
241 |
* @todo Final removal in Moodle 6.0 MDL-80804
|
192 |
*/
|
242 |
*/
|
- |
|
243 |
#[\core\attribute\deprecated(
|
- |
|
244 |
'\core_question\category_manager::get_real_question_ids_in_category',
|
- |
|
245 |
since: 4.5,
|
- |
|
246 |
reason: 'No longer used',
|
- |
|
247 |
mdl: 'MDL-72397',
|
- |
|
248 |
)]
|
193 |
public function get_course_ids(array $categories): array {
|
249 |
public function get_course_ids(array $categories): array {
|
- |
|
250 |
\core\deprecation::emit_deprecation([$this, __FUNCTION__]);
|
194 |
$courseids = [];
|
251 |
$courseids = [];
|
195 |
foreach ($categories as $key => $cat) {
|
252 |
foreach ($categories as $key => $cat) {
|
196 |
$courseids[$key] = $cat->course;
|
253 |
$courseids[$key] = $cat->course;
|
197 |
if (!empty($cat->children)) {
|
254 |
if (!empty($cat->children)) {
|
198 |
$courseids = array_merge($courseids, $this->get_course_ids($cat->children));
|
255 |
$courseids = array_merge($courseids, $this->get_course_ids($cat->children));
|
Línea 203... |
Línea 260... |
203 |
|
260 |
|
204 |
/**
|
261 |
/**
|
205 |
* Edit a category, or add a new one if the id is zero.
|
262 |
* Edit a category, or add a new one if the id is zero.
|
206 |
*
|
263 |
*
|
- |
|
264 |
* @param int $categoryid Category id.
|
- |
|
265 |
* @deprecated Since Moodle 4.5 MDL-72397. No longer used.
|
207 |
* @param int $categoryid Category id.
|
266 |
* @todo Final removal in Moodle 6.0 MDL-80804
|
- |
|
267 |
*/
|
- |
|
268 |
#[\core\attribute\deprecated(
|
- |
|
269 |
'\core_question\category_manager::get_real_question_ids_in_category',
|
- |
|
270 |
since: 4.5,
|
- |
|
271 |
reason: 'No longer used',
|
- |
|
272 |
mdl: 'MDL-72397',
|
208 |
*/
|
273 |
)]
|
- |
|
274 |
public function edit_single_category(int $categoryid): void {
|
209 |
public function edit_single_category(int $categoryid): void {
|
275 |
\core\deprecation::emit_deprecation([$this, __FUNCTION__]);
|
210 |
// Interface for adding a new category.
|
276 |
// Interface for adding a new category.
|
Línea 211... |
Línea 277... |
211 |
global $DB;
|
277 |
global $DB;
|
212 |
|
278 |
|
Línea 233... |
Línea 299... |
233 |
* Viable parents are any except for the category itself, or any of it's descendants
|
299 |
* Viable parents are any except for the category itself, or any of it's descendants
|
234 |
* The parentstrings parameter is passed by reference and changed by this function.
|
300 |
* The parentstrings parameter is passed by reference and changed by this function.
|
235 |
*
|
301 |
*
|
236 |
* @param array $parentstrings a list of parentstrings
|
302 |
* @param array $parentstrings a list of parentstrings
|
237 |
* @param object $category Category object
|
303 |
* @param object $category Category object
|
- |
|
304 |
* @deprecated Since Moodle 4.5 MDL-72397. No longer used.
|
- |
|
305 |
* @todo Final removal in Moodle 6.0 MDL-80804
|
238 |
*/
|
306 |
*/
|
- |
|
307 |
#[\core\attribute\deprecated(
|
- |
|
308 |
'\core_question\category_manager::get_real_question_ids_in_category',
|
- |
|
309 |
since: 4.5,
|
- |
|
310 |
reason: 'No longer used',
|
- |
|
311 |
mdl: 'MDL-72397',
|
- |
|
312 |
)]
|
239 |
public function set_viable_parents(array &$parentstrings, object $category): void {
|
313 |
public function set_viable_parents(array &$parentstrings, object $category): void {
|
240 |
|
- |
|
- |
|
314 |
\core\deprecation::emit_deprecation([$this, __FUNCTION__]);
|
241 |
unset($parentstrings[$category->id]);
|
315 |
unset($parentstrings[$category->id]);
|
242 |
if (isset($category->children)) {
|
316 |
if (isset($category->children)) {
|
243 |
foreach ($category->children as $child) {
|
317 |
foreach ($category->children as $child) {
|
244 |
$this->set_viable_parents($parentstrings, $child);
|
318 |
$this->set_viable_parents($parentstrings, $child);
|
245 |
}
|
319 |
}
|
Línea 250... |
Línea 324... |
250 |
* Gets question categories.
|
324 |
* Gets question categories.
|
251 |
*
|
325 |
*
|
252 |
* @param int|null $parent - if given, restrict records to those with this parent id.
|
326 |
* @param int|null $parent - if given, restrict records to those with this parent id.
|
253 |
* @param string $sort - [[sortfield [,sortfield]] {ASC|DESC}].
|
327 |
* @param string $sort - [[sortfield [,sortfield]] {ASC|DESC}].
|
254 |
* @return array categories.
|
328 |
* @return array categories.
|
- |
|
329 |
* @deprecated Since Moodle 4.5 MDL-72397. No longer used.
|
- |
|
330 |
* @todo Final removal in Moodle 6.0 MDL-80804
|
255 |
*/
|
331 |
*/
|
- |
|
332 |
#[\core\attribute\deprecated(
|
- |
|
333 |
'\core_question\category_manager::get_real_question_ids_in_category',
|
- |
|
334 |
since: 4.5,
|
- |
|
335 |
reason: 'No longer used',
|
- |
|
336 |
mdl: 'MDL-72397',
|
- |
|
337 |
)]
|
256 |
public function get_question_categories(int $parent = null, string $sort = "sortorder ASC"): array {
|
338 |
public function get_question_categories(?int $parent = null, string $sort = "sortorder ASC"): array {
|
- |
|
339 |
\core\deprecation::emit_deprecation([$this, __FUNCTION__]);
|
257 |
global $COURSE, $DB;
|
340 |
global $COURSE, $DB;
|
258 |
if (is_null($parent)) {
|
341 |
if (is_null($parent)) {
|
259 |
$categories = $DB->get_records('question_categories', ['course' => $COURSE->id], $sort);
|
342 |
$categories = $DB->get_records('question_categories', ['course' => $COURSE->id], $sort);
|
260 |
} else {
|
343 |
} else {
|
261 |
$select = "parent = ? AND course = ?";
|
344 |
$select = "parent = ? AND course = ?";
|
Línea 266... |
Línea 349... |
266 |
|
349 |
|
267 |
/**
|
350 |
/**
|
268 |
* Deletes an existing question category.
|
351 |
* Deletes an existing question category.
|
269 |
*
|
352 |
*
|
- |
|
353 |
* @param int $categoryid id of category to delete.
|
- |
|
354 |
* @deprecated Since Moodle 4.5 MDL-72397. Use \core_question\category_manager instead.
|
270 |
* @param int $categoryid id of category to delete.
|
355 |
* @todo Final removal in Moodle 6.0 MDL-80804
|
- |
|
356 |
*/
|
- |
|
357 |
#[\core\attribute\deprecated(
|
- |
|
358 |
'\core_question\category_manager::delete_category',
|
- |
|
359 |
since: 4.5,
|
- |
|
360 |
reason: 'API properly divided between qbank_managecategories and core_question',
|
- |
|
361 |
mdl: 'MDL-72397',
|
271 |
*/
|
362 |
)]
|
- |
|
363 |
public function delete_category(int $categoryid): void {
|
272 |
public function delete_category(int $categoryid): void {
|
364 |
\core\deprecation::emit_deprecation([$this, __FUNCTION__]);
|
273 |
global $CFG, $DB;
|
365 |
global $CFG, $DB;
|
274 |
helper::question_can_delete_cat($categoryid);
|
366 |
helper::question_can_delete_cat($categoryid);
|
275 |
if (!$category = $DB->get_record("question_categories", ["id" => $categoryid])) { // Security.
|
367 |
if (!$category = $DB->get_record("question_categories", ["id" => $categoryid])) { // Security.
|
276 |
throw new moodle_exception('unknowcategory');
|
368 |
throw new moodle_exception('unknowcategory');
|
Línea 291... |
Línea 383... |
291 |
/**
|
383 |
/**
|
292 |
* Move questions and then delete the category.
|
384 |
* Move questions and then delete the category.
|
293 |
*
|
385 |
*
|
294 |
* @param int $oldcat id of the old category.
|
386 |
* @param int $oldcat id of the old category.
|
295 |
* @param int $newcat id of the new category.
|
387 |
* @param int $newcat id of the new category.
|
- |
|
388 |
* @deprecated Since Moodle 4.5 MDL-72397. Use \core_question\category_manager instead.
|
- |
|
389 |
* @todo Final removal in Moodle 6.0 MDL-80804
|
296 |
*/
|
390 |
*/
|
- |
|
391 |
#[\core\attribute\deprecated(
|
- |
|
392 |
'\core_question\category_manager::move_questions_and_delete_category',
|
- |
|
393 |
since: 4.5,
|
- |
|
394 |
reason: 'API properly divided between qbank_managecategories and core_question',
|
- |
|
395 |
mdl: 'MDL-72397',
|
- |
|
396 |
)]
|
297 |
public function move_questions_and_delete_category(int $oldcat, int $newcat): void {
|
397 |
public function move_questions_and_delete_category(int $oldcat, int $newcat): void {
|
- |
|
398 |
\core\deprecation::emit_deprecation([$this, __FUNCTION__]);
|
298 |
helper::question_can_delete_cat($oldcat);
|
399 |
helper::question_can_delete_cat($oldcat);
|
299 |
$this->move_questions($oldcat, $newcat);
|
400 |
$this->move_questions($oldcat, $newcat);
|
300 |
$this->delete_category($oldcat);
|
401 |
$this->delete_category($oldcat);
|
301 |
}
|
402 |
}
|
Línea 308... |
Línea 409... |
308 |
* @throws \coding_exception
|
409 |
* @throws \coding_exception
|
309 |
*
|
410 |
*
|
310 |
* @deprecated No longer used by internal code and not recommended since Moodle 4.2 MDL-77299.
|
411 |
* @deprecated No longer used by internal code and not recommended since Moodle 4.2 MDL-77299.
|
311 |
*/
|
412 |
*/
|
312 |
public function display_move_form($questionsincategory, $category): void {
|
413 |
public function display_move_form($questionsincategory, $category): void {
|
- |
|
414 |
\core\deprecation::emit_deprecation([$this, __FUNCTION__]);
|
313 |
debugging(
|
415 |
debugging(
|
314 |
'display_move_form() is deprecated and no longer used by internal code.',
|
416 |
'display_move_form() is deprecated and no longer used by internal code.',
|
315 |
DEBUG_DEVELOPER
|
417 |
DEBUG_DEVELOPER
|
316 |
);
|
418 |
);
|
317 |
global $OUTPUT;
|
419 |
global $OUTPUT;
|
Línea 326... |
Línea 428... |
326 |
* Move questions to another category.
|
428 |
* Move questions to another category.
|
327 |
*
|
429 |
*
|
328 |
* @param int $oldcat id of the old category.
|
430 |
* @param int $oldcat id of the old category.
|
329 |
* @param int $newcat id of the new category.
|
431 |
* @param int $newcat id of the new category.
|
330 |
* @throws \dml_exception
|
432 |
* @throws \dml_exception
|
- |
|
433 |
* @deprecated Since Moodle 4.5 MDL-72397. Use \core_question\category_manager instead.
|
- |
|
434 |
* @todo Final removal in Moodle 6.0 MDL-80804
|
331 |
*/
|
435 |
*/
|
- |
|
436 |
#[\core\attribute\deprecated(
|
- |
|
437 |
'\core_question\category_manager::move_questions',
|
- |
|
438 |
since: 4.5,
|
- |
|
439 |
reason: 'API properly divided between qbank_managecategories and core_question',
|
- |
|
440 |
mdl: 'MDL-72397',
|
- |
|
441 |
)]
|
332 |
public function move_questions(int $oldcat, int $newcat): void {
|
442 |
public function move_questions(int $oldcat, int $newcat): void {
|
- |
|
443 |
\core\deprecation::emit_deprecation([$this, __FUNCTION__]);
|
333 |
$questionids = $this->get_real_question_ids_in_category($oldcat);
|
444 |
$questionids = $this->get_real_question_ids_in_category($oldcat);
|
334 |
question_move_questions_to_category($questionids, $newcat);
|
445 |
question_move_questions_to_category($questionids, $newcat);
|
335 |
}
|
446 |
}
|
Línea 336... |
Línea 447... |
336 |
|
447 |
|
Línea 346... |
Línea 457... |
346 |
* @param string $newinfo the description.
|
457 |
* @param string $newinfo the description.
|
347 |
* @param bool $return if true, return rather than redirecting.
|
458 |
* @param bool $return if true, return rather than redirecting.
|
348 |
* @param int|string $newinfoformat description format. One of the FORMAT_ constants.
|
459 |
* @param int|string $newinfoformat description format. One of the FORMAT_ constants.
|
349 |
* @param null $idnumber the idnumber. '' is converted to null.
|
460 |
* @param null $idnumber the idnumber. '' is converted to null.
|
350 |
* @return bool|int New category id if successful, else false.
|
461 |
* @return bool|int New category id if successful, else false.
|
- |
|
462 |
* @deprecated Since Moodle 4.5 MDL-72397. Use \core_question\category_manager instead.
|
- |
|
463 |
* @todo Final removal in Moodle 6.0 MDL-80804
|
351 |
*/
|
464 |
*/
|
- |
|
465 |
#[\core\attribute\deprecated(
|
- |
|
466 |
'\core_question\category_manager::add_category',
|
- |
|
467 |
since: 4.5,
|
- |
|
468 |
reason: 'API properly divided between qbank_managecategories and core_question',
|
- |
|
469 |
mdl: 'MDL-72397',
|
- |
|
470 |
)]
|
352 |
public function add_category($newparent, $newcategory, $newinfo, $return = false, $newinfoformat = FORMAT_HTML,
|
471 |
public function add_category($newparent, $newcategory, $newinfo, $return = false, $newinfoformat = FORMAT_HTML,
|
353 |
$idnumber = null): int {
|
472 |
$idnumber = null): int {
|
- |
|
473 |
\core\deprecation::emit_deprecation([$this, __FUNCTION__]);
|
354 |
global $DB;
|
474 |
global $DB;
|
355 |
if (empty($newcategory)) {
|
475 |
if (empty($newcategory)) {
|
356 |
throw new moodle_exception('categorynamecantbeblank', 'question');
|
476 |
throw new moodle_exception('categorynamecantbeblank', 'question');
|
357 |
}
|
477 |
}
|
358 |
list($parentid, $contextid) = explode(',', $newparent);
|
478 |
list($parentid, $contextid) = explode(',', $newparent);
|
Línea 412... |
Línea 532... |
412 |
* @param string $newname category name.
|
532 |
* @param string $newname category name.
|
413 |
* @param string $newinfo category description.
|
533 |
* @param string $newinfo category description.
|
414 |
* @param int|string $newinfoformat description format. One of the FORMAT_ constants.
|
534 |
* @param int|string $newinfoformat description format. One of the FORMAT_ constants.
|
415 |
* @param int $idnumber the idnumber. '' is converted to null.
|
535 |
* @param int $idnumber the idnumber. '' is converted to null.
|
416 |
* @param bool $redirect if true, will redirect once the DB is updated (default).
|
536 |
* @param bool $redirect if true, will redirect once the DB is updated (default).
|
- |
|
537 |
* @deprecated Since Moodle 4.5 MDL-72397. Use \core_question\category_manager instead.
|
- |
|
538 |
* @todo Final removal in Moodle 6.0 MDL-80804
|
417 |
*/
|
539 |
*/
|
- |
|
540 |
#[\core\attribute\deprecated(
|
- |
|
541 |
'\core_question\category_manager::update_category',
|
- |
|
542 |
since: 4.5,
|
- |
|
543 |
reason: 'API properly divided between qbank_managecategories and core_question',
|
- |
|
544 |
mdl: 'MDL-72397',
|
- |
|
545 |
)]
|
418 |
public function update_category($updateid, $newparent, $newname, $newinfo, $newinfoformat = FORMAT_HTML,
|
546 |
public function update_category($updateid, $newparent, $newname, $newinfo, $newinfoformat = FORMAT_HTML,
|
419 |
$idnumber = null, $redirect = true): void {
|
547 |
$idnumber = null, $redirect = true): void {
|
- |
|
548 |
\core\deprecation::emit_deprecation([$this, __FUNCTION__]);
|
420 |
global $CFG, $DB;
|
549 |
global $CFG, $DB;
|
421 |
if (empty($newname)) {
|
550 |
if (empty($newname)) {
|
422 |
throw new moodle_exception('categorynamecantbeblank', 'question');
|
551 |
throw new moodle_exception('categorynamecantbeblank', 'question');
|
423 |
}
|
552 |
}
|
Línea 499... |
Línea 628... |
499 |
* This method only returns the real question. It does not include
|
628 |
* This method only returns the real question. It does not include
|
500 |
* subquestions of question types like multianswer.
|
629 |
* subquestions of question types like multianswer.
|
501 |
*
|
630 |
*
|
502 |
* @param int $categoryid id of the category.
|
631 |
* @param int $categoryid id of the category.
|
503 |
* @return int[] array of question ids.
|
632 |
* @return int[] array of question ids.
|
- |
|
633 |
* @deprecated Since Moodle 4.5 MDL-72397. Use \core_question\category_manager instead.
|
- |
|
634 |
* @todo Final removal in Moodle 6.0 MDL-80804
|
504 |
*/
|
635 |
*/
|
- |
|
636 |
#[\core\attribute\deprecated(
|
- |
|
637 |
'\core_question\category_manager::get_real_question_ids_in_category',
|
- |
|
638 |
since: 4.5,
|
- |
|
639 |
reason: 'API properly divided between qbank_managecategories and core_question',
|
- |
|
640 |
mdl: 'MDL-72397',
|
- |
|
641 |
)]
|
505 |
public function get_real_question_ids_in_category(int $categoryid): array {
|
642 |
public function get_real_question_ids_in_category(int $categoryid): array {
|
- |
|
643 |
\core\deprecation::emit_deprecation([$this, __FUNCTION__]);
|
506 |
global $DB;
|
644 |
global $DB;
|
Línea 507... |
Línea 645... |
507 |
|
645 |
|
508 |
$sql = "SELECT q.id
|
646 |
$sql = "SELECT q.id
|
509 |
FROM {question} q
|
647 |
FROM {question} q
|