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

Course format API in 4.0 is impossible to partially extend

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Blocker Blocker
    • 4.0
    • 4.0
    • Course
    • MOODLE_400_STABLE
    • MOODLE_400_STABLE
    • MDL-73679-master-2
    • Hide
      1. Apply the attached commit:

        git am 73679 - example.patch
        

      2. Read through the notes in the following files:
        1. course/format/topics/templates/local/content.mustache
        2. course/format/topics/templates/local/content/cm/title.mustache
        3. course/format/topics/templates/local/content/section.mustache
        4. course/format/topics/templates/local/content/section/cmitem.mustache
        5. course/format/topics/templates/local/content/section/summary.mustache
      3. Make some changes as advised by those templates
        1. Confirm that they work as expected
      Show
      Apply the attached commit: git am 73679 - example.patch Read through the notes in the following files: course/format/topics/templates/local/content.mustache course/format/topics/templates/local/content/cm/title.mustache course/format/topics/templates/local/content/section.mustache course/format/topics/templates/local/content/section/cmitem.mustache course/format/topics/templates/local/content/section/summary.mustache Make some changes as advised by those templates Confirm that they work as expected

      With the renderers in 3.11 and before course formats were able to override individual methods in order to change how some parts of the course looks.

      In 4.0 it is possible to override only the output classes, which is mostly useless because the DATA for the course format is always the same anyway, course formats what to change how it LOOKS (i.e. override templates).

      Here is the example:

      I want to modify in my course format how the button "Mark as done" looks. The template responsible for it is course/templates/completion_manual.mustache

      This template is referenced by name from the template core_courseformat/local/content/cm/activity_info , and this template referenced by name from core_courseformat/local/content/cm and that one from core_courseformat/local/content/section/cmitem and that one from core_courseformat/local/content/section/cmlist and that one from core_courseformat/local/content/section and that one from core_courseformat/local/content

      So it looks like I have to copy 7 templates to my course format, modify one line in each of them and also override the section_renderer::render() function because it hardcodes the 'core_courseformat/local/' prefix for templates as well

        1. BPMN_023.png
          BPMN_023.png
          56 kB
        2. BPMN_024.png
          BPMN_024.png
          47 kB
        3. cm.mustache
          4 kB
        4. cmp1.json
          59 kB
        5. cmp2.json
          58 kB
        6. example.patch
          20 kB
        7. MDL-73679.png
          MDL-73679.png
          111 kB
        8. Screenshot from 2022-03-01 09-37-08.png
          Screenshot from 2022-03-01 09-37-08.png
          11 kB
        9. theme_cm.mustache
          4 kB

            dobedobedoh Andrew Lyons
            marina Marina Glancy
            Ferran Recio Ferran Recio
            Victor Déniz Falcón Victor Déniz Falcón
            Mihail Geshoski Mihail Geshoski
            Votes:
            2 Vote for this issue
            Watchers:
            18 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 days, 6 hours, 17 minutes
                4d 6h 17m

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