Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fatal error that occurred when viewing quiz attempts with deleted questions. #2867

Merged
merged 3 commits into from
Feb 5, 2025

Conversation

ideadude
Copy link
Member

Description

Viewing quiz attempts when questions were deleted would throw a fatal error:

PHP Fatal error: Uncaught Error: Call to a member function get() on null in ...\wp-content\plugins\lifterlms\templates\quiz\results-attempt-questions-list.php

How has this been tested?

To recreate the issue:

  • Create a quiz with 2 questions.
  • Complete the quiz from the frontend.
  • Delete 1 of the questions.
  • Go to LifterLMS > Reports > Quizzes
  • Click on the quiz, then Click on Attempts.

Types of changes

This issue was introduced by accident in the work to add the quiz resume feature. Some code was incorrectly updated to get data from the $question variable instead of the $attempt_question variable.

Note: Since $attempt_question->get('question_type') is always null, we instead add type--deleted as a css class on the li element instead of trying to find the type.

Checklist:

  • This PR requires and contains at least one changelog file.
  • My code has been tested.
  • My code passes all existing automated tests.
  • My code follows the LifterLMS Coding & Documentation Standards.

@ideadude ideadude changed the base branch from trunk to dev January 29, 2025 21:05
@ideadude ideadude added this to the Next Available Release milestone Jan 29, 2025
@brianhogg brianhogg merged commit 6d2a643 into dev Feb 5, 2025
24 checks passed
@brianhogg brianhogg deleted the fix/quiz-attempt-with-deleted-question branch February 5, 2025 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants