/**
  * Displays the view home.
  *
  * @param \mod_activequiz\forms\view\student_start_form $studentstartform
  * @param \mod_activequiz\activequiz_session            $session The activequiz session object to call methods on
  */
 public function view_student_home($studentstartform, $session)
 {
     global $USER;
     echo html_writer::start_div('activequizbox');
     if ($session->get_session()) {
         // check if there is an open session
         // if we have an existing session show the join quiz button
         $joinquiz = clone $this->pageurl;
         $joinquiz->param('action', 'quizstart');
         echo html_writer::tag('p', get_string('joinquizinstructions', 'activequiz'));
         echo html_writer::tag('p', get_string('sessionnametext', 'activequiz') . $session->get_session()->name);
         // see if the user has attempts, if so, let them know that continuing will continue them to their attempt
         if ($session->get_open_attempt_for_current_user()) {
             echo html_writer::tag('p', get_string('attemptstarted', 'activequiz'), array('id' => 'quizinfobox'));
         }
         // add the student join quiz form
         $studentstartform->display();
     } else {
         echo html_writer::tag('p', get_string('quiznotrunning', 'activequiz'));
         // show a reload page button to make it easy to reload page
         $reloadbutton = $this->output->single_button($this->pageurl, get_string('reload'), 'get');
         echo html_writer::tag('p', $reloadbutton);
     }
     echo html_writer::end_div();
     if (count($this->rtq->get_closed_sessions()) == 0) {
         return;
         // return early if there are no closed sessions
     }
     echo html_writer::start_div('activequizbox');
     // show overall grade
     $a = new stdClass();
     $usergrades = \mod_activequiz\utils\grade::get_user_grade($this->rtq->getRTQ(), $USER->id);
     // should only be 1 grade, but we'll always get end()
     if (!empty($usergrades)) {
         $usergrade = end($usergrades);
         $a->overallgrade = number_format($usergrade->rawgrade, 2);
         $a->scale = $this->rtq->getRTQ()->scale;
         echo html_writer::start_tag('h3');
         echo get_string('overallgrade', 'activequiz', $a);
         echo html_writer::end_tag('h3');
     } else {
         return;
         // if no user grade there are no attempts for this user
     }
     // show attempts table if rtq is set up to show attempts in the after review options
     if ($this->rtq->get_review_options('after')->attempt == 1) {
         echo html_writer::tag('h3', get_string('attempts', 'activequiz'));
         $viewownattemptstable = new \mod_activequiz\tableviews\ownattempts('viewownattempts', $this->rtq, $this->pageurl);
         $viewownattemptstable->setup();
         $viewownattemptstable->set_data();
         $viewownattemptstable->finish_output();
     }
     echo html_writer::end_div();
 }