mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-66359 core_course: Modify get_enrolled_users_by_cmid
We need to also provide a user's group along with the current information
This commit is contained in:
parent
01aa126848
commit
e3bb3da406
2
course/amd/build/repository.min.js
vendored
2
course/amd/build/repository.min.js
vendored
@ -1,2 +1,2 @@
|
||||
define ("core_course/repository",["jquery","core/ajax"],function(a,b){return{getEnrolledCoursesByTimelineClassification:function getEnrolledCoursesByTimelineClassification(a,c,d,e){var f={classification:a};if("undefined"!=typeof c){f.limit=c}if("undefined"!=typeof d){f.offset=d}if("undefined"!=typeof e){f.sort=e}return b.call([{methodname:"core_course_get_enrolled_courses_by_timeline_classification",args:f}])[0]},getLastAccessedCourses:function getLastAccessedCourses(a,c,d,e){var f={};if("undefined"!=typeof a){f.userid=a}if("undefined"!=typeof c){f.limit=c}if("undefined"!=typeof d){f.offset=d}if("undefined"!=typeof e){f.sort=e}return b.call([{methodname:"core_course_get_recent_courses",args:f}])[0]},getUsersFromCourseModuleID:function getEnrolledUsersFromCourseModuleID(a){return b.call([{methodname:"core_course_get_enrolled_users_by_cmid",args:{cmid:a}}])[0]}}});
|
||||
define ("core_course/repository",["jquery","core/ajax"],function(a,b){return{getEnrolledCoursesByTimelineClassification:function getEnrolledCoursesByTimelineClassification(a,c,d,e){var f={classification:a};if("undefined"!=typeof c){f.limit=c}if("undefined"!=typeof d){f.offset=d}if("undefined"!=typeof e){f.sort=e}return b.call([{methodname:"core_course_get_enrolled_courses_by_timeline_classification",args:f}])[0]},getLastAccessedCourses:function getLastAccessedCourses(a,c,d,e){var f={};if("undefined"!=typeof a){f.userid=a}if("undefined"!=typeof c){f.limit=c}if("undefined"!=typeof d){f.offset=d}if("undefined"!=typeof e){f.sort=e}return b.call([{methodname:"core_course_get_recent_courses",args:f}])[0]},getUsersFromCourseModuleID:function getEnrolledUsersFromCourseModuleID(a,c){return b.call([{methodname:"core_course_get_enrolled_users_by_cmid",args:{cmid:a,groupid:c}}])[0]}}});
|
||||
//# sourceMappingURL=repository.min.js.map
|
||||
|
File diff suppressed because one or more lines are too long
@ -98,13 +98,15 @@ define(['jquery', 'core/ajax'], function($, Ajax) {
|
||||
* Get the list of users enrolled in this cmid.
|
||||
*
|
||||
* @param {Number} cmid Course Module from which the users will be obtained
|
||||
* @param {Number} groupID Group ID from which the users will be obtained
|
||||
* @returns {Promise} Promise containing a list of users
|
||||
*/
|
||||
var getEnrolledUsersFromCourseModuleID = function(cmid) {
|
||||
var getEnrolledUsersFromCourseModuleID = function(cmid, groupID) {
|
||||
var request = {
|
||||
methodname: 'core_course_get_enrolled_users_by_cmid',
|
||||
args: {
|
||||
cmid: cmid,
|
||||
groupid: groupID,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -4062,6 +4062,7 @@ class core_course_external extends external_api {
|
||||
public static function get_enrolled_users_by_cmid_parameters() {
|
||||
return new external_function_parameters([
|
||||
'cmid' => new external_value(PARAM_INT, 'id of the course module', VALUE_REQUIRED),
|
||||
'groupid' => new external_value(PARAM_INT, 'id of the group', VALUE_DEFAULT, 0),
|
||||
]);
|
||||
}
|
||||
|
||||
@ -4069,24 +4070,27 @@ class core_course_external extends external_api {
|
||||
* Get all users in a course for a given cmid.
|
||||
*
|
||||
* @param int $cmid Course Module id from which the users will be obtained
|
||||
* @param int $groupid Group id from which the users will be obtained
|
||||
* @return array List of users
|
||||
* @throws invalid_parameter_exception
|
||||
*/
|
||||
public static function get_enrolled_users_by_cmid(int $cmid) {
|
||||
global $PAGE;
|
||||
public static function get_enrolled_users_by_cmid(int $cmid, int $groupid = 0) {
|
||||
global $PAGE;
|
||||
$warnings = [];
|
||||
|
||||
[
|
||||
'cmid' => $cmid,
|
||||
'groupid' => $groupid,
|
||||
] = self::validate_parameters(self::get_enrolled_users_by_cmid_parameters(), [
|
||||
'cmid' => $cmid,
|
||||
'groupid' => $groupid,
|
||||
]);
|
||||
|
||||
list($course, $cm) = get_course_and_cm_from_cmid($cmid);
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
self::validate_context($coursecontext);
|
||||
|
||||
$enrolledusers = get_enrolled_users($coursecontext);
|
||||
$enrolledusers = get_enrolled_users($coursecontext, '', $groupid);
|
||||
|
||||
$users = array_map(function ($user) use ($PAGE) {
|
||||
$user->fullname = fullname($user);
|
||||
|
@ -625,7 +625,7 @@ $functions = array(
|
||||
'classname' => 'core_course_external',
|
||||
'methodname' => 'get_enrolled_users_by_cmid',
|
||||
'classpath' => 'course/externallib.php',
|
||||
'description' => 'List users bycourse module id.',
|
||||
'description' => 'List users by course module id & filter by group id.',
|
||||
'type' => 'read',
|
||||
'ajax' => true,
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user