Skip to content

Quiz attempt review enhancements#2566

Open
b-l-i-n-d wants to merge 15 commits into4.0.0-devfrom
v4-blind
Open

Quiz attempt review enhancements#2566
b-l-i-n-d wants to merge 15 commits into4.0.0-devfrom
v4-blind

Conversation

@b-l-i-n-d
Copy link
Copy Markdown
Collaborator

Summary

  • Add is_attempt_answer_skipped() helper method
  • Refactor review_quiz_answer() to handle skipped questions
  • Use status_badges array for multiple status badges in question headers
  • Add question_id data attribute for manual review actions
  • Fix status fallback values to use 'incorrect' consistently
  • Show skipped questions in attempt details
  • Disable pointer cursor for non-interactive question previews (except scale)

Commits

  • fix(quiz): add is_attempt_answer_skipped() and fix docblock
  • feat(quiz): refactor review_quiz_answer to handle skipped questions
  • refactor(quiz): use status_badges array for multiple badges
  • fix(quiz): correct status fallback values
  • feat(quiz): add question_id data attribute for manual review
  • fix(quiz): show skipped questions in attempt details
  • fix(preview): disable pointer cursor for non-interactive question options

@b-l-i-n-d b-l-i-n-d added the 4.0.0 Tutor v4.w0w label Apr 15, 2026
Comment thread classes/Quiz.php
*
* @return object|null
*/
private function get_attempt_answer_by_attempt_and_question( int $attempt_id, int $question_id ) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a method for fetching attempt: tutor_utils()->get_attempt( $attempt_id )

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need get_attempt_answer_by_attempt_and_question() because creating a placeholder row is only correct when no answer row already exists for the same attempt_id + question_id. In the skipped legacy case there is no attempt_answer_id, so the review flow first has to look up by attempt_id and question_id: if a row exists we should update it, and if not we create the missing row and then apply the review. Without that lookup the fallback becomes a blind insert, which can create duplicate attempt-answer rows for questions that already have a saved record.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0.0 Tutor v4.w0w

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants