From: gustav_delius Date: Fri, 28 Apr 2006 09:44:13 +0000 (+0000) Subject: Removed the answershuffle field from the random short answer question because in... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=3f13e160943b79c7eca03c6425f2fa3d660ab618;p=moodle.git Removed the answershuffle field from the random short answer question because in a random question this options is irrelevant. --- diff --git a/question/type/randomsamatch/db/mysql.php b/question/type/randomsamatch/db/mysql.php index 86a8c00aaa..b57d42ff8b 100644 --- a/question/type/randomsamatch/db/mysql.php +++ b/question/type/randomsamatch/db/mysql.php @@ -5,6 +5,10 @@ function qtype_randomsamatch_upgrade($oldversion=0) { global $CFG; + if ($oldversion < 2006042800) { + // This is a random questiontype and therefore answers are always shuffled, no need for this field + modify_database('', 'ALTER TABLE prefix_question_randomsamatch DROP shuffleanswers'); + } return true; } diff --git a/question/type/randomsamatch/db/mysql.sql b/question/type/randomsamatch/db/mysql.sql index 43a8c53564..79d8b4d45c 100644 --- a/question/type/randomsamatch/db/mysql.sql +++ b/question/type/randomsamatch/db/mysql.sql @@ -6,7 +6,6 @@ CREATE TABLE prefix_question_randomsamatch ( id int(10) unsigned NOT NULL auto_increment, question int(10) unsigned NOT NULL default '0', choose int(10) unsigned NOT NULL default '4', - shuffleanswers tinyint(4) NOT NULL default '1', PRIMARY KEY (id), KEY question (question) ) TYPE=MyISAM COMMENT='Info about a random short-answer matching question'; diff --git a/question/type/randomsamatch/db/postgres7.php b/question/type/randomsamatch/db/postgres7.php index fe37c48afa..734594fcc1 100644 --- a/question/type/randomsamatch/db/postgres7.php +++ b/question/type/randomsamatch/db/postgres7.php @@ -5,6 +5,11 @@ function qtype_randomsamatch_upgrade($oldversion=0) { global $CFG; + if ($oldversion < 2006042800) { + // This is a random questiontype and therefore answers are always shuffled, no need for this field + modify_database('', 'ALTER TABLE prefix_question_randomsamatch DROP shuffleanswers'); + } + return true; } diff --git a/question/type/randomsamatch/db/postgres7.sql b/question/type/randomsamatch/db/postgres7.sql index ac9392778a..67fa91e45c 100644 --- a/question/type/randomsamatch/db/postgres7.sql +++ b/question/type/randomsamatch/db/postgres7.sql @@ -9,7 +9,6 @@ CREATE TABLE prefix_question_randomsamatch ( id SERIAL PRIMARY KEY, question integer NOT NULL default '0', choose integer NOT NULL default '4', - shuffleanswers integer NOT NULL default '1' ); CREATE INDEX prefix_question_randomsamatch_question_idx ON prefix_question_randomsamatch (question); diff --git a/question/type/randomsamatch/editquestion.html b/question/type/randomsamatch/editquestion.html index 8f0aa4a151..1f03ace305 100644 --- a/question/type/randomsamatch/editquestion.html +++ b/question/type/randomsamatch/editquestion.html @@ -94,15 +94,6 @@ ?> - - : - - shuffleanswers", ""); - helpbutton("matchshuffle", get_string("shuffle","quiz"), "quiz"); - ?> - - qtype]->print_replacement_options($question, $course, $contextquiz); $QTYPES[$question->qtype]->print_question_form_end($question); diff --git a/question/type/randomsamatch/editquestion.php b/question/type/randomsamatch/editquestion.php index cdd93f1781..f39f7d2f14 100644 --- a/question/type/randomsamatch/editquestion.php +++ b/question/type/randomsamatch/editquestion.php @@ -3,7 +3,6 @@ $options = get_record("question_randomsamatch", "question", $question->id); } else { $options->choose = ""; - $options->shuffleanswers = 1; } $saquestions = $QTYPES['randomsamatch']->get_sa_candidates($category->id); $numberavailable = count($saquestions); diff --git a/question/type/randomsamatch/questiontype.php b/question/type/randomsamatch/questiontype.php index d3d214a6a0..21f16fd94b 100644 --- a/question/type/randomsamatch/questiontype.php +++ b/question/type/randomsamatch/questiontype.php @@ -32,7 +32,6 @@ class question_randomsamatch_qtype extends question_match_qtype { function save_question_options($question) { $options->question = $question->id; $options->choose = $question->choose; - $options->shuffleanswers = $question->shuffleanswers; if (2 > $question->choose) { $result->error = "At least two shortanswer questions need to be chosen!"; @@ -150,12 +149,10 @@ class question_randomsamatch_qtype extends question_match_qtype { $state->options->subquestions[$key] = clone($wrappedquestion); } - // Shuffle the answers if required + // Shuffle the answers (Do this always because this is a random question type) $subquestionids = array_values(array_map(create_function('$val', 'return $val->id;'), $state->options->subquestions)); - if ($cmoptions->shuffleanswers and $question->options->shuffleanswers) { - $subquestionids = swapshuffle($subquestionids); - } + $subquestionids = swapshuffle($subquestionids); // Create empty responses foreach ($subquestionids as $val) { @@ -261,7 +258,6 @@ class question_randomsamatch_qtype extends question_match_qtype { $status = fwrite ($bf,start_tag("RANDOMSAMATCH",6,true)); //Print randomsamatch contents fwrite ($bf,full_tag("CHOOSE",7,false,$randomsamatch->choose)); - fwrite ($bf,full_tag("SHUFFLEANSWERS",7,false,$randomsamatch->shuffleanswers)); $status = fwrite ($bf,end_tag("RANDOMSAMATCH",6,true)); } } @@ -289,7 +285,6 @@ class question_randomsamatch_qtype extends question_match_qtype { //Now, build the question_randomsamatch record structure $randomsamatch->question = $new_question_id; $randomsamatch->choose = backup_todb($ran_info['#']['CHOOSE']['0']['#']); - $randomsamatch->shuffleanswers = backup_todb($ran_info['#']['SHUFFLEANSWERS']['0']['#']); //The structure is equal to the db, so insert the question_randomsamatch $newid = insert_record ("question_randomsamatch",$randomsamatch); diff --git a/question/type/randomsamatch/version.php b/question/type/randomsamatch/version.php index 2d2a8d9fa7..d1384a822e 100644 --- a/question/type/randomsamatch/version.php +++ b/question/type/randomsamatch/version.php @@ -1,6 +1,6 @@ version = 2006032200; +$plugin->version = 2006042800; $plugin->requires = 2006032200; ?>