mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-64031 enrol_manual: Fix hard-coded list of user fields.
Respect get_extra_user_fields() in PHP code
This commit is contained in:
parent
4c5b60a0f9
commit
26208463fe
@ -1 +1 @@
|
||||
define(["jquery","core/ajax","core/templates","core/str"],function(a,b,c,d){var e=100;return{processResults:function(b,c){var d=[];return a.isArray(c)?(a.each(c,function(a,b){d.push({value:b.id,label:b._label})}),d):c},transport:function(f,g,h,i){var j,k=a(f).attr("courseid");"undefined"==typeof k&&(k="1");var l=a(f).attr("enrolid");"undefined"==typeof l&&(l=""),j=b.call([{methodname:"core_enrol_get_potential_users",args:{courseid:k,enrolid:l,search:g,searchanywhere:!0,page:0,perpage:e+1}}]),j[0].then(function(b){var f=[],g=0;return b.length<=e?(a.each(b,function(b,d){var e=d,g=[];a.each(["idnumber","email","phone1","phone2","department","institution"],function(a,b){"undefined"!=typeof d[b]&&""!==d[b]&&(e.hasidentity=!0,g.push(d[b]))}),e.identity=g.join(", "),f.push(c.render("enrol_manual/form-user-selector-suggestion",e))}),a.when.apply(a.when,f).then(function(){var c=arguments;a.each(b,function(a,b){b._label=c[g],g++}),h(b)})):d.get_string("toomanyuserstoshow","core",">"+e).then(function(a){h(a)})}).fail(i)}}});
|
||||
define(["jquery","core/ajax","core/templates","core/str"],function(a,b,c,d){var e=100;return{processResults:function(b,c){var d=[];return a.isArray(c)?(a.each(c,function(a,b){d.push({value:b.id,label:b._label})}),d):c},transport:function(f,g,h,i){var j,k=a(f).attr("courseid"),l=a(f).attr("userfields").split(",");"undefined"==typeof k&&(k="1");var m=a(f).attr("enrolid");"undefined"==typeof m&&(m=""),j=b.call([{methodname:"core_enrol_get_potential_users",args:{courseid:k,enrolid:m,search:g,searchanywhere:!0,page:0,perpage:e+1}}]),j[0].then(function(b){var f=[],g=0;return b.length<=e?(a.each(b,function(b,d){var e=d,g=[];a.each(l,function(a,b){"undefined"!=typeof d[b]&&""!==d[b]&&(e.hasidentity=!0,g.push(d[b]))}),e.identity=g.join(", "),f.push(c.render("enrol_manual/form-user-selector-suggestion",e))}),a.when.apply(a.when,f).then(function(){var c=arguments;a.each(b,function(a,b){b._label=c[g],g++}),h(b)})):d.get_string("toomanyuserstoshow","core",">"+e).then(function(a){h(a)})}).fail(i)}}});
|
@ -49,6 +49,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], function($, Ajax,
|
||||
transport: function(selector, query, success, failure) {
|
||||
var promise;
|
||||
var courseid = $(selector).attr('courseid');
|
||||
var userfields = $(selector).attr('userfields').split(',');
|
||||
if (typeof courseid === "undefined") {
|
||||
courseid = '1';
|
||||
}
|
||||
@ -78,7 +79,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str'], function($, Ajax,
|
||||
$.each(results, function(index, user) {
|
||||
var ctx = user,
|
||||
identity = [];
|
||||
$.each(['idnumber', 'email', 'phone1', 'phone2', 'department', 'institution'], function(i, k) {
|
||||
$.each(userfields, function(i, k) {
|
||||
if (typeof user[k] !== 'undefined' && user[k] !== '') {
|
||||
ctx.hasidentity = true;
|
||||
identity.push(user[k]);
|
||||
|
@ -98,7 +98,8 @@ class enrol_manual_enrol_users_form extends moodleform {
|
||||
'ajax' => 'enrol_manual/form-potential-user-selector',
|
||||
'multiple' => true,
|
||||
'courseid' => $course->id,
|
||||
'enrolid' => $instance->id
|
||||
'enrolid' => $instance->id,
|
||||
'userfields' => implode(',', get_extra_user_fields($context))
|
||||
);
|
||||
$mform->addElement('autocomplete', 'userlist', get_string('selectusers', 'enrol_manual'), array(), $options);
|
||||
|
||||
|
@ -153,3 +153,28 @@ Feature: Teacher can search and enrol users one by one into the course
|
||||
When I set the field "Select users" to "example.com"
|
||||
And I click on ".form-autocomplete-downarrow" "css_element" in the "Select users" "form_row"
|
||||
Then I should see "Too many users (>100) to show"
|
||||
|
||||
@javascript
|
||||
Scenario: Change the Show user identity setting affects the enrolment pop-up.
|
||||
Given I log out
|
||||
When I log in as "admin"
|
||||
Then the following "users" exist:
|
||||
| username | firstname | lastname | email | phone1 | phone2 | department | institution | city | country |
|
||||
| student100 | Student | 100 | student100@example.com | 1234567892 | 1234567893 | ABC1 | ABC2 | CITY1 | UK |
|
||||
And the following config values are set as admin:
|
||||
| showuseridentity | idnumber,email,city,country,phone1,phone2,department,institution |
|
||||
When I am on "Course 001" course homepage
|
||||
Then I navigate to course participants
|
||||
And I press "Enrol users"
|
||||
When I set the field "Select users" to "student100@example.com"
|
||||
And I click on ".form-autocomplete-downarrow" "css_element" in the "Select users" "form_row"
|
||||
Then I should see "student100@example.com, CITY1, UK, 1234567892, 1234567893, ABC1, ABC2"
|
||||
# Remove identity field in setting User policies
|
||||
And the following config values are set as admin:
|
||||
| showuseridentity | idnumber,email,phone1,phone2,department,institution |
|
||||
When I am on "Course 001" course homepage
|
||||
And I navigate to course participants
|
||||
And I press "Enrol users"
|
||||
When I set the field "Select users" to "student100@example.com"
|
||||
And I click on ".form-autocomplete-downarrow" "css_element" in the "Select users" "form_row"
|
||||
Then I should see "student100@example.com, 1234567892, 1234567893, ABC1, ABC2"
|
||||
|
Loading…
x
Reference in New Issue
Block a user