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