tmuras / Moodle-Flashcard

Moodle flashcard module
http://moodle.org/mod/data/view.php?d=13&rid=1539&filter=1
12 stars 9 forks source link

Flashcard error when question categories exist in bad context #14

Open heather-williams opened 9 years ago

heather-williams commented 9 years ago

If you have a site that has question categories that are in an incorrect context (seen by running a health report), you will receive the following error when trying to add a flashcard module to a course;

More information about this error

Debug info: SELECT * FROM {context} WHERE id = ?

[array (

0 => '16310',

)]

Error code: invalidrecord

Stack trace:

line 1403 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown

line 1379 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()

line 5349 of /lib/accesslib.php: call to moodle_database->get_record()

line 1377 of /lib/questionlib.php: call to context::instance_by_id()

line 66 of /mod/flashcard/mod_form.php: call to question_has_capability_on()

line ? of unknownfile: call to drop_questions()

line 69 of /mod/flashcard/mod_form.php: call to array_filter()

line 191 of /lib/formslib.php: call to mod_flashcard_mod_form->definition()

line 86 of /course/moodleform_mod.php: call to moodleform->moodleform()

line 256 of /course/modedit.php: call to moodleform_mod->moodleform_mod()

If you run the health report and the categories have questions in them it is difficult to resolve. As a work around I have created a course and moved those categories into it's context, so they are in a valid context and the error goes away. However, I am wondering if it is possible that the module could just skip over these categories instead of throwing an error and not being usable?

vfremaux commented 9 years ago

As you can see in your report, the issue is caused by a non compliant situation in question internal data model. The stack actually shows the error is thrown on a deep sub call in the question library, and thus comes outside of the functional responsibility of the flashcard module. It is thus not easy or even architecturally consistant that flashcard have to care about a deep functional condition handled elsewhere. Perhaps also your output reveals that you are runnign your Moodle at high debugging level, which might not be essential on production sites (or ?)

cheers

heather-williams commented 9 years ago

Since it appears that this is only happening for the flashcard module and makes it quite unusable, I thought it would be fruitful to open an issue for it. But if you think I should take another route (maybe a Moodle tracker?) then I can do that.

The high debugging level was turned on so I could capture that stack and provide it here.

Thanks!