Moodle error when previewing generated quiz from plugin

37 Views Asked by At

I am trying to develop a mod plugin within Moodle 4.3. This plugin will take as an input a PDF file, which is parsed then sent to GPT 4 via the API, that will come back with 10 multiple choice questions based on the PDF file. Up until this point, everything works fine. Connected to MariaDB, I can see that the mdl_question table is populated, as well as the categories, question_bank, etc.

However, the only issue at this point is when previewing the quiz.

Can't find data record in database

Debug info: SELECT quid, qc.id as category, q.parent, q.name, q.questiontext, q.questiontextformat, q.generalfeedback, q.generalfeedbackformat, q.defaultmark, q.penalty, q.qtype,
q.length, q.stamp, q.timecreated, q.timemodified,
q.createdby, q.modifiedby, qbe.idnumber,
qc.contextid,
qv.status,
qv.id as versionid,
qv.version,
qv.questionbankentryid
FROM (question) q
JOIN {question_versions) qv ON qv.questionid = q.id
JOIN (question_bank_entries) qbe ON qbe.id = qv.questionbankentryid
JOIN (question_categories) qc ON qc.id = qbe.questioncategoryid
WHERE q.id = id
[array (
'id' => 's61',
Error code: invalidrecordunknown

Stack trace:
• line 1686 of \lib\dmi\moodle_database.php: dml_missing_record_exception thrown
line 694 of \question\engine\bank.php: call to moodle_database->get_record_sql()
line 600 of \cache\classes\loaders.php: call to question_finder->load_for_cache()
• line 418 of \cache\classes\loaders.php: call to cache->get_implementation()
line 530 of \question\engine\bank.php: call to cache->get()
line 257 of \question\engine\bank.php: call to question_finder->load_question_data()
line 275 of \question\engine\bank.php: call to question_bank::load_question_data()
• line 190 of \mod\quiz\locallib.php: call to question_bank::load_question()
line 2056 of \mod\quiz\locallib.php: call to quiz_start_new_attempt()
line 110 of \mod\quiz\startattempt.php: call to quiz_prepare_and_start_new_attempt()

In the first instance, I don't understand why will it search for an id starting with "s".

I can provide the lib.php and view.php files from my mod plugins if needed. Any help will be much appreciated.

I've tried looking through all the tables between a normal quiz that was generated via the normal quiz process and then I've looked at the one generated via the plugin. This didn't seem to help, as the database values were really similar.

0

There are 0 best solutions below