mirror of
https://github.com/moodle/moodle.git
synced 2025-04-18 23:15:38 +02:00
Merge branch 'MDL-62485' of https://github.com/willianmano/moodle
This commit is contained in:
commit
7067db2847
@ -157,8 +157,14 @@ switch ($action) {
|
||||
foreach ($users as $user) {
|
||||
$plugin->enrol_user($instance, $user->id, $roleid, $timestart, $timeend, null, $recovergrades);
|
||||
}
|
||||
$counter = count($users);
|
||||
foreach ($cohorts as $cohort) {
|
||||
$plugin->enrol_cohort($instance, $cohort->id, $roleid, $timestart, $timeend, null, $recovergrades);
|
||||
$totalenrolledusers = $plugin->enrol_cohort($instance, $cohort->id, $roleid, $timestart, $timeend, null, $recovergrades);
|
||||
$counter += $totalenrolledusers;
|
||||
}
|
||||
// Display a notification message after the bulk user enrollment.
|
||||
if ($counter > 0) {
|
||||
\core\notification::info(get_string('totalenrolledusers', 'enrol', $counter));
|
||||
}
|
||||
} else {
|
||||
throw new enrol_ajax_exception('enrolnotpermitted');
|
||||
|
@ -502,6 +502,7 @@ class enrol_manual_plugin extends enrol_plugin {
|
||||
* @param int $timeend 0 means forever
|
||||
* @param int $status default to ENROL_USER_ACTIVE for new enrolments, no change by default in updates
|
||||
* @param bool $recovergrades restore grade history
|
||||
* @return int The number of enrolled cohort users
|
||||
*/
|
||||
public function enrol_cohort(stdClass $instance, $cohortid, $roleid = null, $timestart = 0, $timeend = 0, $status = null, $recovergrades = null) {
|
||||
global $DB;
|
||||
@ -514,6 +515,7 @@ class enrol_manual_plugin extends enrol_plugin {
|
||||
foreach ($members as $userid) {
|
||||
$this->enrol_user($instance, $userid, $roleid, $timestart, $timeend, $status, $recovergrades);
|
||||
}
|
||||
return count($members);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -350,20 +350,24 @@ class enrol_manual_deleteselectedusers_operation extends enrol_bulk_enrolment_op
|
||||
* @param stdClass $properties The data returned by the form.
|
||||
*/
|
||||
public function process(course_enrolment_manager $manager, array $users, stdClass $properties) {
|
||||
global $DB;
|
||||
|
||||
if (!has_capability("enrol/manual:unenrol", $manager->get_context())) {
|
||||
return false;
|
||||
}
|
||||
$counter = 0;
|
||||
foreach ($users as $user) {
|
||||
foreach ($user->enrolments as $enrolment) {
|
||||
$plugin = $enrolment->enrolmentplugin;
|
||||
$instance = $enrolment->enrolmentinstance;
|
||||
if ($plugin->allow_unenrol_user($instance, $enrolment)) {
|
||||
$plugin->unenrol_user($instance, $user->id);
|
||||
$counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Display a notification message after the bulk user unenrollment.
|
||||
if ($counter > 0) {
|
||||
\core\notification::info(get_string('totalunenrolledusers', 'enrol', $counter));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -124,6 +124,7 @@ Feature: Teacher can search and enrol users one by one into the course
|
||||
And I should see "Student 001"
|
||||
And I click on "Enrol users" "button" in the "Enrol users" "dialogue"
|
||||
Then I should see "Active" in the "Student 001" "table_row"
|
||||
And I should see "1 enrolled users"
|
||||
|
||||
@javascript
|
||||
Scenario: Searching for a non-existing user
|
||||
|
@ -157,6 +157,8 @@ class enrol_self_plugin extends enrol_plugin {
|
||||
|
||||
$this->enrol_user($instance, $USER->id, $instance->roleid, $timestart, $timeend);
|
||||
|
||||
\core\notification::success(get_string('youenrolledincourse', 'enrol'));
|
||||
|
||||
if ($instance->password and $instance->customint1 and $data->enrolpassword !== $instance->password) {
|
||||
// It must be a group enrolment, let's assign group too.
|
||||
$groups = $DB->get_records('groups', array('courseid'=>$instance->courseid), 'id', 'id, enrolmentkey');
|
||||
|
@ -50,6 +50,8 @@ $PAGE->set_title($plugin->get_instance_name($instance));
|
||||
if ($confirm and confirm_sesskey()) {
|
||||
$plugin->unenrol_user($instance, $USER->id);
|
||||
|
||||
\core\notification::success(get_string('youunenrolledfromcourse', 'enrol', $course->fullname));
|
||||
|
||||
redirect(new moodle_url('/index.php'));
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,10 @@
|
||||
This files describes API changes in /enrol/* - plugins,
|
||||
information provided here is intended especially for developers.
|
||||
|
||||
=== 3.8 ===
|
||||
|
||||
* Function enrol_manual_plugin::enrol_cohort now return the number of enrolled cohort users.
|
||||
|
||||
=== 3.7 ===
|
||||
|
||||
* Functions get_potential_users() and search_other_users() now return more information to avoid extra count query:
|
||||
|
@ -132,6 +132,7 @@ $string['synced'] = 'Synced';
|
||||
$string['testsettings'] = 'Test settings';
|
||||
$string['testsettingsheading'] = 'Test enrol settings - {$a}';
|
||||
$string['totalenrolledusers'] = '{$a} enrolled users';
|
||||
$string['totalunenrolledusers'] = '{$a} unenrolled users';
|
||||
$string['totalotherusers'] = '{$a} other users';
|
||||
$string['unassignnotpermitted'] = 'You do not have permission to unassign roles in this course';
|
||||
$string['unenrol'] = 'Unenrol';
|
||||
@ -161,3 +162,5 @@ $string['privacy:metadata:user_enrolments:timeend'] = 'The time when the user en
|
||||
$string['privacy:metadata:user_enrolments:timestart'] = 'The time when the user enrolment starts';
|
||||
$string['privacy:metadata:user_enrolments:timemodified'] = 'The time when the user enrolment was modified';
|
||||
$string['privacy:metadata:user_enrolments:userid'] = 'The ID of the user';
|
||||
$string['youenrolledincourse'] = 'You are enrolled in the course.';
|
||||
$string['youunenrolledfromcourse'] = 'You are unenrolled from the course "{$a}".';
|
||||
|
@ -46,6 +46,7 @@ Feature: Bulk enrolments
|
||||
Then I should not see "Student 1"
|
||||
And I should not see "Student 2"
|
||||
And I should not see "Teacher 1"
|
||||
And I should see "3 unenrolled users"
|
||||
|
||||
@javascript
|
||||
Scenario: Bulk edit enrolment for deleted user
|
||||
|
Loading…
x
Reference in New Issue
Block a user