Skip to content

Course Outline: Add CSS class to lessons blocked by an incomplete prerequisite#7937

Open
Drivingralle wants to merge 3 commits into
Automattic:trunkfrom
Drivingralle:7936
Open

Course Outline: Add CSS class to lessons blocked by an incomplete prerequisite#7937
Drivingralle wants to merge 3 commits into
Automattic:trunkfrom
Drivingralle:7936

Conversation

@Drivingralle

Copy link
Copy Markdown

Resolves #7936

Proposed Changes

Add a blocked CSS class to the lesson <a> element in render_lesson_block() when Sensei_Lesson::is_prerequisite_complete() returns false for the current user. Follows the same pattern as the existing completed class and the pending class proposed in #7934.

Testing Instructions

  1. Set up a course with at least two lessons where the second lesson has the first set as a prerequisite.
  2. Log in as a student who is enrolled but has not yet completed the first lesson.
  3. View the course page and inspect the second lesson's link in the course outline — it should have both wp-block-sensei-lms-course-outline-lesson and blocked in its class attribute.
  4. Complete the first lesson, then revisit the course outline — the blocked class should no longer be present on the second lesson.
  5. Verify that lessons without a prerequisite are unaffected.

New/Updated Hooks

  • None

Deprecated Code

  • None

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new CSS hook to the Course Outline lesson link markup so themes can visually indicate lessons that are locked due to an incomplete prerequisite.

Changes:

  • Add a blocked CSS class to lesson <a> elements when Sensei_Lesson::is_prerequisite_complete() is false for the current user.

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

Comment on lines +37 to +39
if ( ! Sensei_Lesson::is_prerequisite_complete( $lesson_id, get_current_user_id() ) ) {
$class_names[] = 'blocked';
}
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.

Course Outline: Add CSS class to lessons blocked by an incomplete prerequisite

3 participants