/** * Gets the data for the table * * @return array $data The array of data to show */ protected function get_data() { global $DB, $USER; $data = array(); $sessions = $this->rtq->get_sessions(); foreach ($sessions as $session) { /** @var \mod_activequiz\activequiz_session $session */ $sessionattempts = $session->getall_attempts(false, 'closed', $USER->id); foreach ($sessionattempts as $sattempt) { $ditem = new \stdClass(); $ditem->attemptid = $sattempt->id; $ditem->sessionid = $sattempt->sessionid; $ditem->sessionname = $session->get_session()->name; if ($this->rtq->group_mode()) { $ditem->group = $this->rtq->get_groupmanager()->get_group_name($sattempt->forgroupid); } $ditem->timestart = $sattempt->timestart; $ditem->timefinish = $sattempt->timefinish; $ditem->grade = number_format($this->rtq->get_grader()->calculate_attempt_grade($sattempt), 2); $ditem->totalgrade = $this->rtq->getRTQ()->scale; $data[$sattempt->id] = $ditem; } } return $data; }
/** * Process grades for a specific user * * @param int $userid * * @return bool */ public function save_user_grades($userid) { $sessions = $this->rtq->get_sessions(); if (empty($sessions)) { return true; // return true if the sessions are empty } // check grading methods if ($this->rtq->getRTQ()->grademethod == \mod_activequiz\utils\scaletypes::activequiz_FIRSTSESSION) { // only grading first session return $this->process_sessions(array($sessions[0]), $userid); } else { if ($this->rtq->getRTQ()->grademethod == \mod_activequiz\utils\scaletypes::REALTIMQUIZ_LASTSESSION) { // only grading last session return $this->process_sessions(array(end($sessions)), $userid); } else { // otherwise do all sessions // other grading methods are processed later return $this->process_sessions($sessions, $userid); } } }