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

The functions in the core_courseformat\output\local\* classes are too long

XMLWordPrintable

    • Moppies Kanban

      I was trying to migrate my course format to 4.0 and noticed that it is very difficult to extend classes such as

      core_courseformat\output\local\content\cm
      core_courseformat\output\local\content\section

      The functions export_for_template() in these classes are over 100 lines long. When I want to change just a small part of these functions I need to copy them completely.

      Here are simple examples of what I wanted to change:

      1. core_courseformat\output\local\content\cm::export_for_template() in the line 140 calls:

                  $activityinfo = new activity_information($mod, $completiondetails, $activitydates);
                  $activityinfodata = $activityinfo->export_for_template($output);
      

      Unlike all other templatable classes in course formats I can not specify my own class for the activity_information, so I need to copy the whole 130 line long function in order to replace the name of this class.

      2. core_courseformat\output\local\content\section::export_for_template() in line 216 has this code:

          if (!$format->show_editor() && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
      

      Now, the 'coursedisplay' is a course format option defined in the topics and weeks formats. It is not present in my format, for example. So this line throws an exception in PHP "Trying to access non-existing property". Again, I have to copy the 120 line long function in order to change one line.

      I understand that these two places can be changed in core and it would solve this particular problem, but I'm sure other plugin developers will face different problems.

      The functions can never be that long, especially in the classes that are intended to be extended.

            tusefomal Ferran Recio
            marina Marina Glancy
            Carlos Escobedo Carlos Escobedo
            Andrew Lyons Andrew Lyons
            CiBoT CiBoT
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 6 hours, 30 minutes
                1d 6h 30m

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