mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 13:02:07 +02:00
Merge branch 'MDL-60179_master' of git://github.com/markn86/moodle
This commit is contained in:
commit
43b8618b40
@ -73,7 +73,14 @@ $PAGE->set_pagelayout('admin');
|
||||
navigation_node::override_active_url($usersurl);
|
||||
|
||||
// Get the enrolment edit form.
|
||||
$mform = new enrol_user_enrolment_form($url, array('user'=>$user, 'course'=>$course, 'ue'=>$ue));
|
||||
$mform = new enrol_user_enrolment_form($url,
|
||||
[
|
||||
'user' => $user,
|
||||
'course' => $course,
|
||||
'ue' => $ue,
|
||||
'enrolinstancename' => $plugin->get_instance_name($instance)
|
||||
]
|
||||
);
|
||||
$mform->set_data($PAGE->url->params());
|
||||
|
||||
if ($mform->is_cancelled()) {
|
||||
|
@ -31,8 +31,11 @@ class enrol_user_enrolment_form extends moodleform {
|
||||
$mform = $this->_form;
|
||||
|
||||
$ue = $this->_customdata['ue'];
|
||||
$instancename = $this->_customdata['enrolinstancename'];
|
||||
$modal = !empty($this->_customdata['modal']);
|
||||
|
||||
$mform->addElement('static', 'enrolmentmethod', get_string('enrolmentmethod', 'enrol'), $instancename);
|
||||
|
||||
$options = array(ENROL_USER_ACTIVE => get_string('participationactive', 'enrol'),
|
||||
ENROL_USER_SUSPENDED => get_string('participationsuspended', 'enrol'));
|
||||
if (isset($options[$ue->status])) {
|
||||
|
@ -859,10 +859,13 @@ class core_enrol_external extends external_api {
|
||||
$errors = [];
|
||||
|
||||
// Validate data against the edit user enrolment form.
|
||||
$instance = $DB->get_record('enrol', ['id' => $userenrolment->enrolid], '*', MUST_EXIST);
|
||||
$plugin = enrol_get_plugin($instance->enrol);
|
||||
require_once("$CFG->dirroot/enrol/editenrolment_form.php");
|
||||
$customformdata = [
|
||||
'ue' => $userenrolment,
|
||||
'modal' => true,
|
||||
'enrolinstancename' => $plugin->get_instance_name($instance)
|
||||
];
|
||||
$mform = new \enrol_user_enrolment_form(null, $customformdata, 'post', '', null, true, $userenroldata);
|
||||
$mform->set_data($userenroldata);
|
||||
|
@ -70,7 +70,13 @@ if ($confirm && confirm_sesskey()) {
|
||||
}
|
||||
|
||||
$yesurl = new moodle_url($PAGE->url, array('confirm'=>1, 'sesskey'=>sesskey()));
|
||||
$message = get_string('unenrolconfirm', 'core_enrol', array('user'=>fullname($user, true), 'course'=>format_string($course->fullname)));
|
||||
$message = get_string('unenrolconfirm', 'core_enrol',
|
||||
[
|
||||
'user' => fullname($user, true),
|
||||
'course' => format_string($course->fullname),
|
||||
'enrolinstancename' => $plugin->get_instance_name($instance)
|
||||
]
|
||||
);
|
||||
$fullname = fullname($user);
|
||||
$title = get_string('unenrol', 'core_enrol');
|
||||
|
||||
|
@ -132,7 +132,7 @@ $string['totalenrolledusers'] = '{$a} enrolled users';
|
||||
$string['totalotherusers'] = '{$a} other users';
|
||||
$string['unassignnotpermitted'] = 'You do not have permission to unassign roles in this course';
|
||||
$string['unenrol'] = 'Unenrol';
|
||||
$string['unenrolconfirm'] = 'Do you really want to unenrol user "{$a->user}" from course "{$a->course}"?';
|
||||
$string['unenrolconfirm'] = 'Do you really want to unenrol "{$a->user}" (previously enrolled via "{$a->enrolinstancename}") from "{$a->course}"?';
|
||||
$string['unenrolme'] = 'Unenrol me from {$a}';
|
||||
$string['unenrolnotpermitted'] = 'You do not have permission or can not unenrol this user from this course.';
|
||||
$string['unenrolroleusers'] = 'Unenrol users';
|
||||
|
@ -1528,9 +1528,12 @@ function enrol_output_fragment_user_enrolment_form($args) {
|
||||
|
||||
$ueid = $args->ueid;
|
||||
$userenrolment = $DB->get_record('user_enrolments', ['id' => $ueid], '*', MUST_EXIST);
|
||||
$instance = $DB->get_record('enrol', ['id' => $userenrolment->enrolid], '*', MUST_EXIST);
|
||||
$plugin = enrol_get_plugin($instance->enrol);
|
||||
$customdata = [
|
||||
'ue' => $userenrolment,
|
||||
'modal' => true,
|
||||
'enrolinstancename' => $plugin->get_instance_name($instance)
|
||||
];
|
||||
|
||||
// Set the data if applicable.
|
||||
|
2
user/amd/build/status_field.min.js
vendored
2
user/amd/build/status_field.min.js
vendored
@ -1 +1 @@
|
||||
define(["core/templates","jquery","core/str","core/config","core/notification","core/modal_factory","core/modal_events","core/fragment","core/ajax"],function(a,b,c,d,e,f,g,h,i){var j={EDIT_ENROLMENT:'[data-action="editenrolment"]',SHOW_DETAILS:'[data-action="showdetails"]',UNENROL:'[data-action="unenrol"]'},k=function(a){this.contextid=a.contextid,this.courseid=a.courseid,this.bindEditEnrol(),this.bindUnenrol(),this.bindStatusDetails()};return k.prototype.courseid=0,k.prototype.bindEditEnrol=function(){var a=this;b(j.EDIT_ENROLMENT).click(function(d){d.preventDefault();var h=b(this),i=h.parent(),j=i.data("fullname"),k=h.attr("rel");b.when(c.get_string("edituserenrolment","enrol",j)).then(function(a){return f.create({large:!0,title:a,type:f.types.SAVE_CANCEL})}).done(function(b){b.getRoot().on(g.save,function(c){c.preventDefault(),a.submitEditFormAjax(b)}),b.getRoot().on(g.hidden,function(){b.destroy()}),b.setBody(a.getBody(k)),b.show()}).fail(e.exception)})},k.prototype.bindUnenrol=function(){b(j.UNENROL).click(function(a){a.preventDefault();var h=b(this),i=h.parent(),j=[{key:"unenrol",component:"enrol"},{key:"unenrolconfirm",component:"enrol",param:{user:i.data("fullname"),course:i.data("coursename")}}],k=f.create({type:f.types.SAVE_CANCEL});b.when(c.get_strings(j),k).done(function(a,c){var e=a[0],f=a[1];c.setTitle(e),c.setBody(f),c.setSaveButtonText(e),c.getRoot().on(g.save,function(){var a={confirm:1,sesskey:d.sesskey,ue:b(h).attr("rel")};window.location.href=d.wwwroot+"/enrol/unenroluser.php?"+b.param(a)}),c.getRoot().on(g.hidden,function(){c.destroy()}),c.show()}).fail(e.exception)})},k.prototype.bindStatusDetails=function(){b(j.SHOW_DETAILS).click(function(d){d.preventDefault();var h=b(this),i=h.parent(),k={fullname:i.data("fullname"),coursename:i.data("coursename"),enrolinstancename:i.data("enrolinstancename"),status:i.data("status"),statusclass:i.find("span").attr("class"),timestart:i.data("timestart"),timeend:i.data("timeend")},l=[{key:"enroldetails",component:"enrol"}],m=h.next(j.EDIT_ENROLMENT);m.length&&(k.editenrollink=b("<div>").append(m.clone()).html());var n=c.get_strings(l),o=f.create({large:!0,type:f.types.CANCEL});b.when(n,o).done(function(c,d){var e=a.render("core_user/status_details",k);d.setTitle(c[0]),d.setBody(e),m.length&&d.getRoot().on("click",j.EDIT_ENROLMENT,function(a){a.preventDefault(),d.hide(),b(m).trigger("click")}),d.show(),d.getRoot().on(g.hidden,function(){d.destroy()})}).fail(e.exception)})},k.prototype.submitEditFormAjax=function(a){var c=this,d=a.getRoot().find("form"),f=b(d).find('[name="ue"]').val(),g=b(d).find('[name="status"]').val(),h={courseid:this.courseid,ueid:f,status:g},j=b(d).find('[name="timestart[enabled]"]');if(j.is(":checked")){var k=b(d).find('[name="timestart[year]"]').val(),l=b(d).find('[name="timestart[month]"]').val()-1,m=b(d).find('[name="timestart[day]"]').val(),n=b(d).find('[name="timestart[hour]"]').val(),o=b(d).find('[name="timestart[minute]"]').val(),p=new Date(k,l,m,n,o);h.timestart=p.getTime()/1e3}var q=b(d).find('[name="timeend[enabled]"]');if(q.is(":checked")){var r=b(d).find('[name="timeend[year]"]').val(),s=b(d).find('[name="timeend[month]"]').val()-1,t=b(d).find('[name="timeend[day]"]').val(),u=b(d).find('[name="timeend[hour]"]').val(),v=b(d).find('[name="timeend[minute]"]').val(),w=new Date(r,s,t,u,v);h.timeend=w.getTime()/1e3}var x={methodname:"core_enrol_edit_user_enrolment",args:h};i.call([x])[0].done(function(b){if(b.result)a.hide(),"undefined"!=typeof window.M.core_formchangechecker&&window.M.core_formchangechecker.reset_form_dirty_state(),window.location.reload();else{var e=JSON.stringify(d.serialize());a.setBody(c.getBody(f,e))}}).fail(e.exception)},k.prototype.getBody=function(a,b){var c={ueid:a};return"undefined"!=typeof b&&(c.formdata=b),h.loadFragment("enrol","user_enrolment_form",this.contextid,c).fail(e.exception)},{init:function(a){new k(a)}}});
|
||||
define(["core/templates","jquery","core/str","core/config","core/notification","core/modal_factory","core/modal_events","core/fragment","core/ajax"],function(a,b,c,d,e,f,g,h,i){var j={EDIT_ENROLMENT:'[data-action="editenrolment"]',SHOW_DETAILS:'[data-action="showdetails"]',UNENROL:'[data-action="unenrol"]'},k=function(a){this.contextid=a.contextid,this.courseid=a.courseid,this.bindEditEnrol(),this.bindUnenrol(),this.bindStatusDetails()};return k.prototype.courseid=0,k.prototype.bindEditEnrol=function(){var a=this;b(j.EDIT_ENROLMENT).click(function(d){d.preventDefault();var h=b(this),i=h.parent(),j=i.data("fullname"),k=h.attr("rel");b.when(c.get_string("edituserenrolment","enrol",j)).then(function(a){return f.create({large:!0,title:a,type:f.types.SAVE_CANCEL})}).done(function(b){b.getRoot().on(g.save,function(c){c.preventDefault(),a.submitEditFormAjax(b)}),b.getRoot().on(g.hidden,function(){b.destroy()}),b.setBody(a.getBody(k)),b.show()}).fail(e.exception)})},k.prototype.bindUnenrol=function(){b(j.UNENROL).click(function(a){a.preventDefault();var h=b(this),i=h.parent(),j=[{key:"unenrol",component:"enrol"},{key:"unenrolconfirm",component:"enrol",param:{user:i.data("fullname"),course:i.data("coursename"),enrolinstancename:i.data("enrolinstancename")}}],k=f.create({type:f.types.SAVE_CANCEL});b.when(c.get_strings(j),k).done(function(a,c){var e=a[0],f=a[1];c.setTitle(e),c.setBody(f),c.setSaveButtonText(e),c.getRoot().on(g.save,function(){var a={confirm:1,sesskey:d.sesskey,ue:b(h).attr("rel")};window.location.href=d.wwwroot+"/enrol/unenroluser.php?"+b.param(a)}),c.getRoot().on(g.hidden,function(){c.destroy()}),c.show()}).fail(e.exception)})},k.prototype.bindStatusDetails=function(){b(j.SHOW_DETAILS).click(function(d){d.preventDefault();var h=b(this),i=h.parent(),k={fullname:i.data("fullname"),coursename:i.data("coursename"),enrolinstancename:i.data("enrolinstancename"),status:i.data("status"),statusclass:i.find("span").attr("class"),timestart:i.data("timestart"),timeend:i.data("timeend")},l=[{key:"enroldetails",component:"enrol"}],m=h.next(j.EDIT_ENROLMENT);m.length&&(k.editenrollink=b("<div>").append(m.clone()).html());var n=c.get_strings(l),o=f.create({large:!0,type:f.types.CANCEL});b.when(n,o).done(function(c,d){var e=a.render("core_user/status_details",k);d.setTitle(c[0]),d.setBody(e),m.length&&d.getRoot().on("click",j.EDIT_ENROLMENT,function(a){a.preventDefault(),d.hide(),b(m).trigger("click")}),d.show(),d.getRoot().on(g.hidden,function(){d.destroy()})}).fail(e.exception)})},k.prototype.submitEditFormAjax=function(a){var c=this,d=a.getRoot().find("form"),f=b(d).find('[name="ue"]').val(),g=b(d).find('[name="status"]').val(),h={courseid:this.courseid,ueid:f,status:g},j=b(d).find('[name="timestart[enabled]"]');if(j.is(":checked")){var k=b(d).find('[name="timestart[year]"]').val(),l=b(d).find('[name="timestart[month]"]').val()-1,m=b(d).find('[name="timestart[day]"]').val(),n=b(d).find('[name="timestart[hour]"]').val(),o=b(d).find('[name="timestart[minute]"]').val(),p=new Date(k,l,m,n,o);h.timestart=p.getTime()/1e3}var q=b(d).find('[name="timeend[enabled]"]');if(q.is(":checked")){var r=b(d).find('[name="timeend[year]"]').val(),s=b(d).find('[name="timeend[month]"]').val()-1,t=b(d).find('[name="timeend[day]"]').val(),u=b(d).find('[name="timeend[hour]"]').val(),v=b(d).find('[name="timeend[minute]"]').val(),w=new Date(r,s,t,u,v);h.timeend=w.getTime()/1e3}var x={methodname:"core_enrol_edit_user_enrolment",args:h};i.call([x])[0].done(function(b){if(b.result)a.hide(),"undefined"!=typeof window.M.core_formchangechecker&&window.M.core_formchangechecker.reset_form_dirty_state(),window.location.reload();else{var e=JSON.stringify(d.serialize());a.setBody(c.getBody(f,e))}}).fail(e.exception)},k.prototype.getBody=function(a,b){var c={ueid:a};return"undefined"!=typeof b&&(c.formdata=b),h.loadFragment("enrol","user_enrolment_form",this.contextid,c).fail(e.exception)},{init:function(a){new k(a)}}});
|
@ -140,7 +140,8 @@ define(['core/templates',
|
||||
component: 'enrol',
|
||||
param: {
|
||||
user: parentContainer.data('fullname'),
|
||||
course: parentContainer.data('coursename')
|
||||
course: parentContainer.data('coursename'),
|
||||
enrolinstancename: parentContainer.data('enrolinstancename')
|
||||
}
|
||||
}
|
||||
];
|
||||
|
@ -61,7 +61,7 @@
|
||||
data-status="{{status}}" data-timestart="{{timestart}}" data-timeend="{{timeend}}">
|
||||
<span class="label {{#active}}label-success{{/active}}{{#suspended}}label-warning{{/suspended}}{{#notcurrent}}label-default{{/notcurrent}}">{{status}}</span>
|
||||
<a data-action="showdetails" href="#" role="button" tabindex="0">{{!
|
||||
}}{{#pix}}docs, core, {{#str}}enroldetails, enrol{{/str}}{{/pix}}{{!
|
||||
}}{{#pix}}docs, core, {{enrolinstancename}}{{/pix}}{{!
|
||||
}}</a>
|
||||
{{#enrolactions}}
|
||||
<a href="{{url}}" role="button" {{#attributes}}{{name}}="{{value}}" {{/attributes}}>{{!
|
||||
|
@ -53,13 +53,13 @@ Feature: Edit user enrolment
|
||||
Given I log in as "teacher1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to course participants
|
||||
When I click on "Enrolment details" "icon" in the "student1" "table_row"
|
||||
When I click on "Manual enrolments" "icon" in the "student1" "table_row"
|
||||
Then I should see "Enrolment details"
|
||||
And I should see "Student 1" in the "Full name" "table_row"
|
||||
And I should see "Active" in the "//td[@class='user-enrol-status']" "xpath_element"
|
||||
And I should see "Manual enrolments" in the "Enrolment method" "table_row"
|
||||
And I press "Cancel"
|
||||
And I click on "Enrolment details" "icon" in the "student2" "table_row"
|
||||
And I click on "Manual enrolments" "icon" in the "student2" "table_row"
|
||||
And I should see "Enrolment details"
|
||||
And I should see "Student 2" in the "Full name" "table_row"
|
||||
And I should see "Suspended" in the "//td[@class='user-enrol-status']" "xpath_element"
|
||||
@ -90,7 +90,7 @@ Feature: Edit user enrolment
|
||||
Then I should see "Student 3" in the "participants" "table"
|
||||
And "Edit enrolment" "icon" should not exist in the "student3" "table_row"
|
||||
And "Unenrol" "icon" should not exist in the "student3" "table_row"
|
||||
And I click on "Enrolment details" "icon" in the "student3" "table_row"
|
||||
And I click on "Course meta link (Course 2)" "icon" in the "student3" "table_row"
|
||||
And I should see "Enrolment details"
|
||||
And I should see "Student 3" in the "Full name" "table_row"
|
||||
And I should see "Active" in the "//td[@class='user-enrol-status']" "xpath_element"
|
||||
@ -102,7 +102,7 @@ Feature: Edit user enrolment
|
||||
Given I log in as "teacher1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to course participants
|
||||
When I click on "Enrolment details" "icon" in the "student2" "table_row"
|
||||
When I click on "Manual enrolments" "icon" in the "student2" "table_row"
|
||||
And I click on "Edit enrolment" "icon" in the "Enrolment method" "table_row"
|
||||
And I should see "Edit Student 2's enrolment"
|
||||
And I set the field "Status" to "Active"
|
||||
|
Loading…
x
Reference in New Issue
Block a user