mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-76614 quiz: move quiz_review_nav_panel to classes
This commit is contained in:
parent
ccbb5da784
commit
03116995d5
@ -1870,7 +1870,7 @@ class quiz_attempt {
|
||||
* Get the navigation panel object for this attempt.
|
||||
*
|
||||
* @param renderer $output the quiz renderer to use to output things.
|
||||
* @param string $panelclass The type of panel, navigation_panel_attempt::class or quiz_review_nav_panel
|
||||
* @param string $panelclass The type of panel, navigation_panel_attempt::class or navigation_panel_review::class
|
||||
* @param int $page the current page number.
|
||||
* @param bool $showall whether we are showing the whole quiz on one page. (Used by review.php.)
|
||||
* @return block_contents the requested object.
|
||||
@ -2710,33 +2710,3 @@ class quiz_attempt {
|
||||
return $totalunanswered;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specialisation of {@see navigation_panel_base} for the review quiz page.
|
||||
*
|
||||
* @copyright 2008 Tim Hunt
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 2.0
|
||||
*/
|
||||
class quiz_review_nav_panel extends navigation_panel_base {
|
||||
public function get_question_url($slot) {
|
||||
return $this->attemptobj->review_url($slot, -1, $this->showall, $this->page);
|
||||
}
|
||||
|
||||
public function render_end_bits(renderer $output) {
|
||||
$html = '';
|
||||
if ($this->attemptobj->get_num_pages() > 1) {
|
||||
if ($this->showall) {
|
||||
$html .= html_writer::link($this->attemptobj->review_url(null, 0, false),
|
||||
get_string('showeachpage', 'quiz'));
|
||||
} else {
|
||||
$html .= html_writer::link($this->attemptobj->review_url(null, 0, true),
|
||||
get_string('showall', 'quiz'));
|
||||
}
|
||||
}
|
||||
$html .= $output->finish_review_link($this->attemptobj);
|
||||
$html .= $this->render_restart_preview_link($output);
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
52
mod/quiz/classes/output/navigation_panel_review.php
Normal file
52
mod/quiz/classes/output/navigation_panel_review.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace mod_quiz\output;
|
||||
|
||||
use html_writer;
|
||||
|
||||
/**
|
||||
* Specialisation of {@see navigation_panel_base} for the review quiz page.
|
||||
*
|
||||
* This class is not currently renderable or templatable, but it probably should be in the future,
|
||||
* which is why it is already in the output namespace.
|
||||
*
|
||||
* @package mod_quiz
|
||||
* @category output
|
||||
* @copyright 2008 Tim Hunt
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class navigation_panel_review extends navigation_panel_base {
|
||||
public function get_question_url($slot) {
|
||||
return $this->attemptobj->review_url($slot, -1, $this->showall, $this->page);
|
||||
}
|
||||
|
||||
public function render_end_bits(renderer $output) {
|
||||
$html = '';
|
||||
if ($this->attemptobj->get_num_pages() > 1) {
|
||||
if ($this->showall) {
|
||||
$html .= html_writer::link($this->attemptobj->review_url(null, 0, false),
|
||||
get_string('showeachpage', 'quiz'));
|
||||
} else {
|
||||
$html .= html_writer::link($this->attemptobj->review_url(null, 0, true),
|
||||
get_string('showall', 'quiz'));
|
||||
}
|
||||
}
|
||||
$html .= $output->finish_review_link($this->attemptobj);
|
||||
$html .= $this->render_restart_preview_link($output);
|
||||
return $html;
|
||||
}
|
||||
}
|
@ -63,4 +63,5 @@ $renamedclasses = [
|
||||
'quiz_nav_section_heading' => 'mod_quiz\output\navigation_section_heading',
|
||||
'quiz_nav_panel_base' => 'mod_quiz\output\navigation_panel_base',
|
||||
'quiz_attempt_nav_panel' => 'mod_quiz\output\navigation_panel_attempt',
|
||||
'quiz_review_nav_panel' => 'mod_quiz\output\navigation_panel_review',
|
||||
];
|
||||
|
@ -25,6 +25,8 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
use mod_quiz\output\navigation_panel_review;
|
||||
use mod_quiz\output\renderer;
|
||||
|
||||
require_once(__DIR__ . '/../../config.php');
|
||||
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
|
||||
@ -254,10 +256,11 @@ if ($showall) {
|
||||
$lastpage = $attemptobj->is_last_page($page);
|
||||
}
|
||||
|
||||
/** @var renderer $output */
|
||||
$output = $PAGE->get_renderer('mod_quiz');
|
||||
|
||||
// Arrange for the navigation to be displayed.
|
||||
$navbc = $attemptobj->get_navigation_panel($output, 'quiz_review_nav_panel', $page, $showall);
|
||||
$navbc = $attemptobj->get_navigation_panel($output, navigation_panel_review::class, $page, $showall);
|
||||
$regions = $PAGE->blocks->get_regions();
|
||||
$PAGE->blocks->add_fake_block($navbc, reset($regions));
|
||||
|
||||
|
@ -47,6 +47,7 @@ This files describes API changes in the quiz code.
|
||||
- quiz_nav_section_heading => mod_quiz\output\navigation_section_heading
|
||||
- quiz_nav_panel_base => mod_quiz\output\navigation_panel_base
|
||||
- quiz_attempt_nav_panel => mod_quiz\output\navigation_panel_attempt
|
||||
- quiz_review_nav_panel => mod_quiz\output\navigation_panel_review
|
||||
|
||||
* The following classes have been deprecated:
|
||||
- mod_quiz_overdue_attempt_updater - merged into mod_quiz\task\update_overdue_attempts
|
||||
|
Loading…
x
Reference in New Issue
Block a user