Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-42181 quiz nav: highight all buttons when all Qs on one page

  • Loading branch information...
commit f6240d9eea3cf668602ffdf512a1894590d7f9d2 1 parent 49d367d
@mkassaei mkassaei authored danpoltawski committed
Showing with 17 additions and 2 deletions.
  1. +15 −1 mod/quiz/attemptlib.php
  2. +2 −1  mod/quiz/renderer.php
View
16 mod/quiz/attemptlib.php
@@ -1664,7 +1664,7 @@ public function get_question_buttons() {
$button->stateclass = 'complete';
}
$button->statestring = $this->get_state_string($qa, $showcorrectness);
- $button->currentpage = $this->attemptobj->get_question_page($slot) == $this->page;
+ $button->currentpage = $this->showall || $this->attemptobj->get_question_page($slot) == $this->page;
$button->flagged = $qa->is_flagged();
$button->url = $this->get_question_url($slot);
$buttons[] = $button;
@@ -1715,6 +1715,20 @@ public function user_picture() {
}
return $userpicture;
}
+
+ /**
+ * Return 'allquestionsononepage' as CSS class name when $showall is set,
+ * otherwise, return 'multipages' as CSS class name.
+ * @return string, CSS class name
+ */
+ public function get_button_container_class() {
+ // Quiz navigation is set on 'Show all questions on one page'.
+ if ($this->showall) {
+ return 'allquestionsononepage';
+ }
+ // Quiz navigation is set on 'Show one page at a time'.
+ return 'multipages';
+ }
}
View
3  mod/quiz/renderer.php
@@ -313,7 +313,8 @@ public function navigation_panel(quiz_nav_panel_base $panel) {
}
$output .= $panel->render_before_button_bits($this);
- $output .= html_writer::start_tag('div', array('class' => 'qn_buttons'));
+ $bcc = $panel->get_button_container_class();
+ $output .= html_writer::start_tag('div', array('class' => "qn_buttons $bcc"));
foreach ($panel->get_question_buttons() as $button) {
$output .= $this->render($button);
}
Please sign in to comment.
Something went wrong with that request. Please try again.