/**
  * This function calculates all unassigned students for a particular grouping.
  * We enforce a rule that students can only be a member of one group in the
  * grouping.
  *
  * @return array {IDs => names) of potential members.
  *
  */
 public function get_potential_students()
 {
     $student = get_archetype_roles('student');
     $student = reset($student);
     $allmembers = groups_get_potential_members($this->courseid, $student->id);
     $allocatedmembers = $this->get_all_grouped_students();
     $potentialmemberids = array();
     foreach ($allmembers as $allmember) {
         if (array_search($allmember->id, $allocatedmembers) === false) {
             $potentialmemberids[] = $allmember->id;
         }
     }
     sort($potentialmemberids);
     $potentialmembernames = block_skills_group_retrieve_names($potentialmemberids);
     // Note: array_combine() will not work with empty arrays.
     if (count($potentialmemberids) > 0) {
         return array_combine($potentialmemberids, $potentialmembernames);
     } else {
         return array();
     }
 }
 /**
  * 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();
     }
 }