1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
namespace mod_quiz\output;
|
|
|
18 |
|
|
|
19 |
use moodle_url;
|
|
|
20 |
use renderable;
|
|
|
21 |
use renderer_base;
|
|
|
22 |
use templatable;
|
|
|
23 |
use url_select;
|
|
|
24 |
|
|
|
25 |
/**
|
|
|
26 |
* Represents the tertiary navigation around the quiz edit pages.
|
|
|
27 |
*
|
|
|
28 |
* @package mod_quiz
|
|
|
29 |
* @copyright 2023 The Open University
|
|
|
30 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
31 |
*/
|
|
|
32 |
class edit_nav_actions implements renderable, templatable {
|
|
|
33 |
/** @var string option for $whichpage argument to the constructor. */
|
|
|
34 |
const SUMMARY = 'summary';
|
|
|
35 |
|
|
|
36 |
/** @var string option for $whichpage argument to the constructor. */
|
|
|
37 |
const GRADING = 'grading';
|
|
|
38 |
|
|
|
39 |
/**
|
|
|
40 |
* overrides_action constructor.
|
|
|
41 |
*
|
|
|
42 |
* @param int $cmid The course module id.
|
|
|
43 |
* @param string $whichpage self::SUMMARY (edit.php) or self::GRADING (editgrading.php).
|
|
|
44 |
*/
|
|
|
45 |
public function __construct(
|
|
|
46 |
|
|
|
47 |
/** @var int The course module ID. */
|
|
|
48 |
protected readonly int $cmid,
|
|
|
49 |
|
|
|
50 |
/** @var string which page this is. Either self::SUMMARY (edit.php) or self::GRADING (editgrading.php). */
|
|
|
51 |
protected readonly string $whichpage,
|
|
|
52 |
|
|
|
53 |
) {
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
public function export_for_template(renderer_base $output): array {
|
|
|
57 |
|
|
|
58 |
// Build the navigation drop-down.
|
|
|
59 |
$questionsurl = new moodle_url('/mod/quiz/edit.php', ['cmid' => $this->cmid]);
|
|
|
60 |
$gradeitemsetupurl = new moodle_url('/mod/quiz/editgrading.php', ['cmid' => $this->cmid]);
|
|
|
61 |
|
|
|
62 |
$menu = [
|
|
|
63 |
$questionsurl->out(false) => get_string('questions', 'quiz'),
|
|
|
64 |
$gradeitemsetupurl->out(false) => get_string('gradeitemsetup', 'quiz'),
|
|
|
65 |
];
|
|
|
66 |
|
|
|
67 |
$overridesnav = new url_select(
|
|
|
68 |
$menu,
|
|
|
69 |
$this->whichpage === self::SUMMARY ? $questionsurl->out(false) : $gradeitemsetupurl->out(false),
|
|
|
70 |
null
|
|
|
71 |
);
|
|
|
72 |
$overridesnav->set_label(get_string('quizsetupnavigation', 'quiz'), ['class' => 'sr-only']);
|
|
|
73 |
|
|
|
74 |
return [
|
|
|
75 |
'navmenu' => $overridesnav->export_for_template($output),
|
|
|
76 |
];
|
|
|
77 |
}
|
|
|
78 |
}
|