Skip to content

Correct answer and feedback may disappear after manual regrading in deferred feedback attempts #329

Description

@cmassoglia

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

  1. Create a quiz containing a qtype_formulas question with visible right answer / feedback in review.
  2. Configure the quiz to use deferredfeedback.
  3. Attempt the quiz as a student and submit/finish the attempt.
  4. Open the finished attempt review as a teacher.
  5. Manually regrade the question from the review page.
  6. Open the attempt review again.
  7. 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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions