Skip to content

Commit a755d46

Browse files
committed
add template for first overview
1 parent 210029c commit a755d46

File tree

3 files changed

+172
-19
lines changed

3 files changed

+172
-19
lines changed

classes/output/renderer.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
/**
18+
* LSF unification renderer.
19+
*
20+
* @package local_lsf_unification
21+
* @copyright 2025 Tamaro Walter
22+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23+
*/
24+
namespace local_lsf_unification\output;
25+
26+
27+
use plugin_renderer_base;
28+
29+
global $CFG;
30+
require_once($CFG->dirroot . '/local/lsf_unification/lib_features.php');
31+
require_once($CFG->dirroot . '/local/lsf_unification/request_form.php');
32+
require_once($CFG->dirroot . '/lib/outputlib.php');
33+
34+
/**
35+
* Class to call mustache templates.
36+
*
37+
* @package local_lsf_unification
38+
* @copyright 2025 Tamaro Walter
39+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
40+
*/
41+
class renderer extends plugin_renderer_base {
42+
/**
43+
* Return the first overview in the request.php.
44+
*
45+
* @return string HTML
46+
*/
47+
public function render_first_overview(): string {
48+
global $USER;
49+
$courselist = [];
50+
foreach (get_teachers_course_list($USER->username, true) as $course) {
51+
if (!course_exists($course->veranstid)) {
52+
$courselist[] = (object)['title' => $course->info,];
53+
}
54+
}
55+
56+
$mustachedata = [
57+
'courselist' => $courselist,
58+
'showremotecreation' => get_config('local_lsf_unification', 'remote_creation'),
59+
];
60+
return $this->render_from_template("local_lsf_unification/first_overview", $mustachedata);
61+
}
62+
}

request.php

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,8 @@
6868
}
6969

7070
function print_first_overview() {
71-
global $USER;
72-
$courselist = "<ul>";
73-
foreach (get_teachers_course_list($USER->username, true) as $course) {
74-
if (!course_exists($course->veranstid)) {
75-
$courselist .= "<li>" . $course->info . "</li>";
76-
}
77-
}
78-
$courselist .= "</ul>";
79-
echo "<p>" . get_string('notice', 'local_lsf_unification') . "</p>";
80-
echo "<form name='input' action='request.php' method='post'><table><tr><td colspan='2'><b>" . get_string('question', 'local_lsf_unification') . "</b>";
81-
echo "</td></tr>";
82-
echo ($courselist != "<ul></ul>") ? ("<tr><td style='vertical-align:top;'><input type='radio' name='answer' id='answer1' value='1'></td><td><label for='answer1'>" . get_string('answer_course_found', 'local_lsf_unification') . "" . $courselist . "</label></td></tr>") : "";
83-
84-
echo "<tr><td><input type='radio' name='answer' id='answer3' value='3'></td><td><label for='answer3'>" . get_string('answer_course_in_lsf_and_visible', 'local_lsf_unification') . "</label></td></tr>";
85-
if (get_config('local_lsf_unification', 'remote_creation')) {
86-
echo "<tr><td><input type='radio' name='answer' id='answer11' value='11'></td><td><label for='answer11'>" . get_string('answer_proxy_creation', 'local_lsf_unification') . "</label></td></tr>";
87-
}
88-
echo "<tr><td><input type='radio' name='answer' id='answer6' value='6'></td><td><label for='answer6'>" . get_string('answer_goto_old_requestform', 'local_lsf_unification') . "</label></td></tr>";
89-
echo "<tr><td>&nbsp;</td><td><input type='submit' value='" . get_string('select', 'local_lsf_unification') . "'/></td></tr></table></form>";
71+
global $PAGE;
72+
echo $PAGE->get_renderer('local_lsf_unification')->render_first_overview();
9073
}
9174

9275
function print_helptext($t, $s = null) {

templates/first_overview.mustache

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
{{!
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+
{{!
18+
@template block_townsquare/blockcontent
19+
20+
This template renders the main content area for the townsquare block.
21+
22+
Variables required for this template:
23+
* content - Array with content
24+
* isorientationmarker - Boolean variable if current content is a orientationmarker
25+
* isbasic - Boolean variable if current content is a basic notification
26+
* isactivitycompletion - Boolean variable if current content is an activity completion
27+
* ispost - Boolean variable if current content is a post
28+
29+
Example (json):
30+
{
31+
"courselist": [
32+
{
33+
"title": "Veranstaltungstitel Nr.1",
34+
},
35+
{
36+
"title": "Veranstaltungstitel Nr.2",
37+
},
38+
{
39+
"title": "Veranstaltungstitel Nr.3",
40+
}
41+
]
42+
}
43+
}}
44+
<div id="lsf_unification_courselist_root">
45+
<p>{{#str}} notice, local_lsf_unification {{/str}}</p>
46+
<form name="input" action="request.php" method="post">
47+
<table>
48+
<tr>
49+
<td colspan="2">
50+
<b>{{#str}} question, local_lsf_unification {{/str}}</b>
51+
</td>
52+
</tr>
53+
{{#courselist}}
54+
<tr>
55+
<td style="vertical-align:top;">
56+
<input type="radio" name="answer" id="answer1" value="1">
57+
</td>
58+
<td>
59+
<label for="answer1">
60+
{{#str}} answer_course_found, local_lsf_unification {{/str}}
61+
<ul>
62+
<li>{{{title}}}</li>
63+
</ul>
64+
</label>
65+
</td>
66+
</tr>
67+
{{/courselist}}
68+
<tr>
69+
<td>
70+
<input type="radio" name="answer" id="answer3" value="3">
71+
</td>
72+
<td>
73+
<label for="answer3">
74+
{{#str}} answer_course_in_lsf_and_visible, local_lsf_unification {{/str}}
75+
</label>
76+
</td>
77+
</tr>
78+
{{#showremotecreation}}
79+
<tr>
80+
<td>
81+
<input type="radio" name="answer" id="answer11" value="11">
82+
</td>
83+
<td>
84+
<label for="answer11">
85+
{{#str}} answer_proxy_creation, local_lsf_unification {{/str}}
86+
</label>
87+
</td>
88+
</tr>
89+
{{/showremotecreation}}
90+
<tr>
91+
<td>
92+
<input type="radio" name="answer" id="answer6" value="6">
93+
</td>
94+
<td>
95+
<label for="answer6">
96+
{{#str}} answer_goto_old_requestform, local_lsf_unification {{/str}}
97+
</label>
98+
</td>
99+
</tr>
100+
<tr>
101+
<td>&#160;</td>
102+
<td>
103+
<input type="submit" value="{{#str}} select, local_lsf_unification {{/str}}">
104+
</td>
105+
</tr>
106+
</table>
107+
</form>
108+
</div>

0 commit comments

Comments
 (0)