Skip to content

Commit

Permalink
MDL-28268 Missing ORDER BY when using extra answer table.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jamiepratt authored and timhunt committed Jul 9, 2011
1 parent f6f6138 commit da8cd9f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion question/type/questiontypebase.php
Expand Up @@ -630,7 +630,8 @@ public function get_question_options($question) {
$question->options->answers = $DB->get_records_sql(" $question->options->answers = $DB->get_records_sql("
SELECT qa.*, qax." . implode(', qax.', $extraanswerfields) . " SELECT qa.*, qax." . implode(', qax.', $extraanswerfields) . "
FROM {question_answers} qa, {{$answer_extension_table}} qax 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) { if (!$question->options->answers) {
echo $OUTPUT->notification('Failed to load question answers from the table ' . echo $OUTPUT->notification('Failed to load question answers from the table ' .
$answer_extension_table . 'for questionid ' . $question->id); $answer_extension_table . 'for questionid ' . $question->id);
Expand Down

0 comments on commit da8cd9f

Please sign in to comment.