-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderer.php
156 lines (145 loc) · 5.62 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
<?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/>.
/**
* @package mod_cardbox
* @copyright 2019 RWTH Aachen (see README.md)
* @author Anna Heynkes
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once('../../config.php');
class mod_cardbox_renderer extends plugin_renderer_base {
/**
* Construct a tab header.
*
* @param moodle_url $baseurl
* @param string $namekey
* @param string $what
* @param string $subpage
* @param string $nameargs
* @return tabobject
*/
private function cardbox_create_tab(moodle_url $baseurl, $namekey = null, $action, $cardboxname = null, $nameargs = null) {
$taburl = new moodle_url($baseurl, array('action' => $action));
$tabname = get_string($namekey, 'cardbox', $nameargs);
if ($cardboxname) {
strlen($cardboxname) > 20 ? $tabname = substr($cardboxname, 0, 21) . "..." : $tabname = $cardboxname;
}
$id = $action;
$tab = new tabobject($id, $taburl, $tabname);
return $tab;
}
/**
* Render the tab header hierarchy.
*
* @param moodle_url $baseurl
* @param type $selected
* @param type $cardboxname
* @param type $context
* @param type $inactive
* @return type
*/
public function cardbox_render_tabs(moodle_url $baseurl, $selected = null, $context, $inactive = null) {
global $USER;
$level1 = array($this->cardbox_create_tab($baseurl, 'addflashcard', 'addflashcard'));
if (has_capability('mod/cardbox:approvecard', $context)) {
$level1[] = $this->cardbox_create_tab($baseurl, 'massimport', 'massimport');
}
$level1[] = $this->cardbox_create_tab($baseurl, 'practice', 'practice');
$level1[] = $this->cardbox_create_tab($baseurl, 'statistics', 'statistics');
if (has_capability('mod/cardbox:approvecard', $context)) {
$level1[] = $this->cardbox_create_tab($baseurl, 'review', 'review');
}
$level1[] = $this->cardbox_create_tab($baseurl, 'overview', 'overview');
if (has_capability('mod/cardbox:edittopics', $context)) {
$level1[] = $this->cardbox_create_tab($baseurl, 'edittopic', 'edittopic');
}
return $this->tabtree($level1, $selected, $inactive);
}
/**
*
* @param \templatable $studyview
* @return type
*/
public function cardbox_render_studyview(\templatable $studyview) {
$data = $studyview->export_for_template($this);
return $this->render_from_template('mod_cardbox/studyview', $data); // 1. Param specifies the template, 2. param the data to pass into it.
}
/**
*
* @param \templatable $practice
* @return type
*/
public function cardbox_render_practice(\templatable $practice) {
$data = $practice->export_for_template($this);
return $this->render_from_template('mod_cardbox/practice', $data);
}
/**
* Function renders a modal dialogue which asks the user to choose a correction mode
* and/or topics to prefer in card selection.
*
* @param \templatable $practice
* @return type
*/
public function cardbox_render_practice_start(\templatable $practice) {
$data = $practice->export_for_template($this);
return $this->render_from_template('mod_cardbox/practice_start', $data);
}
/**
*
* @param \templatable $review
* @return type
*/
public function cardbox_render_statistics(\templatable $statistics) {
$data = $statistics->export_for_template($this);
return $this->render_from_template('mod_cardbox/statistics', $data); // 1. Param specifies the template, 2. param the data to pass into it.
}
/**
*
* @param \templatable $review
* @return type
*/
public function cardbox_render_review(\templatable $review) {
$data = $review->export_for_template($this);
return $this->render_from_template('mod_cardbox/review', $data); // 1. Param specifies the template, 2. param the data to pass into it.
}
/**
*
* @param \templatable $review
* @return type
*/
public function cardbox_render_overview(\templatable $review) {
$data = $review->export_for_template($this);
return $this->render_from_template('mod_cardbox/overview', $data);
}
/**
*
* @param \array $errorlines : consists of errored rows, no of successfully imported card, url to continue
* @return type
*/
public function cardbox_render_errimport(array $errorlines) {
return $this->render_from_template('mod_cardbox/errimport', $errorlines);
}
/**
*
* @param \templatable $edittopics
* @return type
*/
public function cardbox_render_topics(\templatable $topics) {
$data = $topics->export_for_template($this);
return $this->render_from_template('mod_cardbox/topic', $data); // 1. Param specifies the template, 2. param the data to pass into it.
}
}