Automattic / Automattic/sensei

Private completed lessons prevent user from completing the course

Open
#2,802 5 comments 0 reactions 0 assignees View on GitHub
[Type] Bug
Dominant language
PHP
Stars
594
Forks
218
Avg merge
1d 22h
Merged PRs (30d)
53

Description

#### Steps to Reproduce
1. Create a private Course and Lesson with a Quiz
2. Complete the Quiz with a pass grade
3. Check Learner Management admin page for that course

#### What I Expected
As all lessons were completed user should be in Completed status. If Lessons are not private but published status, then all works well. This bug happens only with private lessons status.

#### What Happened Instead
The course for that user is still "In Progress"

#### PHP / WordPress / Sensei version
PHP 7.3 / WP 5.2.3 / Sensei 1.12.3

#### Browser / OS version
Any, this is PHP related issue

#### Context / Source
I identified the issue to be in the wp-content/plugins/woothemes-sensei/includes/class-sensei-utils.php:1584:
$lesson_ids = Sensei()->course->course_lessons( $course_id, 'publish', 'ids' );
If that line it's replaced with
$lesson_ids = Sensei()->course->course_lessons( $course_id, ['publish', 'private'], 'ids' );
then everything works well.
As you can see that part of the code it's ignoring private lessons so it ends up later when comparing if all lessons were completed in a wrong result.

Issue first reported on WP at: https://wordpress.org/support/topic/analysis-date-completed-field-blank-for-course/

Contributor guide

Open the contributing guide

Research direction

Start in wp-content/plugins/woothemes-sensei/includes/class-sensei-utils.php at line 1584 and inspect how course_lessons selects lesson IDs for completion checks. Reproduce the private-course scenario, verify that private lessons are included in the comparison, and confirm that Learner Management reports the course as Completed.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.