/**
  * Use a static cache to try and reduce DB calls.
  *
  * @param int $userid The user id for this submission
  * @param int $group The groupid (returned)
  * @param stdClass|false $submission The stdClass submission or false (returned)
  * @param int $attemptnumber Return a specific attempt number (-1 for latest)
  */
 protected function get_group_and_submission($userid, &$group, &$submission, $attemptnumber)
 {
     $group = false;
     if (isset($this->submissiongroups[$userid])) {
         $group = $this->submissiongroups[$userid];
     } else {
         $group = $this->seplment->get_submission_group($userid, false);
         $this->submissiongroups[$userid] = $group;
     }
     $groupid = 0;
     if ($group) {
         $groupid = $group->id;
     }
     // Static cache is keyed by groupid and attemptnumber.
     // We may need both the latest and previous attempt in the same page.
     if (isset($this->groupsubmissions[$groupid . ':' . $attemptnumber])) {
         $submission = $this->groupsubmissions[$groupid . ':' . $attemptnumber];
     } else {
         $submission = $this->seplment->get_group_submission($userid, $groupid, false, $attemptnumber);
         $this->groupsubmissions[$groupid . ':' . $attemptnumber] = $submission;
     }
 }