Show "Mark Complete" button when quiz requirements are already met#3092
Open
faisalahammad wants to merge 2 commits intogocodebox:devfrom
Open
Show "Mark Complete" button when quiz requirements are already met#3092faisalahammad wants to merge 2 commits intogocodebox:devfrom
faisalahammad wants to merge 2 commits intogocodebox:devfrom
Conversation
Fixes gocodebox#3058 When a lesson has an attached quiz, students who mark the lesson as incomplete can now re-mark it as complete without retaking the quiz, provided they have already met the quiz requirements. Changes: - Modified llms_show_mark_complete_button() to check quiz completion status - Added 4 new unit tests for quiz completion scenarios
Contributor
|
@faisalahammad Will review internally but this looks good to me. Thanks! |
Contributor
|
Note: will need a changelog before or after merge into |
brianhogg
approved these changes
Feb 12, 2026
faisalahammad
added a commit
to faisalahammad/lifterlms
that referenced
this pull request
Feb 12, 2026
Author
|
Hi @brianhogg, |
Contributor
|
@faisalahammad If you're able to add one into each of the PRs that'd be great. I don't believe I can push to your branch to add one. Thanks! |
Author
|
@brianhogg |
Contributor
|
@faisalahammad The CHANGELOG.md is built, the changelog files are the yml files described in this comment on the other PR: Sorry for any confusion and if it's a pain no worries, we can make a note to add the changelog(s) if/when the PRs are merged, or re-create the PRs from your diff. Thanks! |
0b7d91b to
b988a89
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3058
This PR allows students to re-mark a lesson as complete after clicking "Mark Incomplete", without needing to retake the quiz. The button is shown only when the student has already met the quiz requirements (passed or attempted based on lesson settings).
Problem
When a lesson has an attached quiz:
This is frustrating for students who want to review a lesson without losing their quiz results.
Root Cause
The
llms_show_mark_complete_button()function unconditionally returnsfalsewhen a quiz exists:Before (Problematic Code)
The function never checks if the student has already met the quiz requirements. It blindly hides the button whenever a quiz is attached.
Solution
Check if the current user has already met the quiz requirements before hiding the button. This uses the same logic that exists in
quiz_maybe_prevent_lesson_completion()in the lesson progression controller.After (Fixed Code)
How It Works
The fix adds these checks in order:
Decision Table
Files Changed
includes/functions/llms-functions-progression.phpllms_show_mark_complete_button()to check quiz completion statustests/phpunit/unit-tests/functions/class-llms-test-functions-progression.phpAdded 4 new test cases:
test_llms_show_mark_complete_button_quiz_not_attemptedtest_llms_show_mark_complete_button_quiz_passedtest_llms_show_mark_complete_button_quiz_failed_passing_requiredtest_llms_show_mark_complete_button_quiz_failed_passing_not_requiredBackward Compatibility
This change is fully backward compatible:
llms_show_mark_complete_buttonfilter still works as beforePerformance
The fix adds a database query to fetch the best quiz attempt. This query:
get_best_attempt()methodTesting Instructions
Manual Testing
Automated Tests
Related
quiz_maybe_prevent_lesson_completion()inclass.llms.controller.lesson.progression.phpNote on Assignments
Assignments are provided by LifterLMS add-ons, not the core plugin. The same filter (
llms_show_mark_complete_button) can be used by add-on developers to implement similar logic for assignments.