MDL-7567 Numerical questions occasionally mix up the order of their answers
This commit is contained in:
@@ -33,7 +33,8 @@ class question_numerical_qtype extends question_shortanswer_qtype {
|
||||
"FROM {$CFG->prefix}question_answers a, " .
|
||||
" {$CFG->prefix}question_numerical n " .
|
||||
"WHERE a.question = $question->id " .
|
||||
"AND a.id = n.answer;")) {
|
||||
"AND a.id = n.answer " .
|
||||
"ORDER BY a.id ASC")) {
|
||||
notify('Error: Missing question answer!');
|
||||
return false;
|
||||
}
|
||||
@@ -94,11 +95,11 @@ class question_numerical_qtype extends question_shortanswer_qtype {
|
||||
// interface, but the GIFT format supports it. The multianswer qtype,
|
||||
// for example can make use of this feature.
|
||||
// Get old versions of the objects
|
||||
if (!$oldanswers = get_records("question_answers", "question", $question->id)) {
|
||||
if (!$oldanswers = get_records("question_answers", "question", $question->id, 'id ASC')) {
|
||||
$oldanswers = array();
|
||||
}
|
||||
|
||||
if (!$oldoptions = get_records("question_numerical", "question", $question->id)) {
|
||||
if (!$oldoptions = get_records("question_numerical", "question", $question->id, 'answer ASC')) {
|
||||
$oldoptions = array();
|
||||
}
|
||||
|
||||
@@ -171,7 +172,7 @@ class question_numerical_qtype extends question_shortanswer_qtype {
|
||||
}
|
||||
|
||||
function save_numerical_units($question) {
|
||||
if (!$oldunits = get_records("question_numerical_units", "question", $question->id)) {
|
||||
if (!$oldunits = get_records('question_numerical_units', 'question', $question->id, 'id ASC')) {
|
||||
$oldunits = array();
|
||||
}
|
||||
|
||||
@@ -418,7 +419,7 @@ class question_numerical_qtype extends question_shortanswer_qtype {
|
||||
|
||||
$status = true;
|
||||
|
||||
$numericals = get_records("question_numerical","question",$question,"id");
|
||||
$numericals = get_records('question_numerical', 'question', $question, 'id ASC');
|
||||
//If there are numericals
|
||||
if ($numericals) {
|
||||
//Iterate over each numerical
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
$options->usecase = 0;
|
||||
}
|
||||
if (!empty($options->answers)) {
|
||||
$answersraw = get_records_list("question_answers", "id", $options->answers);
|
||||
$answersraw = get_records_list("question_answers", "id", $options->answers, 'id ASC');
|
||||
}
|
||||
|
||||
$answers = array();
|
||||
|
||||
@@ -34,7 +34,7 @@ class question_shortanswer_qtype extends default_questiontype {
|
||||
}
|
||||
|
||||
function save_question_options($question) {
|
||||
if (!$oldanswers = get_records("question_answers", "question", $question->id, "id ASC")) {
|
||||
if (!$oldanswers = get_records('question_answers', 'question', $question->id, 'id ASC')) {
|
||||
$oldanswers = array();
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ class question_shortanswer_qtype extends default_questiontype {
|
||||
|
||||
$status = true;
|
||||
|
||||
$shortanswers = get_records("question_shortanswer","question",$question,"id");
|
||||
$shortanswers = get_records('question_shortanswer', 'question', $question, 'id ASC');
|
||||
//If there are shortanswers
|
||||
if ($shortanswers) {
|
||||
//Iterate over each shortanswer
|
||||
|
||||
Reference in New Issue
Block a user