ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSurveyExecutionGUI.php
Go to the documentation of this file.
1 <?php
2 
20 
31 {
35  protected array $raw_post_data;
36  protected \ILIAS\Survey\Execution\ExecutionGUIRequest $request;
38  protected ilObjUser $user;
39  protected ilHelpGUI $help;
41  protected ilObjSurvey $object;
42  protected ilLanguage $lng;
44  protected ilCtrl $ctrl;
45  protected ilTree $tree;
46  protected bool $preview;
47  protected ilLogger $log;
48  protected \ILIAS\Survey\Execution\RunManager $run_manager;
49  protected \ILIAS\Survey\Participants\StatusManager $participant_manager;
50  protected \ILIAS\Survey\Access\AccessManager $access_manager;
51  protected int $requested_appr_id;
52  protected Mode\FeatureConfig $feature_config;
53 
54  public function __construct(ilObjSurvey $a_object)
55  {
56  global $DIC;
57 
58  $this->rbacsystem = $DIC->rbac()->system();
59  $this->user = $DIC->user();
60  $this->help = $DIC["ilHelp"];
61  $this->toolbar = $DIC->toolbar();
62  $lng = $DIC->language();
63  $tpl = $DIC["tpl"];
64  $ilCtrl = $DIC->ctrl();
65  $tree = $DIC->repositoryTree();
66 
67  $this->lng = $lng;
68  $this->tpl = $tpl;
69  $this->ctrl = $ilCtrl;
70  $this->object = $a_object;
71  $this->tree = $tree;
72  $this->user = $DIC->user();
73 
74  $this->request = $DIC->survey()
75  ->internal()
76  ->gui()
77  ->execution()
78  ->request();
79 
80  // stay in preview mode
81  $this->preview = (bool) $this->request->getPreview();
82  $this->requested_appr_id = $this->request->getAppraiseeId();
83  $this->ctrl->saveParameter($this, "prvw");
84  $this->ctrl->saveParameter($this, "appr_id");
85  $this->ctrl->saveParameter($this, "pgov");
86 
87  $this->log = ilLoggerFactory::getLogger("svy");
88 
89  $domain_service = $DIC->survey()->internal();
90  $appraisee_id = ($a_object->getMode() === ilObjSurvey::MODE_SELF_EVAL)
91  ? $this->user->getId()
93  $this->run_manager = $domain_service->domain()->execution()->run(
94  $a_object,
95  $this->user->getId(),
96  $appraisee_id
97  );
98  $this->participant_manager = $domain_service->domain()->participants()->status(
99  $a_object,
100  $this->user->getId()
101  );
102  $this->access_manager = $domain_service->domain()->access(
103  $a_object->getRefId(),
104  $this->user->getId()
105  );
106 
107  $this->feature_config = $domain_service->domain()->modeFeatureConfig($a_object->getMode());
108 
109 
110  // @todo this is used to store answers in the session, but should
111  // be refactored somehow to avoid the use of the complete post body
112  $this->raw_post_data = $DIC->http()->request()->getParsedBody() ?? [];
113  }
114 
115  public function executeCommand(): string
116  {
117  // record read event for lp
119  'svy',
120  $this->object->getRefId(),
121  $this->object->getId(),
122  $GLOBALS['DIC']->user()->getId()
123  );
124 
125  $cmd = $this->ctrl->getCmd();
126  $next_class = $this->ctrl->getNextClass($this);
127 
128  $this->log->debug("- cmd= " . $cmd);
129 
130  if ($cmd === null || $cmd === '') {
131  $this->ctrl->setParameter(
132  $this,
133  "qid",
134  $this->request->getQuestionId()
135  );
136  $this->ctrl->redirect($this, "gotoPage");
137  }
138  switch ($next_class) {
139  default:
140  $ret = $this->$cmd();
141  break;
142  }
143  return (string) $ret;
144  }
145 
146  protected function checkAuth(
147  bool $a_may_start = false,
148  bool $a_ignore_status = false
149  ): void {
150  $rbacsystem = $this->rbacsystem;
152 
153  if ($this->preview) {
154  if (!$rbacsystem->checkAccess("write", $this->object->getRefId())) {
155  // only with write access it is possible to preview the survey
156  throw new ilSurveyException($this->lng->txt("survey_cannot_preview_survey"));
157  }
158  return;
159  }
160 
161 
162  if (!$this->access_manager->canStartSurvey()) {
163  // only with read access it is possible to run the test
164  throw new ilSurveyException($this->lng->txt("cannot_read_survey"));
165  }
166 
167  $user_id = $ilUser->getId();
168 
169  // check existing code
170  // see ilObjSurveyGUI::infoScreen()
171  $anonymous_id = null;
172  $anonymous_code = "";
173  if ($this->access_manager->isCodeInputAllowed()) {
174  $anonymous_code = $this->run_manager->getCode();
175  $anonymous_id = $this->object->getAnonymousIdByCode($anonymous_code);
176  if (!$anonymous_id) {
177  $this->tpl->setOnScreenMessage('failure', sprintf($this->lng->txt("error_retrieving_anonymous_survey"), $anonymous_code, true));
178  $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
179  }
180  }
181 
182  // appraisee validation
183  $appr_id = 0;
184  $appraisees = [];
185  if ($this->feature_config->usesAppraisees()) {
186  $appr_id = $this->requested_appr_id;
187  //if (!$appr_id) {
188  // $appr_id = $_SESSION["appr_id"][$this->object->getId()];
189  //}
190  // check if appraisee is valid
191  if ($anonymous_id) {
192  $appraisees = $this->object->getAppraiseesToRate(0, $anonymous_id);
193  }
194  if (!$appraisees && $user_id !== ANONYMOUS_USER_ID) {
195  $appraisees = $this->object->getAppraiseesToRate($user_id);
196  }
197  if (!in_array($appr_id, $appraisees)) {
198  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("survey_360_execution_invalid_appraisee"), true);
199  $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
200  }
201  }
202  //Self evaluation mode
203  #23575 in self eval the appraisee is the current user.
204  if ($this->object->getMode() === ilObjSurvey::MODE_SELF_EVAL) {
205  $appr_id = $ilUser->getId();
206  }
207 
208  //$_SESSION["appr_id"][$this->object->getId()] = $appr_id;
209 
210  if (!$a_ignore_status) {
211  // completed
212  if ($this->run_manager->hasFinished()) {
213  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("already_completed_survey"), true);
214  $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
215  }
216  // starting
217  elseif (!$this->run_manager->hasStarted()) {
218  if ($a_may_start) {
219  //$_SESSION["finished_id"][$this->object->getId()] =
220  // $this->object->startSurvey($user_id, $anonymous_code, $appr_id);
221  $this->run_manager->start($appr_id);
222  } else {
223  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("survey_use_start_button"), true);
224  $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
225  }
226  }
227  // resuming
228  else {
229  // nothing todo
230  }
231  }
232 
233  // validate finished id
234  if ($this->object->getActiveID($user_id, $anonymous_code, $appr_id) !==
235  $this->run_manager->getCurrentRunId()) {
236  throw new ilSurveyException("Run ID mismatch");
237  }
238  }
239 
240  public function resume(): void
241  {
242  $this->start(true);
243  }
244 
245  public function start(bool $resume = false): void
246  {
247  if ($this->preview) {
248  $this->run_manager->clearAllPreviewData();
249  }
250  $this->run_manager->clearErrors();
251 
252  $this->checkAuth(!$resume);
253 
254  $activepage = "";
255  if ($resume) {
256  $activepage = $this->object->getLastActivePage(
257  $this->getCurrentRunId()
258  );
259  }
260 
261  if ((string) $activepage !== '') {
262  $this->ctrl->setParameter($this, "qid", (string) $activepage);
263  }
264  $this->ctrl->setParameter($this, "activecommand", "default");
265  $this->ctrl->redirect($this, "redirectQuestion");
266  }
267 
272  public function redirectQuestion(): void
273  {
274  switch ($this->request->getActiveCommand()) {
275  case "previous":
276  case "gotoPage":
277  case "next":
278  $this->outSurveyPage(
279  $this->request->getQuestionId(),
280  $this->request->getDirection()
281  );
282  break;
283  case "default":
284  $this->outSurveyPage($this->request->getQuestionId());
285  break;
286  default:
287  // don't save input, go to the first page
288  $this->outSurveyPage();
289  break;
290  }
291  }
292 
293  public function previousNoSave(): void
294  {
295  $this->previous(false);
296  }
297 
298  public function previous(
299  bool $a_save_input = true
300  ): void {
301  $has_error = "";
302  if ($a_save_input) {
303  // #16209
304  $has_error = $this->saveUserInput("previous");
305  }
306  $this->ctrl->setParameter($this, "activecommand", "previous");
307  $this->ctrl->setParameter($this, "qid", $this->request->getQuestionId());
308  if ($has_error > 0) {
309  $this->ctrl->setParameter($this, "direction", "0");
310  } else {
311  $this->ctrl->setParameter($this, "direction", "-1");
312  }
313  $this->ctrl->redirect($this, "redirectQuestion");
314  }
315 
319  public function next(): void
320  {
321  $result = $this->saveUserInput("next");
322  $this->ctrl->setParameter($this, "activecommand", "next");
323  $this->ctrl->setParameter($this, "qid", $this->request->getQuestionId());
324  if ($result > 0) {
325  $this->ctrl->setParameter($this, "direction", "0");
326  } else {
327  $this->ctrl->setParameter($this, "direction", "1");
328  }
329  $this->ctrl->redirect($this, "redirectQuestion");
330  }
331 
335  public function gotoPage(): void
336  {
337  $this->ctrl->setParameter($this, "activecommand", "gotoPage");
338  $this->ctrl->setParameter($this, "qid", $this->request->getQuestionId());
339  $this->ctrl->setParameter($this, "direction", "0");
340  $this->ctrl->redirect($this, "redirectQuestion");
341  }
342 
348  public function outSurveyPage(
349  int $activepage = 0,
350  int $direction = 0
351  ): void {
353 
354  $this->checkAuth();
355  $page = $this->object->getNextPage($activepage, $direction);
356  $constraint_true = 0;
357 
358  // check for constraints
359  if (!is_null($page) && is_array($page[0]["constraints"]) && count($page[0]["constraints"])) {
360  $this->log->debug("Page constraints= ", $page[0]["constraints"]);
361 
362  while (!is_null($page) and ($constraint_true == 0) and (count($page[0]["constraints"]))) {
363  $constraint_true = $page[0]['constraints'][0]['conjunction'] == 0;
364  foreach ($page[0]["constraints"] as $constraint) {
365  if (!$this->preview) {
366  $working_data = $this->object->loadWorkingData($constraint["question"], $this->getCurrentRunId());
367  } else {
368  $working_data = $this->run_manager->getPreviewData($constraint["question"]);
369  }
370  if ($constraint['conjunction'] == 0) {
371  // and
372  $constraint_true &= $this->object->checkConstraint($constraint, $working_data);
373  } else {
374  // or
375  $constraint_true |= $this->object->checkConstraint($constraint, $working_data);
376  }
377  }
378  if ($constraint_true == 0) {
379  // #11047 - we are skipping the page, so we have to get rid of existing answers for that question(s)
380  foreach ($page as $page_question) {
381  $qid = $page_question["question_id"];
382 
383  // see saveActiveQuestionData()
384  if (!$this->preview) {
385  $this->object->deleteWorkingData($qid, $this->getCurrentRunId());
386  } else {
387  $this->run_manager->clearPreviewData($qid);
388  }
389  }
390 
391  $page = $this->object->getNextPage($page[0]["question_id"], $direction);
392  }
393  }
394  }
395  $first_question = -1;
396  if (is_null($page) && $direction === -1) {
397  $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
398  } elseif (is_null($page) && $direction === 1) {
399  $state = $this->object->getUserSurveyExecutionStatus();
400  if ($this->preview ||
401  !($state["runs"][$this->getCurrentRunId()]["finished"] ?? false)) {
402  $this->showFinishConfirmation();
403  } else {
404  $this->runShowFinishedPage();
405  }
406  return;
407  } else {
408  $ilHelp = $this->help;
409  $ilHelp->setScreenIdComponent("svy");
410  $ilHelp->setScreenId("quest_presentation");
411 
412  if ($ilUser->getId() !== ANONYMOUS_USER_ID) {
413  ilLearningProgress::_tracProgress($ilUser->getId(), $this->object->getId(), $this->object->getRefId(), "svy");
414  }
415 
416  $required = false;
417  //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_content.html", "Modules/Survey");
418  $stpl = new ilTemplate("tpl.il_svy_svy_content.html", true, true, "Modules/Survey");
419 
420  // title / appraisee
421  if ($this->feature_config->usesAppraisees()) {
422  $appr_id = $this->requested_appr_id;
423 
424  $this->tpl->setTitle($this->object->getTitle() . " (" .
425  $this->lng->txt("survey_360_appraisee") . ": " .
426  ilUserUtil::getNamePresentation($appr_id) . ")");
427  }
428 
429  // top / bottom nav
430  if (!($this->object->getAnonymize() && $this->object->isAccessibleWithoutCode() && ($ilUser->getId() === ANONYMOUS_USER_ID))) {
431  $stpl->setCurrentBlock("suspend_survey");
432 
433  if (!$this->preview) {
434  $stpl->setVariable("TEXT_SUSPEND", $this->lng->txt("cancel_survey"));
435  $stpl->setVariable("HREF_SUSPEND", $this->ctrl->getLinkTargetByClass("ilObjSurveyGUI", "infoScreen"));
436  } else {
437  $this->ctrl->setParameterByClass("ilObjSurveyGUI", "pgov", $this->request->getTargetPosition());
438  $stpl->setVariable("TEXT_SUSPEND", $this->lng->txt("survey_cancel_preview"));
439  $stpl->setVariable("HREF_SUSPEND", $this->ctrl->getLinkTargetByClass(array("ilObjSurveyGUI", "ilSurveyEditorGUI"), "questions"));
440  }
441 
442  $stpl->setVariable("ALT_IMG_SUSPEND", $this->lng->txt("cancel_survey"));
443  $stpl->setVariable("TITLE_IMG_SUSPEND", $this->lng->txt("cancel_survey"));
444  $stpl->parseCurrentBlock();
445  }
446  $this->outNavigationButtons("top", $page, $stpl);
447  $this->outNavigationButtons("bottom", $page, $stpl);
448 
449  // progress
450  $stpl->setCurrentBlock("percentage");
451  $percentage = (int) (($page[0]["position"]) * 100);
452  $pbar = ilProgressBar::getInstance();
453  $pbar->setCurrent($percentage);
454  $stpl->setVariable("NEW_PBAR", $pbar->render());
455  $stpl->parseCurrentBlock();
456 
457  // questions
458  $working_data = [];
459  $errors = $this->run_manager->getErrors();
460  foreach ($page as $data) {
461  if ($first_question === -1) {
462  $first_question = $data["question_id"];
463  }
464  $question_gui = $this->object->getQuestionGUI($data["type_tag"], $data["question_id"]);
465 
466  if (count($errors) > 0) {
467  $working_data[$data["question_id"]] = $question_gui->object->getWorkingDataFromUserInput(
468  $this->run_manager->getPostData()
469  );
470  } else {
471  if (!$this->preview) {
472  $working_data[$data["question_id"]] = $this->object->loadWorkingData(
473  $data["question_id"],
474  $this->run_manager->getCurrentRunId()
475  );
476  } else {
477  $working_data[$data["question_id"]] =
478  $this->run_manager->getPreviewData($data["question_id"]);
479  }
480  }
481  }
482 
483  $page_renderer = new \ILIAS\Survey\Page\PageRenderer(
484  $this->object,
485  $page,
486  $working_data,
487  $errors
488  );
489 
490  $stpl->setVariable("PAGE", $page_renderer->render());
491 
492  $this->ctrl->setParameter($this, "qid", $first_question);
493  $stpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "redirectQuestion"));
494  $this->tpl->setContent($stpl->get());
495  }
496 
497  if (!$this->preview) {
498  $this->object->setPage($this->getCurrentRunId(), $page[0]['question_id']);
499  $this->run_manager->setStartTime($first_question);
500  }
501  }
502 
503  protected function getCurrentRunId(): int
504  {
505  return $this->run_manager->getCurrentRunId();
506  }
507 
511  public function saveUserInput(
512  string $navigationDirection = "next"
513  ): int {
514  if (!$this->preview) {
515  $this->run_manager->setEndTime();
516  }
517 
518  // check users input when it is a metric question
519  $this->run_manager->clearErrors();
520  $this->run_manager->setPostData($this->raw_post_data);
521 
522  $page_error = 0;
523  $page = $this->object->getNextPage($this->request->getQuestionId(), 0);
524  foreach ($page as $data) {
525  $page_error += $this->saveActiveQuestionData($data);
526  }
527  if ($page_error && (strcmp($navigationDirection, "previous") !== 0)) {
528  if ($page_error === 1) {
529  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("svy_page_error"), true);
530  } else {
531  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("svy_page_errors"), true);
532  }
533  } else {
534  $page_error = 0;
535  $this->run_manager->clearErrors();
536  }
537  return $page_error;
538  }
539 
543  public function saveActiveQuestionData(array $data): int
544  {
545  $question = SurveyQuestion::_instanciateQuestion($data["question_id"]);
546  $error = $question->checkUserInput($this->raw_post_data, $this->object->getSurveyId());
547  if (strlen($error) === 0) {
548  if (!$this->preview) {
549  // delete old answers
550  $this->object->deleteWorkingData($data["question_id"], $this->getCurrentRunId());
551 
552  $question->saveUserInput($this->raw_post_data, $this->getCurrentRunId());
553  } else {
554  $this->run_manager->setPreviewData(
555  $data["question_id"],
556  $question->saveUserInput($this->raw_post_data, 0, true)
557  );
558  }
559  return 0;
560  } else {
561  $errors = $this->run_manager->getErrors();
562  $errors[$question->getId()] = $error;
563  $this->run_manager->setErrors($errors);
564  return 1;
565  }
566  }
567 
568  public function cancel(): void
569  {
570  $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
571  }
572 
576  public function runShowFinishedPage(): void
577  {
578  $ilToolbar = $this->toolbar;
580 
581  $has_button = false;
582 
583 
584  if (!$this->preview) {
585  if ($this->object->hasViewOwnResults()) {
586  $button = ilLinkButton::getInstance();
587  $button->setCaption("svy_view_own_results");
588  $button->setUrl($this->ctrl->getLinkTarget($this, "viewUserResults"));
589  $ilToolbar->addButtonInstance($button);
590 
591  $has_button = true;
592  }
593 
594  if ($this->object->hasMailConfirmation()) {
595  if ($has_button) {
596  $ilToolbar->addSeparator();
597  }
598 
599  if ($ilUser->getId() === ANONYMOUS_USER_ID ||
600  !$ilUser->getEmail()) {
601  $mail = new ilTextInputGUI($this->lng->txt("email"), "mail");
602  $mail->setSize(25);
603  $ilToolbar->addInputItem($mail, true);
604  }
605 
606  $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "mailUserResults"));
607 
608  $button = ilSubmitButton::getInstance();
609  $button->setCaption("svy_mail_send_confirmation");
610  $button->setCommand("mailUserResults");
611  $ilToolbar->addButtonInstance($button);
612 
613  $has_button = true;
614  }
615 
616  // #6307
617  if (ilObjSurveyAccess::_hasEvaluationAccess($this->object->getId(), $ilUser->getId())) {
618  $button = ilLinkButton::getInstance();
619  $button->setCaption("svy_results");
620  $button->setUrl($this->ctrl->getLinkTargetByClass("ilObjSurveyGUI", "evaluation"));
621  $ilToolbar->addButtonInstance($button);
622 
623  $has_button = true;
624  }
625  }
626 
627  if (!$has_button &&
628  $this->object->getOutro() === '') {
629  $this->exitSurvey();
630  } else {
631  if ($has_button) {
632  $ilToolbar->addSeparator();
633  }
634 
635  $button = ilLinkButton::getInstance();
636  if ($this->object->getMode() === ilObjSurvey::MODE_360) {
637  $button->setCaption("survey_execution_exit_360");
638  } else {
639  $button->setCaption("survey_execution_exit");
640  }
641  $button->setUrl($this->ctrl->getLinkTarget($this, "exitSurvey"));
642  $ilToolbar->addButtonInstance($button);
643 
644  if ($this->object->getOutro() !== '') {
646  $panel->setBody($this->object->prepareTextareaOutput($this->object->getOutro()));
647  $this->tpl->setContent($panel->getHTML());
648  }
649  }
650  }
651 
652  public function backToRepository(): void
653  {
654  $tree = $this->tree;
655 
656  // #14971
657  if ($this->object->getMode() === ilObjSurvey::MODE_360) {
658  $target_ref_id = $this->object->getRefId();
659  } else {
660  // #11534
661  $target_ref_id = $tree->getParentId($this->object->getRefId());
662  }
663 
664  ilUtil::redirect(ilLink::_getLink($target_ref_id));
665  }
666 
670  public function exitSurvey(): void
671  {
672  if (!$this->preview) {
673  $this->backToRepository();
674  } else {
675  // #12841
676  $this->ctrl->setParameterByClass("ilsurveyeditorgui", "pgov", $this->request->getTargetPosition());
677  $this->ctrl->redirectByClass(array("ilobjsurveygui", "ilsurveyeditorgui"), "questions");
678  }
679  }
680 
681  public function outNavigationButtons(
682  string $navigationblock,
683  array $page,
684  ilTemplate $stpl
685  ): void {
686  $prevpage = $this->object->getNextPage($page[0]["question_id"], -1);
687  $stpl->setCurrentBlock($navigationblock . "_prev");
688  if (is_null($prevpage)) {
689  $stpl->setVariable("BTN_PREV", $this->lng->txt("survey_start"));
690  } else {
691  $stpl->setVariable("BTN_PREV", $this->lng->txt("survey_previous"));
692  }
693  $stpl->parseCurrentBlock();
694  $nextpage = $this->object->getNextPage($page[0]["question_id"], 1);
695  $stpl->setCurrentBlock($navigationblock . "_next");
696  if (is_null($nextpage)) {
697  $stpl->setVariable("BTN_NEXT", $this->lng->txt("survey_finish"));
698  } else {
699  $stpl->setVariable("BTN_NEXT", $this->lng->txt("survey_next"));
700  }
701  $stpl->parseCurrentBlock();
702  }
703 
704  public function preview(): void
705  {
706  $this->outSurveyPage();
707  }
708 
709  public function viewUserResults(): void
710  {
711  $ilToolbar = $this->toolbar;
712 
713  if (!$this->object->hasViewOwnResults()) {
714  $this->backToRepository();
715  }
716 
717  $this->checkAuth(false, true);
718 
719  $button = ilLinkButton::getInstance();
720  $button->setCaption("btn_back");
721  $button->setUrl($this->ctrl->getLinkTarget($this, "runShowFinishedPage"));
722  $ilToolbar->addButtonInstance($button);
723 
724  $survey_gui = new ilObjSurveyGUI();
725  $html = $survey_gui->getUserResultsTable($this->getCurrentRunId());
726  $this->tpl->setContent($html);
727  }
728 
729  public function mailUserResults(): void
730  {
732 
733  if (!$this->object->hasMailConfirmation()) {
734  $this->backToRepository();
735  }
736 
737  $this->checkAuth(false, true);
738 
739  $recipient = $this->request->getMail();
740  if (!$recipient) {
741  $recipient = $ilUser->getEmail();
742  }
743  if (!ilUtil::is_email($recipient)) {
744  $this->ctrl->redirect($this, "runShowFinishedPage");
745  }
746 
747  $survey_gui = new ilObjSurveyGUI();
748  $survey_gui->sendUserResultsMail(
749  $this->getCurrentRunId(),
750  $recipient
751  );
752 
753  $this->tpl->setOnScreenMessage('success', $this->lng->txt("mail_sent"), true);
754  $this->ctrl->redirect($this, "runShowFinishedPage");
755  }
756 
757  public function showFinishConfirmation(): void
758  {
759  $tpl = $this->tpl;
760 
761  $cgui = new ilConfirmationGUI();
762  $cgui->setHeaderText($this->lng->txt("survey_execution_sure_finish"));
763 
764  $cgui->setFormAction($this->ctrl->getFormAction($this, "confirmedFinish"));
765  $cgui->setCancel($this->lng->txt("cancel"), "previousNoSave");
766  $cgui->setConfirm($this->lng->txt("confirm"), "confirmedFinish");
767 
768  $tpl->setContent($cgui->getHTML());
769  }
770 
771  public function confirmedFinish(): void
772  {
774 
775  if (!$this->preview) {
776  $this->object->finishSurvey($this->getCurrentRunId(), $this->requested_appr_id);
777 
778  if ($ilUser->getId() !== ANONYMOUS_USER_ID) {
779  ilLPStatusWrapper::_updateStatus($this->object->getId(), $ilUser->getId());
780  }
781 
782  // send "single participant has finished" mail to tutors
783  if ($this->object->getMailNotification()) {
784  $this->object->sendNotificationMail(
785  $ilUser->getId(),
786  $this->run_manager->getCode(),
788  );
789  }
790  }
791 
792  $this->ctrl->redirect($this, "runShowFinishedPage");
793  }
794 }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
Mode FeatureConfig $feature_config
ILIAS Survey Participants StatusManager $participant_manager
const ANONYMOUS_USER_ID
Definition: constants.php:27
static getLogger(string $a_component_id)
Get component logger.
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:
outSurveyPage(int $activepage=0, int $direction=0)
Output of the active survey question to the screen.
$errors
Definition: imgupload.php:65
static is_email(string $a_email, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
Definition: imgupload.php:198
exitSurvey()
Exits the survey after finishing it.
Help GUI class.
outNavigationButtons(string $navigationblock, array $page, ilTemplate $stpl)
redirectQuestion()
Called when a user answered a page to perform a redirect after POST.
saveActiveQuestionData(array $data)
Saves the users input of the active page.
ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _tracProgress(int $a_user_id, int $a_obj_id, int $a_ref_id, string $a_obj_type='')
global $DIC
Definition: feed.php:28
Class ilObjSurveyGUI.
__construct(ilObjSurvey $a_object)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
next()
Navigates to the next page.
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
ILIAS Survey Execution RunManager $run_manager
setContent(string $a_html)
Sets content for standard template.
checkAuth(bool $a_may_start=false, bool $a_ignore_status=false)
gotoPage()
Go to a specific page without saving.
setScreenIdComponent(string $a_comp)
ILIAS Survey Access AccessManager $access_manager
Survey execution graphical output.
static _recordReadEvent(string $a_type, int $a_ref_id, int $obj_id, int $usr_id, bool $isCatchupWriteEvents=true, $a_ext_rc=null, $a_ext_time=null)
runShowFinishedPage()
Show finish page.
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
ILIAS Survey Execution ExecutionGUIRequest $request
getParentId(int $a_node_id)
get parent id of given node
static _hasEvaluationAccess(int $a_obj_id, int $user_id)
static redirect(string $a_script)
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
static getInstance()
previous(bool $a_save_input=true)
saveUserInput(string $navigationDirection="next")
Save the user&#39;s input.
$ilUser
Definition: imgupload.php:34
static _instanciateQuestion(int $question_id)
Get question object.
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...