Enrolment: Enrol by user profile fields

enrol_attributes
Maintained by Picture of Nicolas Dunand Nicolas Dunand
This plugin allows users to be enrolled according to any value stored in their user profile.
542 sites
556 downloads
36 fans

This plugin allows users to be enrolled according to any value stored in their user profile. If you use an external authentication scheme (LDAP, Shibboleth), you can store values in hidden user fields of the users' Moodle profile, and then use these values to automatically enrol users if some courses.

Screenshots

Screenshot #0

Contributors

Picture of Nicolas Dunand
Nicolas Dunand (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Picture of Nicolas Dunand
    Fri, 30 Jun 2017, 5:12 PM
    Hi Dario,

    Thanks for your feedback and suggestion. Indeed it would be very useful – and so would be other operators (greater than, etc.) – but I have really not time at all to do that in the foreseeable future.

    If somebody was willing to program it I'd be very happy to integrate it so that everybody could use.
  • Picture of Dario Pappalardo
    Fri, 30 Jun 2017, 5:33 PM
    Same here Nicolas, I'd like to implement that function from your basis but ain't got no time... Hope that someone will continue your work. Anyway, again, great job
  • Picture of Lynn Danzig
    Tue, 18 Jul 2017, 5:18 PM
    Hi
    Thanks for a great plugin.

    I am having trouble working out why I am not able to enrol based on a user profile I have set up.

    I have created a custom profile field and successfully updated records of 20 users with a particular value I want to use for enrolment.

    I can find these users by filtering on the field and value in Browse users in site admin.

    When I go to a course, I can select the enrolment method and it brings up the correct field and I can enter the value.

    There is no error message but in the enrolment data box it shows 0 users have been enrolled with this method.

    I am logged in as admin so permissions should not be an issue.

    I was able to enrol a cohort, so it should not be to do with course or user expiry (I am working on a dev site).

    Any suggestions?

    Many thanks
    Lynn
  • Picture of Nicolas Dunand
    Tue, 18 Jul 2017, 5:35 PM
    Hi Lynn,

    Thanks for your message. What happens if, after having saved your rule, you display it and click the "Force enrolments" button?
  • Picture of ray cheng
    Wed, 19 Jul 2017, 1:39 AM
    Hi, First of all, thanks for sharing this plugin.

    I installed moodle 3.3 version using mysql 5.6.36 and I have install this plugin.

    I have added 2 other fields (named field1 & fields) in user profile. However, when I selected the "Enrol by user profile" (in Users > Enrolment Methods) , the error showed as below

    customtext1=line 112 of /enrol/attributes/edit.php: call to debugging()

    Notice: Trying to get property of non-object in /var/www/html/moodle/enrol/attributes/lib.php on line 128
    fieldsandrules= Array ( [customuserfields] => Array ( [1] => field1 [2] => field2 ) [rules] => )
    line 114 of /enrol/attributes/edit.php: call to debugging()

    Warning: Invalid argument supplied for foreach() in /var/www/html/moodle/enrol/attributes/lib.php on line 149
    arraysql= Array ( [select] => [where] => [params] => Array egg )
    line 116 of /enrol/attributes/edit.php: call to debugging()
    sqlquery= SELECT DISTINCT u.id FROM {user} u WHERE
    line 119 of /enrol/attributes/edit.php: call to debugging()

    Debug info: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
    SELECT DISTINCT u.id FROM mdl_user u WHERE
    [array (
    )]
    Error code: dmlreadexception

    Stack trace:
    line 486 of /lib/dml/moodle_database.php: dml_read_exception thrown
    line 1175 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
    line 120 of /enrol/attributes/edit.php: call to mysqli_native_moodle_database->get_records_sql()

    Hope anyone can help. Thanks in advance.
  • Picture of Nicolas Dunand
    Wed, 19 Jul 2017, 2:23 PM
    HI Ray,

    Thanks for reporting this problem. First, can you confirm you have the latest version of this plugin ?

    Then, does this error appear as you're trying to create a new enrolment method ? Or when displaying an existing one ?
  • Picture of ray cheng
    Wed, 19 Jul 2017, 10:13 PM
    Hi Nicolas,

    Thanks for your prompt reply.

    My installed plugin version is 2017050100. And the error appears when displaying an existing one.
  • Picture of Nicolas Dunand
    Thu, 20 Jul 2017, 4:33 PM
    Hi Ray,
    This looks like what would happen is the rule set is completely empty (see "customtext1=" at the beginning of your debugging messages). There should be something there, not just nothing. Have you set up a rule ? If you reload the page with JavaScript turned off, you should see the code (JSON) for the rule, e.g. "{"rules":[{"param":"paramname","value":"somevalue"}]}". is that the case?
  • Picture of Francesco Di Pascasio
    Thu, 27 Jul 2017, 10:04 PM
    Hi Nicolas,

    I've installed your -really very useful, thank you very much indeed!- plugin on Moodle 3.2.1+ (Build: 20170223) and got it working on a development site here at La Sapienza University in Rome.

    Nevertheless at the bottom of the edit page (/enrol/attributes/edit.php?courseid=XYZ&id=ZX) I read:

    customtext1= stdClass Object ( [rules] => Array ( [0] => stdClass Object ( [param] => CODCDL [value] => 14493 ) [1] => stdClass Object ( [param] => CODCDL [value] => 14494 [cond_op] => or ) ) )
    line 112 of /enrol/attributes/edit.php: call to debugging()

    fieldsandrules= Array ( [customuserfields] => Array ( [2] => CODCDL ) [rules] => Array ( [0] => stdClass Object ( [param] => CODCDL [value] => 14493 ) [1] => stdClass Object ( [param] => CODCDL [value] => 14494 [cond_op] => or ) ) )
    line 114 of /enrol/attributes/edit.php: call to debugging()

    arraysql= Array ( [select] => RIGHT JOIN {user_info_data} d1 ON d1.userid = u.id AND d1.fieldid = 2 RIGHT JOIN {user_info_data} d2 ON d2.userid = u.id AND d2.fieldid = 2 [where] => (d1.data = ? OR d1.data LIKE ? COLLATE utf8_bin ESCAPE '\\' OR d1.data LIKE ? COLLATE utf8_bin ESCAPE '\\' OR d1.data LIKE ? COLLATE utf8_bin ESCAPE '\\') OR (d2.data = ? OR d2.data LIKE ? COLLATE utf8_bin ESCAPE '\\' OR d2.data LIKE ? COLLATE utf8_bin ESCAPE '\\' OR d2.data LIKE ? COLLATE utf8_bin ESCAPE '\\') [params] => Array ( [0] => 14493 [1] => %;14493 [2] => 14493;% [3] => %;14493;% [4] => 14494 [5] => %;14494 [6] => 14494;% [7] => %;14494;% ) )
    line 116 of /enrol/attributes/edit.php: call to debugging()

    sqlquery= SELECT DISTINCT u.id FROM {user} u RIGHT JOIN {user_info_data} d1 ON d1.userid = u.id AND d1.fieldid = 2 RIGHT JOIN {user_info_data} d2 ON d2.userid = u.id AND d2.fieldid = 2 WHERE (d1.data = ? OR d1.data LIKE ? COLLATE utf8_bin ESCAPE '\\' OR d1.data LIKE ? COLLATE utf8_bin ESCAPE '\\' OR d1.data LIKE ? COLLATE utf8_bin ESCAPE '\\') OR (d2.data = ? OR d2.data LIKE ? COLLATE utf8_bin ESCAPE '\\' OR d2.data LIKE ? COLLATE utf8_bin ESCAPE '\\' OR d2.data LIKE ? COLLATE utf8_bin ESCAPE '\\')
    line 119 of /enrol/attributes/edit.php: call to debugging()

    countusers= 0
    line 121 of /enrol/attributes/edit.php: call to debugging()

    If I disable Javascript I see in the rule box:

    {"rules":[{"param":"CODCDL","value":"14493"},{"param":"CODCDL","value":"14494","cond_op":"or"}]}

    As I miss the meaning and wonder if it is dangerous, any suggestion is really appreciated.

    Thank you for your time.

    Have a wonderful day.

    Ciao,

    Francesco
  • Picture of Nicolas Dunand
    Thu, 27 Jul 2017, 10:27 PM
    Ciao Francesco and thanks for your concern. This only displays if your site has debugging activated (and on display) OR if you are an administrator.
  • Picture of Francesco Di Pascasio
    Thu, 27 Jul 2017, 10:47 PM
    Ciao Nicolas, so I guess I don't have to worry about it... thanks again and Grazie for your excellent work.
  • Picture of Romel Hernandez
    Sat, 29 Jul 2017, 6:46 PM
    I did all the chances and possibilities to have this plugin fixed on my system. But I never had the result to get this plugin work properly. I did reinstall the Enrolment Plugin on my system, have the other enrolment plugins reviewed, and eventually put this Plugin on the top of the Enrollment Stack.
  • Picture of Oguzhan Ahiskali
    Wed, 9 Aug 2017, 2:33 AM
    I want to teach those who are unequal.

    Please help me!
  • Picture of Sandeep Nehra
    Tue, 15 Aug 2017, 2:03 PM
    We are using Moodle 3.3 and want to use existing profile fields to enroll users like department, team and others instead of custom user fields. How I can do that?
  • Picture of Rolf Petersen
    Sun, 3 Sep 2017, 12:11 AM
    Hello, this sounds to be a usefull Plugin for me. BUT I cannot get that work. Using M3.3 on Win-Server Installation is without failure. I can setup Default-role for example. I Activated this enrolement-Plugin but it does nor show up in enrolement-methods for any cours I have. Have restarted my moodle already with no effect. What may be wrong??? Thanks! Rolf
1 2 3 4 5 6 7 8 9 10 11
Please login to post comments