コード例 #1
0
 /**
  * This function retrieves a list of all students currently within a group in the
  * saved grouping.
  *
  * @return mixed Array containing grouped member IDs or false if none found.
  *
  */
 private function get_all_grouped_students()
 {
     global $DB;
     $sgs = new skills_group_setting($this->courseid);
     $params = array($sgs->get_grouping_id());
     $query = "SELECT DISTINCT b.userid\n                  FROM {groupings_groups} a INNER JOIN {groups_members} b ON a.groupid = b.groupid\n                  WHERE a.groupingid = ?";
     $records = $DB->get_records_sql($query, $params);
     if ($records === false) {
         return false;
     } else {
         return block_skills_group_strip_to_ids($records);
     }
 }
コード例 #2
0
 /**
  * This function retrieves and returns a list of members in the given group ID.
  *
  * @return array {IDs => names} of all members in group.
  *
  */
 public function get_group_members()
 {
     global $DB, $USER;
     $params = array($this->groupid, $USER->id);
     $query = "SELECT userid\n                  FROM {groups_members}\n                  WHERE groupid = ? AND userid <> ?";
     $records = $DB->get_records_sql($query, $params);
     $ids = block_skills_group_strip_to_ids($records);
     sort($ids);
     $names = block_skills_group_retrieve_names($ids);
     // Note: array_combine() will not work with empty arrays.
     if (count($ids) > 0) {
         return array_combine(array_values($ids), $names);
     } else {
         return array();
     }
 }