Affects Version/s: 3.5.7, 3.6.5, 3.7.1, 3.8
- Create a course
- In that course, create a lesson activity
- In that lesson activity, add a numerical question page
- Set one answer to 0
- Save the page
- Edit the page and save the page again
- The 0 answer must still be present
Affected Branches:MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE
Fixed Branches:MOODLE_36_STABLE, MOODLE_37_STABLE
Pull from Repository:
Pull 3.7 Branch:
Pull Master Branch:
When editing a numerical question in a lesson, all the answers equal to zero are being deleted.
This has been fixed when adding such an answer (
MDL-57366) but editing is still broken.
The field text value is saved into a lesson_page_answer (extending lesson_base) object. And within that class, the isset function is overridden and is returning the empty function result.
Which makes this test https://github.com/moodle/moodle/blob/MOODLE_36_STABLE/mod/lesson/locallib.php#L4479 fail. The answer is therefore dropped.
A simple fix would be to replace the test mentioned above:
to avoid calling the "magic" isset function.
In order to reproduce the issue:
- Create a new lesson
- Add a new numerical page
- Add an answer with value of 0
- Save the question
- Edit that question and save it again
=> The answer is dropped.