Affects Version/s: 3.6
Fix Version/s: None
I often have issues with the relationship between questions and their answers breaking down, when trying to import a quiz from one course into another.
The error message usefully mentions the question's database ID, but could easily go a little further to provide a link for editing the question.
The following SQL (adapted from https://moodle.org/mod/forum/discuss.php?d=340262) provides such a link.
Concat('../question/question.php?courseid=', c.id, '&id=', q.id) AS question_bank_link
FROM mdl_question q
LEFT JOIN mdl_question_categories qc ON qc.id = q.category
LEFT JOIN mdl_context ctx ON ctx.id = qc.contextid
LEFT JOIN mdl_course_modules cm ON cm.id = ctx.instanceid AND ctx.contextlevel = 70
LEFT JOIN mdl_course c ON (ctx.contextlevel = 50 AND c.id = ctx.instanceid) OR (ctx.contextlevel = 70 AND c.id = cm.course)
LEFT JOIN mdl_question_answers qa on qa.question = q.id
WHERE q.id = [questionid]