/**
  * This function loops through each group, calculates, and formats the scores.
  *
  * @return array List of all scores for each of the valid groups a user could join.
  *
  */
 public function get_table_rows()
 {
     global $DB;
     $sgs = new skills_group_setting($this->courseid);
     $tablerows = array();
     foreach ($this->records as $group) {
         $sgroup = new skills_group($group->groupid);
         if ($sgroup->count_members() < $sgs->get_group_size() && $sgroup->get_allow_others_to_join() === true) {
             $scores = $sgs->get_feedback_id() == 0 ? array() : $sgroup->get_join_form_score();
             $name = $sgroup->get_group_name();
             $temp = array_merge(array('id' => $group->groupid, 'name' => $name), $scores);
             $tablerows[] = $temp;
         }
     }
     return $tablerows;
 }
 /**
  * This function runs through the scores (both all and individual items) and compares
  * them to the desired result stored in $expected.
  *
  * @param      array  $expected  Desired outcome of score comparison.
  */
 private function verify_join_form_scores($expected)
 {
     for ($i = 0; $i < self::NUMBEROFGROUPS; $i++) {
         // Now test the group.
         $sgroup = new skills_group($this->groupids[$i]);
         $scores = $sgroup->get_join_form_score();
         foreach ($scores as $score) {
             $this->assertEquals($score, $expected[$i]);
         }
     }
     // Now test getting individual score.
     for ($i = 0; $i < self::NUMBEROFGROUPS; $i++) {
         $sgroup = new skills_group($this->groupids[$i]);
         for ($j = 1; $j <= self::FEEDBACKITEMS; $j++) {
             $this->assertEquals($sgroup->get_join_form_score($j), $expected[$i]);
         }
     }
 }