public static function get_users_json($resource, $context, $contextid, $tool, $role, $limitfrom, $limitnum, $lti, $info) {

        $withcapability = '';
        $exclude = array();
        if (!empty($role)) {
            if ((strpos($role, 'http://') !== 0) && (strpos($role, 'https://') !== 0)) {
                $role = self::CONTEXT_ROLE_PREFIX . $role;
            }
            if ($role === self::CONTEXT_ROLE_INSTRUCTOR) {
                $withcapability = self::INSTRUCTOR_CAPABILITY;
            } else if ($role === self::CONTEXT_ROLE_LEARNER) {
                $exclude = array_keys(get_enrolled_users($context, self::INSTRUCTOR_CAPABILITY, 0, 'u.id',
                                                         null, null, null, true));
            }
        }
        $users = get_enrolled_users($context, $withcapability, 0, 'u.*', null, $limitfrom, $limitnum, true);
        if (count($users) < $limitnum) {
            $limitfrom = 0;
            $limitnum = 0;
        }
        $json = self::users_to_json($resource, $users, $contextid, $tool, $exclude, $limitfrom, $limitnum, $lti, $info);

        return $json;
    }
public static function get_users_json($resource, $context, $contextid, $tool, $role, $limitfrom, $limitnum, $lti, $info) {

        $withcapability = '';
        $exclude = array();
        if (!empty($role)) {
            if ((strpos($role, 'http://') !== 0) && (strpos($role, 'https://') !== 0)) {
                $role = self::CONTEXT_ROLE_PREFIX . $role;
            }
            if ($role === self::CONTEXT_ROLE_INSTRUCTOR) {
                $withcapability = self::INSTRUCTOR_CAPABILITY;
            } else if ($role === self::CONTEXT_ROLE_LEARNER) {
                $exclude = array_keys(get_enrolled_users($context, self::INSTRUCTOR_CAPABILITY, 0, 'u.id',
                                                         null, null, null, true));
            }
        }
        $users = get_enrolled_users($context, $withcapability, 0, 'u.*', null, $limitfrom, $limitnum, true);
        if (count($users) < $limitnum) {
            $limitfrom = 0;
            $limitnum = 0;
        }
        $json = self::users_to_json($resource, $users, $contextid, $tool, $exclude, $limitfrom, $limitnum, $lti, $info);

        return $json;
    }
public static function get_users_json ( $ resource , $ context , $ contextid , $ tool , $ role , $ limitfrom , $ limitnum , $ lti , $ info ) { $ withcapability = '' ; $ exclude = array ( ) ; if ( ! empty ( $ role ) ) { if ( ( strpos ( $ role , 'http://' ) !== 0 ) && ( strpos ( $ role , 'https://' ) !== 0 ) ) { $ role = self :: CONTEXT_ROLE_PREFIX . $ role ; } if ( $ role === self :: CONTEXT_ROLE_INSTRUCTOR ) { $ withcapability = self :: INSTRUCTOR_CAPABILITY ; } else if ( $ role === self :: CONTEXT_ROLE_LEARNER ) { $ exclude = array_keys ( get_enrolled_users ( $ context , self :: INSTRUCTOR_CAPABILITY , 0 , 'u.id' , null , null , null , true ) ) ; } } $ users = get_enrolled_users ( $ context , $ withcapability , 0 , 'u.*' , null , $ limitfrom , $ limitnum , true ) ; if ( count ( $ users ) < $ limitnum ) { $ limitfrom = 0 ; $ limitnum = 0 ; } $ json = self :: users_to_json ( $ resource , $ users , $ contextid , $ tool , $ exclude , $ limitfrom , $ limitnum , $ lti , $ info ) ; return $ json ; }
Get the JSON for members.

@param \mod_lti\local\ltiservice\resource_base $resource       Resource handling the request
@param \context_course   $context    Course context
@param string            $contextid  Course ID
@param object            $tool       Tool instance object
@param string            $role       User role requested (empty if none)
@param int               $limitfrom  Position of first record to be returned
@param int               $limitnum   Maximum number of records to be returned
@param object            $lti        LTI instance record
@param \core_availability\info_module $info Conditional availability information
for LTI instance (null if context-level request)

@return string
Get the JSON for members .