Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-78207

Implement activity card information badge integration

XMLWordPrintable

    • MOODLE_403_STABLE
    • MOODLE_403_STABLE
    • MDL-78207-master
    • Hide

      Setup

      1. Login as admin.
      2. Create a course.
      3. Add a File resource to the course with a file attached and set the following settings in the Appearance section:
        • Set Display to "Embed".
        • Enable, at least, Show size, Show type and Show upload/modified date.
      4. Add a Forum activity to the course.
      5. Post, at least, a message to the forum.

      Testing scenario

      1. Login as student.
      2. Go to the User preferences and in "Forum preferences" set "Forum tracking" to "Yes: highlight new posts for me".
      3. Access to the course.
      4. Check the "X unread post(s)" badge in the forum activity card on the main course page is displayed near the activity name with a black background.
      5. Check the file extension (for example, PDF) in the file activity card on the main course page is displayed near the activity name, with a transparent background.
      6. Check the file size and the file updated date are displayed at the bottom of the file activity card on the course page.
      7. Access to the file.
      8. Check the size, file extension and date are displayed in the same line, with a "·" between them.
      Show
      Setup Login as admin. Create a course. Add a File resource to the course with a file attached and set the following settings in the Appearance section: Set Display to "Embed". Enable, at least, Show size, Show type and Show upload/modified date. Add a Forum activity to the course. Post, at least, a message to the forum. Testing scenario Login as student. Go to the User preferences and in "Forum preferences" set "Forum tracking" to "Yes: highlight new posts for me". Access to the course. Check the "X unread post(s)" badge in the forum activity card on the main course page is displayed near the activity name with a black background. Check the file extension (for example, PDF) in the file activity card on the main course page is displayed near the activity name, with a transparent background. Check the file size and the file updated date are displayed at the bottom of the file activity card on the course page. Access to the file. Check the size, file extension and date are displayed in the same line, with a "·" between them.
    • 3
    • HQ 2023 Sprint i2.2 Moppies

      Activities can add extra HTML to the activity card using the afterlink feature. This integration allows things like:

      • In mod_forum, this HTML is a bootstrap pill with unread messages.
      • In mod_resource is plain text with the file details.

      The new activity card design proposed for 4.3 differentiates badge information from other HTML content. The badge will appear just after the activity name and any other content will appear on the lower part of the card.

      This issue is to implement the new "badge" integration allowing plugins to:

      • Decide if they want to display a badge near the activity name
      • Return the plain text (not HTML) badge content
      • Optionally, set the badge style (notice, alert, warning...). Important note: it should be a "badge-none" class to display the badge as a transparent background and without a border (needed in some cases when the badge is secondary information like the file extension)
      • An optional URL to direct the user when the badge is clicked
      • An optional ID to add the element in case the module wants to add some JS to the badge events.
      • Optionally, any other extra HTML attributes to the badge element (for example, data attributes).

      To test the integration, this issue also includes moving the current mod_forum unread messages pill from the generic information to the pill one.

      Technical shaping

      The current afterlink is the typical integration that allows anarchy because they don't limit the content plugins can add to the course page.

      In this case, the badge should only allow plain text and some specifications like the badge style. To limit the excess of creativity of the plugins, the best approach is to allow plugins to implement a specific class. For example, mod_PLUGINNAME\output\courseformat\activitybadge that extends from an original core_courseformat\output\activitybadge. The core_courseformat\output\activitybadge will delegate most data attributes to protected methods.

      Using this approach, we can guarantee activities will only override some methods.

      Finally, the activity badge can be rendered using the existing course/format/templates/local/content/cm/badges mustache or creating a new one.

        1. file_type.png
          file_type.png
          15 kB
        2. forum_unreadmessages.png
          forum_unreadmessages.png
          4 kB
        3. file_type_editing.png
          file_type_editing.png
          11 kB
        4. MDL-78207.png
          MDL-78207.png
          1.94 MB

            sarjona Sara Arjona (@sarjona)
            tusefomal Ferran Recio
            Mikel Martín Corrales Mikel Martín Corrales
            Ferran Recio Ferran Recio
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 days, 6 hours, 11 minutes
                2d 6h 11m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.