From e5060e2209085b75dd60f00efb10bfb366ebe4bd Mon Sep 17 00:00:00 2001 From: Jamie Pratt Date: Thu, 30 Jun 2011 17:21:37 +0100 Subject: [PATCH] MDL-28129 two issues with loading and saving questions 1. Missing order by could randomise the order of the hints. 2. the extraanswerfields big had some SQL errros. --- question/type/questiontypebase.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/question/type/questiontypebase.php b/question/type/questiontypebase.php index e98591e33eb..f7234b63c97 100644 --- a/question/type/questiontypebase.php +++ b/question/type/questiontypebase.php @@ -493,7 +493,8 @@ class question_type { global $DB; $context = $formdata->context; - $oldhints = $DB->get_records('question_hints', array('questionid' => $formdata->id)); + $oldhints = $DB->get_records('question_hints', + array('questionid' => $formdata->id), 'id ASC'); if (!empty($formdata->hint)) { $numhints = max(array_keys($formdata->hint)) + 1; @@ -628,8 +629,8 @@ class question_type { $answer_extension_table = array_shift($extraanswerfields); $question->options->answers = $DB->get_records_sql(" SELECT qa.*, qax." . implode(', qax.', $extraanswerfields) . " - FROM {question_answers} qa, {$answer_extension_table} qax - WHERE qa.questionid = ? AND qax.answerid = qa.id", array($question->id)); + FROM {question_answers} qa, {{$answer_extension_table}} qax + WHERE qa.question = ? AND qax.answerid = qa.id", array($question->id)); if (!$question->options->answers) { echo $OUTPUT->notification('Failed to load question answers from the table ' . $answer_extension_table . 'for questionid ' . $question->id);