diff --git a/question/behaviour/adaptive/renderer.php b/question/behaviour/adaptive/renderer.php index 2eb8793edb5..5a5f80c2989 100644 --- a/question/behaviour/adaptive/renderer.php +++ b/question/behaviour/adaptive/renderer.php @@ -102,7 +102,8 @@ class qbehaviour_adaptive_renderer extends qbehaviour_renderer { // print info about new penalty // penalty is relevant only if the answer is not correct and further attempts are possible if (!$qa->get_state()->is_finished()) { - $output .= ' ' . get_string('gradingdetailspenalty', 'qbehaviour_adaptive', $qa->get_question()->penalty); + $output .= ' ' . get_string('gradingdetailspenalty', 'qbehaviour_adaptive', + $qa->get_question()->penalty); } return $output; diff --git a/question/behaviour/adaptive/simpletest/testwalkthrough.php b/question/behaviour/adaptive/simpletest/testwalkthrough.php index bcd7b5e554b..b331d8f0f48 100644 --- a/question/behaviour/adaptive/simpletest/testwalkthrough.php +++ b/question/behaviour/adaptive/simpletest/testwalkthrough.php @@ -233,7 +233,6 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b $this->get_contains_partcorrect_expectation(), $this->get_does_not_contain_validation_error_expectation()); - // Now submit blank again. $this->process_submission(array('-submit' => 1, 'answer' => '')); diff --git a/question/behaviour/behaviourbase.php b/question/behaviour/behaviourbase.php index 153038d9db4..ff098d4bc16 100644 --- a/question/behaviour/behaviourbase.php +++ b/question/behaviour/behaviourbase.php @@ -135,7 +135,8 @@ abstract class question_behaviour { */ public function check_file_access($options, $component, $filearea, $args, $forcedownload) { $this->adjust_display_options($options); - return $this->question->check_file_access($this->qa, $options, $component, $filearea, $args, $forcedownload); + return $this->question->check_file_access($this->qa, $options, $component, + $filearea, $args, $forcedownload); } /** @@ -301,7 +302,8 @@ abstract class question_behaviour { /** * @return array subpartid => object with fields - * ->responseclassid matches one of the values returned from quetion_type::get_possible_responses. + * ->responseclassid matches one of the values returned from + * quetion_type::get_possible_responses. * ->response the actual response the student gave to this part, as a string. * ->fraction the credit awarded for this subpart, may be null. * returns an empty array if no analysis is possible. @@ -409,8 +411,8 @@ abstract class question_behaviour { * for examples. * * @param question_attempt_pending_step $pendingstep a partially initialised step - * containing all the information about the action that is being peformed. - * This information can be accessed using {@link question_attempt_step::get_behaviour_var()}. + * containing all the information about the action that is being peformed. This + * information can be accessed using {@link question_attempt_step::get_behaviour_var()}. * @return bool either {@link question_attempt::KEEP} or {@link question_attempt::DISCARD} */ public abstract function process_action(question_attempt_pending_step $pendingstep); @@ -432,7 +434,8 @@ abstract class question_behaviour { } if ($pendingstep->has_behaviour_var('mark')) { - $fraction = $pendingstep->get_behaviour_var('mark') / $pendingstep->get_behaviour_var('maxmark'); + $fraction = $pendingstep->get_behaviour_var('mark') / + $pendingstep->get_behaviour_var('maxmark'); if ($pendingstep->get_behaviour_var('mark') === '') { $fraction = null; } else if ($fraction > 1 || $fraction < $this->qa->get_min_fraction()) { @@ -442,8 +445,8 @@ abstract class question_behaviour { $pendingstep->set_fraction($fraction); } - $pendingstep->set_state($this->qa->get_state()-> - corresponding_commented_state($pendingstep->get_fraction())); + $pendingstep->set_state($this->qa->get_state()->corresponding_commented_state( + $pendingstep->get_fraction())); return question_attempt::KEEP; } diff --git a/question/behaviour/deferredcbm/behaviour.php b/question/behaviour/deferredcbm/behaviour.php index 1a852bc173e..8947c784e10 100644 --- a/question/behaviour/deferredcbm/behaviour.php +++ b/question/behaviour/deferredcbm/behaviour.php @@ -85,11 +85,13 @@ class qbehaviour_deferredcbm extends qbehaviour_deferredfeedback { protected function is_same_response($pendingstep) { return parent::is_same_response($pendingstep) && - $this->qa->get_last_behaviour_var('certainty') == $pendingstep->get_behaviour_var('certainty'); + $this->qa->get_last_behaviour_var('certainty') == + $pendingstep->get_behaviour_var('certainty'); } protected function is_complete_response($pendingstep) { - return parent::is_complete_response($pendingstep) && $pendingstep->has_behaviour_var('certainty'); + return parent::is_complete_response($pendingstep) && + $pendingstep->has_behaviour_var('certainty'); } public function process_finish(question_attempt_pending_step $pendingstep) { diff --git a/question/behaviour/deferredcbm/renderer.php b/question/behaviour/deferredcbm/renderer.php index 72b1ca8117f..582a0e52c1b 100644 --- a/question/behaviour/deferredcbm/renderer.php +++ b/question/behaviour/deferredcbm/renderer.php @@ -75,21 +75,25 @@ class qbehaviour_deferredcbm_renderer extends qbehaviour_renderer { return ''; } - if ($qa->get_state() == question_state::$gaveup || $qa->get_state() == question_state::$mangaveup) { + if ($qa->get_state() == question_state::$gaveup || $qa->get_state() == + question_state::$mangaveup) { return ''; } $feedback = ''; - if (!$qa->get_last_behaviour_var('certainty') && $qa->get_last_behaviour_var('_assumedcertainty')) { - $feedback .= html_writer::tag('p', get_string('assumingcertainty', 'qbehaviour_deferredcbm', + if (!$qa->get_last_behaviour_var('certainty') && + $qa->get_last_behaviour_var('_assumedcertainty')) { + $feedback .= html_writer::tag('p', + get_string('assumingcertainty', 'qbehaviour_deferredcbm', question_cbm::get_string($qa->get_last_behaviour_var('_assumedcertainty')))); } if ($options->marks >= question_display_options::MARK_AND_MAX) { - $a->rawmark = format_float( - $qa->get_last_behaviour_var('_rawfraction') * $qa->get_max_mark(), $options->markdp); + $a->rawmark = format_float($qa->get_last_behaviour_var('_rawfraction') * + $qa->get_max_mark(), $options->markdp); $a->mark = $qa->format_mark($options->markdp); - $feedback .= html_writer::tag('p', get_string('markadjustment', 'qbehaviour_deferredcbm', $a)); + $feedback .= html_writer::tag('p', + get_string('markadjustment', 'qbehaviour_deferredcbm', $a)); } return $feedback; diff --git a/question/behaviour/deferredcbm/simpletest/testwalkthrough.php b/question/behaviour/deferredcbm/simpletest/testwalkthrough.php index da3a878bab4..b321053b316 100644 --- a/question/behaviour/deferredcbm/simpletest/testwalkthrough.php +++ b/question/behaviour/deferredcbm/simpletest/testwalkthrough.php @@ -100,7 +100,8 @@ class qbehaviour_deferredcbm_walkthrough_test extends qbehaviour_walkthrough_tes // Verify. $this->check_current_state(question_state::$mangrpartial); $this->check_current_mark(1); - $this->check_current_output(new PatternExpectation('/' . preg_quote('Not good enough!') . '/')); + $this->check_current_output(new PatternExpectation('/' . + preg_quote('Not good enough!') . '/')); // Now change the correct answer to the question, and regrade. $tf->rightanswer = false; @@ -145,7 +146,8 @@ class qbehaviour_deferredcbm_walkthrough_test extends qbehaviour_walkthrough_tes $this->check_current_mark(0.6666667); $this->check_current_output($this->get_contains_correct_expectation(), $this->get_contains_cbm_radio_expectation(1, false, true)); - $this->assertEqual(get_string('true', 'qtype_truefalse') . ' [' . question_cbm::get_string(1) . ']', + $this->assertEqual(get_string('true', 'qtype_truefalse') . ' [' . + question_cbm::get_string(1) . ']', $this->quba->get_response_summary($this->slot)); } @@ -173,8 +175,10 @@ class qbehaviour_deferredcbm_walkthrough_test extends qbehaviour_walkthrough_tes $this->check_current_mark(0.6666667); $this->check_current_output($this->get_contains_correct_expectation(), $this->get_contains_cbm_radio_expectation(1, false, false), - new PatternExpectation('/' . preg_quote(get_string('assumingcertainty', 'qbehaviour_deferredcbm', - question_cbm::get_string($qa->get_last_behaviour_var('_assumedcertainty')))) . '/')); + new PatternExpectation('/' . preg_quote( + get_string('assumingcertainty', 'qbehaviour_deferredcbm', + question_cbm::get_string( + $qa->get_last_behaviour_var('_assumedcertainty')))) . '/')); $this->assertEqual(get_string('true', 'qtype_truefalse'), $this->quba->get_response_summary($this->slot)); } diff --git a/question/behaviour/immediatecbm/behaviour.php b/question/behaviour/immediatecbm/behaviour.php index 46aead66619..febba7e3f6e 100644 --- a/question/behaviour/immediatecbm/behaviour.php +++ b/question/behaviour/immediatecbm/behaviour.php @@ -83,11 +83,13 @@ class qbehaviour_immediatecbm extends qbehaviour_immediatefeedback { protected function is_same_response($pendingstep) { return parent::is_same_response($pendingstep) && - $this->qa->get_last_behaviour_var('certainty') == $pendingstep->get_behaviour_var('certainty'); + $this->qa->get_last_behaviour_var('certainty') == + $pendingstep->get_behaviour_var('certainty'); } protected function is_complete_response($pendingstep) { - return parent::is_complete_response($pendingstep) && $pendingstep->has_behaviour_var('certainty'); + return parent::is_complete_response($pendingstep) && + $pendingstep->has_behaviour_var('certainty'); } public function process_submit(question_attempt_pending_step $pendingstep) { @@ -132,9 +134,9 @@ class qbehaviour_immediatecbm extends qbehaviour_immediatefeedback { $pendingstep->set_behaviour_var('_rawfraction', $fraction); $pendingstep->set_fraction(question_cbm::adjust_fraction($fraction, $certainty)); $pendingstep->set_state($state); - $pendingstep->set_new_response_summary( - question_cbm::summary_with_certainty( - $this->question->summarise_response($response), $responsesstep->get_behaviour_var('certainty'))); + $pendingstep->set_new_response_summary(question_cbm::summary_with_certainty( + $this->question->summarise_response($response), + $responsesstep->get_behaviour_var('certainty'))); } return question_attempt::KEEP; } diff --git a/question/behaviour/immediatecbm/renderer.php b/question/behaviour/immediatecbm/renderer.php index 8512faceb3e..eef27e9504e 100644 --- a/question/behaviour/immediatecbm/renderer.php +++ b/question/behaviour/immediatecbm/renderer.php @@ -40,7 +40,8 @@ require_once(dirname(__FILE__) . '/../deferredcbm/renderer.php'); class qbehaviour_immediatecbm_renderer extends qbehaviour_deferredcbm_renderer { public function controls(question_attempt $qa, question_display_options $options) { $output = parent::controls($qa, $options); - if ($qa->get_state() == question_state::$invalid && !$qa->get_last_step()->has_behaviour_var('certainty')) { + if ($qa->get_state() == question_state::$invalid && + !$qa->get_last_step()->has_behaviour_var('certainty')) { $output .= html_writer::tag('div', get_string('pleaseselectacertainty', 'qbehaviour_immediatecbm'), array('class' => 'validationerror')); diff --git a/question/behaviour/immediatecbm/simpletest/testwalkthrough.php b/question/behaviour/immediatecbm/simpletest/testwalkthrough.php index 79a3df7edb7..560c30a5a6d 100644 --- a/question/behaviour/immediatecbm/simpletest/testwalkthrough.php +++ b/question/behaviour/immediatecbm/simpletest/testwalkthrough.php @@ -79,7 +79,8 @@ class qbehaviour_immediatecbm_walkthrough_test extends qbehaviour_walkthrough_te $this->get_does_not_contain_feedback_expectation()); // Submit the right answer. - $this->process_submission(array('answer' => $rightindex, '-certainty' => 2, '-submit' => 1)); + $this->process_submission( + array('answer' => $rightindex, '-certainty' => 2, '-submit' => 1)); // Verify. $this->check_current_state(question_state::$gradedright); diff --git a/question/behaviour/immediatefeedback/behaviour.php b/question/behaviour/immediatefeedback/behaviour.php index af345afe1ec..b45011c9189 100644 --- a/question/behaviour/immediatefeedback/behaviour.php +++ b/question/behaviour/immediatefeedback/behaviour.php @@ -126,7 +126,8 @@ class qbehaviour_immediatefeedback extends question_behaviour_with_save { public function process_save(question_attempt_pending_step $pendingstep) { $status = parent::process_save($pendingstep); - if ($status == question_attempt::KEEP && $pendingstep->get_state() == question_state::$complete) { + if ($status == question_attempt::KEEP && + $pendingstep->get_state() == question_state::$complete) { $pendingstep->set_state(question_state::$todo); } return $status; diff --git a/question/behaviour/informationitem/simpletest/testwalkthrough.php b/question/behaviour/informationitem/simpletest/testwalkthrough.php index 6b7710f2aee..d3cf3fb8199 100644 --- a/question/behaviour/informationitem/simpletest/testwalkthrough.php +++ b/question/behaviour/informationitem/simpletest/testwalkthrough.php @@ -59,7 +59,8 @@ class qbehaviour_informationitem_walkthrough_test extends qbehaviour_walkthrough $this->check_current_state(question_state::$complete); $this->check_current_mark(null); $this->check_current_output($this->get_does_not_contain_correctness_expectation(), - new NoPatternExpectation('/type=\"hidden\"[^>]*name=\"[^"]*seen\"|name=\"[^"]*seen\"[^>]*type=\"hidden\"/'), + new NoPatternExpectation( + '/type=\"hidden\"[^>]*name=\"[^"]*seen\"|name=\"[^"]*seen\"[^>]*type=\"hidden\"/'), $this->get_does_not_contain_feedback_expectation()); // Finish the attempt. diff --git a/question/behaviour/interactive/behaviour.php b/question/behaviour/interactive/behaviour.php index 04ad8be6126..bd1c5b1e85a 100644 --- a/question/behaviour/interactive/behaviour.php +++ b/question/behaviour/interactive/behaviour.php @@ -66,8 +66,8 @@ class qbehaviour_interactive extends question_behaviour_with_save { */ protected function is_try_again_state() { $laststep = $this->qa->get_last_step(); - return $this->qa->get_state()->is_active() && - $laststep->has_behaviour_var('submit') && $laststep->has_behaviour_var('_triesleft'); + return $this->qa->get_state()->is_active() && $laststep->has_behaviour_var('submit') && + $laststep->has_behaviour_var('_triesleft'); } public function adjust_display_options(question_display_options $options) { @@ -238,7 +238,8 @@ class qbehaviour_interactive extends question_behaviour_with_save { public function process_save(question_attempt_pending_step $pendingstep) { $status = parent::process_save($pendingstep); - if ($status == question_attempt::KEEP && $pendingstep->get_state() == question_state::$complete) { + if ($status == question_attempt::KEEP && + $pendingstep->get_state() == question_state::$complete) { $pendingstep->set_state(question_state::$todo); } return $status; diff --git a/question/behaviour/interactive/simpletest/testwalkthrough.php b/question/behaviour/interactive/simpletest/testwalkthrough.php index 575b77961b3..996489e8cf9 100644 --- a/question/behaviour/interactive/simpletest/testwalkthrough.php +++ b/question/behaviour/interactive/simpletest/testwalkthrough.php @@ -98,7 +98,8 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes $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')); // Check that, if we review in this state, the try again button is disabled. @@ -205,7 +206,8 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes $this->get_does_not_contain_feedback_expectation(), $this->get_tries_remaining_expectation(2), $this->get_no_hint_visible_expectation(), - new PatternExpectation('/' . preg_quote(get_string('selectone', 'qtype_multichoice'), '/') . '/')); + new PatternExpectation('/' . + preg_quote(get_string('selectone', 'qtype_multichoice'), '/') . '/')); // Submit the wrong answer. $this->process_submission(array('answer' => $wrongindex, '-submit' => 1)); @@ -221,7 +223,8 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes $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')); // Finish the attempt. @@ -285,7 +288,8 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes $this->get_contains_submit_button_expectation(false), $this->get_does_not_contain_validation_error_expectation(), $this->get_contains_try_again_button_expectation(true), - 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->assertEqual('newt', $this->quba->get_response_summary($this->slot)); @@ -346,7 +350,8 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes $right = array_keys($mc->get_correct_response()); $wrong = array_diff(array('choice0', 'choice1', 'choice2', 'choice3'), $right); - $wrong = array_values(array_diff(array('choice0', 'choice1', 'choice2', 'choice3'), $right)); + $wrong = array_values(array_diff( + array('choice0', 'choice1', 'choice2', 'choice3'), $right)); // Check the initial state. $this->check_current_state(question_state::$todo); @@ -363,7 +368,8 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes $this->get_does_not_contain_num_parts_correct(), $this->get_tries_remaining_expectation(3), $this->get_no_hint_visible_expectation(), - new PatternExpectation('/' . preg_quote(get_string('selectmulti', 'qtype_multichoice'), '/') . '/')); + new PatternExpectation('/' . + preg_quote(get_string('selectmulti', 'qtype_multichoice'), '/') . '/')); // Submit an answer with one right, and one wrong. $this->process_submission(array($right[0] => 1, $wrong[0] => 1, '-submit' => 1)); @@ -380,14 +386,19 @@ class qbehaviour_interactive_walkthrough_test extends qbehaviour_walkthrough_tes $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(1), $this->get_contains_standard_incorrect_combined_feedback_expectation(), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . $right[0], '1'), - $this->get_does_not_contain_hidden_expectation($this->quba->get_field_prefix($this->slot) . $right[1]), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . $wrong[0], '0'), - $this->get_does_not_contain_hidden_expectation($this->quba->get_field_prefix($this->slot) . $wrong[1])); + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . $right[0], '1'), + $this->get_does_not_contain_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . $right[1]), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . $wrong[0], '0'), + $this->get_does_not_contain_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . $wrong[1])); // Do try again. $this->process_submission(array($right[0] => 1, '-tryagain' => 1)); diff --git a/question/behaviour/interactivecountback/behaviour.php b/question/behaviour/interactivecountback/behaviour.php index d1885e08cdb..6efeb93db4d 100644 --- a/question/behaviour/interactivecountback/behaviour.php +++ b/question/behaviour/interactivecountback/behaviour.php @@ -75,7 +75,8 @@ class qbehaviour_interactivecountback extends qbehaviour_interactive { $responses = array(); $lastsave = array(); foreach ($this->qa->get_step_iterator() as $step) { - if ($step->has_behaviour_var('submit') && $step->get_state() != question_state::$invalid) { + if ($step->has_behaviour_var('submit') && + $step->get_state() != question_state::$invalid) { $responses[] = $step->get_qt_data(); $lastsave = array(); } else { diff --git a/question/behaviour/interactivecountback/simpletest/testwalkthrough.php b/question/behaviour/interactivecountback/simpletest/testwalkthrough.php index 0a98919ba43..82649ffd9ed 100644 --- a/question/behaviour/interactivecountback/simpletest/testwalkthrough.php +++ b/question/behaviour/interactivecountback/simpletest/testwalkthrough.php @@ -90,14 +90,19 @@ class qbehaviour_interactivecountback_walkthrough_test extends qbehaviour_walkth $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) . 'sub0', $orderforchoice[1]), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'sub1', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'sub2', '0'), - $this->get_contains_hidden_expectation($this->quba->get_field_prefix($this->slot) . 'sub3', $orderforchoice[1])); + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'sub0', $orderforchoice[1]), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'sub1', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'sub2', '0'), + $this->get_contains_hidden_expectation( + $this->quba->get_field_prefix($this->slot) . 'sub3', $orderforchoice[1])); // Check that extract responses will return the reset data. $prefix = $this->quba->get_field_prefix($this->slot); @@ -105,7 +110,8 @@ class qbehaviour_interactivecountback_walkthrough_test extends qbehaviour_walkth $this->quba->extract_responses($this->slot, array($prefix . 'sub0' => 1))); // Do try again. - $this->process_submission(array('sub0' => $orderforchoice[1], 'sub3' => $orderforchoice[1], '-tryagain' => 1)); + $this->process_submission(array('sub0' => $orderforchoice[1], + 'sub3' => $orderforchoice[1], '-tryagain' => 1)); // Verify. $this->check_current_state(question_state::$todo); diff --git a/question/behaviour/manualgraded/simpletest/testwalkthrough.php b/question/behaviour/manualgraded/simpletest/testwalkthrough.php index 8b4d1e369c8..52d8f4a2ed3 100644 --- a/question/behaviour/manualgraded/simpletest/testwalkthrough.php +++ b/question/behaviour/manualgraded/simpletest/testwalkthrough.php @@ -46,8 +46,8 @@ class qbehaviour_manualgraded_walkthrough_test extends qbehaviour_walkthrough_te $this->start_attempt_at_question($essay, 'deferredfeedback', 10); // Check the right model is being used. - $this->assertEqual('manualgraded', $this->quba-> - get_question_attempt($this->slot)->get_behaviour_name()); + $this->assertEqual('manualgraded', $this->quba->get_question_attempt( + $this->slot)->get_behaviour_name()); // Check the initial state. $this->check_current_state(question_state::$todo); @@ -156,8 +156,8 @@ class qbehaviour_manualgraded_walkthrough_test extends qbehaviour_walkthrough_te $this->start_attempt_at_question($essay, 'deferredfeedback', 10); // Check the right model is being used. - $this->assertEqual('manualgraded', $this->quba-> - get_question_attempt($this->slot)->get_behaviour_name()); + $this->assertEqual('manualgraded', $this->quba->get_question_attempt( + $this->slot)->get_behaviour_name()); // Check the initial state. $this->check_current_state(question_state::$todo); @@ -193,7 +193,8 @@ class qbehaviour_manualgraded_walkthrough_test extends qbehaviour_walkthrough_te $this->check_current_state(question_state::$needsgrading); $this->check_current_mark(null); $this->check_current_output( - new PatternExpectation('/' . preg_quote('I am not sure what grade to award.') . '/')); + new PatternExpectation('/' . + preg_quote('I am not sure what grade to award.') . '/')); // Now grade it. $this->manual_grade('Pretty good!', '9.00000'); @@ -215,7 +216,8 @@ class qbehaviour_manualgraded_walkthrough_test extends qbehaviour_walkthrough_te $this->check_current_state(question_state::$needsgrading); $this->check_current_mark(null); $this->check_current_output( - new PatternExpectation('/' . preg_quote('Actually, I am not sure any more.') . '/')); + new PatternExpectation('/' . + preg_quote('Actually, I am not sure any more.') . '/')); $qa = $this->quba->get_question_attempt($this->slot); $this->assertEqual('Commented: Actually, I am not sure any more.', @@ -229,8 +231,8 @@ class qbehaviour_manualgraded_walkthrough_test extends qbehaviour_walkthrough_te $this->start_attempt_at_question($essay, 'deferredfeedback', 10); // Check the right model is being used. - $this->assertEqual('manualgraded', $this->quba-> - get_question_attempt($this->slot)->get_behaviour_name()); + $this->assertEqual('manualgraded', $this->quba->get_question_attempt( + $this->slot)->get_behaviour_name()); // Check the initial state. $this->check_current_state(question_state::$todo); diff --git a/question/behaviour/missing/behaviour.php b/question/behaviour/missing/behaviour.php index 555d70730f7..473b49f1d01 100644 --- a/question/behaviour/missing/behaviour.php +++ b/question/behaviour/missing/behaviour.php @@ -55,14 +55,17 @@ class qbehaviour_missing extends question_behaviour { } public function init_first_step(question_attempt_step $step) { - throw new coding_exception('The behaviour used for this question is not available. No processing is possible.'); + throw new coding_exception('The behaviour used for this question is not available. ' . + 'No processing is possible.'); } public function process_action(question_attempt_pending_step $pendingstep) { - throw new coding_exception('The behaviour used for this question is not available. No processing is possible.'); + throw new coding_exception('The behaviour used for this question is not available. ' . + 'No processing is possible.'); } public function get_min_fraction() { - throw new coding_exception('The behaviour used for this question is not available. No processing is possible.'); + throw new coding_exception('The behaviour used for this question is not available. ' . + 'No processing is possible.'); } } diff --git a/question/behaviour/missing/simpletest/testmissingbehaviour.php b/question/behaviour/missing/simpletest/testmissingbehaviour.php index 14527f66e87..a033deac729 100644 --- a/question/behaviour/missing/simpletest/testmissingbehaviour.php +++ b/question/behaviour/missing/simpletest/testmissingbehaviour.php @@ -63,13 +63,16 @@ class qbehaviour_missing_test extends UnitTestCase { public function test_render_missing() { $records = testing_db_record_builder::build_db_records(array( array('id', 'questionattemptid', 'contextid', 'questionusageid', 'slot', - 'behaviour', 'questionid', 'maxmark', 'minfraction', 'flagged', - 'questionsummary', 'rightanswer', 'responsesummary', 'timemodified', - 'attemptstepid', 'sequencenumber', 'state', 'fraction', - 'timecreated', 'userid', 'name', 'value'), - array(1, 1, 123, 1, 1, 'strangeunknown', -1, 2.0000000, 0.0000000, 0, '', '', '', 1256233790, 1, 0, 'todo', null, 1256233700, 1, '_order', '1,2,3'), - array(2, 1, 123, 1, 1, 'strangeunknown', -1, 2.0000000, 0.0000000, 0, '', '', '', 1256233790, 2, 1, 'complete', 0.50, 1256233705, 1, '-submit', '1'), - array(3, 1, 123, 1, 1, 'strangeunknown', -1, 2.0000000, 0.0000000, 0, '', '', '', 1256233790, 2, 1, 'complete', 0.50, 1256233705, 1, 'choice0', '1'), + 'behaviour', 'questionid', 'maxmark', 'minfraction', 'flagged', + 'questionsummary', 'rightanswer', 'responsesummary', + 'timemodified', 'attemptstepid', 'sequencenumber', 'state', 'fraction', + 'timecreated', 'userid', 'name', 'value'), + array(1, 1, 123, 1, 1, 'strangeunknown', -1, 2.0000000, 0.0000000, 0, '', '', '', + 1256233790, 1, 0, 'todo', null, 1256233700, 1, '_order', '1,2,3'), + array(2, 1, 123, 1, 1, 'strangeunknown', -1, 2.0000000, 0.0000000, 0, '', '', '', + 1256233790, 2, 1, 'complete', 0.50, 1256233705, 1, '-submit', '1'), + array(3, 1, 123, 1, 1, 'strangeunknown', -1, 2.0000000, 0.0000000, 0, '', '', '', + 1256233790, 2, 1, 'complete', 0.50, 1256233705, 1, 'choice0', '1'), )); $question = test_question_maker::make_a_truefalse_question(); @@ -99,7 +102,8 @@ class qbehaviour_missing_test extends UnitTestCase { $output = $qa->render(new question_display_options(), '1'); $this->assertPattern('/' . preg_quote($qa->get_question()->questiontext) . '/', $output); - $this->assertPattern('/' . preg_quote(get_string('questionusedunknownmodel', 'qbehaviour_missing')) . '/', $output); + $this->assertPattern('/' . preg_quote( + get_string('questionusedunknownmodel', 'qbehaviour_missing')) . '/', $output); $this->assert(new ContainsTagWithAttribute('div', 'class', 'warning'), $output); } } diff --git a/question/behaviour/opaque/renderer.php b/question/behaviour/opaque/renderer.php index 8965a2bc0e7..72763fbc459 100644 --- a/question/behaviour/opaque/renderer.php +++ b/question/behaviour/opaque/renderer.php @@ -46,7 +46,8 @@ class qbehaviour_opaque_renderer extends qbehaviour_renderer { $opaquestate = qtype_opaque_update_state($qa); } catch (SoapFault $sf) { return html_writer::tag('div', get_string('errorconnecting', 'qtype_opaque') . - html_writer::tag('pre', get_string('soapfault', 'qtype_opaque', $sf), array('class' => 'notifytiny')), + html_writer::tag('pre', get_string('soapfault', 'qtype_opaque', $sf), + array('class' => 'notifytiny')), array('class' => 'opaqueerror')); } @@ -67,7 +68,8 @@ class qbehaviour_opaque_renderer extends qbehaviour_renderer { $resourcecache = new qtype_opaque_resource_cache($question->engineid, $question->remoteid, $question->remoteversion); - if (!empty($opaquestate->cssfilename) && $resourcecache->file_in_cache($opaquestate->cssfilename)) { + if (!empty($opaquestate->cssfilename) && + $resourcecache->file_in_cache($opaquestate->cssfilename)) { $this->page->requires->css($resourcecache->file_url($opaquestate->cssfilename)); } diff --git a/question/behaviour/opaque/simpletest/testopaquebehaviour.php b/question/behaviour/opaque/simpletest/testopaquebehaviour.php index f78bb9016ee..949008bcd57 100644 --- a/question/behaviour/opaque/simpletest/testopaquebehaviour.php +++ b/question/behaviour/opaque/simpletest/testopaquebehaviour.php @@ -77,7 +77,8 @@ class qbehaviour_opaque_test extends qbehaviour_walkthrough_test_base { $this->check_current_output( new PatternExpectation('/Below is a plan of a proposed garden/'), new PatternExpectation('/You have 3 attempts/'), - $this->get_contains_button_expectation($qa->get_qt_field_name('omact_gen_14'), 'Check')); + $this->get_contains_button_expectation( + $qa->get_qt_field_name('omact_gen_14'), 'Check')); $this->assertPattern('/^\s*Below is a plan of a proposed garden./', $qa->get_question_summary()); $this->assertNull($qa->get_right_answer_summary()); @@ -92,8 +93,10 @@ class qbehaviour_opaque_test extends qbehaviour_walkthrough_test_base { $this->check_current_output( new PatternExpectation('/Below is a plan of a proposed garden/'), new PatternExpectation('/incorrect/'), - new PatternExpectation('/' . preg_quote(get_string('notcomplete', 'qbehaviour_opaque')) . '/'), - $this->get_contains_button_expectation($qa->get_qt_field_name('omact_ok'), 'Try again')); + new PatternExpectation('/' . + preg_quote(get_string('notcomplete', 'qbehaviour_opaque')) . '/'), + $this->get_contains_button_expectation( + $qa->get_qt_field_name('omact_ok'), 'Try again')); // Try again. $this->process_submission(array('omact_ok' => 'Try again')); @@ -114,7 +117,8 @@ class qbehaviour_opaque_test extends qbehaviour_walkthrough_test_base { $this->check_current_output( new PatternExpectation('/Below is a plan of a proposed garden/'), new PatternExpectation('/still incorrect/'), - new PatternExpectation('/' . preg_quote(get_string('notcomplete', 'qbehaviour_opaque')) . '/')); + new PatternExpectation('/' . + preg_quote(get_string('notcomplete', 'qbehaviour_opaque')) . '/')); // Try again. $this->process_submission(array('omact_ok' => 'Try again')); @@ -133,9 +137,11 @@ class qbehaviour_opaque_test extends qbehaviour_walkthrough_test_base { $this->check_current_state(question_state::$gradedwrong); $this->check_current_mark(0); $this->check_current_output( - new PatternExpectation('/Please see MU120 Preparatory Resource Book B section 5.1/'), + new PatternExpectation( + '/Please see MU120 Preparatory Resource Book B section 5.1/'), new PatternExpectation('/still incorrect/')); - $this->assertTrue(preg_match('/What is \(X\*W\) (\d+\.\d+)\*(\d+), \(X\*L\)(\d+\.\d+)\*(\d+)\?/', + $this->assertTrue(preg_match( + '/What is \(X\*W\) (\d+\.\d+)\*(\d+), \(X\*L\)(\d+\.\d+)\*(\d+)\?/', $qa->get_question_summary(), $matches)); $this->assertNull($qa->get_right_answer_summary()); $this->assertPattern('/' . $matches[1]*$matches[2] . '.*, ' . $matches[3]*$matches[4] . '/', @@ -168,7 +174,8 @@ class qbehaviour_opaque_test extends qbehaviour_walkthrough_test_base { $this->check_current_output( new PatternExpectation('/Below is a plan of a proposed garden/'), new PatternExpectation('/You have 3 attempts/'), - $this->get_contains_button_expectation($qa->get_qt_field_name('omact_gen_14'), 'Check')); + $this->get_contains_button_expectation( + $qa->get_qt_field_name('omact_gen_14'), 'Check')); // Submit the right answer. $this->process_submission(array('omval_response1' => $size[0] * $scale, @@ -208,7 +215,8 @@ class qbehaviour_opaque_test extends qbehaviour_walkthrough_test_base { $this->check_current_output( new PatternExpectation('/Below is a plan of a proposed garden/'), new PatternExpectation('/You have 3 attempts/'), - $this->get_contains_button_expectation($qa->get_qt_field_name('omact_gen_14'), 'Check')); + $this->get_contains_button_expectation( + $qa->get_qt_field_name('omact_gen_14'), 'Check')); // Submit the right answer. $this->process_submission(array('omval_response1' => $size[0] * $scale, diff --git a/question/behaviour/rendererbase.php b/question/behaviour/rendererbase.php index 9206520b44e..c8779c76bf4 100644 --- a/question/behaviour/rendererbase.php +++ b/question/behaviour/rendererbase.php @@ -74,10 +74,11 @@ abstract class qbehaviour_renderer extends plugin_renderer_base { $commentfield = $qa->get_behaviour_field_name('comment'); list($commenttext, $commentformat) = $qa->get_manual_comment(); - $comment = print_textarea(can_use_html_editor(), 10, 80, null, null, $commentfield, $commenttext, 0, true); + $comment = print_textarea(can_use_html_editor(), 10, 80, null, null, + $commentfield, $commenttext, 0, true); $comment = html_writer::tag('div', html_writer::tag('div', - html_writer::tag('label', get_string('comment', 'question'), array('for' => $commentfield)), - array('class' => 'fitemtitle')) . + html_writer::tag('label', get_string('comment', 'question'), + array('for' => $commentfield)), array('class' => 'fitemtitle')) . html_writer::tag('div', $comment, array('class' => 'felement fhtmleditor')), array('class' => 'fitem')); @@ -95,7 +96,8 @@ abstract class qbehaviour_renderer extends plugin_renderer_base { 'name' => $markfield, ); if (!is_null($currentmark)) { - $attributes['value'] = $qa->format_fraction_as_mark($currentmark / $maxmark, $options->markdp); + $attributes['value'] = $qa->format_fraction_as_mark( + $currentmark / $maxmark, $options->markdp); } $a = new stdClass(); $a->max = $qa->format_max_mark($options->markdp); @@ -120,7 +122,8 @@ abstract class qbehaviour_renderer extends plugin_renderer_base { } $mark = html_writer::tag('div', html_writer::tag('div', - html_writer::tag('label', get_string('mark', 'question'), array('for' => $markfield)), + html_writer::tag('label', get_string('mark', 'question'), + array('for' => $markfield)), array('class' => 'fitemtitle')) . html_writer::tag('div', $error . get_string('xoutofmax', 'question', $a) . $markrange, array('class' => 'felement ftext' . $errorclass) @@ -139,7 +142,8 @@ abstract class qbehaviour_renderer extends plugin_renderer_base { if ($options->manualcommentlink) { $url = new moodle_url($options->manualcommentlink, array('slot' => $qa->get_slot())); $link = $this->output->action_link($url, get_string('commentormark', 'question'), - new popup_action('click', $url, 'commentquestion', array('width' => 600, 'height' => 800))); + new popup_action('click', $url, 'commentquestion', + array('width' => 600, 'height' => 800))); $output .= html_writer::tag('div', $link, array('class' => 'commentlink')); } return $output;