From 944829e93094ec0ca97494e6cd145c0674089b39 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Tue, 5 Apr 2011 17:54:39 +0100 Subject: [PATCH] MDL-47494 ddimageortext: Fix codechecker problems in match, description and ddwtos qtypes. --- .../moodle2/restore_qtype_ddwtos_plugin.class.php | 3 - question/type/ddimageortext/edit_ddwtos_form.php | 4 +- question/type/ddimageortext/question.php | 2 +- question/type/ddimageortext/questiontype.php | 107 +--------- question/type/ddimageortext/renderer.php | 11 +- question/type/ddimageortext/script.js | 6 +- .../type/ddimageortext/simpletest/testquestion.php | 6 +- .../ddimageortext/simpletest/testquestiontype.php | 119 ++++++++--- .../ddimageortext/simpletest/testwalkthrough.php | 237 ++++++++++++++------- 9 files changed, 270 insertions(+), 225 deletions(-) diff --git a/question/type/ddimageortext/backup/moodle2/restore_qtype_ddwtos_plugin.class.php b/question/type/ddimageortext/backup/moodle2/restore_qtype_ddwtos_plugin.class.php index 1676ddbb227..ddf034ff12b 100755 --- a/question/type/ddimageortext/backup/moodle2/restore_qtype_ddwtos_plugin.class.php +++ b/question/type/ddimageortext/backup/moodle2/restore_qtype_ddwtos_plugin.class.php @@ -50,7 +50,6 @@ class restore_qtype_ddwtos_plugin extends restore_qtype_plugin { $elepath = $this->get_pathfor('/ddwtos'); // we used get_recommended_name() so this works $paths[] = new restore_path_element($elename, $elepath); - return $paths; // And we return the interesting paths } @@ -76,8 +75,6 @@ class restore_qtype_ddwtos_plugin extends restore_qtype_plugin { $newitemid = $DB->insert_record('question_ddwtos', $data); // Create mapping (needed for decoding links) $this->set_mapping('question_ddwtos', $oldid, $newitemid); - } else { - // Nothing to remap if the question already existed } } diff --git a/question/type/ddimageortext/edit_ddwtos_form.php b/question/type/ddimageortext/edit_ddwtos_form.php index fd2273b71b1..d9840386f1d 100755 --- a/question/type/ddimageortext/edit_ddwtos_form.php +++ b/question/type/ddimageortext/edit_ddwtos_form.php @@ -51,7 +51,9 @@ class qtype_ddwtos_edit_form extends qtype_gapselect_edit_form_base { protected function choice_group($mform) { $grouparray = parent::choice_group($mform); - $grouparray[] = $mform->createElement('checkbox', 'infinite', ' ', get_string('infinite', 'qtype_ddwtos'), null, array('size'=>1, 'class'=>'tweakcss')); + $grouparray[] = $mform->createElement('checkbox', 'infinite', ' ', + get_string('infinite', 'qtype_ddwtos'), null, + array('size' => 1, 'class' => 'tweakcss')); return $grouparray; } } diff --git a/question/type/ddimageortext/question.php b/question/type/ddimageortext/question.php index 6861858bbf3..6894248d242 100755 --- a/question/type/ddimageortext/question.php +++ b/question/type/ddimageortext/question.php @@ -57,7 +57,7 @@ class qtype_ddwtos_choice { $this->draggroup = $draggroup; $this->isinfinite = $isinfinite; } - public function choice_group(){ + public function choice_group() { return $this->draggroup; } } diff --git a/question/type/ddimageortext/questiontype.php b/question/type/ddimageortext/questiontype.php index c990afab802..aeff6ec3185 100755 --- a/question/type/ddimageortext/questiontype.php +++ b/question/type/ddimageortext/questiontype.php @@ -40,7 +40,7 @@ require_once($CFG->dirroot . '/question/type/gapselect/questiontypebase.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class qtype_ddwtos extends qtype_gapselect_base { - protected function choice_group_key(){ + protected function choice_group_key() { return 'draggroup'; } @@ -48,21 +48,22 @@ class qtype_ddwtos extends qtype_gapselect_base { return array('gapselect'); } - protected function choice_options_to_feedback($choice){ + protected function choice_options_to_feedback($choice) { $output = new stdClass(); $output->draggroup = $choice['choicegroup']; $output->infinite = !empty($choice['infinite']); return serialize($output); } - protected function feedback_to_choice_options($feedback){ + protected function feedback_to_choice_options($feedback) { $feedbackobj = unserialize($feedback); - return array('draggroup'=> $feedbackobj->draggroup, 'infinite'=> $feedbackobj->infinite); + return array('draggroup' => $feedbackobj->draggroup, 'infinite' => $feedbackobj->infinite); } - protected function make_choice($choicedata){ + protected function make_choice($choicedata) { $options = unserialize($choicedata->feedback); - return new qtype_ddwtos_choice($choicedata->answer, $options->draggroup, $options->infinite); + return new qtype_ddwtos_choice( + $choicedata->answer, $options->draggroup, $options->infinite); } public function import_from_xml($data, $question, $format, $extra=null) { @@ -113,7 +114,8 @@ class qtype_ddwtos extends qtype_gapselect_base { public function export_to_xml($question, $format, $extra = null) { $output = ''; - $output .= ' ' . $question->options->shuffleanswers . "\n"; + $output .= ' ' . $question->options->shuffleanswers . + "\n"; $output .= $format->write_combined_feedback($question->options); @@ -131,95 +133,4 @@ class qtype_ddwtos extends qtype_gapselect_base { return $output; } - - /* - * Backup the data in the question - * - * This is used in question/backuplib.php - */ - public function backup($bf, $preferences, $question, $level = 6) { - $status = true; - $ddwtos = get_records("question_ddwtos", "questionid", $question, "id"); - - //If there are ddwtos - if ($ddwtos) { - //Iterate over each ddwtos - foreach ($ddwtos as $ddws) { - $status = fwrite ($bf,start_tag("DDWORDSSENTENCES",$level,true)); - //Print oumultiresponse contents - fwrite ($bf,full_tag("SHUFFLEANSWERS",$level+1,false,$ddws->shuffleanswers)); - fwrite ($bf,full_tag("CORRECTFEEDBACK",$level+1,false,$ddws->correctfeedback)); - fwrite ($bf,full_tag("PARTIALLYCORRECTFEEDBACK",$level+1,false,$ddws->partiallycorrectfeedback)); - fwrite ($bf,full_tag("INCORRECTFEEDBACK",$level+1,false,$ddws->incorrectfeedback)); - fwrite ($bf,full_tag("SHOWNUMCORRECT",$level+1,false,$ddws->shownumcorrect)); - $status = fwrite ($bf,end_tag("DDWORDSSENTENCES",$level,true)); - } - - //Now print question_answers - $status = question_backup_answers($bf,$preferences,$question); - } - return $status; - } - - /** - * Restores the data in the question (This is used in question/restorelib.php) - * - */ - public function restore($old_question_id,$new_question_id,$info,$restore) { - $status = true; - - //Get the ddwtos array - $ddwtos = $info['#']['DDWORDSSENTENCES']; - - //Iterate over oumultiresponses - for($i = 0; $i < sizeof($ddwtos); $i++) { - $mul_info = $ddwtos[$i]; - - //Now, build the question_ddwtos record structure - $ddwtos = new stdClass(); - $ddwtos->questionid = $new_question_id; - $ddwtos->shuffleanswers = isset($mul_info['#']['SHUFFLEANSWERS']['0']['#'])?backup_todb($mul_info['#']['SHUFFLEANSWERS']['0']['#']):''; - if (array_key_exists("CORRECTFEEDBACK", $mul_info['#'])) { - $ddwtos->correctfeedback = backup_todb($mul_info['#']['CORRECTFEEDBACK']['0']['#']); - } else { - $ddwtos->correctfeedback = ''; - } - if (array_key_exists("PARTIALLYCORRECTFEEDBACK", $mul_info['#'])) { - $ddwtos->partiallycorrectfeedback = backup_todb($mul_info['#']['PARTIALLYCORRECTFEEDBACK']['0']['#']); - } else { - $ddwtos->partiallycorrectfeedback = ''; - } - if (array_key_exists("INCORRECTFEEDBACK", $mul_info['#'])) { - $ddwtos->incorrectfeedback = backup_todb($mul_info['#']['INCORRECTFEEDBACK']['0']['#']); - } else { - $ddwtos->incorrectfeedback = ''; - } - if (array_key_exists('SHOWNUMCORRECT', $mul_info['#'])) { - $ddwtos->shownumcorrect = backup_todb($mul_info['#']['SHOWNUMCORRECT']['0']['#']); - } else if (array_key_exists('CORRECTRESPONSESFEEDBACK', $mul_info['#'])) { - $ddwtos->shownumcorrect = backup_todb($mul_info['#']['CORRECTRESPONSESFEEDBACK']['0']['#']); - } else { - $ddwtos->shownumcorrect = 0; - } - - $newid = insert_record ("question_ddwtos",$ddwtos); - - //Do some output - if (($i+1) % 50 == 0) { - if (!defined('RESTORE_SILENTLY')) { - echo "."; - if (($i+1) % 1000 == 0) { - echo "
"; - } - } - backup_flush(300); - } - - if (!$newid) { - $status = false; - } - } - return $status; - } - } diff --git a/question/type/ddimageortext/renderer.php b/question/type/ddimageortext/renderer.php index 9c127b6fc27..5e4b772784e 100755 --- a/question/type/ddimageortext/renderer.php +++ b/question/type/ddimageortext/renderer.php @@ -38,11 +38,12 @@ require_once($CFG->dirroot . '/question/type/gapselect/rendererbase.php'); */ class qtype_ddwtos_renderer extends qtype_elements_embedded_in_question_text_renderer { - protected function qtext_classname(){ + protected function qtext_classname() { return 'qtext ddwtos_questionid_for_javascript'; } - protected function post_qtext_elements(question_attempt $qa, question_display_options $options){ + protected function post_qtext_elements(question_attempt $qa, + question_display_options $options) { $result = ''; $question = $qa->get_question(); $dragboxs = ''; @@ -71,7 +72,8 @@ class qtype_ddwtos_renderer extends qtype_elements_embedded_in_question_text_ren return ' ' . $string . ' '; } - protected function embedded_element(question_attempt $qa, $place, question_display_options $options) { + protected function embedded_element(question_attempt $qa, $place, + question_display_options $options) { $question = $qa->get_question(); $group = $question->places[$place]; $boxcontents = $this->dodgy_ie_fix(' '); @@ -94,7 +96,8 @@ class qtype_ddwtos_renderer extends qtype_elements_embedded_in_question_text_ren $response = $qa->get_last_qt_data(); $fieldname = $question->field($place); if (array_key_exists($fieldname, $response)) { - $fraction = (int) ($response[$fieldname] == $question->get_right_choice_for($place)); + $fraction = (int) ($response[$fieldname] == + $question->get_right_choice_for($place)); $attributes['class'] .= ' ' . $this->feedback_class($fraction); $feedbackimage = $this->feedback_image($fraction); } diff --git a/question/type/ddimageortext/script.js b/question/type/ddimageortext/script.js index bf84942f3a7..8e5f2d38980 100755 --- a/question/type/ddimageortext/script.js +++ b/question/type/ddimageortext/script.js @@ -104,7 +104,6 @@ var ddwtos_currentzindex = 10; initPlayer : function(id, sGroup, config) { this.isTarget = false; this.currentPos = YAHOO.util.Dom.getXY(this.getEl()); - }, //Abstract method called after a drag/drop object is clicked and the drag or mousedown time thresholds have beeen met. @@ -178,7 +177,6 @@ var ddwtos_currentzindex = 10; YAHOO.util.Event.onDOMReady(YAHOO.example.DDApp.init, YAHOO.example.DDApp, true); - // Objects/////////////////////////////////////////////////////////////////// var Questions = new Object(); @@ -300,7 +298,9 @@ var ddwtos_currentzindex = 10; var slot = slots[i]; var hiddenElement = document.getElementById(slot.id + '_hidden'); - if (!hiddenElement) continue; + if (!hiddenElement) { + continue; + } // get group var group = getGroupForThis(slot.id); diff --git a/question/type/ddimageortext/simpletest/testquestion.php b/question/type/ddimageortext/simpletest/testquestion.php index 9bce14087fa..a32cfda3375 100755 --- a/question/type/ddimageortext/simpletest/testquestion.php +++ b/question/type/ddimageortext/simpletest/testquestion.php @@ -41,7 +41,8 @@ class qtype_ddwtos_question_test extends UnitTestCase { public function test_get_question_summary() { $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question(); - $this->assertEqual('The [[1]] brown [[2]] jumped over the [[3]] dog.; [[1]] -> {quick / slow}; [[2]] -> {fox / dog}; [[3]] -> {lazy / assiduous}', + $this->assertEqual('The [[1]] brown [[2]] jumped over the [[3]] dog.; ' . + '[[1]] -> {quick / slow}; [[2]] -> {fox / dog}; [[3]] -> {lazy / assiduous}', $dd->get_question_summary()); } @@ -125,7 +126,8 @@ class qtype_ddwtos_question_test extends UnitTestCase { $dd->start_attempt(new question_attempt_step()); $this->assertEqual(array(2, 4), - $dd->get_num_parts_right(array('p1' => '1', 'p2' => '1', 'p3' => '1', 'p4' => '1'))); + $dd->get_num_parts_right(array( + 'p1' => '1', 'p2' => '1', 'p3' => '1', 'p4' => '1'))); } public function test_get_expected_data() { diff --git a/question/type/ddimageortext/simpletest/testquestiontype.php b/question/type/ddimageortext/simpletest/testquestiontype.php index ee8dc7883fc..e87315c6e70 100755 --- a/question/type/ddimageortext/simpletest/testquestiontype.php +++ b/question/type/ddimageortext/simpletest/testquestiontype.php @@ -89,12 +89,18 @@ class qtype_ddwtos_test extends UnitTestCase { test_question_maker::set_standard_combined_feedback_fields($dd->options); $dd->options->answers = array( - (object) array('answer' => 'quick', 'feedback' => 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}'), - (object) array('answer' => 'fox', 'feedback' => 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}'), - (object) array('answer' => 'lazy', 'feedback' => 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"3";s:8:"infinite";i:0;}'), - (object) array('answer' => 'assiduous', 'feedback' => 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"3";s:8:"infinite";i:0;}'), - (object) array('answer' => 'dog', 'feedback' => 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}'), - (object) array('answer' => 'slow', 'feedback' => 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}'), + (object) array('answer' => 'quick', 'feedback' => + 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}'), + (object) array('answer' => 'fox', 'feedback' => + 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}'), + (object) array('answer' => 'lazy', 'feedback' => + 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"3";s:8:"infinite";i:0;}'), + (object) array('answer' => 'assiduous', 'feedback' => + 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"3";s:8:"infinite";i:0;}'), + (object) array('answer' => 'dog', 'feedback' => + 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"2";s:8:"infinite";i:0;}'), + (object) array('answer' => 'slow', 'feedback' => + 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";i:0;}'), ); return $dd; @@ -209,10 +215,14 @@ class qtype_ddwtos_test extends UnitTestCase { $expectedq->penalty = 0.3333333; $expectedq->shuffleanswers = 1; - $expectedq->correctfeedback = array('text' => '

