chamilo / chamilo-lms

Chamilo is a learning management system focused on ease of use and accessibility
https://chamilo.org
GNU General Public License v3.0
785 stars 478 forks source link

[C2] Roles and permissions fine-grained management #5644

Open ywarnier opened 2 months ago

ywarnier commented 2 months ago

Add the possibility to define fine-grained permissions and assign them to roles.

A definition of basic permissions is ongoing here: https://github.com/chamilo/chamilo-lms/wiki/Permissions

Create a Permission entity with id, title, slug and description. Create a PermissionRelRole entity with id, permission_id, role_code, changeable, updated_at. Create an assignment interface with roles in columns and permissions in rows, like so:

Permission ROLE_INVITEE ROLE_STUDENT ROLE_TEACHER ...
analytics:view [] [x] [x]
assignment:create [] [] [X]

allowing one to check the boxes for each role (except when changeable == 0). This is then sent to the PermissionRelRole entity/table.

Use the wiki table as source for the default definition of each set of permissions per role.

Define a global permission function to search for the existence of a permission based on the permission name and an array of roles. Something like api_get_permission('analytics:view', ['ROLE_STUDENT','ROLE_TEACHER']). This function/helper will then check, for the given permission, if one or more of the roles provided has the permission enabled and return true or false based on that.

Relates to #2540

christianbeeznest commented 2 months ago

Added in this PR https://github.com/chamilo/chamilo-lms/pull/5651 , waiting for testing to merge , the interface for permissions management is /permissions

ywarnier commented 2 months ago

Well done!

ywarnier commented 1 month ago

@christianbeeznest We need to add one permission "Edit course settings" so that teachers can be given limited access to a course, if needed. This permission is on by default for all teachers, but can be removed (also for all teachers) at once.

christianbeeznest commented 1 month ago

It is done with this commit https://github.com/chamilo/chamilo-lms/pull/5723/commits/70b8eef2bd90d3ad518da5a2367c994d615b9f39