MDL-42181 quiz nav: highight all buttons when all Qs on one page
authorM Kassaei <m.kassaei@open.ac.uk>
Thu, 17 Oct 2013 13:46:58 +0000 (14:46 +0100)
committerM Kassaei <m.kassaei@open.ac.uk>
Fri, 15 Nov 2013 15:30:31 +0000 (15:30 +0000)
mod/quiz/attemptlib.php
mod/quiz/renderer.php

index cb05a54..30c05e6 100644 (file)
@@ -1664,7 +1664,7 @@ abstract class quiz_nav_panel_base {
                 $button->stateclass = 'complete';
             }
             $button->statestring = $this->get_state_string($qa, $showcorrectness);
                 $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;
             $button->flagged     = $qa->is_flagged();
             $button->url         = $this->get_question_url($slot);
             $buttons[] = $button;
@@ -1715,6 +1715,20 @@ abstract class quiz_nav_panel_base {
         }
         return $userpicture;
     }
         }
         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';
+    }
 }
 
 
 }
 
 
index 6900a3b..aca16a5 100644 (file)
@@ -313,7 +313,8 @@ class mod_quiz_renderer extends plugin_renderer_base {
         }
         $output .= $panel->render_before_button_bits($this);
 
         }
         $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);
         }
         foreach ($panel->get_question_buttons() as $button) {
             $output .= $this->render($button);
         }