Your answer is correct.

', 'format' => FORMAT_MOODLE, 'files' => array()); - $expectedq->partiallycorrectfeedback = array('text' => '

Your answer is partially correct.

', 'format' => FORMAT_MOODLE, 'files' => array()); + $expectedq->correctfeedback = array('text' => '

Your answer is correct.

', + 'format' => FORMAT_MOODLE, 'files' => array()); + $expectedq->partiallycorrectfeedback = array( + 'text' => '

Your answer is partially correct.

', + 'format' => FORMAT_MOODLE, 'files' => array()); $expectedq->shownumcorrect = true; - $expectedq->incorrectfeedback = array('text' => '

Your answer is incorrect.

', 'format' => FORMAT_MOODLE, 'files' => array()); + $expectedq->incorrectfeedback = array('text' => '

Your answer is incorrect.

', + 'format' => FORMAT_MOODLE, 'files' => array()); $expectedq->choices = array( array('answer' => 'Alpha', 'choicegroup' => 1, 'infinite' => false), @@ -222,7 +232,8 @@ class qtype_ddwtos_test extends UnitTestCase { $expectedq->hint = array( array('text' => 'Try again.', 'format' => FORMAT_MOODLE, 'files' => array()), - array('text' => 'These are the first three letters of the Greek alphabet.', 'format' => FORMAT_MOODLE, 'files' => array())); + array('text' => 'These are the first three letters of the Greek alphabet.', + 'format' => FORMAT_MOODLE, 'files' => array())); $expectedq->hintshownumcorrect = array(true, true); $expectedq->hintclearwrong = array(false, true); @@ -235,11 +246,19 @@ class qtype_ddwtos_test extends UnitTestCase { QDandD1 Base definition - <p>Drag and drop the words from the list below to fill the blank spaces and correctly complete the sentence.</p> <p>At 25°C all aqueous basic solutions have [[1]] ion concentrations less than [[8]]<br />mol litre<sup>-1</sup> and pH values [[9]] than [[6]].</p> <!--DONOTCLEAN--> + <p>Drag and drop the words from the list below to fill the blank spaces ' . + 'and correctly complete the sentence.</p> <p>At 25°C all aqueous basic ' . + 'solutions have [[1]] ion concentrations less than [[8]]<br />mol ' . + 'litre<sup>-1</sup> and pH values [[9]] than [[6]].</p> ' . + '<!--DONOTCLEAN--> - <p>At 25 &#xB0;C all aqueous basic solutions have hydrogen ion concentrations less than 10<sup>&#x2212;7</sup> mol litre<sup>&#x2212;1</sup> and pH values greater than 7.</p> <p>See Section 9 of S103 <em class="italic">Discovering Science</em> Block 8.</p> + <p>At 25 &#xB0;C all aqueous basic solutions have hydrogen ion ' . + 'concentrations less than 10<sup>&#x2212;7</sup> mol ' . + 'litre<sup>&#x2212;1</sup> and pH values greater than 7.</p> ' . + '<p>See Section 9 of S103 <em class="italic">Discovering ' . + 'Science</em> Block 8.</p> 1 0.33 @@ -332,7 +351,8 @@ class qtype_ddwtos_test extends UnitTestCase { 1 0 - You may wish to read Section 9 of <em class="italic">Discovering Science</em> Block 8. + You may wish to read Section 9 of <em ' . + 'class="italic">Discovering Science</em> Block 8. @@ -352,36 +372,57 @@ class qtype_ddwtos_test extends UnitTestCase { $expectedq = new stdClass(); $expectedq->qtype = 'ddwtos'; $expectedq->name = 'QDandD1 Base definition'; - $expectedq->questiontext = '

