Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have a limitation to add course section #115

Closed
TomoTsuyuki opened this issue Feb 15, 2024 · 3 comments
Closed

Have a limitation to add course section #115

TomoTsuyuki opened this issue Feb 15, 2024 · 3 comments

Comments

@TomoTsuyuki
Copy link

TomoTsuyuki commented Feb 15, 2024

We have a requirement to control 'Add a new section' for mass action plugin.
Currently it's just check 'moodle/course:update'.

$canaddsection = has_capability('moodle/course:update', \context_course::instance($targetcourseid));

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 Add a callback to let other plugins to limit sections allowed to move activities to #86

Which option do you prefer? @Syxton

@Syxton
Copy link
Owner

Syxton commented Feb 15, 2024

@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
Copy link

I have also created a tracker for can_add_section

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

@PhMemmel
Copy link
Collaborator

PhMemmel commented May 10, 2024

Fixed by #118

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants