From da8cd9f4b3dba0f8c78cdba451c59e6c697fef39 Mon Sep 17 00:00:00 2001 From: Jamie Pratt Date: Wed, 6 Jul 2011 17:54:59 +0700 Subject: [PATCH] MDL-28268 Missing ORDER BY when using extra answer table. From OU bug #921 "Order of answer fields in Variable numeric keeps changing" Cannot reproduce this bug on my system but hopefully this will fix the problem. I added an ORDER BY clause to the sql for fetching answers with extra answer fields. --- question/type/questiontypebase.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/question/type/questiontypebase.php b/question/type/questiontypebase.php index f7234b63c97..75766690ca6 100644 --- a/question/type/questiontypebase.php +++ b/question/type/questiontypebase.php @@ -630,7 +630,8 @@ class question_type { $question->options->answers = $DB->get_records_sql(" SELECT qa.*, qax." . implode(', qax.', $extraanswerfields) . " FROM {question_answers} qa, {{$answer_extension_table}} qax - WHERE qa.question = ? AND qax.answerid = qa.id", array($question->id)); + WHERE qa.question = ? AND qax.answerid = qa.id + ORDER BY 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);