Skip to content

Commit b8a49bd

Browse files
committed
WIP8d
1 parent 46854b4 commit b8a49bd

File tree

1 file changed

+152
-78
lines changed

1 file changed

+152
-78
lines changed

tabs.php

Lines changed: 152 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -40,56 +40,80 @@
4040

4141
$owner = $questionnaire->is_survey_owner();
4242
if ($questionnaire->capabilities->manage && $owner) {
43-
$row[] = new tabobject('settings', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/qsettings.php?'.
44-
'id='.$questionnaire->cm->id), get_string('advancedsettings'));
43+
$row[] = new tabobject(
44+
'settings',
45+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/qsettings.php?' . 'id=' . $questionnaire->cm->id),
46+
get_string('advancedsettings')
47+
);
4548
}
4649

4750
if ($questionnaire->capabilities->editquestions && $owner) {
48-
$row[] = new tabobject('questions', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/questions.php?'.
49-
'id='.$questionnaire->cm->id), get_string('questions', 'questionnaire'));
51+
$row[] = new tabobject(
52+
'questions',
53+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/questions.php?' . 'id=' . $questionnaire->cm->id),
54+
get_string('questions', 'questionnaire')
55+
);
5056
}
5157

5258
if ($questionnaire->capabilities->editquestions && $owner) {
53-
$row[] = new tabobject('feedback', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/feedback.php?'.
54-
'id='.$questionnaire->cm->id), get_string('feedback'));
59+
$row[] = new tabobject(
60+
'feedback',
61+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/feedback.php?' . 'id=' . $questionnaire->cm->id),
62+
get_string('feedback')
63+
);
5564
}
5665

5766
if ($questionnaire->capabilities->preview && $owner) {
5867
if (!empty($questionnaire->questions)) {
59-
$row[] = new tabobject('preview', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/preview.php?'.
60-
'id='.$questionnaire->cm->id), get_string('preview_label', 'questionnaire'));
68+
$row[] = new tabobject(
69+
'preview',
70+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/preview.php?' . 'id=' . $questionnaire->cm->id),
71+
get_string('preview_label', 'questionnaire')
72+
);
6173
}
6274
}
6375

6476
$usernumresp = $questionnaire->count_submissions($USER->id);
6577

6678
if ($questionnaire->capabilities->readownresponses && ($usernumresp > 0)) {
67-
$argstr = 'instance='.$questionnaire->id.'&user='.$USER->id.'&group='.$currentgroupid;
79+
$argstr = 'instance=' . $questionnaire->id . '&user=' . $USER->id . '&group=' . $currentgroupid;
6880
if ($usernumresp == 1) {
6981
$argstr .= '&byresponse=1&action=vresp';
7082
$yourrespstring = get_string('yourresponse', 'questionnaire');
7183
} else {
7284
$yourrespstring = get_string('yourresponses', 'questionnaire');
7385
}
74-
$row[] = new tabobject('myreport', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/myreport.php?'.
75-
$argstr), $yourrespstring);
86+
$row[] = new tabobject(
87+
'myreport',
88+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/myreport.php?'. $argstr),
89+
$yourrespstring
90+
);
7691

