From: tjhunt Date: Mon, 29 Jan 2007 12:35:29 +0000 (+0000) Subject: When editing some question types, the options get jumbled up. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f07d1d319716a0b381ece29435c72999a798f778;p=moodle.git When editing some question types, the options get jumbled up. --- diff --git a/question/type/calculated/questiontype.php b/question/type/calculated/questiontype.php index 31d493e055..e2e7eb8efb 100644 --- a/question/type/calculated/questiontype.php +++ b/question/type/calculated/questiontype.php @@ -60,7 +60,8 @@ class question_calculated_qtype extends question_dataset_dependent_questiontype c.correctanswerlength, c.id AS calcid FROM {$CFG->prefix}question_answers a, {$CFG->prefix}question_calculated c - WHERE c.question = $question->id AND a.id = c.answer")) { + WHERE c.question = $question->id AND a.id = c.answer + ORDER BY a.id ASC")) { $oldanswers = array(); } diff --git a/question/type/match/questiontype.php b/question/type/match/questiontype.php index 7e5d26c32c..c1538b82e2 100644 --- a/question/type/match/questiontype.php +++ b/question/type/match/questiontype.php @@ -13,7 +13,7 @@ class question_match_qtype extends default_questiontype { function get_question_options(&$question) { $question->options = get_record('question_match', 'question', $question->id); - $question->options->subquestions = get_records("question_match_sub", "question", $question->id, "id ASC" ); + $question->options->subquestions = get_records('question_match_sub', 'question', $question->id, 'id ASC'); return true; } @@ -110,8 +110,7 @@ class question_match_qtype extends default_questiontype { } function create_session_and_responses(&$question, &$state, $cmoptions, $attempt) { - if (!$state->options->subquestions = get_records('question_match_sub', - 'question', $question->id)) { + if (!$state->options->subquestions = get_records('question_match_sub', 'question', $question->id, 'id ASC')) { notify('Error: Missing subquestions!'); return false; } @@ -147,8 +146,7 @@ class question_match_qtype extends default_questiontype { $responses = array_map(create_function('$val', 'return explode("-", $val);'), $responses); - if (!$questions = get_records('question_match_sub', - 'question', $question->id)) { + if (!$questions = get_records('question_match_sub', 'question', $question->id, 'id ASC')) { notify('Error: Missing subquestions!'); return false; } @@ -416,7 +414,7 @@ class question_match_qtype extends default_questiontype { $status = true; - $matchs = get_records("question_match_sub","question",$question,"id"); + $matchs = get_records('question_match_sub', 'question', $question, 'id ASC'); //If there are matchs if ($matchs) { $status = fwrite ($bf,start_tag("MATCHS",6,true)); diff --git a/question/type/multianswer/questiontype.php b/question/type/multianswer/questiontype.php index 910cc234bb..4bdc51c20a 100644 --- a/question/type/multianswer/questiontype.php +++ b/question/type/multianswer/questiontype.php @@ -28,7 +28,7 @@ class embedded_cloze_qtype extends default_questiontype { return false; } - $wrappedquestions = get_records_list('question', 'id', $sequence); + $wrappedquestions = get_records_list('question', 'id', $sequence, 'id ASC'); // We want an array with question ids as index and the positions as values $sequence = array_flip(explode(',', $sequence)); diff --git a/question/type/questiontype.php b/question/type/questiontype.php index 2e7d7cb404..14f44a59d4 100644 --- a/question/type/questiontype.php +++ b/question/type/questiontype.php @@ -271,8 +271,7 @@ class default_questiontype { $question->options = new object; } // The default implementation attaches all answers for this question - $question->options->answers = get_records('question_answers', 'question', - $question->id); + $question->options->answers = get_records('question_answers', 'question', $question->id, 'id ASC'); return true; } diff --git a/question/type/rqp/types.php b/question/type/rqp/types.php index d3c5f51238..3132f08262 100644 --- a/question/type/rqp/types.php +++ b/question/type/rqp/types.php @@ -136,7 +136,7 @@ if ($types) { foreach ($types as $type) { - if (!$servers = get_records('question_rqp_servers', 'typeid', $type->id)) { + if (!$servers = get_records('question_rqp_servers', 'typeid', $type->id, 'id ASC')) { delete_records('question_rqp_types', 'id', $type->id); } else { foreach ($servers as $server) { diff --git a/question/type/truefalse/questiontype.php b/question/type/truefalse/questiontype.php index 50ad388814..11cd11c725 100644 --- a/question/type/truefalse/questiontype.php +++ b/question/type/truefalse/questiontype.php @@ -102,7 +102,7 @@ class question_truefalse_qtype extends default_questiontype { return false; } // Load the answers - if (!$question->options->answers = get_records('question_answers', 'question', $question->id)) { + if (!$question->options->answers = get_records('question_answers', 'question', $question->id, 'id ASC')) { notify('Error: Missing question answers!'); return false; }