A backup taken in a version before 3.11.7 or 4.0.1 (where
MDL-65478 was integrated) will have its course format settings reverted to defaults when restored into a 3.11.7 or 4.0.1 site. This is a consequence of the MDL-65478 change not accounting for earlier version backups when it changed the storage strategy for format options.
Additionally, a second related fault exists with course format options being restored against the wrong format type because the format is not used as a condition of the record existence check.
To reproduce the loss of format settings old-to-new:
1. Create a course in a 3.11.6 site with weeks/topics format and change the 'Hidden sections' and 'Course layout' settings to values other than the site defaults (typically that would mean setting 'Hidden sections are completely invisible' and 'Show one section per page').
2. Back up the course.
3. In a 3.11.7 site, restore the backup.
4. Edit the restored course settings and observe the 'Hidden sections' and 'Course layout' settings are back to the site defaults (typically 'Hidden sections are shown in collapsed form' and 'Show all sections on one page')
To reproduce restoration of course format options against the wrong format type:
1. Create a course using Topics format and set its 'Hidden sections' option to '.. are shown as not available' and 'Course layout' to 'Show all sections on one page'.
2. Create a second course using Weekly format and set 'Hidden sections' to '.. completely invisible' and 'Course layout' to 'Show one section per page'.
3. Back up the second course and restore it over the first course. i.e. Restore into an existing course → Delete the contents of the existing course and then restore, choose to overwrite course configuration but not the names.
4. Compare the first and second courses and observe they don't have the expected matching course format settings.