ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ResultsPerUserPrintViewProviderGUI.php
Go to the documentation of this file.
1<?php
2
20
21use ILIAS\Export;
24
29{
30 protected \ilTree $tree;
31 protected \ILIAS\Survey\InternalGUIService $gui;
32 protected \ILIAS\Survey\Evaluation\EvaluationManager $evaluation_manager;
33 protected \ILIAS\Survey\Evaluation\EvaluationGUIRequest $request;
34 protected \ILIAS\Survey\Access\AccessManager $access_manager;
35 protected \ilObjSurvey $survey;
36 protected int $ref_id;
37 protected \ilLanguage $lng;
38 protected \ilCtrl $ctrl;
39
40 public function __construct(
43 int $ref_id
44 ) {
45 global $DIC;
46
47 $this->lng = $lng;
48 $this->ctrl = $ctrl;
49 $this->ref_id = $ref_id;
50 $this->survey = new \ilObjSurvey($this->ref_id);
51 $this->access_manager = $DIC->survey()
52 ->internal()
53 ->domain()
54 ->access($this->ref_id, $DIC->user()->getId());
55 $this->request = $DIC->survey()
56 ->internal()
57 ->gui()
58 ->evaluation($this->survey)
59 ->request();
60 $this->evaluation_manager = $DIC->survey()
61 ->internal()
62 ->domain()
63 ->evaluation(
64 $this->survey,
65 $DIC->user()->getId(),
66 $this->request->getAppraiseeId(),
67 $this->request->getRaterId()
68 );
69 $this->gui = $DIC->survey()
70 ->internal()
71 ->gui();
72 $this->tree = $DIC->repositoryTree();
73 }
74
75 public function getTemplateInjectors(): array
76 {
77 return [
78 static function (\ilGlobalTemplate $tpl): void {
79 //$tpl add js/css
80 }
81 ];
82 }
83
85 {
87 $ilCtrl = $this->ctrl;
88
89 $form = new \ilPropertyFormGUI();
90
91 $radg = new \ilRadioGroupInputGUI($lng->txt("svy_selection"), "print_selection");
92 $radg->setValue("all");
93 $op1 = new \ilRadioOption($lng->txt("svy_all_participants"), "all");
94 $radg->addOption($op1);
95 $op2 = new \ilRadioOption($lng->txt("svy_selected_participants"), "selected");
96 $radg->addOption($op2);
97
98 $nl = new \ilNestedListInputGUI("", "active_ids");
99 $op2->addSubItem($nl);
100
101 foreach ($this->access_manager->canReadResultOfParticipants() as $participant) {
102 $nl->addListNode(
103 $participant["active_id"],
104 $participant["fullname"],
105 0,
106 false,
107 false
108 );
109 }
110
111 $form->addItem($radg);
112 $form->addCommandButton("printResultsPerUser", $lng->txt("print_view"));
113
114 $form->setTitle($lng->txt("svy_print_selection"));
115 $form->setFormAction($ilCtrl->getFormActionByClass(
116 "ilSurveyEvaluationGUI",
117 "printResultsPerUser"
118 ));
119
120 return $form;
121 }
122
123 public function getPages(): array
124 {
125 $print_pages = [];
126
127 $data = $this->evaluation_manager->getUserSpecificResults();
128
129 $selection = $this->request->getPrintSelection();
130 $active_ids = $this->request->getActiveIds();
131
132 $table_gui = new \ilSurveyResultsUserTableGUI(null, '');
133 $filtered_data = [];
134 foreach ($data as $active_id => $d) {
135 if ($selection === "all" || in_array($active_id, $active_ids)) {
136 $filtered_data[$active_id] = $d;
137 }
138 }
139
140 $table_gui->setData($filtered_data);
141
142 $print_pages[] = $this->getPrintHeader() .
143 $table_gui->getHTML();
144
145 return $print_pages;
146 }
147
148 protected function getPrintHeader(): string
149 {
150 $head = "<h2>" . $this->survey->getTitle() . "</h2>\n";
151 $path = "";
152 $path_full = $this->tree->getPathFull($this->survey->getRefId());
153 foreach ($path_full as $data) {
154 $path .= " &raquo; ";
155 $path .= $data['title'];
156 }
157
159 $props = array(
160 $this->lng->txt("url") => \ilLink::_getStaticLink($this->survey->getRefId()),
161 $this->lng->txt("path") => $path,
162 $this->lng->txt("date") => \ilDatePresentation::formatDate(new \ilDateTime(time(), IL_CAL_UNIX)),
163 );
164
165 $f = $this->gui->ui()->factory();
166 $r = $this->gui->ui()->renderer();
167 $l = $f->listing()->descriptive($props);
168
169 return $head . $r->render($l);
170 }
171
172}
const IL_CAL_UNIX
Class ilCtrl provides processing control methods.
static setUseRelativeDates(bool $a_status)
set use relative dates
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
special template class to simplify handling of ITX/PEAR
language handling
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This class represents a property form user interface.
$path
Definition: ltiservices.php:30
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...
global $DIC
Definition: shib_login.php:26