-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrenderer.php
168 lines (148 loc) · 6 KB
/
renderer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<?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/>.
/**
* Defines the renderer for the question engine upgrade helper plugin.
*
* @package local
* @subpackage qeupgradehelper
* @copyright 2010 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Renderer for the question engine upgrade helper plugin.
*
* @copyright 2010 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class local_qeupgradehelper_renderer extends plugin_renderer_base {
/**
* Render the index page.
* @param string $detected information about what sort of site was detected.
* @param array $actions list of actions to show on this page.
* @return string html to output.
*/
public function index_page($detected, array $actions) {
$output = '';
$output .= $this->header();
$output .= $this->heading(get_string('pluginname', 'local_qeupgradehelper'));
$output .= $this->box($detected);
$output .= html_writer::start_tag('ul');
foreach ($actions as $action) {
$output .= html_writer::tag('li',
html_writer::link($action->url, $action->name) . ' - ' .
$action->description);
}
$output .= html_writer::end_tag('ul');
$output .= $this->footer();
return $output;
}
/**
* Render a page that is just a simple message.
* @param string $message the message to display.
* @return string html to output.
*/
public function simple_message_page($message) {
$output = '';
$output .= $this->header();
$output .= $this->heading($message);
$output .= $this->back_to_index();
$output .= $this->footer();
return $output;
}
/**
* Render the list of quizzes that still need to be upgraded page.
* @param array $quizzes of data about quizzes.
* @param int $numveryoldattemtps only relevant before upgrade.
* @return string html to output.
*/
public function quiz_list_page(local_qeupgradehelper_quiz_list $quizzes,
$numveryoldattemtps = null) {
$output = '';
$output .= $this->header();
$output .= $this->heading($quizzes->title);
$output .= $this->box($quizzes->intro);
$table = new html_table();
$table->head = $quizzes->get_col_headings();
$rowcount = 0;
foreach ($quizzes->quizlist as $quizinfo) {
$table->data[$rowcount] = $quizzes->get_row($quizinfo);
if ($class = $quizzes->get_row_class($quizinfo)) {
$table->rowclasses[$rowcount] = $class;
}
$rowcount += 1;
}
$table->data[] = $quizzes->get_total_row();
$output .= html_writer::table($table);
if ($numveryoldattemtps) {
$output .= $this->box(get_string('veryoldattemtps', 'local_qeupgradehelper',
$numveryoldattemtps));
}
$output .= $this->back_to_index();
$output .= $this->footer();
return $output;
}
/**
* Render the are-you-sure page to confirm a manual upgrade.
* @param object $quizsummary data about the quiz to upgrade.
* @return string html to output.
*/
public function convert_quiz_are_you_sure($quizsummary) {
$output = '';
$output .= $this->header();
$output .= $this->heading(get_string('areyousure', 'local_qeupgradehelper'));
$params = array('quizid' => $quizsummary->id, 'confirmed' => 1, 'sesskey' => sesskey());
$output .= $this->confirm(get_string('areyousuremessage', 'local_qeupgradehelper', $quizsummary),
new single_button(local_qeupgradehelper_url('convertquiz', $params), get_string('yes')),
local_qeupgradehelper_url('listtodo'));
$output .= $this->footer();
return $output;
}
/**
* Render the are-you-sure page to confirm a manual reset.
* @param object $quizsummary data about the quiz to reset.
* @return string html to output.
*/
public function reset_quiz_are_you_sure($quizsummary) {
$output = '';
$output .= $this->header();
$output .= $this->heading(get_string('areyousure', 'local_qeupgradehelper'));
$params = array('quizid' => $quizsummary->id, 'confirmed' => 1, 'sesskey' => sesskey());
$output .= $this->confirm(get_string('areyousureresetmessage', 'local_qeupgradehelper', $quizsummary),
new single_button(local_qeupgradehelper_url('resetquiz', $params), get_string('yes')),
local_qeupgradehelper_url('listupgraded'));
$output .= $this->footer();
return $output;
}
/**
* Render a link in a div, such as the 'Back to plugin main page' link.
* @param $url the link URL.
* @param $text the link text.
* @return string html to output.
*/
public function end_of_page_link($url, $text) {
return html_writer::tag('div', html_writer::link($url ,$text),
array('class' => 'mdl-align'));
}
/**
* Output a link back to the plugin index page.
* @return string html to output.
*/
public function back_to_index() {
return $this->end_of_page_link(local_qeupgradehelper_url('index'),
get_string('backtoindex', 'local_qeupgradehelper'));
}
}