Display course listings as card components

Created on 10 April 2025, 3 months ago

Problem/Motivation

Currently the Courses listing is a simple unformatted list of links. It would have a more polished look, and be more informative, if they are displayed as cards.

Each course card could include:

  • title
  • image
  • description summary
  • prerequisites
  • status
  • progress indicator
  • tags
  • action buttons

Some of these will need extra fields to be added to the lms_course group type, which may involve an upgrade path.

πŸ“Œ Task
Status

Active

Version

1.0

Component

General appearance

Created by

πŸ‡¨πŸ‡¦Canada ob3ron Canada

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @ob3ron
  • πŸ‡΅πŸ‡±Poland Graber

    I think that’s site building and theming.. not sure if this should be in LMS core, every project will customize that anyway.

  • πŸ‡΅πŸ‡±Poland Graber

    Maybe providing some default components is a good idea though. The question is what’s the best place for them?

  • πŸ‡¨πŸ‡¦Canada ob3ron Canada

    I was thinking just to set up a basic SDC card component, possibly with a default generic course image. Then site builders can customize in their theme or through UI Suite. It can live in a course_card directory under /components.

  • πŸ‡¬πŸ‡§United Kingdom catch

    The extra fields are the sort of thing that would best live in an LMS recipe / site template along the lines of Drupal CMS. I'm not sure what this means for an SDC card component in terms of where it could live or what it could support. If we only included title + a media image field that might be doable, although does UI suite or similar provide one like that already?

  • Pipeline finished with Failed
    about 1 month ago
    Total: 217s
    #506862
  • πŸ‡¨πŸ‡¦Canada ob3ron Canada
  • πŸ‡¨πŸ‡¦Canada ob3ron Canada

    ob3ron β†’ changed the visibility of the branch 3518648-display-course-listings to hidden.

  • Assigned to ob3ron
  • Status changed to Needs work 23 days ago
  • πŸ‡¨πŸ‡¦Canada ob3ron Canada

    ob3ron β†’ changed the visibility of the branch lms-3518648 to hidden.

  • Merge request !104Course cards SDC and Views plugin β†’ (Merged) created by Unnamed author
  • Pipeline finished with Failed
    23 days ago
    #522390
  • πŸ‡¨πŸ‡¦Canada ob3ron Canada

    Added a course card SDC in a responsive grid view, plus a views plugin that allows site builders to optionally display fields of their choice in the SDC that they've added to their Course group. Includes options for assigning fields to course card background, description, and two custom fields.

    Notes:

    • May depend on πŸ“Œ [PP-1] Convert course navigation block to SDC Active to be merged first to avoid conflicts.
    • Includes an update hook that overwrites the existing /courses view, or adds it if not present.
    • It would be good to coordinate release with a documentation update explaining the view options.
  • πŸ‡΅πŸ‡±Poland Graber

    1. Latest changes from 1.0.x need to be included
    2. Some coding standards tests fail
    3. We should avoid having a hard dependency on media module.

  • Pipeline finished with Failed
    18 days ago
    Total: 198s
    #526562
  • Pipeline finished with Failed
    16 days ago
    Total: 276s
    #528231
  • Pipeline finished with Success
    16 days ago
    Total: 378s
    #528239
  • Pipeline finished with Success
    16 days ago
    Total: 367s
    #528241
  • Pipeline finished with Success
    16 days ago
    Total: 366s
    #528242
  • Pipeline finished with Success
    16 days ago
    Total: 458s
    #528243
  • Pipeline finished with Success
    16 days ago
    Total: 290s
    #528251
  • πŸ‡¨πŸ‡¦Canada ob3ron Canada

    Latest changes from 1.0.x included, and hard dependency on media module removed.

    The start_link component needed to be refactored to work in all contexts.

  • Pipeline finished with Success
    16 days ago
    Total: 363s
    #528253
  • Pipeline finished with Success
    15 days ago
    Total: 283s
    #528581
  • Pipeline finished with Success
    15 days ago
    Total: 400s
    #528613
  • Pipeline finished with Success
    15 days ago
    Total: 311s
    #528619
  • Pipeline finished with Success
    15 days ago
    Total: 416s
    #528628
  • πŸ‡¨πŸ‡¦Canada ob3ron Canada

    To clarify the architectural changes:

    StartLinkFieldItemList was both building and rendering the start_link component. That led to context-dependent fatal errors when a form was rebuilt via an AJAX call (like adding a lesson to a new course), and when displaying a start_link component from within a views plugin like our new

    So the building and rendering responsibilities were separated:

    StartLinkFieldItemList now only calculates the component props and stores them as a serialized string. It gets its context directly from the entity it is attached to.

    A new field formatter LmsComponentFormatter calls the field's view() method, which takes the serialized props, unserializes them, and builds the component render array.

    CourseStartLink no longer needs the getRenderable() method. Attributes were added for styling of each of the start_link statuses.

  • Pipeline finished with Success
    15 days ago
    Total: 364s
    #528638
  • Pipeline finished with Success
    14 days ago
    Total: 347s
    #529307
  • πŸ‡¨πŸ‡¦Canada ob3ron Canada

    Documentation for configuring the course cards added at https://www.drupal.org/docs/extending-drupal/contributed-modules/contrib... β†’

  • πŸ‡΅πŸ‡±Poland Graber
  • Pipeline finished with Failed
    9 days ago
    Total: 299s
    #534240
  • Pipeline finished with Success
    9 days ago
    Total: 304s
    #534276
  • πŸ‡¨πŸ‡¦Canada ob3ron Canada

    Bouncing back for review after incorporating all feedback.

  • πŸ‡΅πŸ‡±Poland Graber

    Left some more comments on the MR, let's strip this as much as possible from extra fields and config in favor of exposing API if needed. Looks great otherwise.

  • Pipeline finished with Success
    about 20 hours ago
    Total: 281s
    #540695
  • Pipeline finished with Canceled
    about 20 hours ago
    Total: 148s
    #540701
  • Pipeline finished with Success
    about 20 hours ago
    Total: 262s
    #540707
  • πŸ‡¨πŸ‡¦Canada ob3ron Canada

    Addressed all review comments. Reinstated hook_update_N to set the field display format of the start_link component, which is necessary for all sites, but it does not install the updated /courses view.

  • Pipeline finished with Skipped
    about 12 hours ago
    #541032
  • πŸ‡΅πŸ‡±Poland Graber

    Merged this after making some changes:
    Dropped custom fields UI and renamed to `extra_fields`. Those can now be added by the new hook
    Dropped the second module handler invoke as that can be done in a theme preprocess function
    Constructor property promotion in the new Views row plugin
    Removed duplicated custom fields code from component twig

    Please create follow-ups if needed, I think we'll need a bit of automated test coverage for that, in short visit the view page after some course tests are done and check if start link text is as expected and if other fields contain correct values in a foreach loop.

  • πŸ‡¬πŸ‡§United Kingdom catch

    Hadn't reviewed this yet. The default view is added in config/install, but LMS doesn't have a views dependency, so I think that should be in config/optional?

  • πŸ‡΅πŸ‡±Poland Graber

    Ahh, correct, I'll move it. Somehow thought we have that dependency but it's installed only in automated tests and obviously in the kickstarter repo.

  • πŸ‡΅πŸ‡±Poland Graber

    Ok. There is a views dependency in the .info file actually.

Production build 0.71.5 2024