Collapsed Topics updated from V405.0.1 to V405.0.2 for Moodle 4.5

Collapsed Topics updated from V405.0.1 to V405.0.2 for Moodle 4.5

by Gareth J Barnard -
Number of replies: 6
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hello,

I've released an updated 'release candidate' version of the Collapsed Topics course format for Moodle 4.5 as follows:

Release 405.0.2 for Moodle 4.5 version 2024100700.00 (Build: 20241007) and above within the MOODLE_405_STABLE branch until the next release:

with:

  1. Fix 'Student view not working as expected within hidden sections' - #153.
  2. Fix 'Hidden from Students not showing in section header' - #154.  Note: Does not update via AJAX yet!
  3. Fix the Course Index to always link to the main course page as being dynamic is not possible due to caching.  This is contrary to core where the links are to the single section page, which the format already implements next to the section.
  4. Refactored toggle JS to convert from YUI to ES6.
  5. One section applies even when editing.
  6. Old toggle format was ages ago, so no longer checking.
  7. Sub section support.
  8. 'numsections' has been removed in order to feasibly support Sub sections.

Important:

This is still a 'release candidate' because of 'Sub section support' which has been incredibly difficult to support to the extent that I've had to wave a 'white flag' and remove the 'numsections' setting.  The course format API has been broken apart into so many interconnected small pieces (each tending to have separate PHP, JS and Mustache files), https://moodledev.io/docs/4.5/apis/plugintypes/format#format-output-classes-and-templates and https://moodledev.io/docs/4.5/apis/plugintypes/format#the-course-editor-structure, that it is difficult at times to understand and keep in working memory what is going on and where a given element of functionality is implemented to the extent where it can be overridden and changed.  Thus the format will now operate as 'Topics' does in terms of number of sections management.  Collapsed Topics was only ever designed to operate on sections and as such sees 'Sub sections' as different entities not related to the number of sections in a course.  This has an impact on the core 'maxsections' setting and when its restriction comes into play.  Collapsed Topics will allow you to have as many 'Sub sections' as you want as long as they're added before the number of 'Sections' is less than the maximum number of sections.  Tracker issues of interest for this are: MDL-84038 and MDL-84291.

Because of the removal of 'numsections', this has an impact on backup and restore, which I've tested.  However with such a change brings risk and a greater chance of error, thus I cannot stress enough that you MUST test and be sure that the format works as expected before it goes anywhere near a production server.  I found with the Grid format that once 'numsections' was removed that it was tricky to go back, and therefore it would be unlikely even with the flexibility I like of being able to set the number of sections both as a course setting and add / remove in the course itself.

I have refactored the whole toggle state preference JavaScript such that it no longer uses YUI.  This I hope will help to keep the format going for many years to come as older technologies are removed from core.

Note: Always install on a test server to confirm that the format does what you want it to do before updating or installing on a production server!  And as this release could contain bugs and so I strongly recommend that you check on a test server first!  Not sure how to set one up?  Then look at the 'Installer packages' on https://download.moodle.org/releases/latest/. Ensure that you have multiple backups of all data before using.  Please report any issues. i.e. 'bugs' with this release ONLY here.  Before doing so please read 'Reporting issues' on the 'Information' tab on the course format 'Settings' under 'Site administration' -> 'Plugins' -> 'Course formats' -> 'Collapsed Topics'.

If you find this post useful, then please mark it so.

Thank you,

Gareth

Average of ratings: -
In reply to Gareth J Barnard

Re: Collapsed Topics updated from V405.0.1 to V405.0.2 for Moodle 4.5

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Issue detected!

If you create a backup of a course that has more sections than max sections (i.e. the number of sub-sections pushes this limit) then the backup file will not restore, but fail.  Instead (if you have xDebug installed + developer debugging) then cron will show:

