ILIAS  release_8 Revision v8.24
class.AbstractUIModifier.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
22
26
30abstract class AbstractUIModifier implements UIModifier
31{
32 protected ?InternalService $service = null;
33
34 public function __construct()
35 {
36 }
37
38 public function setInternalService(InternalService $internal_service): void
39 {
40 $this->service = $internal_service;
41 }
42
44 {
45 return $this->service;
46 }
47
48 public function getSurveySettingsGeneral(
49 \ilObjSurvey $survey
50 ): array {
51 return [];
52 }
53
55 \ilObjSurvey $survey,
56 InternalGUIService $ui_service
57 ): array {
58 return [];
59 }
60
61 public function getSurveySettingsResults(
62 \ilObjSurvey $survey,
63 InternalGUIService $ui_service
64 ): array {
65 return [];
66 }
67
68 public function setValuesFromForm(
69 \ilObjSurvey $survey,
71 ): void {
72 }
73
74 public function setResultsOverviewToolbar(
75 \ilObjSurvey $survey,
76 \ilToolbarGUI $toolbar,
77 int $user_id
78 ): void {
79 $config = $this->getInternalService()->domain()->modeFeatureConfig($survey->getMode());
80 if ($config->usesAppraisees()) {
81 $this->addApprSelectionToToolbar(
82 $survey,
83 $toolbar,
84 $user_id
85 );
86 }
87
88 $this->addExportAndPrintButton(
89 $survey,
90 $toolbar,
91 false
92 );
93 }
94
96 \ilObjSurvey $survey,
97 \ilToolbarGUI $toolbar,
98 int $user_id
99 ): void {
100 $this->addApprSelectionToToolbar(
101 $survey,
102 $toolbar,
103 $user_id
104 );
105 }
106
107
108 public function setResultsDetailToolbar(
109 \ilObjSurvey $survey,
110 \ilToolbarGUI $toolbar,
111 int $user_id
112 ): void {
113 $request = $this->service
114 ->gui()
115 ->evaluation($survey)
116 ->request();
117
118 $gui = $this->service->gui();
119 $lng = $gui->lng();
120
121 $config = $this->getInternalService()->domain()->modeFeatureConfig($survey->getMode());
122 if ($config->usesAppraisees()) {
123 $this->addApprSelectionToToolbar(
124 $survey,
125 $toolbar,
126 $user_id
127 );
128 }
129
130 $captions = new \ilSelectInputGUI($lng->txt("svy_eval_captions"), "cp");
131 $captions->setOptions(array(
132 "ap" => $lng->txt("svy_eval_captions_abs_perc"),
133 "a" => $lng->txt("svy_eval_captions_abs"),
134 "p" => $lng->txt("svy_eval_captions_perc")
135 ));
136 $captions->setValue($request->getCP());
137 $toolbar->addInputItem($captions, true);
138
139 $view = new \ilSelectInputGUI($lng->txt("svy_eval_view"), "vw");
140 $view->setOptions(array(
141 "tc" => $lng->txt("svy_eval_view_tables_charts"),
142 "t" => $lng->txt("svy_eval_view_tables"),
143 "c" => $lng->txt("svy_eval_view_charts")
144 ));
145 $view->setValue($request->getVW());
146 $toolbar->addInputItem($view, true);
147
149 $button->setCaption("ok");
150 $button->setCommand("evaluationdetails");
151 $button->setOmitPreventDoubleSubmission(true);
152 $toolbar->addButtonInstance($button);
153
154 $toolbar->addSeparator();
155
156 $this->addExportAndPrintButton(
157 $survey,
158 $toolbar,
159 true
160 );
161 }
162
163 protected function addExportAndPrintButton(
164 \ilObjSurvey $survey,
165 \ilToolbarGUI $toolbar,
166 bool $details
167 ): void {
168 $modal_id = "svy_ev_exp";
169 $modal = $this->buildExportModal($modal_id, $details
170 ? 'exportDetailData'
171 : 'exportData');
172
173 $button = \ilLinkButton::getInstance();
174 $button->setCaption("export");
175 $button->setOnClick('$(\'#' . $modal_id . '\').modal(\'show\')');
176 $toolbar->addButtonInstance($button);
177
178 $toolbar->addSeparator();
179
180 if ($details) {
181 $pv = $this->service->gui()->print()->resultsDetails($survey->getRefId());
182 $this->service->gui()->ctrl()->setParameterByClass(
183 "ilSurveyEvaluationGUI",
184 "vw",
185 $this->service->gui()->evaluation($survey)->request()->getVW()
186 );
187 $this->service->gui()->ctrl()->setParameterByClass(
188 "ilSurveyEvaluationGUI",
189 "cp",
190 $this->service->gui()->evaluation($survey)->request()->getCP()
191 );
192 $modal_elements = $pv->getModalElements(
193 $this->service->gui()->ctrl()->getLinkTargetByClass(
194 "ilSurveyEvaluationGUI",
195 "printResultsDetailsSelection"
196 )
197 );
198 } else {
199 $pv = $this->service->gui()->print()->resultsOverview($survey->getRefId());
200 $modal_elements = $pv->getModalElements(
201 $this->service->gui()->ctrl()->getLinkTargetByClass(
202 "ilSurveyEvaluationGUI",
203 "printResultsOverviewSelection"
204 )
205 );
206 }
207
208 $toolbar->addComponent($modal_elements->button);
209 $toolbar->addComponent($modal_elements->modal);
210
211 /*
212 $button = \ilLinkButton::getInstance();
213 $button->setCaption("print");
214 $button->setOnClick("if(il.Accordion) { il.Accordion.preparePrint(); } window.print(); return false;");
215 $button->setOmitPreventDoubleSubmission(true);
216 $toolbar->addButtonInstance($button);*/
217
218 $toolbar->addText($modal);
219 }
220
221 protected function buildExportModal(
222 string $a_id,
223 string $a_cmd
224 ): string {
225 $tpl = $this->service->gui()->mainTemplate();
226 $lng = $this->service->gui()->lng();
227 $ctrl = $this->service->gui()->ctrl();
228
229 $form_id = "svymdfrm";
230
231 // hide modal on form submit
232 $tpl->addOnLoadCode('$("#form_' . $form_id . '").submit(function() { $("#' . $a_id . '").modal("hide"); });');
233
234 $modal = \ilModalGUI::getInstance();
235 $modal->setId($a_id);
236 $modal->setHeading(($lng->txt("svy_export_format")));
237
238 $form = new \ilPropertyFormGUI();
239 $form->setId($form_id);
240 $form->setFormAction($ctrl->getFormActionByClass("ilsurveyevaluationgui", $a_cmd));
241
242 $format = new \ilSelectInputGUI($lng->txt("filetype"), "export_format");
243 $format->setOptions(array(
244 \ilSurveyEvaluationGUI::TYPE_XLS => $lng->txt('exp_type_excel'),
245 \ilSurveyEvaluationGUI::TYPE_SPSS => $lng->txt('exp_type_csv')
246 ));
247 $form->addItem($format);
248
249 $label = new \ilSelectInputGUI($lng->txt("title"), "export_label");
250 $label->setOptions(array(
251 'label_only' => $lng->txt('export_label_only'),
252 'title_only' => $lng->txt('export_title_only'),
253 'title_label' => $lng->txt('export_title_label')
254 ));
255 $form->addItem($label);
256
257 $form->addCommandButton($a_cmd, $lng->txt("export"));
258 $form->setPreventDoubleSubmission(false);
259
260 $modal->setBody($form->getHTML());
261
262 return $modal->getHTML();
263 }
264
266 \ilObjSurvey $survey,
267 \ilToolbarGUI $toolbar,
268 int $user_id
269 ): void {
270 $lng = $this->service->gui()->lng();
271 $ctrl = $this->service->gui()->ctrl();
272 $req = $this->service->gui()->evaluation($survey)->request();
273
274 $evaluation_manager = $this->service->domain()->evaluation(
275 $survey,
276 $user_id,
277 $req->getAppraiseeId(),
278 $req->getRaterId()
279 );
280
281 if ($evaluation_manager->isMultiParticipantsView()) {
282 $appr_id = $evaluation_manager->getCurrentAppraisee();
283 $options = array();
284 if (!$appr_id) {
285 $options[""] = $lng->txt("please_select");
286 }
287
288 foreach ($evaluation_manager->getSelectableAppraisees() as $appraisee_usr_id) {
289 $options[$appraisee_usr_id] = \ilUserUtil::getNamePresentation(
290 $appraisee_usr_id,
291 false,
292 false,
293 "",
294 true
295 );
296 }
297
298 $appr = new \ilSelectInputGUI($lng->txt("survey_360_appraisee"), "appr_id");
299 $appr->setOptions($options);
300 $appr->setValue($appr_id);
301 $toolbar->addInputItem($appr, true);
302
304 $button->setCaption("survey_360_select_appraisee");
305 $button->setCommand($ctrl->getCmd());
306 $toolbar->addButtonInstance($button);
307
308 if ($appr_id) {
309 $toolbar->addSeparator();
310 }
311 }
312 }
313
314
315 public function getDetailPanels(
316 array $participants,
317 \ILIAS\Survey\Evaluation\EvaluationGUIRequest $request,
319 ): array {
320 $a_results = $a_eval->getResults();
321 $panels = [];
322 $ui_factory = $this->service->gui()->ui()->factory();
323
324 $a_tpl = new \ilTemplate("tpl.svy_results_details_panel.html", true, true, "Modules/Survey/Evaluation");
325
326 $question_res = $a_results;
327 $matrix = false;
328 if (is_array($question_res)) {
329 $question_res = $question_res[0][1];
330 $matrix = true;
331 }
332
333 // see #28507 (matrix question without a row)
334 if (!is_object($question_res)) {
335 return [];
336 }
337
338 $question = $question_res->getQuestion();
339
340 // question "overview"
341 $qst_title = $question->getTitle();
342 $svy_text = nl2br($question->getQuestiontext());
343
344 // Question title anchor
345 $anchor_id = "svyrdq" . $question->getId();
346 $title = "<span id='$anchor_id'>$qst_title</span>";
347 $panel_qst_card = $ui_factory->panel()->sub($title, $ui_factory->legacy($svy_text))
348 ->withFurtherInformation($this->getPanelCard($question_res));
349
350 $panels[] = $panel_qst_card;
351
352 $a_tpl->setVariable("TABLE", $this->getPanelTable(
353 $participants,
354 $request,
355 $a_eval
356 ));
357
358 $a_tpl->setVariable("TEXT", $this->getPanelText(
359 $request,
360 $a_eval,
361 $question_res
362 ));
363
364 $a_tpl->setVariable("CHART", $this->getPanelChart(
365 $request,
366 $a_eval
367 ));
368
369
370 $panels[] = $ui_factory->panel()->sub("", $ui_factory->legacy($a_tpl->get()));
371 return $panels;
372 }
373
374 protected function getPanelTable(
375 array $participants,
376 \ILIAS\Survey\Evaluation\EvaluationGUIRequest $request,
378 ): string {
379 $a_results = $a_eval->getResults();
380
381 $a_tpl = new \ilTemplate("tpl.svy_results_details_table.html", true, true, "Modules/Survey/Evaluation");
382
383 // grid
384 if ($request->getShowTable()) {
385 $grid = $a_eval->getGrid(
386 $a_results,
387 $request->getShowAbsolute(),
388 $request->getShowPercentage()
389 );
390 if ($grid) {
391 foreach ($grid["cols"] as $col) {
392 $a_tpl->setCurrentBlock("grid_col_header_bl");
393 $a_tpl->setVariable("COL_HEADER", $col);
394 $a_tpl->parseCurrentBlock();
395 }
396 foreach ($grid["rows"] as $cols) {
397 foreach ($cols as $idx => $col) {
398 if ($idx > 0) {
399 $a_tpl->touchBlock("grid_col_nowrap_bl");
400 }
401
402 $a_tpl->setCurrentBlock("grid_col_bl");
403 $a_tpl->setVariable("COL_CAPTION", trim((string) $col));
404 $a_tpl->parseCurrentBlock();
405 }
406
407 $a_tpl->touchBlock("grid_row_bl");
408 }
409 }
410 }
411 return $a_tpl->get();
412 }
413
414 protected function getPanelChart(
415 \ILIAS\Survey\Evaluation\EvaluationGUIRequest $request,
417 ): string {
418 $a_results = $a_eval->getResults();
419
420 $a_tpl = new \ilTemplate("tpl.svy_results_details_chart.html", true, true, "Modules/Survey/Evaluation");
421 // chart
422 if ($request->getShowChart()) {
423 $chart = $a_eval->getChart($a_results);
424 if ($chart) {
425 if (is_array($chart)) {
426 // legend
427 if (is_array($chart[1])) {
428 foreach ($chart[1] as $legend_item) {
429 $r = hexdec(substr($legend_item[1], 1, 2));
430 $g = hexdec(substr($legend_item[1], 3, 2));
431 $b = hexdec(substr($legend_item[1], 5, 2));
432
433 $a_tpl->setCurrentBlock("legend_bl");
434 $a_tpl->setVariable("LEGEND_CAPTION", $legend_item[0]);
435 $a_tpl->setVariable("LEGEND_COLOR", $legend_item[1]);
436 $a_tpl->setVariable("LEGEND_COLOR_SVG", $r . "," . $g . "," . $b);
437 $a_tpl->parseCurrentBlock();
438 }
439 }
440
441 $chart = $chart[0];
442 }
443
444 $a_tpl->setVariable("CHART", $chart);
445 }
446 }
447
448 return $a_tpl->get();
449 }
450
451 protected function getPanelText(
452 \ILIAS\Survey\Evaluation\EvaluationGUIRequest $request,
454 \ilSurveyEvaluationResults $question_res
455 ): string {
456 $a_results = $a_eval->getResults();
457 $question = $question_res->getQuestion();
458 $lng = $this->service->gui()->lng();
459
460 $a_tpl = new \ilTemplate("tpl.svy_results_details_text.html", true, true, "Modules/Survey/Evaluation");
461
462 // text answers
463 $texts = $a_eval->getTextAnswers($a_results);
464 if ($texts) {
465 if (array_key_exists("", $texts)) {
466 $a_tpl->setVariable("TEXT_HEADING", $lng->txt("given_answers"));
467 foreach ($texts[""] as $item) {
468 $a_tpl->setCurrentBlock("text_direct_item_bl");
469 $a_tpl->setVariable("TEXT_DIRECT", nl2br(htmlentities($item)));
470 $a_tpl->parseCurrentBlock();
471 }
472 } else {
473 $acc = new \ilAccordionGUI();
474 $acc->setId("svyevaltxt" . $question->getId());
475
476 $a_tpl->setVariable("TEXT_HEADING", $lng->txt("freetext_answers"));
477
478 foreach ($texts as $var => $items) {
479 $list = array("<ul class=\"small\">");
480 foreach ($items as $item) {
481 $list[] = "<li>" . nl2br(htmlentities($item)) . "</li>";
482 }
483 $list[] = "</ul>";
484 $acc->addItem((string) $var, implode("\n", $list));
485 }
486
487 $a_tpl->setVariable("TEXT_ACC", $acc->getHTML());
488 }
489 }
490 return $a_tpl->get();
491 }
492
493 // in fact we want a \ILIAS\UI\Component\Card\Standard
494 // see #31743
495 protected function getPanelCard(
496 \ilSurveyEvaluationResults $question_res
497 ): \ILIAS\UI\Component\Card\Card {
498 $ui_factory = $this->service->gui()->ui()->factory();
499 $lng = $this->service->gui()->lng();
500
501 $question = $question_res->getQuestion();
502 $kv = array();
503 $kv["users_answered"] = $question_res->getUsersAnswered();
504 $kv["users_skipped"] = $question_res->getUsersSkipped();
505
506 $card_table_tpl = new \ilTemplate(
507 "tpl.svy_results_details_card.html",
508 true,
509 true,
510 "Modules/Survey/Evaluation"
511 );
512
513 if (true) { // formerly check for matrix type, shouldnt be needed
514 if ($question_res->getModeValue() !== null) {
515 $kv["mode"] = wordwrap($question_res->getModeValueAsText(), 50, "<br />");
516 $kv["mode_nr_of_selections"] = $question_res->getModeNrOfSelections();
517 }
518 if ($question_res->getMedian() !== null) {
519 $kv["median"] = $question_res->getMedianAsText();
520 }
521 if ($question_res->getMean() !== null) {
522 $kv["arithmetic_mean"] = $question_res->getMean();
523 }
524 }
525
526 foreach ($kv as $key => $value) {
527 $card_table_tpl->setCurrentBlock("question_statistics_card");
528 $card_table_tpl->setVariable("QUESTION_STATISTIC_KEY", $lng->txt($key));
529 $card_table_tpl->setVariable("QUESTION_STATISTIC_VALUE", $value);
530 $card_table_tpl->parseCurrentBlock();
531 }
532
533 $svy_type_title = \SurveyQuestion::_getQuestionTypeName($question->getQuestionType());
534
535 return $ui_factory->card()
536 ->standard($svy_type_title)
537 ->withSections(
538 array($ui_factory->legacy($card_table_tpl->get()))
539 );
540 }
541}
static return function(ContainerConfigurator $containerConfigurator)
Definition: basic_rector.php:9
setInternalService(InternalService $internal_service)
setResultsDetailToolbar(\ilObjSurvey $survey, \ilToolbarGUI $toolbar, int $user_id)
getPanelChart(\ILIAS\Survey\Evaluation\EvaluationGUIRequest $request, \SurveyQuestionEvaluation $a_eval)
buildExportModal(string $a_id, string $a_cmd)
addApprSelectionToToolbar(\ilObjSurvey $survey, \ilToolbarGUI $toolbar, int $user_id)
setValuesFromForm(\ilObjSurvey $survey, \ilPropertyFormGUI $form)
getPanelTable(array $participants, \ILIAS\Survey\Evaluation\EvaluationGUIRequest $request, \SurveyQuestionEvaluation $a_eval)
getSurveySettingsResults(\ilObjSurvey $survey, InternalGUIService $ui_service)
setResultsCompetenceToolbar(\ilObjSurvey $survey, \ilToolbarGUI $toolbar, int $user_id)
getPanelCard(\ilSurveyEvaluationResults $question_res)
addExportAndPrintButton(\ilObjSurvey $survey, \ilToolbarGUI $toolbar, bool $details)
getPanelText(\ILIAS\Survey\Evaluation\EvaluationGUIRequest $request, \SurveyQuestionEvaluation $a_eval, \ilSurveyEvaluationResults $question_res)
getSurveySettingsReminderTargets(\ilObjSurvey $survey, InternalGUIService $ui_service)
getDetailPanels(array $participants, \ILIAS\Survey\Evaluation\EvaluationGUIRequest $request, \SurveyQuestionEvaluation $a_eval)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getGrid( $a_results, bool $a_abs=true, bool $a_perc=true)
Get grid data.
getTextAnswers($a_results)
Get text answers.
static _getQuestionTypeName(string $type_tag)
Return the translation for a given question type.
setFormAction(string $a_formaction)
setPreventDoubleSubmission(bool $a_val)
setId(string $a_id)
static getInstance()
This class represents a property form user interface.
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addButtonInstance(ilButtonBase $a_button)
Add button instance.
addInputItem(ilToolbarItem $a_item, bool $a_output_label=false)
addComponent(\ILIAS\UI\Component\Component $a_comp)
addText(string $a_text)
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link="", bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$format
Definition: metadata.php:235
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
string $key
Consumer key/client ID value.
Definition: System.php:193
array $details
Details for error message relating to last request processed.
Definition: System.php:109
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.
catch(\Exception $e) $req
Definition: xapiproxy.php:93
$lng
$cols
Definition: xhr_table.php:11