Skip to content
Permalink
Browse files
Merge branch 'MDL-60179_master' of git://github.com/markn86/moodle
  • Loading branch information
David Monllao committed Oct 19, 2017
2 parents 23892d0 + af835c2 commit 43b8618b404a6251fdbec7a64dbc1e3ccc5be4ab
@@ -73,7 +73,14 @@
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 @@ function definition() {
$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 @@ public static function edit_user_enrolment($courseid, $ueid, $status, $timestart
$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 @@
}

$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['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.

Some generated files are not rendered by default. Learn more.

@@ -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"

0 comments on commit 43b8618

Please sign in to comment.