original_string: public function get_other_users($sort, $direction='ASC', $page=0, $perpage=25) {
          global $DB;
          if ($direction !== 'ASC') {
              $direction = 'DESC';
          }
          $key = md5("$sort-$direction-$page-$perpage");
          if (!array_key_exists($key, $this->otherusers)) {
              list($ctxcondition, $params) = $DB->get_in_or_equal($this->context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'ctx');
              $params['courseid'] = $this->course->id;
              $params['cid'] = $this->course->id;
              $extrafields = get_extra_user_fields($this->get_context());
              $ufields = user_picture::fields('u', $extrafields);
              $sql = "SELECT ra.id as raid, ra.contextid, ra.component, ctx.contextlevel, ra.roleid, $ufields,
                          coalesce(u.lastaccess,0) AS lastaccess
                      FROM {role_assignments} ra
                      JOIN {user} u ON u.id = ra.userid
                      JOIN {context} ctx ON ra.contextid = ctx.id
                 LEFT JOIN (
                         SELECT ue.id, ue.userid
                           FROM {user_enrolments} ue
                           JOIN {enrol} e ON e.id = ue.enrolid
                          WHERE e.courseid = :courseid
                         ) ue ON ue.userid=u.id
                     WHERE ctx.id $ctxcondition AND
                           ue.id IS NULL
                  ORDER BY $sort $direction, ctx.depth DESC";
              $this->otherusers[$key] = $DB->get_records_sql($sql, $params, $page*$perpage, $perpage);
          }
          return $this->otherusers[$key];
      }
code: public function get_other_users($sort, $direction='ASC', $page=0, $perpage=25) {
          global $DB;
          if ($direction !== 'ASC') {
              $direction = 'DESC';
          }
          $key = md5("$sort-$direction-$page-$perpage");
          if (!array_key_exists($key, $this->otherusers)) {
              list($ctxcondition, $params) = $DB->get_in_or_equal($this->context->get_parent_context_ids(true), SQL_PARAMS_NAMED, 'ctx');
              $params['courseid'] = $this->course->id;
              $params['cid'] = $this->course->id;
              $extrafields = get_extra_user_fields($this->get_context());
              $ufields = user_picture::fields('u', $extrafields);
              $sql = "SELECT ra.id as raid, ra.contextid, ra.component, ctx.contextlevel, ra.roleid, $ufields,
                          coalesce(u.lastaccess,0) AS lastaccess
                      FROM {role_assignments} ra
                      JOIN {user} u ON u.id = ra.userid
                      JOIN {context} ctx ON ra.contextid = ctx.id
                 LEFT JOIN (
                         SELECT ue.id, ue.userid
                           FROM {user_enrolments} ue
                           JOIN {enrol} e ON e.id = ue.enrolid
                          WHERE e.courseid = :courseid
                         ) ue ON ue.userid=u.id
                     WHERE ctx.id $ctxcondition AND
                           ue.id IS NULL
                  ORDER BY $sort $direction, ctx.depth DESC";
              $this->otherusers[$key] = $DB->get_records_sql($sql, $params, $page*$perpage, $perpage);
          }
          return $this->otherusers[$key];
      }
code_tokens: public function get_other_users ( $ sort , $ direction = 'ASC' , $ page = 0 , $ perpage = 25 ) { global $ DB ; if ( $ direction !== 'ASC' ) { $ direction = 'DESC' ; } $ key = md5 ( "$sort-$direction-$page-$perpage" ) ; if ( ! array_key_exists ( $ key , $ this -> otherusers ) ) { list ( $ ctxcondition , $ params ) = $ DB -> get_in_or_equal ( $ this -> context -> get_parent_context_ids ( true ) , SQL_PARAMS_NAMED , 'ctx' ) ; $ params [ 'courseid' ] = $ this -> course -> id ; $ params [ 'cid' ] = $ this -> course -> id ; $ extrafields = get_extra_user_fields ( $ this -> get_context ( ) ) ; $ ufields = user_picture :: fields ( 'u' , $ extrafields ) ; $ sql = "SELECT ra.id as raid, ra.contextid, ra.component, ctx.contextlevel, ra.roleid, $ufields,
                          coalesce(u.lastaccess,0) AS lastaccess
                      FROM {role_assignments} ra
                      JOIN {user} u ON u.id = ra.userid
                      JOIN {context} ctx ON ra.contextid = ctx.id
                 LEFT JOIN (
                         SELECT ue.id, ue.userid
                           FROM {user_enrolments} ue
                           JOIN {enrol} e ON e.id = ue.enrolid
                          WHERE e.courseid = :courseid
                         ) ue ON ue.userid=u.id
                     WHERE ctx.id $ctxcondition AND
                           ue.id IS NULL
                  ORDER BY $sort $direction, ctx.depth DESC" ; $ this -> otherusers [ $ key ] = $ DB -> get_records_sql ( $ sql , $ params , $ page * $ perpage , $ perpage ) ; } return $ this -> otherusers [ $ key ] ; }
docstring: Gets and array of other users.
  
  Other users are users who have been assigned roles or inherited roles
  within this course but who have not been enrolled in the course
  
  @global moodle_database $DB
  @param string $sort
  @param string $direction
  @param int $page
  @param int $perpage
  @return array
docstring_tokens: Gets and array of other users .