Sensei: Private completed lessons prevent user from completing the course

Created on 14 Nov 2019  路  5Comments  路  Source: Automattic/sensei

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/

[Type] Bug

Most helpful comment

Our main use case has been where we deprecate a lesson, and replace it with a better one.

Old one goes to either Private or Draft mode - they should not stay part of the calculations.

All 5 comments

@cleardesign I'm curious as to how your students are taking these courses when they don't show up on the front end? For example, private courses are not listed on the Courses page, but if I'm an admin or an editor I can browse directly to the page for the course.

However, if I then start taking the course, I still don't see the list of lessons. Again though, I can browse directly to the private lesson.

And private courses aren't listed at all in _Sensei LMS_ > _Learner Management_.

It seems as though private courses and lessons don't work well in general, and not marking them as completed is only one small part of the problem.

Our main use case has been where we deprecate a lesson, and replace it with a better one.

Old one goes to either Private or Draft mode - they should not stay part of the calculations.

@cleardesign I'm curious as to how your students are taking these courses when they don't show up on the front end? For example, private courses are not listed on the Courses page, but if I'm an admin or an editor I can browse directly to the page for the course.

However, if I then start taking the course, I still don't see the list of lessons. Again though, I can browse directly to the private lesson.

And private courses aren't listed at all in _Sensei LMS_ > _Learner Management_.

It seems as though private courses and lessons don't work well in general, and not marking them as completed is only one small part of the problem.

@donnapep On our site, we only want logged in members to be able to register for courses. So, we have published all course lessons/quizzes as Private posts, and created a new user type in WordPress for Members, which has the permission to read Private posts. But, of course, course completion and grading in Sensei doesn鈥檛 work as expected for Privately published Lesson posts.

So, we have published all course lessons/quizzes as Private posts, and created a new user type in WordPress for Members, which has the permission to read Private posts.

Risky model. You will need many overrides to make this work. Move towards derisking?

On our site, we only want logged in members to be able to register for courses.

I may be missing something, but I believe this is already Sensei's default behaviour. The user sees a _Register_ button on the single course page, and when they click that button they will need to either log in or create a new account before they can take the course.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danjjohnson picture danjjohnson  路  7Comments

danjjohnson picture danjjohnson  路  6Comments

MindyPostoff picture MindyPostoff  路  3Comments

merkushin picture merkushin  路  3Comments

cycomarcooo picture cycomarcooo  路  5Comments