Skip to content

HPPS: Tables-based lesson progress does not account for pass_required in is_complete() #7943

@donnapep

Description

@donnapep

Summary

The comments-based Lesson_Progress::get_status() checks the quiz's _pass_required setting when the quiz status is failed — if pass is not required, the lesson is still considered complete. The tables-based implementation does not have this check, so a failed quiz always means the lesson is in-progress.

This needs investigation to confirm whether this is a valid discrepancy that should be fixed, or whether the tables-based behavior is intentionally simpler.

Details

Comments-based (Comments_Based_Lesson_Progress::get_status()):

case 'failed':
    $pass_required = get_post_meta( $lesson_quiz_id, '_pass_required', true );
    if ( empty( $pass_required ) ) {
        return self::STATUS_COMPLETE; // Pass not required, so lesson is complete
    }
    return self::STATUS_IN_PROGRESS;

Tables-based (Tables_Based_Lesson_Progress):

  • Empty class, inherits Lesson_Progress_Abstract::get_status() which returns the raw status
  • is_complete() checks get_status() === STATUS_COMPLETE
  • A failed quiz student has lesson status in-progress in the tables → is_complete() returns false

Observed impact

On the Reports pages (discovered during PR #7932), this causes several differences between comments and tables storage:

  1. Date Completed column — comments shows a date for failed students (because comment_date is always updated), tables shows blank (because completed_at is NULL for non-complete lessons)
  2. Percent complete — may be lower in tables because failed + pass-not-required students aren't counted as complete
  3. Completion counts — same as above

Questions to assess

  • Is the comments-based _pass_required check the correct behavior, or is it a legacy workaround?
  • Should the tables-based storage set completed_at and status complete when a quiz is failed but pass is not required?
  • If so, should this be handled at the storage layer (is_complete()) or at the point where quiz results are processed?
  • Would fixing this require a data migration for existing sites?

Related

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions