Syxton / moodle-block_massaction

THE OFFICIAL Mass Actions block for Moodle 3.9 and beyond
9 stars 14 forks source link

Have a limitation to add course section #115

Closed TomoTsuyuki closed 6 months ago

TomoTsuyuki commented 9 months ago

We have a requirement to control 'Add a new section' for mass action plugin. Currently it's just check 'moodle/course:update'. https://github.com/Syxton/moodle-block_massaction/blob/729896c0675e09df59787408a393a974ef1c592e/classes/form/section_select_form.php#L103

We discuessed and there are 3 options to implement for this.

  1. Have a can_add_section() in the \core_courseformat\base and extended classes, same as can_delete_section(). This option needs to update the core, so need to raise a Moodle tracker ticket.

  2. Add a new capability, block/massaction:addnewsection or something in the plugin.

  3. Add a callback function in the plugin, similar as https://github.com/Syxton/moodle-block_massaction/issues/86

Which option do you prefer? @Syxton

Syxton commented 9 months ago

@TomoTsuyuki So if I understand there are some possible restrictions we need to test for:

  1. Does the user have the permission to add sections? (this is course level and is covered by the current cap check)
  2. Does the course format have room for new sections? (format may have a setting numsections that needs to be checked and updated. We already do this as well)
  3. Does the course format allow the sections to be added to (Potentially static numsections). <- We are here?

So it seems to me that a block level permission wouldn't be enough. So option 2 is out. I would say that option 3 is the fastest way around it, assuming the course format that is being used is custom (like #86) and can be altered to use the new callback. However, it also seems like in the long run option 1 would be better.

I like option 1 for a long term fix for #86 as well. So I would be ok to have option 3 implemented for the short-term with option 3 attempted to lay a core groundwork to remove both this callback and the callback from #86.

tuanngocnguyen commented 8 months ago

I have also created a tracker for can_add_section

https://tracker.moodle.org/browse/MDL-81248

PhMemmel commented 6 months ago

Fixed by #118