-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
4.6 - upgrade error with Shared Question Banks #226
Comments
Yes. Moodle 5.0 / 4.6 will change how the question bank works, which means that the age-old hack (is that fair?) in CodeRunner that prototypes are stored in the system question bank will not work any more. There is no longer a system question bank. So, this model needs a re-think. I have some thoughts about how best to deal with that, if you want to discuss it @trampgeek. |
No need for me to be mysterious. My outline solution is:
An advantage of using question_references is that then, for example, the question bank will prevent people from deleting prototyes that are in use. |
Ouch. This is very worrying. We're only just recovering from the introduction of question versioning :-) We're worried about the idea of linking questions to their prototypes using the question references DB table. Some of the concerns have already been outlined on a CodeRunner forum posting: https://coderunner.org.nz/mod/forum/discuss.php?d=570 There, we talk about the problems with exporting a quiz but similar and possibly even more serious concerns arise when backing up and restoring courses. For example, suppose we have a question bank of prototypes that we share between two courses. We now backup both courses at the end of the academic year, ready for setting up our new year's server. How do we manage the question links in this case. Do both course backups include the shared question bank? Or is that backed up separately? In both cases, there seems to be a problem in re-establishing the question references. |
I've started to look into this, Tim. But when I call the required question_bank_helper functions I get an exception thrown to say that they can't be used during an upgrade. I've worked around that with the following bit of code, but I feel very uncomfortable with that approach. There is presumably a good reason not to use those functions during upgrades so switching off the checks seems dangerous. Can you reassure me it's safe please, or alternatively suggest a better approach?
EDIT My concerns look justified. While the above code worked when I did a manual Moodle install (adding CodeRunner after getting the basic Moodle working) it failed in behat testing. Specifically the line $module = $DB->get_record('modules', ['name' => self::get_default_question_bank_activity_name()], '*', MUST_EXIST); throws a "record not found" exception. Implying to me that CodeRunner installer is being run before the qbank module has been installed. |
Your observation about Behat install is correct. The order that Moodle plugins are installed puts question types before activity modules. But, best to avoid relying on the order if you can. I think the best way to deal with this - and the main problem you asked about - is to use an ad-hoc task.
My instinct would be to code this in a way that is idempotnent, so it look for a qbank with idnumber (in the course_modules table) set to something appropriate like 'qtype_coderunner-system-prototypes' and only creates it if it does not already exist. This task can then proceed to do what the existing update_question_types function does. Also, if you have not already looked at I hope that is helpful. |
Many thanks Tim. Very helpful. I had suspected queuing a task would be the way to but it's good to have it confirmed. I had wondered how to notify any errors that occurred, given the task is now asynchronous with the install/upgrade, but no doubt I can find a way to at least log an error. Yes, I had looked at the transfer_question_categories.php file, as you suggested earlier. It's how I was able to get the install code written (which does work if you install CodeRunner after installing Moodle) - many thanks for the earlier link to it. Wouldn't have had a clue, without that. I'll give that a go tomorrow. |
Output from talks (mtrace) get captured, and there is an admin UI where people can chech that. Also, if you task fails (ends by throwing an exception rather than completing) the system tracks that and retries etc. Certainly, at the OU we monitor what all the tasks are doing (using report_customsql to email admins every day if any tasks have failed). |
I'm having some problems with implementing this. I wrote an adhoc task that set up the Front Page question bank, added a category for CodeRunner and uploaded all the question prototypes. But it just didn't seem to be working. After some confusing debugging I discovered that it was in fact working fine but the transfer_question_categories task, which ran after it, was then deleting my question category and all its questions! It seems that the functions question_category_in_use and question_category_delete_safe operate on the assumption that questions that aren't actually used explicitly in quizzes are junk and can be deleted. This is certainly a seriously flawed assumption for CodeRunner prototypes but also seems dangerous for question bank development in general. We often have question categories containing questions we're developing for tests and exams, or have removed from current quizzes but want to keep for possible future use. I thought I might be able to deal with the immediate problem by failing the adhoc task if the front page question bank wasn't present yet, so that it could be retried later. But it seems that retrying of failed adhoc questions doesn't take place during install/upgrade? One further issue is that logging of adhoc tasks, including their mtrace output, doesn't seem to take place during install/upgrades either? So notifying admins of errors seems problematic. However, I would hope that errors shouldn't be occurring once the fundamental issues are dealt with. |
The problem with the questoins being deleted might be https://tracker.moodle.org/browse/MDL-83977. Are you testing aganist the latest main branch of Moodle? There was a flawed assumption, but it should be fixed now. |
Ah, thanks Tim. I was indeed testing against an older branch. Good to know the issue has been addressed. |
Testing Moodle 4.6 for https://tracker.moodle.org/browse/MDLQA-19535
The following failures occur with this plugin that do not occur with 4.5
The text was updated successfully, but these errors were encountered: