Issue Details (XML | Word | Printable)

Key: MDL-13228
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Duplicate
Priority: Major Major
Assignee: Tim Hunt
Reporter: John Isner
Votes: 11
Watchers: 10
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Improve the transparency of Roles and Capabilities by adding a View permissions tab

Created: 29/Jan/08 09:59 PM   Updated: 27/Oct/08 05:39 PM
Return to search
Component/s: Roles
Affects Version/s: 1.9
Fix Version/s: None

File Attachments: 1. File get_permission_table (5 kB)
2. File roletab.php (3 kB)

Image Attachments:

1. Table of permission data used to calculate a permission.jpg
(22 kB)
Issue Links:
Duplicate
 
Relates
 

Participants: Gary Anderson, John Isner, Martin Dougiamas, Petr Skoda, Ray Lawrence, Robert Brenstein and Tim Hunt
Security Level: None
Resolved date: 27/Oct/08
Affected Branches: MOODLE_19_STABLE


 Description  « Hide
The Roles and Capabilities system needs greater transparency. It's too much like a black box. The set of permissions that a user has in a given context is the result of a complex algorithm based on role assignments and overrides. I would like to see exactly what a user's current permissions are, and I would like to be able to walk up the context stack and see the permissions at each level. It would be a great way to explore, learn, and debug the system. Currently, we can only guess a user's permissions, or perform tedious experiments in an attempt to deduce them.

The following proposal only applies to users who have permission to Assign roles to users in a given context

On roles-related pages (e.g., Course administration -> Assign roles or modedit pages), add a "View permissions" tab
  
Clicking the View permissions tab displays a list of users (for simplicity, show all users on the site).

In context Y, clicking on user X displays a page "Permissions for User X in context Y" (the complete list of permissions for the selected user in this context).

This gives complete transparency to the roles system. It lets us see the permissions the algorithm has computed from all assignments and overrides.

