Skip to content

Conversation

@donnapep
Copy link
Contributor

@donnapep donnapep commented Dec 6, 2025

Resolves #7868.

Proposed Changes

This updates the logic such that a multiple choice question is allowed to have no wrong answers. Previously, the logic prevented this.

Determining whether to have questions with no wrong answer is best left to a teacher to decide what makes the most sense for their content, not enforced as a technical constraint.

Testing Instructions

  1. Create a course and a lesson.
  2. Add a Quiz block to the lesson, and add two or more multiple choice questions.
  3. For one of the multiple choice questions, mark all answers as correct.
  4. View the course and ensure all questions are displayed on the frontend.

Pre-Merge Checklist

  • PR title and description contain sufficient detail and accurately describe the changes
  • Adheres to coding standards (PHP, JavaScript, CSS, HTML)
  • All strings are translatable (without concatenation, handles plurals)
  • Follows our naming conventions (P6rkRX-4oA-p2)
  • Hooks (p6rkRX-1uS-p2) and functions are documented
  • New UIs are responsive and use a mobile-first approach
  • Code is tested on the minimum supported PHP and WordPress versions

@donnapep donnapep added this to the 4.25.2 milestone Dec 6, 2025
Copilot AI review requested due to automatic review settings December 6, 2025 19:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the quiz validation logic to allow multiple choice questions where all answers are correct (i.e., no wrong answers). Previously, the system required at least one wrong answer for a question to be considered complete.

  • Updated validation logic in is_multiple_choice_question_complete() to make wrong answers optional
  • Added comprehensive test coverage for the new behavior
  • Improved code robustness by ensuring $wrong_answers is always an array before merging

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
includes/class-sensei-quiz.php Modified validation logic to allow multiple choice questions with only correct answers by removing the requirement for at least one wrong answer and ensuring wrong_answers is properly handled as an array
tests/unit-tests/test-class-quiz.php Added comprehensive test case to verify that questions with all correct answers are not filtered out and are properly displayed on the frontend

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@donnapep donnapep changed the title Allow questions with no wrong answers Allow multiple choice quiz questions with no wrong answers Dec 6, 2025
@donnapep donnapep merged commit aeb47cc into trunk Dec 12, 2025
21 checks passed
@donnapep donnapep deleted the fix/some-questions-not-showing branch December 12, 2025 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple-choice Quiz Question with all correct answers does not show in the frontend

2 participants