* @since Moodle 2.1
*/
class quiz_nav_question_button implements renderable {
+ /** @var string id="..." to add to the HTML for this button. */
public $id;
+ /** @var string number to display in this button. Either the question number of 'i'. */
public $number;
+ /** @var string class to add to the class="" attribute to represnt the question state. */
public $stateclass;
+ /** @var string Textual description of the question state, e.g. to use as a tool tip. */
public $statestring;
+ /** @var int the page number this question is on. */
+ public $page;
+ /** @var bool true if this question is on the current page. */
public $currentpage;
+ /** @var bool true if this question has been flagged. */
public $flagged;
+ /** @var moodle_url the link this button goes to, or null if there should not be a link. */
public $url;
}
$button->stateclass = 'complete';
}
$button->statestring = $this->get_state_string($qa, $showcorrectness);
- $button->currentpage = $this->showall || $this->attemptobj->get_question_page($slot) == $this->page;
+ $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);
$buttons[] = $button;
*/
protected function render_quiz_nav_question_button(quiz_nav_question_button $button) {
$classes = array('qnbutton', $button->stateclass, $button->navmethod);
- $attributes = array();
+ $extrainfo = array();
if ($button->currentpage) {
$classes[] = 'thispage';
- $attributes[] = get_string('onthispage', 'quiz');
+ $extrainfo[] = get_string('onthispage', 'quiz');
}
// Flagged?
} else {
$flaglabel = '';
}
- $attributes[] = html_writer::tag('span', $flaglabel, array('class' => 'flagstate'));
+ $extrainfo[] = html_writer::tag('span', $flaglabel, array('class' => 'flagstate'));
if (is_numeric($button->number)) {
$qnostring = 'questionnonav';
$a = new stdClass();
$a->number = $button->number;
- $a->attributes = implode(' ', $attributes);
+ $a->attributes = implode(' ', $extrainfo);
$tagcontents = html_writer::tag('span', '', array('class' => 'thispageholder')) .
html_writer::tag('span', '', array('class' => 'trafficlight')) .
get_string($qnostring, 'quiz', $a);
$tagattributes = array('class' => implode(' ', $classes), 'id' => $button->id,
- 'title' => $button->statestring);
+ 'title' => $button->statestring, 'data-quiz-page' => $button->page);
if ($button->url) {
return html_writer::link($button->url, $tagcontents, $tagattributes);