If a new course is created using the Collapsed Topics course format, the following error is received upon creation if "Blocks to display" is empty.
I am not a developer, so I'll apologize in advance if this assessment is off target, but I think the problem is in the get_default_blocks function. The function retrieves the value of the defaultdisplayblocks config and then runs the PHP explode function on the value. When there are no blocks selected in the config, the value of the config is empty string. Calling the explode function on empty string produces an array with one key containing empty string. This array is then passed onto the blocks_add_default_course_blocks function in /lib/blocklib.php which in turn calls add_blocks passing the empty string as the name of the block to add. To avoid the error, I think the get_default_blocks function needs to pass an empty array when the value of defaultdisplayblocks is empty string.
STEPS TO REPLICATE
- Go to Site administration > Plugins > Manage Blocks.
- Hide the following blocks:
Latest announcements (new_items)
Recent activity (recent_activity)
Search forums (search_forums)
Upcoming events (calendar_upcoming)
- Go to Site administration > Plugins > Course formats > Collapsed Topics.
- Ensure that no values are selected in "Blocks to display".
- Go to Site administration > Courses > Add a new course.
- Enter a full name and short name for the course. Under Course format set the format to Collapsed Topics.
- Click Save and Return or Save and Display.
The course is created but an error is received stating, "Coding error detected, it must be fixed by a programmer: Block type has been disabled by the administrator."
The course is created without an error.
This issue was replicated on a site built on Moodle 3.11.3 using version 22.214.171.124 of the Collapsed Topics plugin. I have not tested version 126.96.36.199, but the function in question has not been updated between these versions.