Moodle Plugins directory: Purge question categories (Legacy) | Moodle.org
Purge question categories (Legacy)
Local plugins ::: local_purgequestioncategory
Maintained by
Vadim Dvorovenko
Part of set Question bank improvements.
This plugin allows to delete question category with all questions and subcategories
Latest release:
256 sites
94 downloads
17 fans
Current versions available: 2
For Moodle 4.0+ use qbank_purgecategory.
This plugin extends question bank navigation node with "Purge categories" item.
Select category you want to delete and specify where to move questions, that cannot be deleted. Questions, that cannot be deleted, are questions, that are used in quizes or in history of quiz attempts. Such questions will be moved to specified categories and marked as hidden.
This can be useful if you are importing a lot of questions with many categories and want to delete all of them and reimport them.
Useful links
Contributors
Vadim Dvorovenko (Lead maintainer)
Please login to view contributors details and/or to contact them
Moodle V3.1
Doing:
http://***.***.***/local/purgequestioncategory/confirm.php?purge=16
Gives:
Coding problem: $PAGE->context was not set. You may have forgotten to call require_login() or $PAGE->set_context(). The page may not display correctly as a result
line 458 of /lib/pagelib.php: call to debugging()
line 773 of /lib/pagelib.php: call to moodle_page->magic_get_context()
line 1420 of /lib/weblib.php: call to moodle_page->__get()
line 1164 of /lib/pagelib.php: call to format_string()
line 51 of /local/purgequestioncategory/confirm.php: call to moodle_page->set_title()
After choosing "continue" on the confirmation page result is:
A required parameter (courseid) was missing
More information about this error
×Debug info:
Error code: missingparam
×Stack trace:
line 495 of /lib/setuplib.php: moodle_exception thrown
line 552 of /lib/moodlelib.php: call to print_error()
line 290 of /question/editlib.php: call to required_param()
line 31 of /local/purgequestioncategory/category.php: call to question_edit_setup()
Categories are purged though.
MvdN
One thing I did notice (using moodle 3.5.2) is that it throws an error after deleting the questions/categories (at first I thought it did not work):
A required parameter (courseid) was missing
More information about this error
×Debug info:
Error code: missingparam
×Stack trace:
line 482 of /lib/setuplib.php: moodle_exception thrown
line 573 of /lib/moodlelib.php: call to print_error()
line 296 of /question/editlib.php: call to required_param()
line 31 of /local/purgequestioncategory/category.php: call to question_edit_setup()
Greg Lyon. thanks for your feedback. I've found this porblem was reported before, but i can't reproduce problem. Currently i have some ideas.
Are you purging categories on context or system level? i've tested it only on course and course module levels
Blair F., This plugin work same as base category deleting. The only difference, it can delete all subcategories at once. For example, you have category, having 30 subcategories, eatch ot hem have 10 subcategories. With builtin deletion you have to delete 30 * 10 = 300 times, with this plugin - only once.
The category you specify is neededed to move USED questions. UNUSED quiestion can be safely deleted, so they are deleted. Build in deletion works the same
I ran into the same issue as Mike Churchward above.
Moodle 3.9.9
In Moodle 4.0, the question bank has changed quite a lot (see https://docs.moodle.org/dev/Question_bank_improvements_for_Moodle_4.0).
In particular, there is a new type of plugin: qbank_.... This should be documented at https://docs.moodle.org/dev/Question_bank_plugins, but I am afraid that this is not complete yet. (However, there is information in the upgrade.txt files in the code, and the PHPdocs in the code should explain things.)
So, I think it is a case of
Bad news: you will have to re-write all your local plugins as qbank plugins to work with Moodle 4.0+.
Good news: if you do, then they will probably work even better for users and you can probably reuse almost all of your code.
There are a lot of references in question/bank directory in Moodle 4.0 repository. Please do not hesitate to get in touch if you have any questions.
Cheers!