From 8419513e13e50f967cfa68c5afa29ad774cf30ea Mon Sep 17 00:00:00 2001 From: tjhunt Date: Wed, 4 Oct 2006 10:07:42 +0000 Subject: [PATCH] MDL-6297 shuffleanswers option not imported correctly for MC questions. Backported from HEAD. --- question/format/xml/format.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/question/format/xml/format.php b/question/format/xml/format.php index b7a6a26cdc6..8b18fa280e0 100755 --- a/question/format/xml/format.php +++ b/question/format/xml/format.php @@ -57,18 +57,12 @@ class qformat_xml extends qformat_default { * @RETURN int internal code number */ function trans_single( $name ) { - $name = trim($name); - - if ($name=="true") { - $id = 1; - } - elseif ($name=="false") { - $id = 0; - } - else { - $id = 0; // or maybe warning required - } - return $id; + $name = trim($name); + if ($name == "false" || !$name) { + return 0; + } else { + return 1; + } } /* @@ -143,6 +137,12 @@ class qformat_xml extends qformat_default { $qo->qtype = MULTICHOICE; $single = $question['#']['single'][0]['#']; $qo->single = $this->trans_single( $single ); + if (array_key_exists('shuffleanswers', $question['#'])) { + $shuffleanswers = $question['#']['shuffleanswers'][0]['#']; + } else { + $shuffleanswers = 'false'; + } + $qo->shuffleanswers = $this->trans_single($shuffleanswers); // run through the answers $answers = $question['#']['answer'];