Description of bug / unexpected behavior
When a qtype_formulas question is used in a quiz with deferredfeedback, the correct answer / feedback block may stop being displayed after the question is manually regraded from the attempt review page.
The issue is not data loss. The model answers and feedback texts still remain stored in the database, but they are no longer rendered in the review page after manual regrading adds later grading-only steps.
Expected behavior
After manual regrading, the review page should continue to display the correct answer and feedback consistently, as long as:
- the attempt is finished
- the response data still exists
- the quiz review settings allow showing the right answer / feedback
How to reproduce the issue
- Create a quiz containing a
qtype_formulas question with visible right answer / feedback in review.
- Configure the quiz to use
deferredfeedback.
- Attempt the quiz as a student and submit/finish the attempt.
- Open the finished attempt review as a teacher.
- Manually regrade the question from the review page.
- Open the attempt review again.
- Notice that the correct answer / feedback block is no longer displayed.
Moodle XML export
A minimal sample question can be provided if needed.
In our case, the issue was reproduced with a multi-part formulas question whose model answers were stored normally in qtype_formulas_answers.answer.
Error message
No explicit error message is shown.
The problem is that the correct answer / feedback block disappears from the review page after manual regrading.
Screenshots
Before manual regrading: the review page shows the correct answer / feedback normally.
After manual regrading: the same review page no longer shows that block, even though the data still exists in the database.
Environment
System Details
- Moodle version: 4.5.12
- Plugin version: 2026051800
- PHP version: 8.3.31
- Browser: Chromium: 149.0.7827.196
Additional comments
We inspected the database and confirmed that the issue is not caused by missing data:
- The question still had combined feedback stored in
qtype_formulas_options.
- The part model answers were still present in
qtype_formulas_answers.answer.
- The quiz review settings still allowed showing the right answer.
In the affected attempt, the step sequence looked like this:
- one
complete step containing the actual response fields (0_0, 0_1, 1_0, etc.)
- one later
gradedwrong step containing only -finish=1
- later
mangrwrong / mangrpartial steps containing only manual grading fields such as -mark, -maxmark, -comment
This suggests the renderer is relying on the latest chronological step instead of the latest effective question response data.
Proposed fix
A possible fix would be in renderer.php, in response_is_same_as_submitted().
The method should use the latest effective question response data instead of relying on the latest chronological step, because manual regrading can add steps that contain grading metadata only and no actual response fields.
In practice, the renderer should use get_last_qt_data() when the latest steps do not contain question response data, so that feedback and correct answers are still shown consistently after manual regrading.
Description of bug / unexpected behavior
When a
qtype_formulasquestion is used in a quiz withdeferredfeedback, the correct answer / feedback block may stop being displayed after the question is manually regraded from the attempt review page.The issue is not data loss. The model answers and feedback texts still remain stored in the database, but they are no longer rendered in the review page after manual regrading adds later grading-only steps.
Expected behavior
After manual regrading, the review page should continue to display the correct answer and feedback consistently, as long as:
How to reproduce the issue
qtype_formulasquestion with visible right answer / feedback in review.deferredfeedback.Moodle XML export
Error message
Screenshots
Before manual regrading: the review page shows the correct answer / feedback normally.
After manual regrading: the same review page no longer shows that block, even though the data still exists in the database.
Environment
System Details
Additional comments
We inspected the database and confirmed that the issue is not caused by missing data:
qtype_formulas_options.qtype_formulas_answers.answer.In the affected attempt, the step sequence looked like this:
completestep containing the actual response fields (0_0,0_1,1_0, etc.)gradedwrongstep containing only-finish=1mangrwrong/mangrpartialsteps containing only manual grading fields such as-mark,-maxmark,-commentThis suggests the renderer is relying on the latest chronological step instead of the latest effective question response data.
Proposed fix
A possible fix would be in
renderer.php, inresponse_is_same_as_submitted().The method should use the latest effective question response data instead of relying on the latest chronological step, because manual regrading can add steps that contain grading metadata only and no actual response fields.
In practice, the renderer should use
get_last_qt_data()when the latest steps do not contain question response data, so that feedback and correct answers are still shown consistently after manual regrading.