Two possible enhancements to the "Permissions for User X in context Y" page:

    * Highlight the value of each capability in the parent context (as it's done when displaying overrides)

    * Add an Up button, allowing you to change the page view to the parent context. For example, if the parent context of Y is Z, clicking the Up button will display the page "Permissions for User X in context Z." On the parent page, there would be two buttons, Up and Down, allowing you to either go up another level or return to the previous level. Using these buttons, you can "animate" the display of permissions. You should be able to walk all the way up to the System context.

See discussion http://moodle.org/mod/forum/discuss.php?d=86452




 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Gary Anderson added a comment - 30/Jan/08 11:55 AM
+infinity on this one.

It very much undermines our efforts and the expectation of trust when something as simple as an individual being assigned as a teacher on the site (system) level can monitor and edit grades of every course and that there is no a way for student or teacher to see this capability. Often this type of setting is made without understanding the consequences. And it is frequently not the specific assignment of an individual that is the problem (that individual may be trusted and respected by all concerned), but the control that it takes away by doing it invisibly that is the issue.

Roles should be as transparent as possible, most specifically to the teacher and most likely also the student.


Martin Dougiamas added a comment - 30/Jan/08 01:25 PM
Sounds like a good idea to me!

Ray Lawrence added a comment - 31/Jan/08 08:26 PM
Just thinking about the issue of Hidden Assignments (of Roles). "Yes" to transparency, but hidden assignments should be respected too, otherwise we enter into a new realm of loss of trust.

Martin Dougiamas made changes - 05/Feb/08 12:08 PM
Field Original Value New Value
Assignee Martin Dougiamas [ dougiamas ] Petr Skoda [ skodak ]
Martin Dougiamas made changes - 05/Feb/08 12:08 PM
Fix Version/s 1.9.1 [ 10240 ]
Tim Hunt made changes - 26/Feb/08 04:12 PM
Link This issue is duplicated by MDL-13538 [ MDL-13538 ]
John Isner added a comment - 29/Feb/08 04:06 AM - edited
MDL-13538 was recently marked as a duplicate of this issue. MDL-13538 had an attached code patch for generating the listing of calculated permissions for the "View permissions" tab. The patch simply iterates over all capabilities, repeatedly calling has_capability

+foreach($caps as $cap) { + if (has_capability($cap->name, $testedcontext, $user->id)) $hascaps[$cap->name] = $cap; +}

This would be an extremely expensive calculation, especially if the user were allowed to walk the context chain and display calculated permissions at each level.

It might be possible to write a more efficient algorithm capable of calculating the full set of permissions in a single pass through the data, but the algorithm would probably be very complicated.

In discussion http://moodle.org/mod/forum/discuss.php?d=90826, Tim Hunt suggested an interim solution. Rather than showing the complete set of calculated permissions, Tim suggested displaying them one at a time. Tim writes:

"a new tab next to assign and override that lets you select a user and a capability, and then automatically draws the table ...."

Here Tim is referring to the table format described in http://docs.moodle.org/en/How_permissions_are_calculated

The table (see screenshot) displays the permission data relevant to a single has_capability calle. It displays it in such a way that the viewer can easily perform/verify the calculation mentally by visually tracing the path of the algorithm through the table. In fact, the viewer can easily perform/verify the calculation at each level of the context chain. The viewer animates the display mentally, without need for Up and Down buttons.

As I said, this would be an interim solution. In practice, a user is almost never interested in the value of a single permission, but wants to see them all.


John Isner added a comment - 29/Feb/08 04:08 AM
The image is from the doc wiki article "how permissions are calculated"

John Isner made changes - 29/Feb/08 04:08 AM
Petr Skoda added a comment - 03/Mar/08 09:24 PM
The patch MDL-13538 was not supposed to be fast - it was just basic UI demo.

John Isner added a comment - 06/Mar/08 11:10 PM - edited
I'm attaching two files that you can use to create and display the table used in calculating permissions (http://docs.moodle.org/en/How_permissions_are_calculated). Sorry for the crude programming – I'm not a php programmer. Consider it a prototype.

The files are:

::::roletab.php – point your browser at this file and enter 3 parameters
::::::::capability – e.g., mod/quiz:attempt
::::::::context level – e.g., MODULE
::::::::instance id – e.g., the id of the quiz

::::get_permission_table – add these functions to lib/accesslib.php

The table is printed for the current user. The result of has_capability() is also displayed as a check. If you want to test a module or block context, you must first access the module or block context to ensure that the access data is loaded (since access data below course level is only loaded on demand). For example, try to attempt the quiz.

Feedback and discussion here: http://moodle.org/mod/forum/discuss.php?d=91993


John Isner made changes - 06/Mar/08 11:10 PM
Attachment roletab.php [ 13300 ]
Attachment get_permission_table [ 13299 ]
Petr Skoda added a comment - 09/Mar/08 10:17 AM
Do you really think ppl can make out something from that table?
I can not

Petr Skoda made changes - 09/Mar/08 10:18 AM
Link This issue is duplicated by MDL-13538 [ MDL-13538 ]
Petr Skoda made changes - 09/Mar/08 10:19 AM
Link This issue has been marked as being related by MDL-13538 [ MDL-13538 ]
John Isner added a comment - 09/Mar/08 11:03 AM
You bet I do. It's so easy you can explain it to a child.

Petr Skoda added a comment - 09/Mar/08 07:50 PM
are you going to explain it to millions of children (and teachers) all around the world?
the point is it should not require any explanation

if it is easy please try to explain it here and I will ask several ppl to read it and we will see if they understand it

anyway this may be a very useful feature for developers


John Isner added a comment - 10/Mar/08 03:54 AM
It is explained in the docs wiki article "How permissions are calculated"
http://docs.moodle.org/en/How_permissions_are_calculated

It is a feature for users. For most users today, roles are a black box that they do not understand and that they are afraid of. Transparency is for them, not for developers. Developers can always read the code.

The table is easy to explain, but the explainee must obviously have a working mental model of capabilities, permissions, assignments, overrides and how they work. This includes (1) every admin and every teacher who has permission to override roles. When we give a teacher permission to override, we give them incredible power to fiddle with Moodle's core functionality. So yes, they better understand this stuff! Giving a teacher override permission is like giving the keys to your car to someone. You check first that they know how to drive.


Petr Skoda added a comment - 10/Mar/08 04:54 AM
"It's so easy you can explain it to a child." and then linking to ten page wiki doc How_permissions_are_calculated
Your children must be very clever! :-D

Robert Brenstein added a comment - 10/Mar/08 05:12 AM
I think this feature is primarily for administrators and Moodle-advanced teachers, so I would not worry about explaining this to children. Even if it is a bit convoluted at first glance, it is still a major step in explaining the magic behind roles or rather capability calculation. I am sure with input from those that can't follow, it willbe further improved.

John Isner added a comment - 10/Mar/08 05:44 AM
I agree with Robert. It is only for admins and advanced teachers. "Advanced teacher" is by definition any teacher with override permission, since they have the keys to your car.

The docs wiki article was a multi-purpose article. It explains a lot more than a user would need to know in order to use the table. I will write a version of the article for teachers, but only when there is a feature available for them to use and I know what it looks like (Tim Hunt and I are working on this in http://moodle.org/mod/forum/discuss.php?d=91993. For a user, I would only document (1) how to set up the table (2) how to scan the table. The article will be very short. For exmple: list the role assignments in the top row and place the overrides underneath. Then scan the table as in the diagram you spot an imbalance.

Re: explaining to children. My mentor years ago taught me "you'll know you've got it right when you can explain it to a child." I certainly meant no offence to children, and hope none was taken


John Isner added a comment - 15/Apr/08 10:11 PM
Since my last comment, I have written a stand-alone script for debugging roles-related problems. I have used it to help several users in the forums solve problems. This experience has convinced me that the most important use case for such a feature in Moodle is:

A ROLES EXPERT HELPING A ROLES NOVICE TROUBLESHOOT A ROLES-RELATED PROBLEM.

I'll explain the use case below. I hope to convince you that a feature designed to increase the transparency of roles should NOT be a feature "For Admins Only." like Tim Hunt's Users' Roles Report (third party, modules and plugins database, which is only available in the reports section of the Site admininstration menu).

The use case:

A roles_expert is anyone with a good understanding of permissions, including "how permissions are calculated." A roles_novice is a Moodle user with the ability to follow simple instructions from the expert. While the expert and novice may occasionally share the same physical location and have accounts on the same Moodle site, and sometimes even be the same person, the use case requires none of the above. Specifically, the expert must be able to help the novice (1) without logging in to the novice's site (2) communicating only e-mail, messaging, forum posts, etc.. For example, the novice may be a user posting to a moodle.org forum and the expert may be a moodler wanting to be helpful. Even when expert and novice share a physical location and have accounts on the same Moodle site, the expert may not be in a position to give direct help, e.g., by "logging in as" the novice or meeting with the novice. For example, the expert may be a Moodle administrator who is too busy to spare more than a few minutes helping.

Here's a typical scenario. The novice is a teacher who has created a forum, but is being prevented from posting to the forum for some unknown reason. The novice reports the problem to moodle.org. The expert (a helpful moodler) suspects a roles problem and replies by asking the novice to (1) log in to Moodle, reproduce the problem (2) use the new feature to get permission information (3) paste the output into a reply forum post. The expert reviews the output and (hopefully) diagnoses the problem.

Secondary use cases include

  • a user troubleshooting his own problems
  • a user troubleshooting another user's problem while logged in as that user

Both use cases are equivalent, since there is only one actor (the expert), not two. As in the main use case, the user should not require admin privileges.


Martin Dougiamas made changes - 15/May/08 03:02 PM
Fix Version/s 1.9.2 [ 10280 ]
Fix Version/s 1.9.1 [ 10240 ]
Howard Miller made changes - 22/May/08 03:21 AM
Link This issue has been marked as being related by MDL-14937 [ MDL-14937 ]
Petr Skoda made changes - 06/Jul/08 12:36 AM
Fix Version/s 1.9.2 [ 10280 ]
Tim Hunt added a comment - 27/Oct/08 05:34 PM
Sorry, I managed to create a dupe of this. Since the other one is now done and checked in, I am going to resolve this one as the dupe.

Tim Hunt made changes - 27/Oct/08 05:34 PM
Link This issue duplicates MDL-16965 [ MDL-16965 ]
Tim Hunt made changes - 27/Oct/08 05:35 PM
Resolution Duplicate [ 3 ]
Assignee Petr ?koda [ skodak ] Tim Hunt [ timhunt ]
Status Open [ 1 ] Resolved [ 5 ]
Tim Hunt made changes - 27/Oct/08 05:39 PM
Link This issue has been marked as being related by MDL-8524 [ MDL-8524 ]