gjbarnard / moodle-format_topcoll

Collapsed Topics course format for Moodle.
http://docs.moodle.org/en/Collapsed_Topics_course_format
GNU General Public License v3.0
35 stars 60 forks source link

Deleting sections doesn't work in some layouts #130

Closed olivabigyo closed 1 year ago

olivabigyo commented 1 year ago

Describe the bug Deleting sections is broken in layouts without section numbers.

To Reproduce Steps to reproduce the behaviour:

  1. In the 'Collapsed Topics' plugin setting change 'Layout' to anything without section numbers, eg. 'No additions'. (Can do it in a course settings.)
  2. Edit a course with 'Collapsed Topics' format.
  3. (optional) Add a new section at the bottom
  4. Click the 3 dots next to a section, click 'Delete section'
  5. The sections below the deleted one are renumbered, but the deleted section is not removed. There is also an error message in the JS console. (The section is actually removed from the DB and will not be present after a reload.)

Expected behaviour The section disappears after deletion.

Screenshots If applicable, add screenshots to help explain your problem.

Version (please complete the following information)

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

gjb2048 commented 1 year ago

@olivabigyo Thanks for this, I'll see of I can replicate as soon as I can. Given my comments on #131 - then why does the Topics format not suffer from the same issue?

olivabigyo commented 1 year ago

I have replied in the PR. Crucially, your code has an additional part that's different from the Topics format (to update the section numbers), which is where the bug is triggered.

The core Moodle might or might not have a similar issue (which is harder to trigger), this requires more investigation. Definitely the documentation of the getElement method is incorrect.

gjb2048 commented 1 year ago

@olivabigyo Thanks, saw that just after I posted my reply and have replied there.

gjb2048 commented 1 year ago

@olivabigyo Also, would you like a credit in the Changes.md file?

olivabigyo commented 1 year ago

Thank you for the quick handling! Credit: why not, thanks :)

gjb2048 commented 1 year ago

@olivabigyo No problem. Credit added and patch forward ported to master, currently for M4.1.