ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.UIModifier.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
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  \ilTemplate $eval_tpl
123  ): void {
125  $survey,
126  $toolbar,
127  $user_id
128  );
129 
131  $survey,
132  $toolbar,
133  true,
134  $eval_tpl
135  );
136  }
137 
139  \ilObjSurvey $survey,
140  \ilToolbarGUI $toolbar,
141  int $user_id
142  ): void {
144  $survey,
145  $toolbar,
146  $user_id
147  );
148 
150  $survey,
151  $toolbar,
152  $user_id
153  );
154  }
155 
159  public function addRaterSelectionToToolbar(
160  \ilObjSurvey $survey,
161  \ilToolbarGUI $toolbar,
162  int $user_id
163  ): void {
164  $lng = $this->service->gui()->lng();
165  $ctrl = $this->service->gui()->ctrl();
166  $req = $this->service->gui()->evaluation($survey)->request();
167 
168  $evaluation_manager = $this->service->domain()->evaluation(
169  $survey,
170  $user_id,
171  $req->getAppraiseeId(),
172  $req->getRaterId()
173  );
174 
175 
176  if (!$evaluation_manager->isMultiParticipantsView()) {
177  $raters = $evaluation_manager->getSelectableRaters();
178 
179  if (count($raters) > 0) {
180  $options = [];
181  $options["-"] = $lng->txt("svy_all_raters");
182  foreach ($raters as $rater) {
183  $options[$rater["user_id"]] = $rater["name"];
184  }
185 
186  $rat = new \ilSelectInputGUI($lng->txt("svy_rater"), "rater_id");
187  $rat->setOptions($options);
188  $rat->setValue($evaluation_manager->getCurrentRater());
189  $toolbar->addInputItem($rat, true);
190 
191  $this->gui->button(
192  $this->gui->lng()->txt("svy_select_rater"),
193  $ctrl->getCmd()
194  )->submit()->toToolbar(false, $toolbar);
195 
196 
197  $toolbar->addSeparator();
198  }
199  }
200  }
201 
202 
203  protected function getPanelChart(
204  \ILIAS\Survey\Evaluation\EvaluationGUIRequest $request,
205  \SurveyQuestionEvaluation $a_eval
206  ): string {
207  return "";
208  }
209 
210  protected function getPanelText(
211  \ILIAS\Survey\Evaluation\EvaluationGUIRequest $request,
212  \SurveyQuestionEvaluation $a_eval,
213  \ilSurveyEvaluationResults $question_res
214  ): string {
215  return "";
216  }
217 
218  protected function getPanelTable(
219  array $participants,
220  \ILIAS\Survey\Evaluation\EvaluationGUIRequest $request,
221  \SurveyQuestionEvaluation $a_eval
222  ): string {
223  $a_results = $a_eval->getResults();
224  $lng = $this->service->gui()->lng();
225  $matrix = false;
226  if (is_array($a_results)) {
227  $answers = $a_results[0][1]->getAnswers();
228  $q = $a_results[0][1]->getQuestion();
229  $matrix = true;
230  } else {
231  $answers = $a_results->getAnswers();
232  $q = $a_results->getQuestion();
233  }
234  // SurveySingleChoiceQuestion
235  if (!in_array($q->getQuestionType(), [
236  "SurveySingleChoiceQuestion",
237  "SurveyMultipleChoiceQuestion",
238  "SurveyMetricQuestion",
239  "SurveyTextQuestion"
240  ], true)) {
241  //var_dump($q->getQuestionType());
242  //var_dump($answers);
243  //exit;
244  }
245 
246 
248 
249  $a_tpl = new \ilTemplate("tpl.svy_results_details_table.html", true, true, "components/ILIAS/Survey/Evaluation");
250 
251  // table
252  $ret = "";
253  if ($request->getShowTable()) {
254  if (!$matrix) {
255  // rater
256  $a_tpl->setCurrentBlock("grid_col_header_bl");
257  $a_tpl->setVariable("COL_HEADER", $lng->txt("svy_rater"));
258  $a_tpl->parseCurrentBlock();
259 
260  // date
261  $a_tpl->setCurrentBlock("grid_col_header_bl");
262  $a_tpl->setVariable("COL_HEADER", $lng->txt("date"));
263  $a_tpl->parseCurrentBlock();
264 
265  // answer
266  $a_tpl->setCurrentBlock("grid_col_header_bl");
267  $a_tpl->setVariable("COL_HEADER", $lng->txt("answers"));
268  $a_tpl->parseCurrentBlock();
269 
270  $condensed_answers = [];
271  foreach ($answers as $answer) {
272  $condensed_answers[$answer->active_id]["tstamp"] = $answer->tstamp;
273  $condensed_answers[$answer->active_id]["active_id"] = $answer->active_id;
274  // this moves the original multiple answers items of muliple choice question into one array
275  $condensed_answers[$answer->active_id]["value"][] = $answer->value;
276  $condensed_answers[$answer->active_id]["text"] = $answer->text;
277  }
278 
280  foreach ($condensed_answers as $answer) {
281  // rater
282  $a_tpl->setCurrentBlock("grid_col_bl");
283  $a_tpl->setVariable("COL_CAPTION", " ");
284  $a_tpl->parseCurrentBlock();
285 
286  // rater
287  $participant = $this->getParticipantByActiveId($participants, $answer["active_id"]);
288  $part_caption = "";
289  if ($participant) {
290  $part_caption = $this->getCaptionForParticipant($participant);
291  }
292  $a_tpl->setCurrentBlock("grid_col_bl");
293  $a_tpl->setVariable("COL_CAPTION", $part_caption);
294  $a_tpl->parseCurrentBlock();
295 
296  // date
297  $a_tpl->setCurrentBlock("grid_col_bl");
298  $date = new \ilDate($answer["tstamp"], IL_CAL_UNIX);
299  $a_tpl->setVariable(
300  "COL_CAPTION",
302  );
303  $a_tpl->parseCurrentBlock();
304 
305  // answer
306  $a_tpl->setCurrentBlock("grid_col_bl");
307  if ($q->getQuestionType() === "SurveyTextQuestion") {
308  $a_tpl->setVariable(
309  "COL_CAPTION",
310  $a_results->getScaleText($answer["text"])
311  );
312  } else {
313  $scale_texts = array_map(static function ($v) use ($a_results): string {
314  return $a_results->getScaleText($v);
315  }, $answer["value"]);
316  $a_tpl->setVariable(
317  "COL_CAPTION",
318  implode(", ", $scale_texts)
319  );
320  }
321  $a_tpl->parseCurrentBlock();
322 
323  $a_tpl->touchBlock("grid_row_bl");
324  }
325  $ret = $a_tpl->get();
326  } else {
328  foreach ($answers as $answer) {
331  $cats = $q->getColumns();
332  foreach ($cats->getCategories() as $cat) {
333  $a_tpl->touchBlock("grid_col_head_center");
334  $a_tpl->setCurrentBlock("grid_col_header_bl");
335  $a_tpl->setVariable("COL_HEADER", $cat->title);
336  $a_tpl->parseCurrentBlock();
337  }
338 
339  $cats_rows = $q->getRows();
340 
341  reset($a_results);
342  foreach ($cats_rows->getCategories() as $cat) {
343  $a_tpl->setCurrentBlock("grid_col_bl");
344  $a_tpl->setVariable("COL_CAPTION", $cat->title);
345  $a_tpl->parseCurrentBlock();
346 
347  $r = current($a_results);
348  $row_answers = $r[1]->getAnswers();
349  $user_answers = null;
350  foreach ($row_answers as $ra) {
351  if ($ra->active_id == $answer->active_id) {
352  $user_answers = $ra;
353  }
354  }
355 
356  foreach ($cats->getCategories() as $catr) {
357  if ($user_answers && $user_answers->value == $catr->scale) {
358  $a_tpl->touchBlock("grid_col_center");
359  $a_tpl->setCurrentBlock("grid_col_bl");
360  $a_tpl->setVariable("COL_CAPTION", "X");
361  } else {
362  $a_tpl->setCurrentBlock("grid_col_bl");
363  $a_tpl->setVariable("COL_CAPTION", " ");
364  }
365 
366  $a_tpl->parseCurrentBlock();
367  }
368 
369  $a_tpl->touchBlock("grid_row_bl");
370  next($a_results);
371  }
372 
373  // rater
374  $participant = $this->getParticipantByActiveId($participants, $answer->active_id);
375  $part_caption = "";
376  if ($participant) {
377  $part_caption = $participant["sortname"];
378  }
379  $date = new \ilDate($answer->tstamp, IL_CAL_UNIX);
380  $part_caption .= ", " . \ilDatePresentation::formatDate($date);
381 
382  $a_tpl->setVariable("HEADER", $part_caption);
383  $ret .= $a_tpl->get();
384  $a_tpl = new \ilTemplate("tpl.svy_results_details_table.html", true, true, "components/ILIAS/Survey/Evaluation");
385  }
386  }
387  }
388  return $ret;
389  }
390 
391  protected function getParticipantByActiveId(array $participants, int $active_id): ?array
392  {
393  foreach ($participants as $part) {
394  if ((int) $part["active_id"] === $active_id) {
395  return $part;
396  }
397  }
398  return null;
399  }
400 
401  protected function getCaptionForParticipant(array $part_array): string
402  {
403  return $part_array["sortname"];
404  }
405 }
static array static setUseRelativeDates(bool $a_status)
set use relative dates
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)
Interface Observer Contains several chained tasks and infos about them.
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
addExportAndPrintButton(\ilObjSurvey $survey, \ilToolbarGUI $toolbar, bool $details, \ilTemplate $eval_tpl)
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:91
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setReminderTarget(int $a_value)
addApprSelectionToToolbar(\ilObjSurvey $survey, \ilToolbarGUI $toolbar, int $user_id)
const NOTIFICATION_APPRAISEES_AND_RATERS
global $lng
Definition: privfeed.php:31
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
$q
Definition: shib_logout.php:21
setResultsCompetenceToolbar(\ilObjSurvey $survey, \ilToolbarGUI $toolbar, int $user_id)
setResultsDetailToolbar(\ilObjSurvey $survey, \ilToolbarGUI $toolbar, int $user_id, \ilTemplate $eval_tpl)
const NOTIFICATION_RATERS
addInputItem(ilToolbarItem $a_item, bool $a_output_label=false)
$r