Drag and drop the words from the list below to fill the blank spaces and correctly complete the sentence.

At 25°C all aqueous basic solutions have [[1]] ion concentrations less than [[8]]
mol litre-1 and pH values [[9]] than [[6]].

'; + $expectedq->questiontext = '

Drag and drop the words from the list below ' . + 'to fill the blank spaces and correctly complete the sentence.

' . + '

At 25°C all aqueous basic solutions have [[1]] ion concentrations ' . + 'less than [[8]]
mol litre-1 and pH values [[9]] than [[6]].

' . + ''; $expectedq->questiontextformat = FORMAT_HTML; - $expectedq->generalfeedback = '

At 25 °C all aqueous basic solutions have hydrogen ion concentrations less than 10−7 mol litre−1 and pH values greater than 7.

See Section 9 of S103 Discovering Science Block 8.

'; + $expectedq->generalfeedback = '

At 25 °C all aqueous basic solutions ' . + 'have hydrogen ion concentrations less than 10−7 ' . + 'mol litre−1 and pH values greater than 7.

See ' . + 'Section 9 of S103 Discovering Science Block 8.

'; $expectedq->defaultmark = 1; $expectedq->length = 1; $expectedq->penalty = 0.3333333; $expectedq->shuffleanswers = 0; - $expectedq->correctfeedback = array('text' => 'Your answer is correct.', 'format' => FORMAT_MOODLE, 'files' => array()); - $expectedq->partiallycorrectfeedback = array('text' => 'Your answer is partially correct.', 'format' => FORMAT_MOODLE, 'files' => array()); + $expectedq->correctfeedback = array('text' => 'Your answer is correct.', + 'format' => FORMAT_MOODLE, 'files' => array()); + $expectedq->partiallycorrectfeedback = array( + 'text' => 'Your answer is partially correct.', + 'format' => FORMAT_MOODLE, 'files' => array()); $expectedq->shownumcorrect = true; - $expectedq->incorrectfeedback = array('text' => 'Your answer is incorrect.', 'format' => FORMAT_MOODLE, 'files' => array()); + $expectedq->incorrectfeedback = array('text' => 'Your answer is incorrect.', + 'format' => FORMAT_MOODLE, 'files' => array()); $expectedq->choices = array( - array('answer' => array('text' => 'hydrogen', 'format' => FORMAT_MOODLE, 'files' => array()), 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => 'positive', 'format' => FORMAT_MOODLE, 'files' => array()), 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => 'hydroxide', 'format' => FORMAT_MOODLE, 'files' => array()), 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => 'negative', 'format' => FORMAT_MOODLE, 'files' => array()), 'choicegroup' => 1, 'infinite' => false), - array('answer' => array('text' => '107', 'format' => FORMAT_MOODLE, 'files' => array()), 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => '7', 'format' => FORMAT_MOODLE, 'files' => array()), 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => '1', 'format' => FORMAT_MOODLE, 'files' => array()), 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => '10-7', 'format' => FORMAT_MOODLE, 'files' => array()), 'choicegroup' => 2, 'infinite' => false), - array('answer' => array('text' => 'greater', 'format' => FORMAT_MOODLE, 'files' => array()), 'choicegroup' => 3, 'infinite' => false), - array('answer' => array('text' => 'less', 'format' => FORMAT_MOODLE, 'files' => array()), 'choicegroup' => 3, 'infinite' => false), + array('answer' => array('text' => 'hydrogen', 'format' => FORMAT_MOODLE, + 'files' => array()), 'choicegroup' => 1, 'infinite' => false), + array('answer' => array('text' => 'positive', 'format' => FORMAT_MOODLE, + 'files' => array()), 'choicegroup' => 1, 'infinite' => false), + array('answer' => array('text' => 'hydroxide', 'format' => FORMAT_MOODLE, + 'files' => array()), 'choicegroup' => 1, 'infinite' => false), + array('answer' => array('text' => 'negative', 'format' => FORMAT_MOODLE, + 'files' => array()), 'choicegroup' => 1, 'infinite' => false), + array('answer' => array('text' => '107', 'format' => FORMAT_MOODLE, + 'files' => array()), 'choicegroup' => 2, 'infinite' => false), + array('answer' => array('text' => '7', 'format' => FORMAT_MOODLE, + 'files' => array()), 'choicegroup' => 2, 'infinite' => false), + array('answer' => array('text' => '1', 'format' => FORMAT_MOODLE, + 'files' => array()), 'choicegroup' => 2, 'infinite' => false), + array('answer' => array('text' => '10-7', 'format' => FORMAT_MOODLE, + 'files' => array()), 'choicegroup' => 2, 'infinite' => false), + array('answer' => array('text' => 'greater', 'format' => FORMAT_MOODLE, + 'files' => array()), 'choicegroup' => 3, 'infinite' => false), + array('answer' => array('text' => 'less', 'format' => FORMAT_MOODLE, + 'files' => array()), 'choicegroup' => 3, 'infinite' => false), ); - $expectedq->hint = array( - array('text' => 'You may wish to read Section 9 of Discovering Science Block 8.', + $expectedq->hint = array(array('text' => 'You may wish to read Section 9 of ' . + 'Discovering Science Block 8.', 'format' => FORMAT_HTML, 'files' => array()), - array('text' => 'Any incorrect choices will be removed before your final try.', + array('text' => 'Any incorrect choices will be removed before your final try.', 'format' => FORMAT_HTML, 'files' => array()), ); $expectedq->hintshownumcorrect = array(true, true); @@ -416,14 +457,22 @@ class qtype_ddwtos_test extends UnitTestCase { $qdata->options->incorrectfeedbackformat = FORMAT_MOODLE; $qdata->options->answers = array( - 13 => new question_answer(13, 'Alpha', 0, 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:0;}', FORMAT_MOODLE), - 14 => new question_answer(14, 'Beta', 0, 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:0;}', FORMAT_MOODLE), - 15 => new question_answer(15, 'Gamma', 0, 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:1;}', FORMAT_MOODLE), + 13 => new question_answer(13, 'Alpha', 0, + 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:0;}', + FORMAT_MOODLE), + 14 => new question_answer(14, 'Beta', 0, + 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:0;}', + FORMAT_MOODLE), + 15 => new question_answer(15, 'Gamma', 0, + 'O:8:"stdClass":2:{s:9:"draggroup";s:1:"1";s:8:"infinite";b:1;}', + FORMAT_MOODLE), ); $qdata->hints = array( 1 => new question_hint_with_parts(1, 'Try again.', FORMAT_MOODLE, true, false), - 2 => new question_hint_with_parts(2, 'These are the first three letters of the Greek alphabet.', FORMAT_MOODLE, true, true), + 2 => new question_hint_with_parts(2, + 'These are the first three letters of the Greek alphabet.', + FORMAT_MOODLE, true, true), ); $exporter = new qformat_xml(); diff --git a/question/type/ddimageortext/simpletest/testwalkthrough.php b/question/type/ddimageortext/simpletest/testwalkthrough.php index 38ead171d94..79421f3d88d 100755 --- a/question/type/ddimageortext/simpletest/testwalkthrough.php +++ b/question/type/ddimageortext/simpletest/testwalkthrough.php @@ -39,7 +39,8 @@ require_once($CFG->dirroot . '/question/type/ddwtos/simpletest/helper.php'); */ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { - protected function get_contains_drop_box_expectation($place, $group, $readonly, $stateclass = '0') { + protected function get_contains_drop_box_expectation($place, $group, $readonly, + $stateclass = '0') { $qa = $this->quba->get_question_attempt($this->slot); $expectedattrs = array( @@ -77,9 +78,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_drop_box_expectation('p1', 1, false), $this->get_contains_drop_box_expectation('p2', 2, false), $this->get_contains_drop_box_expectation('p3', 3, false), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p1', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p2', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p3', '0'), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation(), $this->get_tries_remaining_expectation(3), @@ -95,9 +99,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_drop_box_expectation('p1', 1, false), $this->get_contains_drop_box_expectation('p2', 2, false), $this->get_contains_drop_box_expectation('p3', 3, false), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '2'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '2'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '2'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p1', '2'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p2', '2'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p3', '2'), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_correctness_expectation(), $this->get_does_not_contain_feedback_expectation(), @@ -117,7 +124,8 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_submit_button_expectation(false), $this->get_contains_try_again_button_expectation(true), $this->get_does_not_contain_correctness_expectation(), - new PatternExpectation('/' . preg_quote(get_string('notcomplete', 'qbehaviour_interactive')) . '/'), + new PatternExpectation('/' . + preg_quote(get_string('notcomplete', 'qbehaviour_interactive')) . '/'), $this->get_contains_hint_expectation('This is the first hint')); // Do try again. @@ -130,9 +138,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_drop_box_expectation('p1', 1, false), $this->get_contains_drop_box_expectation('p2', 2, false), $this->get_contains_drop_box_expectation('p3', 3, false), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '2'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '2'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '2'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p1', '2'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p2', '2'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p3', '2'), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_correctness_expectation(), $this->get_does_not_contain_feedback_expectation(), @@ -175,9 +186,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_drop_box_expectation('p1', 1, false), $this->get_contains_drop_box_expectation('p2', 2, false), $this->get_contains_drop_box_expectation('p3', 3, false), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p1', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p2', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p3', '0'), $this->get_does_not_contain_feedback_expectation()); // Save a partial answer. @@ -190,9 +204,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_drop_box_expectation('p1', 1, false), $this->get_contains_drop_box_expectation('p2', 2, false), $this->get_contains_drop_box_expectation('p3', 3, false), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '1'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '2'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p1', '1'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p2', '2'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p3', '0'), $this->get_does_not_contain_correctness_expectation(), $this->get_does_not_contain_feedback_expectation()); @@ -206,9 +223,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_drop_box_expectation('p1', 1, false), $this->get_contains_drop_box_expectation('p2', 2, false), $this->get_contains_drop_box_expectation('p3', 3, false), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '1'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '1'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '1'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p1', '1'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p2', '1'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p3', '1'), $this->get_does_not_contain_correctness_expectation(), $this->get_does_not_contain_feedback_expectation()); @@ -249,9 +269,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_drop_box_expectation('p1', 1, false), $this->get_contains_drop_box_expectation('p2', 2, false), $this->get_contains_drop_box_expectation('p3', 3, false), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p1', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p2', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p3', '0'), $this->get_does_not_contain_correctness_expectation(), $this->get_does_not_contain_feedback_expectation()); $this->check_step_count(1); @@ -266,9 +289,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_drop_box_expectation('p1', 1, false), $this->get_contains_drop_box_expectation('p2', 2, false), $this->get_contains_drop_box_expectation('p3', 3, false), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p1', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p2', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p3', '0'), $this->get_does_not_contain_correctness_expectation(), $this->get_does_not_contain_feedback_expectation()); $this->check_step_count(1); @@ -299,9 +325,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_drop_box_expectation('p1', 1, false), $this->get_contains_drop_box_expectation('p2', 2, false), $this->get_contains_drop_box_expectation('p3', 3, false), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p1', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p2', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p3', '0'), $this->get_does_not_contain_correctness_expectation(), $this->get_does_not_contain_feedback_expectation()); @@ -315,9 +344,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_drop_box_expectation('p1', 1, false), $this->get_contains_drop_box_expectation('p2', 2, false), $this->get_contains_drop_box_expectation('p3', 3, false), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '1'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p1', '1'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p2', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p3', '0'), $this->get_does_not_contain_correctness_expectation(), $this->get_does_not_contain_feedback_expectation()); @@ -339,8 +371,10 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { // Create a drag-and-drop question. $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question(); $dd->hints = array( - new question_hint_with_parts(1, 'This is the first hint.', FORMAT_MOODLE, true, true), - new question_hint_with_parts(2, 'This is the second hint.', FORMAT_MOODLE, true, true), + new question_hint_with_parts(1, 'This is the first hint.', + FORMAT_MOODLE, true, true), + new question_hint_with_parts(2, 'This is the second hint.', + FORMAT_MOODLE, true, true), ); $dd->shufflechoices = false; $this->start_attempt_at_question($dd, 'interactive', 9); @@ -354,9 +388,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_drop_box_expectation('p1', 1, false), $this->get_contains_drop_box_expectation('p2', 2, false), $this->get_contains_drop_box_expectation('p3', 3, false), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p1', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p2', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p3', '0'), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation(), $this->get_tries_remaining_expectation(3), @@ -376,18 +413,23 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_submit_button_expectation(false), $this->get_contains_try_again_button_expectation(true), $this->get_does_not_contain_correctness_expectation(), - new PatternExpectation('/' . preg_quote(get_string('notcomplete', 'qbehaviour_interactive')) . '/'), + new PatternExpectation('/' . + preg_quote(get_string('notcomplete', 'qbehaviour_interactive')) . '/'), $this->get_contains_hint_expectation('This is the first hint'), $this->get_contains_num_parts_correct(2), $this->get_contains_standard_partiallycorrect_combined_feedback_expectation(), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '1'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '1'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0')); + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p1', '1'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p2', '1'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p3', '0')); // Check that extract responses will return the reset data. $prefix = $this->quba->get_field_prefix($this->slot); $this->assertEqual(array('p1' => '1', 'p2' => '1'), - $this->quba->extract_responses($this->slot, array($prefix . 'p1' => '1', $prefix . 'p2' => '1', '-tryagain' => 1))); + $this->quba->extract_responses($this->slot, + array($prefix . 'p1' => '1', $prefix . 'p2' => '1', '-tryagain' => 1))); // Do try again. $this->process_submission(array('p1' => '1', 'p2' => '1', '-tryagain' => 1)); @@ -399,9 +441,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_drop_box_expectation('p1', 1, false), $this->get_contains_drop_box_expectation('p2', 2, false), $this->get_contains_drop_box_expectation('p3', 3, false), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '1'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '1'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p1', '1'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p2', '1'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p3', '0'), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_try_again_button_expectation(), $this->get_does_not_contain_correctness_expectation(), @@ -422,13 +467,17 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_submit_button_expectation(false), $this->get_contains_try_again_button_expectation(true), $this->get_does_not_contain_correctness_expectation(), - new PatternExpectation('/' . preg_quote(get_string('notcomplete', 'qbehaviour_interactive')) . '/'), + new PatternExpectation('/' . + preg_quote(get_string('notcomplete', 'qbehaviour_interactive')) . '/'), $this->get_contains_hint_expectation('This is the second hint'), $this->get_contains_num_parts_correct(2), $this->get_contains_standard_partiallycorrect_combined_feedback_expectation(), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '1'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '1')); + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p1', '1'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p2', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p3', '1')); // Do try again. $this->process_submission(array('p1' => '1', 'p3' => '1', '-tryagain' => 1)); @@ -440,9 +489,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_drop_box_expectation('p1', 1, false), $this->get_contains_drop_box_expectation('p2', 2, false), $this->get_contains_drop_box_expectation('p3', 3, false), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '1'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '1'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p1', '1'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p2', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p3', '1'), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_try_again_button_expectation(), $this->get_does_not_contain_correctness_expectation(), @@ -466,9 +518,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_no_hint_visible_expectation(), $this->get_does_not_contain_num_parts_correct(), $this->get_contains_standard_correct_combined_feedback_expectation(), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '1'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '1'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '1')); + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p1', '1'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p2', '1'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p3', '1')); } public function test_interactive_correct_no_submit() { @@ -476,8 +531,10 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { // Create a drag-and-drop question. $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question(); $dd->hints = array( - new question_hint_with_parts(23, 'This is the first hint.', FORMAT_MOODLE, false, false), - new question_hint_with_parts(24, 'This is the second hint.', FORMAT_MOODLE, true, true), + new question_hint_with_parts(23, 'This is the first hint.', + FORMAT_MOODLE, false, false), + new question_hint_with_parts(24, 'This is the second hint.', + FORMAT_MOODLE, true, true), ); $dd->shufflechoices = false; $this->start_attempt_at_question($dd, 'interactive', 3); @@ -489,9 +546,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_drop_box_expectation('p1', 1, false), $this->get_contains_drop_box_expectation('p2', 2, false), $this->get_contains_drop_box_expectation('p3', 3, false), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p1', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p2', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p3', '0'), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation(), $this->get_tries_remaining_expectation(3), @@ -527,8 +587,10 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { // Create a drag-and-drop question. $dd = qtype_ddwtos_test_helper::make_a_ddwtos_question(); $dd->hints = array( - new question_hint_with_parts(23, 'This is the first hint.', FORMAT_MOODLE, false, false), - new question_hint_with_parts(24, 'This is the second hint.', FORMAT_MOODLE, true, true), + new question_hint_with_parts(23, 'This is the first hint.', + FORMAT_MOODLE, false, false), + new question_hint_with_parts(24, 'This is the second hint.', + FORMAT_MOODLE, true, true), ); $dd->shufflechoices = false; $this->start_attempt_at_question($dd, 'interactive', 3); @@ -540,9 +602,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_drop_box_expectation('p1', 1, false), $this->get_contains_drop_box_expectation('p2', 2, false), $this->get_contains_drop_box_expectation('p3', 3, false), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p1', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p2', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p3', '0'), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation(), $this->get_tries_remaining_expectation(3), @@ -592,9 +657,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_drop_box_expectation('p1', 1, false), $this->get_contains_drop_box_expectation('p2', 2, false), $this->get_contains_drop_box_expectation('p3', 3, false), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p1', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p2', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p3', '0'), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation(), $this->get_tries_remaining_expectation(3), @@ -625,9 +693,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_drop_box_expectation('p1', 1, false), $this->get_contains_drop_box_expectation('p2', 2, false), $this->get_contains_drop_box_expectation('p3', 3, false), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p1', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p2', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p3', '0'), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation(), $this->get_tries_remaining_expectation(2), @@ -647,9 +718,12 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_drop_box_expectation('p1', 1, false), $this->get_contains_drop_box_expectation('p2', 2, false), $this->get_contains_drop_box_expectation('p3', 3, false), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p1', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p2', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p3', '0'), $this->get_does_not_contain_feedback_expectation()); // Save a partial answer. @@ -662,9 +736,15 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_drop_box_expectation('p1', 1, false), $this->get_contains_drop_box_expectation('p2', 2, false), $this->get_contains_drop_box_expectation('p3', 3, false), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p1', $dd->get_right_choice_for(1)), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p2', $dd->get_right_choice_for(2)), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'p3', $dd->get_right_choice_for(3)), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p1', + $dd->get_right_choice_for(1)), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p2', + $dd->get_right_choice_for(2)), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'p3', + $dd->get_right_choice_for(3)), $this->get_does_not_contain_correctness_expectation(), $this->get_does_not_contain_feedback_expectation()); @@ -681,6 +761,7 @@ class qtype_ddwtos_walkthrough_test extends qbehaviour_walkthrough_test_base { $this->get_contains_drop_box_expectation('p2', 2, true, 'correct'), $this->get_contains_drop_box_expectation('p3', 3, true, 'correct'), $this->get_contains_correct_expectation(), - new PatternExpectation('/' . preg_quote('The [quick] brown [fox] jumped over the [lazy] dog.') . '/')); + new PatternExpectation('/' . + preg_quote('The [quick] brown [fox] jumped over the [lazy] dog.') . '/')); } } -- 2.11.4.GIT