Moodle Plugins directory: Dynamic Multi Select | Moodle.org
Dynamic Multi Select
User profile fields ::: profilefield_dynamicmultiselect
Maintained by
Antonello Moro
Dynamic Multi Select user profile field for Moodle.
Now users can create user multi select fields whose values are retrieved from the moodle DB.
Latest release:
37 sites
11 downloads
11 fans
Current versions available: 2
Dynamic multi-select user profile field for Moodle. Now users can create user multi-select fields whose values are retrieved from the moodle DB. Basically, the user can set an SQL query as value definition of the field. Please note that the query must return two fields: id and data. Please note that this is an advanced plugin, mainly intended for developers and very advanced moodle users. You must be confident with Moodle DB and SQL language to use this plugin properly. In fact, this plugin allows execution of raw SQL. Please be aware that executing raw SQL that has been improperly written can irreparably damage your site and/or cause performance issues. Please ensure you are aware of the impact of your SQL before executing it.
A possible use case is when one needs to link a user profile field to values that change in time because they are stored in a Moodle table and are updated by users and/or by external services.
Contributors
Antonello Moro (Lead maintainer)
Please login to view contributors details and/or to contact them
You are right about security and performance, in fact, besides a notice in the readme about the risks of using this plugin, I have also provided a capability: profilefield/dynamicmultiselect:caneditsql that by default is not enabled. So an admin must enable the capability for a user/role before that role being able to modify the select query.
I have also provided a new version which fixes the bug of the number of records retrieved for the sample set. I have used the suggestion you provided to limit the number of rows returned by the query.
Thanks Antonello for sharing the plugin, and thanks Mike for detailed peer-review. I like the idea of the need to have a capability explicitly granted. Alternatively, the feature could be made available for site admins only. As long as users are aware of the risks, I think this is good to go. You are cleared to land, welcome to the plugins directory!
I think you cannot warn users enough. Having dealt with hundreds of Moodle admins, mistakes are made. I really think it would benefit potential users to say something like:
"This plugin allows execution of raw SQL. Please be aware that executing raw SQL that has been improperly written can irreparably damage you site and/or cause performance issues. Please ensure you are aware of the impact of your SQL before executing it."
Thank for this plugin. I have created a multi select profile field in which our users can select multiple courses that they have completed. Individual users can thus login and update their profile with courses they had completed.
I need to create and bulk upload users prepopulated with the courses that they have completed. The bulk upload will however only allow one of the courses from my multi select field. How can I get it to upload users with more than one course that they have completed.
Issue: "error reading from database" occurs after deleting a user that made use of the created multi select field. The error occurs when want to add an activity to a course. This functionality is restored when I delete the created multi select profile field.
Thank you for this excellent plugin and the update. I am able to select data from a single table with the query "SELECT id, idnumber, fullname data FROM {course} WHERE category = 2" Can i select data from more that one table e.g the user,course and course_completions tables. If yes, do you have a sample query?
Of course you can. You will need to join the tables and extract the data you need. For example
SELECT cc.id, u.username data FROM mdl_course_completions cc, mdl_user u
where u.id = cc.userid
Please consider that the acutal query will depend on the info you need. So even though the above query is syntactically correct, it might not make sense in your context.
but when try add new user as admin it added well and i see select list without any errors
Warning: array_search() expects parameter 2 to be array, null given user/profile/field/dynamicmultiselect/field.class.php on line 113
Warning: array_search() expects parameter 2 to be array, null given in /user/profile/field/dynamicmultiselect/field.class.php on line 114
I can confirm that this plugin (and the simple drop down version) does not work on signup page: the list is not populated.
The "Warning: array_search() expects parameter 2 to be array, null given " is a consequence of the missing data because the plugin is trying to find a default value.
I've found an easy fix (since there is not user id during the signup process):
// Only if we actually need data.
if ($fieldid !== 0 && $userid !== 0) {
became
// Only if we actually need data.
if ($fieldid !== 0) {
Do yo see any issue with this "fix" Antonello ?
Thanks
Thank you