Permalink
Browse files

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

  • Loading branch information...
1 parent b3f2d75 commit bdbbe777d9f6e0e7f7602aa36fe23c9f17158ff0 @mkassaei mkassaei committed Oct 17, 2013
Showing with 17 additions and 2 deletions.
  1. +15 −1 mod/quiz/attemptlib.php
  2. +2 −1 mod/quiz/renderer.php
View
@@ -1643,7 +1643,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;
@@ -1693,6 +1693,20 @@ public function user_picture() {
$userpicture->courseid = $this->attemptobj->get_courseid();
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
@@ -311,7 +311,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);
}

0 comments on commit bdbbe77

Please sign in to comment.