Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -867,13 +867,20 @@ public function part_correct_response($part) {
/**
* Check whether the last response of a question attempt is the same as the last submitted response, i. e. it
* was either submitted (e. g. using the "Check" button) or it was saved during page navigation in a quiz but
* still contains the same answers as the ones from the last regular submission.
* still contains the same answers as the ones from the last regular submission. This is used to decide whether
* the feedback should be shown or not.
*
* @param question_attempt $qa
* @param formulas_part|null $part
* @return bool
*/
protected function response_is_same_as_submitted(question_attempt $qa, formulas_part|null $part = null): bool {
// If the question is marked as finished, we will return true here to make sure the feedback
// will be shown, because students will not be able to interact with the question anymore.
if ($qa->get_state()->is_finished()) {
return true;
}

// If the last step contains the behaviour var 'submit', it was itself a submitted response.
// For the deferredfeedback behaviour, the step will contain 'finish' instead of 'submit'.
$laststep = $qa->get_last_step();
Expand Down
30 changes: 30 additions & 0 deletions tests/renderer_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,36 @@ public function test_show_response_with_backslash(): void {
$this->check_output_contains_text_input('0_0', '\1', false);
}

public function test_feedback_remains_visible_after_manual_regrading(): void {
$q = $this->get_test_formulas_question('testthreeparts');
$this->start_attempt_at_question($q, 'deferredfeedback', 3);

// Submit wrong answer.
$this->process_submission(['0_0' => '1', '1_0' => '6', '2_0' => '7']);
$this->finish();
$this->render();
$this->check_current_state(question_state::$gradedpartial);
$this->check_output_contains_lang_string('correctansweris', 'qtype_formulas', '5');
$this->check_output_contains_lang_string('correctansweris', 'qtype_formulas', '6');
$this->check_output_contains_lang_string('correctansweris', 'qtype_formulas', '7');
$this->check_current_output(
$this->get_contains_num_parts_correct(2),
);

// Manually regrade the question and add a comment.
$this->quba->manual_grade(1, 'giving some bonus', 2.5, FORMAT_HTML);

$this->render();
$this->check_current_state(question_state::$mangrpartial);
$this->check_output_contains_lang_string('correctansweris', 'qtype_formulas', '5');
$this->check_output_contains_lang_string('correctansweris', 'qtype_formulas', '6');
$this->check_output_contains_lang_string('correctansweris', 'qtype_formulas', '7');
$this->check_output_contains('giving some bonus');
$this->check_current_output(
$this->get_contains_num_parts_correct(2),
);
}

public function test_adaptive_grading_details_are_shown(): void {
// Create a simple test question with no feedback strings at all.
$q = $this->get_test_formulas_question('testsinglenum');
Expand Down
Loading