Couldn't find Reports builder forum so I'm posting my question here. Is there any workaround to implement "Relation to the report viewer" feature in standard Moodle Reports builder? I know that's a feature in Moodle Workplace, but I wanted to know is there any trick to implement it in standard Moodle? Are there any variables that can be used in Report builder like in Configurable Reports plugin?
Hi Zoran,
Please see: https://docs.moodle.org/400/en/Report_builder#Conditions - the condition you mention depends on an organisation structure defined on the site (features that are specific to Moodle Workplace). How would you envisage this working without access to an organisation structure?
Please feel free to post your request in the Moodle Tracker.
Please see: https://docs.moodle.org/400/en/Report_builder#Conditions - the condition you mention depends on an organisation structure defined on the site (features that are specific to Moodle Workplace). How would you envisage this working without access to an organisation structure?
Please feel free to post your request in the Moodle Tracker.
Hi Zoran,
to my knowledge, the answer from Paul is correct. In the report builder in Moodle LMS (as opposed to the one in Workplace), there is no user relation implemented. However, Moodle LMS has user relations implemented for many years, google "moodle parent role" to learn more about it. Basically what you can do is: create a new role, call it "mentor", "parent" or "line manager" — depending on your particular use case — and make it a user context role. Then, you can assign this role relative to a user, i.e. you can make a user the "parent" or another user. This can be accomplished in several ways:
1) Open the preferences of a user, then select "assign role relative to this user"
2) Open site admin, go to the users tab and then choose "Assign user roles to cohort" —> this does the same as in (1), but you can assign one "parent" to all members of a cohort at the same time
3) Use one of the plugins available in the plugin db that create these role assignments; most of them are not updated frequently though, but the functionality is so old that in my experience, they usually work fine — but use at your own risk and test carefully!
Capabilities that you give to the role will only apply to the "related" user.
This won't have any effect on the report builder though, but it might be possible to achieve it in a bespoke report source for the report builder, because we have implemented that very login in several of our plugins, e.g. in Dash Pro, which can create reports that list only users that the current user is "related" to or in Magic authentication (not yet released), where users can create "sub accounts".
Hope this helps!
Stefan
to my knowledge, the answer from Paul is correct. In the report builder in Moodle LMS (as opposed to the one in Workplace), there is no user relation implemented. However, Moodle LMS has user relations implemented for many years, google "moodle parent role" to learn more about it. Basically what you can do is: create a new role, call it "mentor", "parent" or "line manager" — depending on your particular use case — and make it a user context role. Then, you can assign this role relative to a user, i.e. you can make a user the "parent" or another user. This can be accomplished in several ways:
1) Open the preferences of a user, then select "assign role relative to this user"
2) Open site admin, go to the users tab and then choose "Assign user roles to cohort" —> this does the same as in (1), but you can assign one "parent" to all members of a cohort at the same time
3) Use one of the plugins available in the plugin db that create these role assignments; most of them are not updated frequently though, but the functionality is so old that in my experience, they usually work fine — but use at your own risk and test carefully!
Capabilities that you give to the role will only apply to the "related" user.
This won't have any effect on the report builder though, but it might be possible to achieve it in a bespoke report source for the report builder, because we have implemented that very login in several of our plugins, e.g. in Dash Pro, which can create reports that list only users that the current user is "related" to or in Magic authentication (not yet released), where users can create "sub accounts".
Hope this helps!
Stefan
I was thinking about more simple approach. Moodle has custom user profile fields that can be used to implement relation between users. For example, I can create a filed called Manager's email. This is actually used by some plugins. For example Face 2 Face plugin uses that kind of relation so that managers can approve user's sing up for the classroom session. We used the same approach for reports built in Configurable Reports plugin. New Report Builder is great but not that flexible as Configurable Reports where we could use variables such as %%USERID%% in custom SQL query reports. What I was hoping that could be possible and very easy to implement in new Reports Builder feature is that we could compare to different database fields as a condition for a report. For example, instead of condition email equals xyz@xyz.xyz, we could use something like managersemail equals currentuser.email, managersemail being custom field value of users fetched by the report and currentuser.email being email of the user running the report. This would be applicable in many situations and not just for hierarchical reporting. Another example would be condition department equals currentuser.department. This would generate report displaying users belonging to department of user running the report.
Does that make any sense?
I know about parent-child relationship that you mentioned but that's not well documented and far more complicated to implement, AFAIK. Maybe I'm wrong.
Does that make any sense?
I know about parent-child relationship that you mentioned but that's not well documented and far more complicated to implement, AFAIK. Maybe I'm wrong.
The user profile fields are available as filters in the user report already, with options like "contains, does not contain etc" - we could pretty easily add a new option to that list "matches current user" - that way you could add a filter/condition on a report that says - only show users with a department that matches the value of the current users department or any other user field type matching.
Of course you'd have to be careful how this was used - normally users have the ability to modify their department field so they could potentially just change it and gain access to different sets of users, but I can see it being used in other cases too.
Adding other filter types / lookups on other fields would take a little more work, but custom filters aren't that hard to write (we've written a few in the plugins we're working on here at Catalyst already)
Of course you'd have to be careful how this was used - normally users have the ability to modify their department field so they could potentially just change it and gain access to different sets of users, but I can see it being used in other cases too.
Adding other filter types / lookups on other fields would take a little more work, but custom filters aren't that hard to write (we've written a few in the plugins we're working on here at Catalyst already)
Awesome! Regarding security, Moodle has an option to lock user certain profile fields so user couldn't change those.