/** * Get the buttons and section headings to go in the quiz navigation block. * @return renderable[] the buttons, possibly interleaved with section headings. */ public function get_question_buttons() { $buttons = array(); foreach ($this->attemptobj->get_slots() as $slot) { if ($heading = $this->attemptobj->get_heading_before_slot($slot)) { $buttons[] = new quiz_nav_section_heading(format_string($heading)); } $qa = $this->attemptobj->get_question_attempt($slot); $showcorrectness = $this->options->correctness && $qa->has_marks(); $button = new quiz_nav_question_button(); $button->id = 'quiznavbutton' . $slot; $button->number = $this->attemptobj->get_question_number($slot); $button->stateclass = $qa->get_state_class($showcorrectness); $button->navmethod = $this->attemptobj->get_navigation_method(); if (!$showcorrectness && $button->stateclass == 'notanswered') { $button->stateclass = 'complete'; } $button->statestring = $this->get_state_string($qa, $showcorrectness); $button->page = $this->attemptobj->get_question_page($slot); $button->currentpage = $this->showall || $button->page == $this->page; $button->flagged = $qa->is_flagged(); $button->url = $this->get_question_url($slot); if ($this->attemptobj->is_blocked_by_previous_question($slot)) { $button->url = null; $button->stateclass = 'blocked'; $button->statestring = get_string('questiondependsonprevious', 'quiz'); } $buttons[] = $button; } return $buttons; }
public function get_question_buttons() { $buttons = array(); foreach ($this->attemptobj->get_slots() as $slot) { $qa = $this->attemptobj->get_question_attempt($slot); $showcorrectness = $this->options->correctness && $qa->has_marks(); $button = new quiz_nav_question_button(); $button->id = 'quiznavbutton' . $slot; $button->number = $this->attemptobj->get_question_number($slot); $button->stateclass = $qa->get_state_class($showcorrectness); $button->navmethod = $this->attemptobj->get_navigation_method(); if (!$showcorrectness && $button->stateclass == 'notanswered') { $button->stateclass = 'complete'; } $button->statestring = $this->get_state_string($qa, $showcorrectness); $button->currentpage = $this->attemptobj->get_question_page($slot) == $this->page; $button->flagged = $qa->is_flagged(); $button->url = $this->get_question_url($slot); $buttons[] = $button; } return $buttons; }