Skip to content

Commit

Permalink
MDL-77550 lesson: Format decimals in feedback page
Browse files Browse the repository at this point in the history
  • Loading branch information
dpalou committed Mar 8, 2023
1 parent 62cfa26 commit 778840f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions mod/lesson/pagetypes/numerical.php
Expand Up @@ -347,6 +347,21 @@ public function update_form_data(stdClass $data) : stdClass {

return $data;
}

/**
* Custom formats the answer to display
*
* @param string $answer
* @param context $context
* @param int $answerformat
* @param array $options Optional param for additional options.
* @return string Returns formatted string
*/
public function format_answer($answer, $context, $answerformat, $options = []) {
$answer = helper::lesson_format_numeric_value($answer);

return parent::format_answer($answer, $context, $answerformat, $options);
}
}

class lesson_add_page_form_numerical extends lesson_add_page_form_base {
Expand Down
Expand Up @@ -57,6 +57,7 @@ Feature: In a lesson activity, I need to edit pages in the lesson taking into ac
| Your answer | 2#87 |
And I press "Submit"
Then I should see "Correct answer"
And I should see "2#87"
And I should not see "Incorrect answer"
And I press "Continue"
And I should see "Congratulations - end of lesson reached"
Expand All @@ -69,6 +70,7 @@ Feature: In a lesson activity, I need to edit pages in the lesson taking into ac
| Your answer | 2#7 |
And I press "Submit"
Then I should not see "Correct answer"
And I should see "2#7"
And I should see "Incorrect answer"
And I press "Continue"
And I should see "Congratulations - end of lesson reached"
Expand All @@ -81,6 +83,7 @@ Feature: In a lesson activity, I need to edit pages in the lesson taking into ac
| Your answer | 2#87 |
And I press "Submit"
Then I should see "Correct answer"
And I should see "2#87"
And I should not see "Incorrect answer"
And I press "Continue"
And I should see "Congratulations - end of lesson reached"
Expand All @@ -106,6 +109,7 @@ Feature: In a lesson activity, I need to edit pages in the lesson taking into ac
| Your answer | 2,7 |
And I press "Submit"
And I should see "Incorrect answer"
And I should see "2,7"
And I should not see "Correct answer"
And I press "Continue"
And I should see "Congratulations - end of lesson reached"
Expand Down

0 comments on commit 778840f

Please sign in to comment.