MDL-77550 lesson: Format decimals in feedback page

This commit is contained in:
Dani Palou 2023-03-07 15:56:26 +01:00
parent f49f934786
commit c90c9b04f6
2 changed files with 19 additions and 0 deletions

View File

@ -347,6 +347,21 @@ class lesson_page_type_numerical extends lesson_page {
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 {

View File

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