Skip to content

Commit

Permalink
MDL-37784 Adaptive no penalty display wrong penalty info
Browse files Browse the repository at this point in the history
Adaptive Mode tells students they have been penalized even when set to no penalties
  • Loading branch information
Jean-Michel Vedrine committed Apr 23, 2013
1 parent d298661 commit 37eadb4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
6 changes: 4 additions & 2 deletions question/behaviour/adaptivenopenalty/renderer.php
Expand Up @@ -38,9 +38,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
class qbehaviour_adaptivenopenalty_renderer extends qbehaviour_adaptive_renderer { class qbehaviour_adaptivenopenalty_renderer extends qbehaviour_adaptive_renderer {
protected function penalty_info(qbehaviour_adaptive_mark_details $details, question_display_options $options) { protected function grading_details(qbehaviour_adaptive_mark_details $details, question_display_options $options) {
return ''; $mark = $details->get_formatted_marks($options->markdp);
return get_string('gradingdetails', 'qbehaviour_adaptive', $mark);
} }

protected function disregarded_info() { protected function disregarded_info() {
return ''; return '';
} }
Expand Down
26 changes: 23 additions & 3 deletions question/behaviour/adaptivenopenalty/tests/walkthrough_test.php
Expand Up @@ -44,6 +44,18 @@ protected function get_does_not_contain_gradingdetails_expectation() {
return new question_no_pattern_expectation('/class="gradingdetails"/'); return new question_no_pattern_expectation('/class="gradingdetails"/');
} }


protected function get_does_not_contain_penalty_info_expectation() {
$penaltyinfo = get_string('gradingdetailspenalty', 'qbehaviour_adaptive', 'XXXXX');
$penaltypattern = '/'.str_replace('XXXXX', '\\w*', preg_quote($penaltyinfo, '/')).'/';
return new question_no_pattern_expectation($penaltypattern);
}

protected function get_does_not_contain_total_penalty_expectation() {
$penaltyinfo = get_string('gradingdetailspenaltytotal', 'qbehaviour_adaptive', 'XXXXX');
$penaltypattern = '/'.str_replace('XXXXX', '\\w*', preg_quote($penaltyinfo, '/')).'/';
return new question_no_pattern_expectation($penaltypattern);
}

public function test_multichoice() { public function test_multichoice() {


// Create a multiple choice, single response question. // Create a multiple choice, single response question.
Expand Down Expand Up @@ -77,7 +89,9 @@ public function test_multichoice() {
$this->get_contains_mc_radio_expectation($wrongindex, true, true), $this->get_contains_mc_radio_expectation($wrongindex, true, true),
$this->get_contains_mc_radio_expectation(($wrongindex + 1) % 3, true, false), $this->get_contains_mc_radio_expectation(($wrongindex + 1) % 3, true, false),
$this->get_contains_mc_radio_expectation(($wrongindex + 2) % 3, true, false), $this->get_contains_mc_radio_expectation(($wrongindex + 2) % 3, true, false),
$this->get_contains_incorrect_expectation()); $this->get_contains_incorrect_expectation(),
$this->get_does_not_contain_penalty_info_expectation(),
$this->get_does_not_contain_total_penalty_expectation());
$this->assertRegExp('/B|C/', $this->assertRegExp('/B|C/',
$this->quba->get_response_summary($this->slot)); $this->quba->get_response_summary($this->slot));


Expand Down Expand Up @@ -106,7 +120,9 @@ public function test_multichoice() {
$this->get_contains_mc_radio_expectation($rightindex, true, true), $this->get_contains_mc_radio_expectation($rightindex, true, true),
$this->get_contains_mc_radio_expectation(($rightindex + 1) % 3, true, false), $this->get_contains_mc_radio_expectation(($rightindex + 1) % 3, true, false),
$this->get_contains_mc_radio_expectation(($rightindex + 2) % 3, true, false), $this->get_contains_mc_radio_expectation(($rightindex + 2) % 3, true, false),
$this->get_contains_correct_expectation()); $this->get_contains_correct_expectation(),
$this->get_does_not_contain_penalty_info_expectation(),
$this->get_does_not_contain_total_penalty_expectation());
$this->assertEquals('A', $this->assertEquals('A',
$this->quba->get_response_summary($this->slot)); $this->quba->get_response_summary($this->slot));


Expand Down Expand Up @@ -176,7 +192,9 @@ public function test_multichoice2() {
$this->check_current_output( $this->check_current_output(
$this->get_contains_mark_summary(2), $this->get_contains_mark_summary(2),
$this->get_contains_submit_button_expectation(true), $this->get_contains_submit_button_expectation(true),
$this->get_contains_correct_expectation()); $this->get_contains_correct_expectation(),
$this->get_does_not_contain_penalty_info_expectation(),
$this->get_does_not_contain_total_penalty_expectation());


// Save the same correct answer again. Should no do anything. // Save the same correct answer again. Should no do anything.
$numsteps = $this->get_step_count(); $numsteps = $this->get_step_count();
Expand Down Expand Up @@ -237,6 +255,8 @@ public function test_numerical_invalid() {
$this->get_contains_mark_summary(0), $this->get_contains_mark_summary(0),
$this->get_contains_submit_button_expectation(true), $this->get_contains_submit_button_expectation(true),
$this->get_contains_incorrect_expectation(), $this->get_contains_incorrect_expectation(),
$this->get_does_not_contain_penalty_info_expectation(),
$this->get_does_not_contain_total_penalty_expectation(),
$this->get_does_not_contain_validation_error_expectation()); $this->get_does_not_contain_validation_error_expectation());


// Submit another non-numerical answer. // Submit another non-numerical answer.
Expand Down

0 comments on commit 37eadb4

Please sign in to comment.