Adhoc task failed: core\task\asynchronous_restore_task,Xdebug has detected a possible infinite loop, and aborted your script with a stack depth of '256' frames
Backtrace:
* line 49 of \backup\util\helper\backup_general_helper.class.php: call to backup_setting->calculate_checksum()
* line 241 of \backup\util\plan\base_task.class.php: call to backup_general_helper::array_checksum_recursive()
* line 49 of \backup\util\helper\backup_general_helper.class.php: call to base_task->calculate_checksum()
* line 51 of \backup\util\helper\backup_general_helper.class.php: call to backup_general_helper::array_checksum_recursive()
* line 242 of \backup\util\plan\base_task.class.php: call to backup_general_helper::array_checksum_recursive()
* line 49 of \backup\util\helper\backup_general_helper.class.php: call to base_task->calculate_checksum()
* line 51 of \backup\util\helper\backup_general_helper.class.php: call to backup_general_helper::array_checksum_recursive()
* line 242 of \backup\util\plan\base_task.class.php: call to backup_general_helper::array_checksum_recursive()
* line 49 of \backup\util\helper\backup_general_helper.class.php: call to base_task->calculate_checksum()
* line 51 of \backup\util\helper\backup_general_helper.class.php: call to backup_general_helper::array_checksum_recursive()
* line 242 of \backup\util\plan\base_task.class.php: call to backup_general_helper::array_checksum_recursive()
* line 49 of \backup\util\helper\backup_general_helper.class.php: call to base_task->calculate_checksum()
* line 51 of \backup\util\helper\backup_general_helper.class.php: call to backup_general_helper::array_checksum_recursive()
* line 242 of \backup\util\plan\base_task.class.php: call to backup_general_helper::array_checksum_recursive()
......
* line 49 of \backup\util\helper\backup_general_helper.class.php: call to base_task->calculate_checksum()
* line 51 of \backup\util\helper\backup_general_helper.class.php: call to backup_general_helper::array_checksum_recursive()
* line 242 of \backup\util\plan\base_task.class.php: call to backup_general_helper::array_checksum_recursive()
* line 49 of \backup\util\helper\backup_general_helper.class.php: call to base_task->calculate_checksum()
* line 169 of \backup\util\plan\base_plan.class.php: call to backup_general_helper::array_checksum_recursive()
* line 49 of \backup\util\helper\backup_general_helper.class.php: call to base_plan->calculate_checksum()
* line 277 of \backup\controller\restore_controller.class.php: call to backup_general_helper::array_checksum_recursive()
* line 494 of \backup\controller\restore_controller.class.php: call to restore_controller->calculate_checksum()
* line 241 of \backup\controller\restore_controller.class.php: call to restore_controller->save_controller()
* line 97 of \lib\classes\task\asynchronous_restore_task.php: call to restore_controller->set_status()
* line 519 of \lib\classes\cron.php: call to core\task\asynchronous_restore_task->execute()
* line 302 of \lib\classes\cron.php: call to core\cron::run_inner_adhoc_task()
* line 128 of \lib\classes\cron.php: call to core\cron::run_adhoc_tasks()
* line 80 of \admin\cron.php: call to core\cron::run_main_process()

I hope to put a fix out in the next release.  In the mean time, ensure that 'maxsections' is equal to or greater than the total number of sections (including sub) you have.

Gareth

In reply to Gareth J Barnard

Re: Collapsed Topics updated from V405.0.1 to V405.0.2 for Moodle 4.5

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Looks like this can happen in 'Custom sections' too, please see MDL-84874. It did take me a while to deduce the replication steps, thus I welcome peer replication of the steps + any comments you may have, positive or negative. I believe that not implementing MDL-83056 is a mistake and so is MDL-84291. Sub-sections are not 'sections' they are modules that contain other modules. If they were 'sections' then you'd be able to move a 'sub-section' to become a 'section' and vice-versa. Please also see: https://moodle.org/mod/forum/discuss.php?d=464693.
In reply to Gareth J Barnard

Re: Collapsed Topics updated from V405.0.1 to V405.0.2 for Moodle 4.5

by Marybeth Koon -
I have been testing this out and one thing I noticed is that in this version, I do see where I can change/adjust the number of sections. This was a setting in the previous version of collapsed topics or the one we still have on our production server. This was a great feature since you cant "bulk remove' section folders like you can bulk remove/delete activities and resources now in the newer version.
In reply to Marybeth Koon

Re: Collapsed Topics updated from V405.0.1 to V405.0.2 for Moodle 4.5

by Marybeth Koon -
I meant "don't" see where you can adjust number of sections. I was also lookin in my admin settings to see if it was a setting perhaps that I could enable there
In reply to Marybeth Koon

Re: Collapsed Topics updated from V405.0.1 to V405.0.2 for Moodle 4.5

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Dear Marybeth,

Please read https://moodle.org/mod/forum/discuss.php?d=466700#p1873454 as to why I've had to remove the 'numsections' setting in order to support sub-sections.

Kind regards,

Gareth
In reply to Gareth J Barnard

Re: Collapsed Topics updated from V405.0.1 to V405.0.2 for Moodle 4.5

by Marybeth Koon -
Ah yes, I see. Right there in front of my face! smile

thank you,

Marybeth