-
Bug
-
Resolution: Fixed
-
Major
-
4.0
-
MOODLE_400_STABLE
-
MOODLE_400_STABLE
-
MDL-73762-master -
-
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.