ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.UIModifier.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 
25 
31 {
32  public function getSurveySettingsGeneral(
33  \ilObjSurvey $survey
34  ): array {
35  $items = [];
36 
37  return $items;
38  }
39 
40  public function getSurveySettingsResults(
41  \ilObjSurvey $survey,
42  InternalGUIService $ui_service
43  ): array {
44  $items = [];
45  $lng = $ui_service->lng();
46 
47  $ts_results = new \ilRadioGroupInputGUI($lng->txt("survey_360_results"), "ts_res");
48  $ts_results->setValue((string) $survey->get360Results());
49 
50  $option = new \ilRadioOption($lng->txt("survey_360_results_none"), (string) \ilObjSurvey::RESULTS_360_NONE);
51  $option->setInfo($lng->txt("survey_360_results_none_info"));
52  $ts_results->addOption($option);
53 
54  $option = new \ilRadioOption(
55  $lng->txt("survey_360_results_own"),
57  );
58  $option->setInfo($lng->txt("survey_360_results_own_info"));
59  $ts_results->addOption($option);
60 
61  $items[] = $ts_results;
62 
63  return $items;
64  }
65 
67  \ilObjSurvey $survey,
68  InternalGUIService $ui_service
69  ): array {
70  $items = [];
71  $lng = $ui_service->lng();
72 
73  // remind appraisees
74  $cb = new \ilCheckboxInputGUI($lng->txt("survey_notification_target_group"), "remind_appraisees");
75  $cb->setOptionTitle($lng->txt("survey_360_appraisees"));
76  $cb->setInfo($lng->txt("survey_360_appraisees_remind_info"));
77  $cb->setValue("1");
78  $cb->setChecked(in_array(
79  $survey->getReminderTarget(),
81  true
82  ));
83  $items[] = $cb;
84 
85  // remind raters
86  $cb = new \ilCheckboxInputGUI("", "remind_raters");
87  $cb->setOptionTitle($lng->txt("survey_360_raters"));
88  $cb->setInfo($lng->txt("survey_360_raters_remind_info"));
89  $cb->setValue("1");
90  $cb->setChecked(in_array(
91  $survey->getReminderTarget(),
93  true
94  ));
95  $items[] = $cb;
96 
97  return $items;
98  }
99 
100  public function setValuesFromForm(
101  \ilObjSurvey $survey,
102  \ilPropertyFormGUI $form
103  ): void {
104  if ($form->getInput("remind_appraisees") && $form->getInput("remind_raters")) {
106  } elseif ($form->getInput("remind_appraisees")) {
108  } elseif ($form->getInput("remind_raters")) {
110  } else {
111  $survey->setReminderTarget(0);
112  }
113 
114  $survey->set360Results((int) $form->getInput("ts_res"));
115  }
116 
117 
118  public function setResultsDetailToolbar(
119  \ilObjSurvey $survey,
120  \ilToolbarGUI $toolbar,
121  int $user_id
122  ): void {
124  $survey,
125  $toolbar,
126  $user_id
127  );
128 
130  $survey,
131  $toolbar,
132  true
133  );
134  }
135 
137  \ilObjSurvey $survey,
138  \ilToolbarGUI $toolbar,
139  int $user_id
140  ): void {
142  $survey,
143  $toolbar,
144  $user_id
145  );
146 
148  $survey,
149  $toolbar,
150  $user_id
151  );
152  }
153 
157  public function addRaterSelectionToToolbar(
158  \ilObjSurvey $survey,
159  \ilToolbarGUI $toolbar,
160  int $user_id
161  ): void {
162  $lng = $this->service->gui()->lng();
163  $ctrl = $this->service->gui()->ctrl();
164  $req = $this->service->gui()->evaluation($survey)->request();
165 
166  $evaluation_manager = $this->service->domain()->evaluation(
167  $survey,
168  $user_id,
169  $req->getAppraiseeId(),
170  $req->getRaterId()
171  );
172 
173 
174  if (!$evaluation_manager->isMultiParticipantsView()) {
175  $raters = $evaluation_manager->getSelectableRaters();
176 
177  if (count($raters) > 0) {
178  $options = [];
179  $options["-"] = $lng->txt("svy_all_raters");
180  foreach ($raters as $rater) {
181  $options[$rater["user_id"]] = $rater["name"];
182  }
183 
184  $rat = new \ilSelectInputGUI($lng->txt("svy_rater"), "rater_id");
185  $rat->setOptions($options);
186  $rat->setValue($evaluation_manager->getCurrentRater());
187  $toolbar->addInputItem($rat, true);
188 
189  $this->gui->button(
190  $this->gui->lng()->txt("svy_select_rater"),
191  $ctrl->getCmd()
192  )->submit()->toToolbar(false, $toolbar);
193 
194 
195  $toolbar->addSeparator();
196  }
197  }
198  }
199 
200 
201  protected function getPanelChart(
202  \ILIAS\Survey\Evaluation\EvaluationGUIRequest $request,
203  \SurveyQuestionEvaluation $a_eval
204  ): string {
205  return "";
206  }
207 
208  protected function getPanelText(
209  \ILIAS\Survey\Evaluation\EvaluationGUIRequest $request,
210  \SurveyQuestionEvaluation $a_eval,
211  \ilSurveyEvaluationResults $question_res
212  ): string {
213  return "";
214  }
215 
216  protected function getPanelTable(
217  array $participants,
218  \ILIAS\Survey\Evaluation\EvaluationGUIRequest $request,
219  \SurveyQuestionEvaluation $a_eval
220  ): string {
221  $a_results = $a_eval->getResults();
222  $lng = $this->service->gui()->lng();
223  $matrix = false;
224  if (is_array($a_results)) {
225  $answers = $a_results[0][1]->getAnswers();
226  $q = $a_results[0][1]->getQuestion();
227  $matrix = true;
228  } else {
229  $answers = $a_results->getAnswers();
230  $q = $a_results->getQuestion();
231  }
232  // SurveySingleChoiceQuestion
233  if (!in_array($q->getQuestionType(), [
234  "SurveySingleChoiceQuestion",
235  "SurveyMultipleChoiceQuestion",
236  "SurveyMetricQuestion",
237  "SurveyTextQuestion"
238  ], true)) {
239  //var_dump($q->getQuestionType());
240  //var_dump($answers);
241  //exit;
242  }
243 
244 
246 
247  $a_tpl = new \ilTemplate("tpl.svy_results_details_table.html", true, true, "Modules/Survey/Evaluation");
248 
249  // table
250  $ret = "";
251  if ($request->getShowTable()) {
252  if (!$matrix) {
253  // rater
254  $a_tpl->setCurrentBlock("grid_col_header_bl");
255  $a_tpl->setVariable("COL_HEADER", $lng->txt("svy_rater"));
256  $a_tpl->parseCurrentBlock();
257 
258  // date
259  $a_tpl->setCurrentBlock("grid_col_header_bl");
260  $a_tpl->setVariable("COL_HEADER", $lng->txt("date"));
261  $a_tpl->parseCurrentBlock();
262 
263  // answer
264  $a_tpl->setCurrentBlock("grid_col_header_bl");
265  $a_tpl->setVariable("COL_HEADER", $lng->txt("answers"));
266  $a_tpl->parseCurrentBlock();
267 
268  $condensed_answers = [];
269  foreach ($answers as $answer) {
270  $condensed_answers[$answer->active_id]["tstamp"] = $answer->tstamp;
271  $condensed_answers[$answer->active_id]["active_id"] = $answer->active_id;
272  // this moves the original multiple answers items of muliple choice question into one array
273  $condensed_answers[$answer->active_id]["value"][] = $answer->value;
274  $condensed_answers[$answer->active_id]["text"] = $answer->text;
275  }
276 
278  foreach ($condensed_answers as $answer) {
279  // rater
280  $a_tpl->setCurrentBlock("grid_col_bl");
281  $a_tpl->setVariable("COL_CAPTION", " ");
282  $a_tpl->parseCurrentBlock();
283 
284  // rater
285  $participant = $this->getParticipantByActiveId($participants, $answer["active_id"]);
286  $part_caption = "";
287  if ($participant) {
288  $part_caption = $this->getCaptionForParticipant($participant);
289  }
290  $a_tpl->setCurrentBlock("grid_col_bl");
291  $a_tpl->setVariable("COL_CAPTION", $part_caption);
292  $a_tpl->parseCurrentBlock();
293 
294  // date
295  $a_tpl->setCurrentBlock("grid_col_bl");
296  $date = new \ilDate($answer["tstamp"], IL_CAL_UNIX);
297  $a_tpl->setVariable(
298  "COL_CAPTION",
300  );
301  $a_tpl->parseCurrentBlock();
302 
303  // answer
304  $a_tpl->setCurrentBlock("grid_col_bl");
305  if ($q->getQuestionType() === "SurveyTextQuestion") {
306  $a_tpl->setVariable(
307  "COL_CAPTION",
308  $a_results->getScaleText($answer["text"])
309  );
310  } else {
311  $scale_texts = array_map(static function ($v) use ($a_results): string {
312  return $a_results->getScaleText($v);
313  }, $answer["value"]);
314  $a_tpl->setVariable(
315  "COL_CAPTION",
316  implode(", ", $scale_texts)
317  );
318  }
319  $a_tpl->parseCurrentBlock();
320 
321  $a_tpl->touchBlock("grid_row_bl");
322  }
323  $ret = $a_tpl->get();
324  } else {
326  foreach ($answers as $answer) {
329  $cats = $q->getColumns();
330  foreach ($cats->getCategories() as $cat) {
331  $a_tpl->touchBlock("grid_col_head_center");
332  $a_tpl->setCurrentBlock("grid_col_header_bl");
333  $a_tpl->setVariable("COL_HEADER", $cat->title);
334  $a_tpl->parseCurrentBlock();
335  }
336 
337  $cats_rows = $q->getRows();
338 
339  reset($a_results);
340  foreach ($cats_rows->getCategories() as $cat) {
341  $a_tpl->setCurrentBlock("grid_col_bl");
342  $a_tpl->setVariable("COL_CAPTION", $cat->title);
343  $a_tpl->parseCurrentBlock();
344 
345  $r = current($a_results);
346  $row_answers = $r[1]->getAnswers();
347  $user_answers = null;
348  foreach ($row_answers as $ra) {
349  if ($ra->active_id == $answer->active_id) {
350  $user_answers = $ra;
351  }
352  }
353 
354  foreach ($cats->getCategories() as $catr) {
355  if ($user_answers && $user_answers->value == $catr->scale) {
356  $a_tpl->touchBlock("grid_col_center");
357  $a_tpl->setCurrentBlock("grid_col_bl");
358  $a_tpl->setVariable("COL_CAPTION", "X");
359  } else {
360  $a_tpl->setCurrentBlock("grid_col_bl");
361  $a_tpl->setVariable("COL_CAPTION", " ");
362  }
363 
364  $a_tpl->parseCurrentBlock();
365  }
366 
367  $a_tpl->touchBlock("grid_row_bl");
368  next($a_results);
369  }
370 
371  // rater
372  $participant = $this->getParticipantByActiveId($participants, $answer->active_id);
373  $part_caption = "";
374  if ($participant) {
375  $part_caption = $participant["sortname"];
376  }
377  $date = new \ilDate($answer->tstamp, IL_CAL_UNIX);
378  $part_caption .= ", " . \ilDatePresentation::formatDate($date);
379 
380  $a_tpl->setVariable("HEADER", $part_caption);
381  $ret .= $a_tpl->get();
382  $a_tpl = new \ilTemplate("tpl.svy_results_details_table.html", true, true, "Modules/Survey/Evaluation");
383  }
384  }
385  }
386  return $ret;
387  }
388 
389  protected function getParticipantByActiveId(array $participants, int $active_id): ?array
390  {
391  foreach ($participants as $part) {
392  if ((int) $part["active_id"] === $active_id) {
393  return $part;
394  }
395  }
396  return null;
397  }
398 
399  protected function getCaptionForParticipant(array $part_array): string
400  {
401  return $part_array["sortname"];
402  }
403 }
getSurveySettingsResults(\ilObjSurvey $survey, InternalGUIService $ui_service)
getSurveySettingsReminderTargets(\ilObjSurvey $survey, InternalGUIService $ui_service)
setValuesFromForm(\ilObjSurvey $survey, \ilPropertyFormGUI $form)
getPanelChart(\ILIAS\Survey\Evaluation\EvaluationGUIRequest $request, \SurveyQuestionEvaluation $a_eval)
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addRaterSelectionToToolbar(\ilObjSurvey $survey, \ilToolbarGUI $toolbar, int $user_id)
Add rater selection to toolbar.
getPanelTable(array $participants, \ILIAS\Survey\Evaluation\EvaluationGUIRequest $request, \SurveyQuestionEvaluation $a_eval)
const NOTIFICATION_APPRAISEES
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
getParticipantByActiveId(array $participants, int $active_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
set360Results(int $a_value)
const IL_CAL_UNIX
getPanelText(\ILIAS\Survey\Evaluation\EvaluationGUIRequest $request, \SurveyQuestionEvaluation $a_eval, \ilSurveyEvaluationResults $question_res)
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
catch(\Exception $e) $req
Definition: xapiproxy.php:93
setReminderTarget(int $a_value)
addApprSelectionToToolbar(\ilObjSurvey $survey, \ilToolbarGUI $toolbar, int $user_id)
$lng
const NOTIFICATION_APPRAISEES_AND_RATERS
addExportAndPrintButton(\ilObjSurvey $survey, \ilToolbarGUI $toolbar, bool $details)
setResultsDetailToolbar(\ilObjSurvey $survey, \ilToolbarGUI $toolbar, int $user_id)
$q
Definition: shib_logout.php:21
setResultsCompetenceToolbar(\ilObjSurvey $survey, \ilToolbarGUI $toolbar, int $user_id)
const NOTIFICATION_RATERS
static setUseRelativeDates(bool $a_status)
set use relative dates
addInputItem(ilToolbarItem $a_item, bool $a_output_label=false)
$r