Skip to content

Commit

Permalink
MDL-42181 quiz nav: highight all buttons when all Qs on one page
Browse files Browse the repository at this point in the history
  • Loading branch information
mkassaei committed Nov 15, 2013
1 parent b3f2d75 commit bdbbe77
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
16 changes: 15 additions & 1 deletion mod/quiz/attemptlib.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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';
}
}


Expand Down
3 changes: 2 additions & 1 deletion mod/quiz/renderer.php
Expand Up @@ -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);
}
Expand Down

0 comments on commit bdbbe77

Please sign in to comment.