7792
if ($usernumresp > 1 && in_array($currenttab, array('mysummary', 'mybyresponse', 'myvall', 'mydownloadcsv'))) {
7893
$inactive[] = 'myreport';
7994
$activated[] = 'myreport';
8095
$row2 = array();
81-
$argstr2 = $argstr.'&action=summary';
82-
$row2[] = new tabobject('mysummary', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/myreport.php?'.$argstr2),
83-
get_string('summary', 'questionnaire'));
84-
$argstr2 = $argstr.'&byresponse=1&action=vresp';
85-
$row2[] = new tabobject('mybyresponse', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/myreport.php?'.$argstr2),
86-
get_string('viewindividualresponse', 'questionnaire'));
87-
$argstr2 = $argstr.'&byresponse=0&action=vall&group='.$currentgroupid;
88-
$row2[] = new tabobject('myvall', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/myreport.php?'.$argstr2),
89-
get_string('myresponses', 'questionnaire'));
96+
$argstr2 = $argstr . '&action=summary';
97+
$row2[] = new tabobject(
98+
'mysummary',
99+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/myreport.php?' . $argstr2),
100+
get_string('summary', 'questionnaire')
101+
);
102+
$argstr2 = $argstr . '&byresponse=1&action=vresp';
103+
$row2[] = new tabobject(
104+
'mybyresponse',
105+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/myreport.php?' . $argstr2),
106+
get_string('viewindividualresponse', 'questionnaire')
107+
);
108+
$argstr2 = $argstr . '&byresponse=0&action=vall&group=' . $currentgroupid;
109+
$row2[] = new tabobject(
110+
'myvall',
111+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/myreport.php?' . $argstr2),
112+
get_string('myresponses', 'questionnaire')
113+
);
90114
if ($questionnaire->capabilities->downloadresponses) {
91-
$argstr2 = $argstr.'&action=dwnpg';
92-
$link = $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/report.php?'.$argstr2);
115+
$argstr2 = $argstr . '&action=dwnpg';
116+
$link = $CFG->wwwroot . htmlspecialchars('/mod/questionnaire/report.php?' . $argstr2);
93117
$row2[] = new tabobject('mydownloadcsv', $link, get_string('downloadtextformat', 'questionnaire'));
94118
}
95119
} else if (in_array($currenttab, array('mybyresponse', 'mysummary'))) {
@@ -118,55 +142,83 @@
118142
$resplogic = ($numresp > 0) && ($numselectedresps > 0);
119143

120144
if ($questionnaire->can_view_all_responses_anytime($grouplogic, $resplogic)) {
121-
$argstr = 'instance='.$questionnaire->id;
122-
$row[] = new tabobject('allreport', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/report.php?'.
123-
$argstr.'&action=vall'), get_string('viewallresponses', 'questionnaire'));
124-
if (in_array($currenttab, array('vall', 'vresp', 'valldefault', 'vallasort', 'vallarsort', 'deleteall', 'downloadcsv',
125-
'vrespsummary', 'individualresp', 'printresp', 'deleteresp'))) {
145+
$argstr = 'instance=' . $questionnaire->id;
146+
$row[] = new tabobject(
147+
'allreport',
148+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/report.php?'. $argstr . '&action=vall'),
149+
get_string('viewallresponses', 'questionnaire')
150+
);
151+
if (in_array(
152+
$currenttab,
153+
array('vall', 'vresp', 'valldefault', 'vallasort', 'vallarsort', 'deleteall', 'downloadcsv',
154+
'vrespsummary', 'individualresp', 'printresp', 'deleteresp')
155+
)
156+
) {
126157
$inactive[] = 'allreport';
127158
$activated[] = 'allreport';
128159
if ($currenttab == 'vrespsummary' || $currenttab == 'valldefault') {
129160
$inactive[] = 'vresp';
130161
}
131162
$row2 = array();
132-
$argstr2 = $argstr.'&action=vall&group='.$currentgroupid;
133-
$row2[] = new tabobject('vall', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/report.php?'.$argstr2),
134-
get_string('summary', 'questionnaire'));
163+
$argstr2 = $argstr . '&action=vall&group=' . $currentgroupid;
164+
$row2[] = new tabobject(
165+
'vall',
166+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/report.php?' . $argstr2),
167+
get_string('summary', 'questionnaire')
168+
);
135169
if ($questionnaire->capabilities->viewsingleresponse) {
136-
$argstr2 = $argstr.'&byresponse=1&action=vresp&group='.$currentgroupid;
137-
$row2[] = new tabobject('vrespsummary', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/report.php?'.$argstr2),
138-
get_string('viewbyresponse', 'questionnaire'));
170+
$argstr2 = $argstr . '&byresponse=1&action=vresp&group=' . $currentgroupid;
171+
$row2[] = new tabobject(
172+
'vrespsummary',
173+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/report.php?' . $argstr2),
174+
get_string('viewbyresponse', 'questionnaire')
175+
);
139176
if ($currenttab == 'individualresp' || $currenttab == 'deleteresp') {
140-
$argstr2 = $argstr.'&byresponse=1&action=vresp';
141-
$row2[] = new tabobject('vresp', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/report.php?'.$argstr2),
142-
get_string('viewindividualresponse', 'questionnaire'));
177+
$argstr2 = $argstr . '&byresponse=1&action=vresp';
178+
$row2[] = new tabobject(
179+
'vresp',
180+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/report.php?' . $argstr2),
181+
get_string('viewindividualresponse', 'questionnaire')
182+
);
143183
}
144184
}
145185
}
146186
if (in_array($currenttab, array('valldefault', 'vallasort', 'vallarsort', 'deleteall', 'downloadcsv'))) {
147187
$activated[] = 'vall';
148188
$row3 = array();
149189

150-
$argstr2 = $argstr.'&action=vall&group='.$currentgroupid;
151-
$row3[] = new tabobject('valldefault', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/report.php?'.$argstr2),
152-
get_string('order_default', 'questionnaire'));
190+
$argstr2 = $argstr . '&action=vall&group=' . $currentgroupid;
191+
$row3[] = new tabobject(
192+
'valldefault',
193+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/report.php?' . $argstr2),
194+
get_string('order_default', 'questionnaire')
195+
);
153196
if ($currenttab != 'downloadcsv' && $currenttab != 'deleteall') {
154-
$argstr2 = $argstr.'&action=vallasort&group='.$currentgroupid;
155-
$row3[] = new tabobject('vallasort', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/report.php?'.$argstr2),
156-
get_string('order_ascending', 'questionnaire'));
157-
$argstr2 = $argstr.'&action=vallarsort&group='.$currentgroupid;
158-
$row3[] = new tabobject('vallarsort', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/report.php?'.$argstr2),
159-
get_string('order_descending', 'questionnaire'));
197+
$argstr2 = $argstr . '&action=vallasort&group=' . $currentgroupid;
198+
$row3[] = new tabobject(
199+
'vallasort',
200+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/report.php?' . $argstr2),
201+
get_string('order_ascending', 'questionnaire')
202+
);
203+
$argstr2 = $argstr . '&action=vallarsort&group=' . $currentgroupid;
204+
$row3[] = new tabobject(
205+
'vallarsort',
206+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/report.php?' . $argstr2),
207+
get_string('order_descending', 'questionnaire')
208+
);
160209
}
161210
if ($questionnaire->capabilities->deleteresponses) {
162-
$argstr2 = $argstr.'&action=delallresp&group='.$currentgroupid;
163-
$row3[] = new tabobject('deleteall', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/report.php?'.$argstr2),
164-
get_string('deleteallresponses', 'questionnaire'));
211+
$argstr2 = $argstr . '&action=delallresp&group=' . $currentgroupid;
212+
$row3[] = new tabobject(
213+
'deleteall',
214+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/report.php?' . $argstr2),
215+
get_string('deleteallresponses', 'questionnaire')
216+
);
165217
}
166218

167219
if ($questionnaire->capabilities->downloadresponses) {
168-
$argstr2 = $argstr.'&action=dwnpg&group='.$currentgroupid;
169-
$link = $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/report.php?'.$argstr2);
220+
$argstr2 = $argstr . '&action=dwnpg&group=' . $currentgroupid;
221+
$link = $CFG->wwwroot . htmlspecialchars('/mod/questionnaire/report.php?' . $argstr2);
170222
$row3[] = new tabobject('downloadcsv', $link, get_string('downloadtextformat', 'questionnaire'));
171223
}
172224
}
@@ -177,44 +229,64 @@
177229
$activated[] = 'vresp';
178230
}
179231
if ($questionnaire->capabilities->deleteresponses) {
180-
$argstr2 = $argstr.'&action=dresp&rid='.$rid.'&individualresponse=1';
181-
$row2[] = new tabobject('deleteresp', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/report.php?'.$argstr2),
182-
get_string('deleteresp', 'questionnaire'));
232+
$argstr2 = $argstr . '&action=dresp&rid=' . $rid . '&individualresponse=1';
233+
$row2[] = new tabobject(
234+
'deleteresp',
235+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/report.php?' . $argstr2),
236+
get_string('deleteresp', 'questionnaire')
237+
);
183238
}
184-
185239
}
186240
} else if ($questionnaire->can_view_all_responses_with_restrictions($usernumresp, $grouplogic, $resplogic)) {
187-
$argstr = 'instance='.$questionnaire->id.'&sid='.$questionnaire->sid;
188-
$row[] = new tabobject('allreport', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/report.php?'.
189-
$argstr.'&action=vall&group='.$currentgroupid), get_string('viewallresponses', 'questionnaire'));
241+
$argstr = 'instance=' . $questionnaire->id . '&sid=' . $questionnaire->sid;
242+
$row[] = new tabobject(
243+
'allreport',
244+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/report.php?' . $argstr . '&action=vall&group=' . $currentgroupid),
245+
get_string('viewallresponses', 'questionnaire')
246+
);
190247
if (in_array($currenttab, array('valldefault', 'vallasort', 'vallarsort', 'deleteall', 'downloadcsv'))) {
191248
$inactive[] = 'vall';
192249
$activated[] = 'vall';
193250
$row2 = array();
194-
$argstr2 = $argstr.'&action=vall&group='.$currentgroupid;
195-
$row2[] = new tabobject('valldefault', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/report.php?'.$argstr2),
196-
get_string('summary', 'questionnaire'));
251+
$argstr2 = $argstr . '&action=vall&group=' . $currentgroupid;
252+
$row2[] = new tabobject(
253+
'valldefault',
254+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/report.php?' . $argstr2),
255+
get_string('summary', 'questionnaire')
256+
);
197257
$inactive[] = $currenttab;
198258
$activated[] = $currenttab;
199259
$row3 = array();
200-
$argstr2 = $argstr.'&action=vall&group='.$currentgroupid;
201-
$row3[] = new tabobject('valldefault', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/report.php?'.$argstr2),
202-
get_string('order_default', 'questionnaire'));
203-
$argstr2 = $argstr.'&action=vallasort&group='.$currentgroupid;
204-
$row3[] = new tabobject('vallasort', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/report.php?'.$argstr2),
205-
get_string('order_ascending', 'questionnaire'));
206-
$argstr2 = $argstr.'&action=vallarsort&group='.$currentgroupid;
207-
$row3[] = new tabobject('vallarsort', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/report.php?'.$argstr2),
208-
get_string('order_descending', 'questionnaire'));
260+
$argstr2 = $argstr . '&action=vall&group=' . $currentgroupid;
261+
$row3[] = new tabobject(
262+
'valldefault',
263+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/report.php?' . $argstr2),
264+
get_string('order_default', 'questionnaire')
265+
;
266+
$argstr2 = $argstr . '&action=vallasort&group=' . $currentgroupid;
267+
$row3[] = new tabobject(
268+
'vallasort',
269+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/report.php?' . $argstr2),
270+
get_string('order_ascending', 'questionnaire')
271+
);
272+
$argstr2 = $argstr . '&action=vallarsort&group=' . $currentgroupid;
273+
$row3[] = new tabobject(
274+
'vallarsort',
275+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/report.php?' . $argstr2),
276+
get_string('order_descending', 'questionnaire')
277+
);
209278
if ($questionnaire->capabilities->deleteresponses) {
210-
$argstr2 = $argstr.'&action=delallresp';
211-
$row2[] = new tabobject('deleteall', $CFG->wwwroot.htmlspecialchars('/mod/questionnaire/report.php?'.$argstr2),
212-
get_string('deleteallresponses', 'questionnaire'));
279+
$argstr2 = $argstr . '&action=delallresp';
280+
$row2[] = new tabobject(
281+
'deleteall',
282+
$CFG->wwwroot . htmlspecialchars('/mod/questionnaire/report.php?' . $argstr2),
283+
get_string('deleteallresponses', 'questionnaire')
284+
);
213285
}
214286

215287
if ($questionnaire->capabilities->downloadresponses) {
216-
$argstr2 = $argstr.'&action=dwnpg';
217-
$link = htmlspecialchars('/mod/questionnaire/report.php?'.$argstr2);
288+
$argstr2 = $argstr . '&action=dwnpg';
289+
$link = htmlspecialchars('/mod/questionnaire/report.php?' . $argstr2);
218290
$row2[] = new tabobject('downloadcsv', $link, get_string('downloadtextformat', 'questionnaire'));
219291
}
220292
if (count($row2) <= 1) {
@@ -224,10 +296,12 @@
224296
}
225297

226298
if ($questionnaire->capabilities->viewsingleresponse && ($canviewallgroups || $canviewgroups)) {
227-
$nonrespondenturl = new moodle_url('/mod/questionnaire/show_nonrespondents.php', array('id' => $questionnaire->cm->id));
228-
$row[] = new tabobject('nonrespondents',
229-
$nonrespondenturl->out(),
230-
get_string('show_nonrespondents', 'questionnaire'));
299+
$nonrespondenturl = new moodle_url('/mod/questionnaire/show_nonrespondents.php', ['id' => $questionnaire->cm->id]);
300+
$row[] = new tabobject(
301+
'nonrespondents',
302+
$nonrespondenturl->out(),
303+
get_string('show_nonrespondents', 'questionnaire')
304+
);
231305
}
232306

233307
if ((count($row) > 1) || (!empty($row2) && (count($row2) > 1))) {

0 commit comments

Comments
 (0)