MDL-20636 Fix codechecker issues in the question behaviours.

This commit is contained in:
Tim Hunt 2011-04-08 07:24:24 +01:00
parent 9447399c11
commit 1631ceeaec
21 changed files with 147 additions and 86 deletions

View file

@ -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;

View file

@ -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' => ''));

View file

@ -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;
}

View file

@ -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) {

View file

@ -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;

View file

@ -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));
}

View file

@ -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;
}

View file

@ -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'));

View file

@ -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);

View file

@ -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;

View file

@ -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.

View file

@ -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;

View file

@ -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));

View file

@ -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 {

View file

@ -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);

View file

@ -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);

View file

@ -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.');
}
}

View file

@ -64,12 +64,15 @@ class qbehaviour_missing_test extends UnitTestCase {
$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',
'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'),
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);
}
}

View file

@ -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));
}

View file

@ -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,

View file

@ -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;