/**
  * This function checks to see whether the list of ungrouped students is returned
  * correctly.  I don't sort the list of user IDs upon return, since it is assumed
  * that they are sorted numerically.
  */
 public function test_get_potential_students()
 {
     $this->configure_settings();
     $sgrouping = new skills_grouping($this->courseid);
     $students = $sgrouping->get_potential_students();
     $i = 0;
     $users = $this->get_ungrouped_studentids();
     foreach ($students as $id => $name) {
         $this->assertEquals($users[$i]->firstname . ' ' . $users[$i]->lastname, $name);
         $this->assertEquals($users[$i++]->id, $id);
     }
 }
/**
 * This function loads the YUI modules that I have written.  I've elected to
 * load these last since that is generally safest.
 *
 * @param int $courseid The ID of the course being used.
 * @param int $groupid The ID of the group that the user belongs to.
 *
 */
function load_yui_modules($courseid, $groupid, $error = null)
{
    global $PAGE;
    $params = array('courseid' => $courseid, 'groupid' => $groupid, 'errorstring' => $error);
    if ($error == null) {
        $sgsetting = new skills_group_setting($courseid);
        $sgrouping = new skills_grouping($courseid);
        $sgroup = new skills_group($groupid);
        // True max group size is: max group size - # of locked members.
        $params['maxgroupsize'] = $sgsetting->get_group_size() - count($sgroup->get_members_list(true));
        $potentialstudents = $sgrouping->get_potential_students();
        $params['availableids'] = array_keys($potentialstudents);
        $params['availablenames'] = array_values($potentialstudents);
        $unlockedstudents = $sgroup->get_members_list(false);
        $params['groupmemberids'] = array_keys($unlockedstudents);
        $params['groupmembernames'] = array_values($unlockedstudents);
    }
    $PAGE->requires->yui_module('moodle-block_skills_group-edit', 'M.block_skills_group.init_edit', array($params));
}