ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilSurveyExecutionGUI.php
Go to the documentation of this file.
1<?php
2 /*
3 +----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +----------------------------------------------------------------------------+
22*/
23
36{
40 protected $rbacsystem;
41
45 protected $user;
46
50 protected $help;
51
55 protected $toolbar;
56
57 public $object;
58 public $lng;
59 public $tpl;
60 public $ctrl;
61 public $tree;
62 public $preview;
63
67 protected $log;
68
77 public function __construct($a_object)
78 {
79 global $DIC;
80
81 $this->rbacsystem = $DIC->rbac()->system();
82 $this->user = $DIC->user();
83 $this->help = $DIC["ilHelp"];
84 $this->toolbar = $DIC->toolbar();
85 $lng = $DIC->language();
86 $tpl = $DIC["tpl"];
87 $ilCtrl = $DIC->ctrl();
88 $tree = $DIC->repositoryTree();
89
90 $this->lng = $lng;
91 $this->tpl = $tpl;
92 $this->ctrl = $ilCtrl;
93 $this->object = $a_object;
94 $this->tree = $tree;
95
96 $this->external_rater_360 = false;
97 if ($this->object->get360Mode() &&
98 $_SESSION["anonymous_id"][$this->object->getId()] &&
100 $this->object->getRefId(),
101 $_SESSION["anonymous_id"][$this->object->getId()]
102 )) {
103 $this->external_rater_360 = true;
104 }
105
106 // stay in preview mode
107 $this->preview = (bool) $_REQUEST["prvw"];
108 $this->ctrl->saveParameter($this, "prvw");
109 $this->ctrl->saveParameter($this, "pgov");
110
111 $this->log = ilLoggerFactory::getLogger("svy");
112 }
113
117 public function executeCommand()
118 {
119 // record read event for lp
121 'svy',
122 $this->object->getRefId(),
123 $this->object->getId(),
124 $GLOBALS['DIC']->user()->getId()
125 );
126
127 $cmd = $this->ctrl->getCmd();
128 $next_class = $this->ctrl->getNextClass($this);
129
130 $cmd = $this->getCommand($cmd);
131
132 $this->log->debug("- cmd= " . $cmd);
133
134 if (strlen($cmd) == 0) {
135 $this->ctrl->setParameter($this, "qid", $_GET["qid"]);
136 $this->ctrl->redirect($this, "gotoPage");
137 }
138 switch ($next_class) {
139 default:
140 $ret = &$this->$cmd();
141 break;
142 }
143 return $ret;
144 }
145
146 protected function checkAuth($a_may_start = false, $a_ignore_status = false)
147 {
150
151 if ($this->preview) {
152 if (!$rbacsystem->checkAccess("write", $this->object->ref_id)) {
153 // only with write access it is possible to preview the survey
154 throw new ilSurveyException($this->lng->txt("survey_cannot_preview_survey"));
155 }
156
157 return true;
158 }
159
160 if (!$this->external_rater_360 &&
161 !$rbacsystem->checkAccess("read", $this->object->ref_id)) {
162 // only with read access it is possible to run the test
163 throw new ilSurveyException($this->lng->txt("cannot_read_survey"));
164 }
165
166 $user_id = $ilUser->getId();
167
168 // check existing code
169 // see ilObjSurveyGUI::infoScreen()
170 $anonymous_id = $anonymous_code = null;
171 if ($this->object->getAnonymize() || !$this->object->isAccessibleWithoutCode()) {
172 $anonymous_code = $_SESSION["anonymous_id"][$this->object->getId()];
173 $anonymous_id = $this->object->getAnonymousIdByCode($anonymous_code);
174 if (!$anonymous_id) {
175 ilUtil::sendFailure(sprintf($this->lng->txt("error_retrieving_anonymous_survey"), $anonymous_code, true));
176 $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
177 }
178 }
179
180 // appraisee validation
181 $appr_id = 0;
182 if ($this->object->get360Mode()) {
183 $appr_id = $_REQUEST["appr_id"];
184 if (!$appr_id) {
185 $appr_id = $_SESSION["appr_id"][$this->object->getId()];
186 }
187 // check if appraisee is valid
188 if ($anonymous_id) {
189 $appraisees = $this->object->getAppraiseesToRate(0, $anonymous_id);
190 }
191 if (!$appraisees && $user_id != ANONYMOUS_USER_ID) {
192 $appraisees = $this->object->getAppraiseesToRate($user_id);
193 }
194 if (!in_array($appr_id, $appraisees)) {
195 ilUtil::sendFailure($this->lng->txt("survey_360_execution_invalid_appraisee"), true);
196 $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
197 }
198 }
199 //Self evaluation mode
200 #23575 in self eval the appraisee is the current user.
201 if ($this->object->getMode() == ilObjSurvey::MODE_SELF_EVAL) {
202 $appr_id = $ilUser->getId();
203 }
204
205 $_SESSION["appr_id"][$this->object->getId()] = $appr_id;
206
207 if (!$a_ignore_status) {
208 $status = $this->object->isSurveyStarted($user_id, $anonymous_code, $appr_id);
209 // completed
210 if ($status === 1) {
211 ilUtil::sendFailure($this->lng->txt("already_completed_survey"), true);
212 $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
213 }
214 // starting
215 elseif ($status === false) {
216 if ($a_may_start) {
217 $_SESSION["finished_id"][$this->object->getId()] =
218 $this->object->startSurvey($user_id, $anonymous_code, $appr_id);
219 } else {
220 ilUtil::sendFailure($this->lng->txt("survey_use_start_button"), true);
221 $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
222 }
223 }
224 // resuming
225 else {
226 // nothing todo
227 }
228 }
229
230 // validate finished id
231 if ($this->object->getActiveID($user_id, $anonymous_code, $appr_id) !=
232 $_SESSION["finished_id"][$this->object->getId()]) {
233 ilUtil::sendFailure($this->lng->txt("cannot_read_survey"), true);
234 $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
235 }
236 }
237
245 public function getCommand($cmd)
246 {
247 return $cmd;
248 }
249
257 public function resume()
258 {
259 $this->start(true);
260 }
261
269 public function start($resume = false)
270 {
271 if ($this->preview) {
272 unset($_SESSION["preview_data"]);
273 }
274 unset($_SESSION["svy_errors"]);
275
276 $this->checkAuth(!$resume);
277
278 $activepage = "";
279 if ($resume) {
280 $activepage = $this->object->getLastActivePage($_SESSION["finished_id"][$this->object->getId()]);
281 }
282
283 if (strlen($activepage)) {
284 $this->ctrl->setParameter($this, "qid", $activepage);
285 }
286 $this->ctrl->setParameter($this, "activecommand", "default");
287 $this->ctrl->redirect($this, "redirectQuestion");
288 }
289
296 public function redirectQuestion()
297 {
298 switch ($_GET["activecommand"]) {
299 case "next":
300 $this->outSurveyPage($_GET["qid"], $_GET["direction"]);
301 break;
302 case "previous":
303 $this->outSurveyPage($_GET["qid"], $_GET["direction"]);
304 break;
305 case "gotoPage":
306 $this->outSurveyPage($_GET["qid"], $_GET["direction"]);
307 break;
308 case "default":
309 $this->outSurveyPage($_GET["qid"]);
310 break;
311 default:
312 // don't save input, go to the first page
313 $this->outSurveyPage();
314 break;
315 }
316 }
317
318 public function previousNoSave()
319 {
320 $this->previous(false);
321 }
322
330 public function previous($a_save_input = true)
331 {
332 if ($a_save_input) {
333 // #16209
334 $has_error = $this->saveUserInput("previous");
335 }
336 $this->ctrl->setParameter($this, "activecommand", "previous");
337 $this->ctrl->setParameter($this, "qid", $_GET["qid"]);
338 if (strlen($has_error)) {
339 $this->ctrl->setParameter($this, "direction", "0");
340 } else {
341 $this->ctrl->setParameter($this, "direction", "-1");
342 }
343 $this->ctrl->redirect($this, "redirectQuestion");
344 }
345
351 public function next()
352 {
353 $result = $this->saveUserInput("next");
354 $this->ctrl->setParameter($this, "activecommand", "next");
355 $this->ctrl->setParameter($this, "qid", $_GET["qid"]);
356 if (strlen($result)) {
357 $this->ctrl->setParameter($this, "direction", "0");
358 } else {
359 $this->ctrl->setParameter($this, "direction", "1");
360 }
361 $this->ctrl->redirect($this, "redirectQuestion");
362 }
363
369 public function gotoPage()
370 {
371 $this->ctrl->setParameter($this, "activecommand", "gotoPage");
372 $this->ctrl->setParameter($this, "qid", $_GET["qid"]);
373 $this->ctrl->setParameter($this, "direction", "0");
374 $this->ctrl->redirect($this, "redirectQuestion");
375 }
376
384 public function outSurveyPage($activepage = null, $direction = null)
385 {
387
388 $this->checkAuth();
389
390 $page = $this->object->getNextPage($activepage, $direction);
391 $constraint_true = 0;
392
393 // check for constraints
394 if (is_array($page[0]["constraints"]) && count($page[0]["constraints"])) {
395 $this->log->debug("Page constraints= ", $page[0]["constraints"]);
396
397 while (is_array($page) and ($constraint_true == 0) and (count($page[0]["constraints"]))) {
398 $constraint_true = ($page[0]['constraints'][0]['conjunction'] == 0) ? true : false;
399 foreach ($page[0]["constraints"] as $constraint) {
400 if (!$this->preview) {
401 $working_data = $this->object->loadWorkingData($constraint["question"], $_SESSION["finished_id"][$this->object->getId()]);
402 } else {
403 $working_data = $_SESSION["preview_data"][$this->object->getId()][$constraint["question"]];
404 }
405 if ($constraint['conjunction'] == 0) {
406 // and
407 $constraint_true = $constraint_true & $this->object->checkConstraint($constraint, $working_data);
408 } else {
409 // or
410 $constraint_true = $constraint_true | $this->object->checkConstraint($constraint, $working_data);
411 }
412 }
413 if ($constraint_true == 0) {
414 // #11047 - we are skipping the page, so we have to get rid of existing answers for that question(s)
415 foreach ($page as $page_question) {
416 $qid = $page_question["question_id"];
417
418 // see saveActiveQuestionData()
419 if (!$this->preview) {
420 $this->object->deleteWorkingData($qid, $_SESSION["finished_id"][$this->object->getId()]);
421 } else {
422 $_SESSION["preview_data"][$this->object->getId()][$qid] = null;
423 }
424 }
425
426 $page = $this->object->getNextPage($page[0]["question_id"], $direction);
427 }
428 }
429 }
430
431 $first_question = -1;
432 if ($page === 0) {
433 $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
434 } elseif ($page === 1) {
435 $state = $this->object->getUserSurveyExecutionStatus();
436 if ($this->preview ||
437 !$state["runs"][$_SESSION["finished_id"][$this->object->getId()]]["finished"]) {
438 $this->showFinishConfirmation();
439 } else {
440 $this->runShowFinishedPage();
441 }
442 return;
443 } else {
444 $ilHelp = $this->help;
445 $ilHelp->setScreenIdComponent("svy");
446 $ilHelp->setScreenId("quest_presentation");
447
448 if ($ilUser->getId() != ANONYMOUS_USER_ID) {
449 ilLearningProgress::_tracProgress($ilUser->getId(), $this->object->getId(), $this->object->ref_id, "svy");
450 }
451
452 $required = false;
453 //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_content.html", "Modules/Survey");
454 $stpl = new ilTemplate("tpl.il_svy_svy_content.html", true, true, "Modules/Survey");
455
456 if ($this->object->get360Mode()) {
457 $appr_id = $_SESSION["appr_id"][$this->object->getId()];
458
459 $this->tpl->setTitle($this->object->getTitle() . " (" .
460 $this->lng->txt("survey_360_appraisee") . ": " .
461 ilUserUtil::getNamePresentation($appr_id) . ")");
462 }
463
464 if (!($this->object->getAnonymize() && $this->object->isAccessibleWithoutCode() && ($ilUser->getId() == ANONYMOUS_USER_ID))) {
465 $stpl->setCurrentBlock("suspend_survey");
466
467 if (!$this->preview) {
468 $stpl->setVariable("TEXT_SUSPEND", $this->lng->txt("cancel_survey"));
469 $stpl->setVariable("HREF_SUSPEND", $this->ctrl->getLinkTargetByClass("ilObjSurveyGUI", "infoScreen"));
470 } else {
471 $this->ctrl->setParameterByClass("ilObjSurveyGUI", "pgov", $_REQUEST["pgov"]);
472 $stpl->setVariable("TEXT_SUSPEND", $this->lng->txt("survey_cancel_preview"));
473 $stpl->setVariable("HREF_SUSPEND", $this->ctrl->getLinkTargetByClass(array("ilObjSurveyGUI", "ilSurveyEditorGUI"), "questions"));
474 }
475
476 $stpl->setVariable("ALT_IMG_SUSPEND", $this->lng->txt("cancel_survey"));
477 $stpl->setVariable("TITLE_IMG_SUSPEND", $this->lng->txt("cancel_survey"));
478 $stpl->parseCurrentBlock();
479 }
480 $this->outNavigationButtons("top", $page, $stpl);
481
482
483 $stpl->setCurrentBlock("percentage");
484
485 $percentage = (int) (($page[0]["position"]) * 100);
486
488 $pbar->setCurrent($percentage);
489 $stpl->setVariable("NEW_PBAR", $pbar->render());
490
491 $stpl->parseCurrentBlock();
492
493
494 if (count($page) > 1 && $page[0]["questionblock_show_blocktitle"]) {
495 $stpl->setCurrentBlock("questionblock_title");
496 $stpl->setVariable("TEXT_QUESTIONBLOCK_TITLE", $page[0]["questionblock_title"]);
497 $stpl->parseCurrentBlock();
498 }
499 $compress_view = false;
500 if (count($page) > 1) {
501 $compress_view = $page[0]["questionblock_compress_view"];
502 }
503 $previous_page = null;
504
505 // set compress view flags
506 $previous_key = null;
507 foreach ($page as $k => $data) {
508 $page[$k]["compressed"] = false;
509 $page[$k]["compressed_first"] = false;
510 if ($compress_view && $this->compressQuestion($previous_page, $data)) {
511 $page[$k]["compressed"] = true;
512 if ($previous_key !== null && $page[$previous_key]["compressed"] == false) {
513 $page[$previous_key]["compressed_first"] = true;
514 }
515 }
516 $previous_key = $k;
517 $previous_page = $data;
518 }
519 foreach ($page as $data) {
520 if ($data["heading"]) {
521 $stpl->setCurrentBlock("heading");
522 $stpl->setVariable("QUESTION_HEADING", $data["heading"]);
523 $stpl->parseCurrentBlock();
524 }
525 $stpl->setCurrentBlock("survey_content");
526 if ($first_question == -1) {
527 $first_question = $data["question_id"];
528 }
529 $question_gui = $this->object->getQuestionGUI($data["type_tag"], $data["question_id"]);
530 if (is_array($_SESSION["svy_errors"])) {
531 $working_data = &$question_gui->object->getWorkingDataFromUserInput($_SESSION["postdata"]);
532 } else {
533 $working_data = $this->object->loadWorkingData($data["question_id"], $_SESSION["finished_id"][$this->object->getId()]);
534 }
535 $question_gui->object->setObligatory($data["obligatory"]);
536 $error_messages = array();
537 if (is_array($_SESSION["svy_errors"])) {
538 $error_messages = $_SESSION["svy_errors"];
539 }
540 $show_questiontext = ($data["questionblock_show_questiontext"]) ? 1 : 0;
541 $show_title = ($this->object->getShowQuestionTitles() && !$data["compressed_first"]);
542 $question_output = $question_gui->getWorkingForm($working_data, $show_title, $show_questiontext, $error_messages[$data["question_id"]], $this->object->getSurveyId(), $compress_view);
543 if ($data["compressed"]) {
544 $question_output = '<div class="il-svy-qst-compressed">' . $question_output . '</div>';
545 }
546 $stpl->setVariable("QUESTION_OUTPUT", $question_output);
547 $this->ctrl->setParameter($this, "qid", $data["question_id"]);
548 //$this->tpl->parse("survey_content");
549 if ($data["obligatory"]) {
550 $required = true;
551 }
552 $stpl->parseCurrentBlock();
553 }
554 if ($required) {
555 $stpl->setCurrentBlock("required");
556 $stpl->setVariable("TEXT_REQUIRED", $this->lng->txt("required_field"));
557 $stpl->parseCurrentBlock();
558 }
559
560 $this->outNavigationButtons("bottom", $page, $stpl);
561
562 $stpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "redirectQuestion"));
563 }
564 $this->tpl->setContent($stpl->get());
565
566 if (!$this->preview) {
567 $this->object->setPage($_SESSION["finished_id"][$this->object->getId()], $page[0]['question_id']);
568 $this->object->setStartTime($_SESSION["finished_id"][$this->object->getId()], $first_question);
569 }
570 }
571
578 protected function compressQuestion($previous_page, $page)
579 {
580 if (!$previous_page) {
581 return false;
582 }
583
584 if ($previous_page["type_tag"] === $page["type_tag"] &&
585 $page["type_tag"] === "SurveySingleChoiceQuestion") {
586 if (SurveySingleChoiceQuestion::compressable($previous_page["question_id"], $page["question_id"])) {
587 return true;
588 }
589 }
590
591 return false;
592 }
593
599 public function saveUserInput($navigationDirection = "next")
600 {
601 if (!$this->preview) {
602 $this->object->setEndTime($_SESSION["finished_id"][$this->object->getId()]);
603 }
604
605 // check users input when it is a metric question
606 unset($_SESSION["svy_errors"]);
607 $_SESSION["postdata"] = $_POST;
608 $page_error = 0;
609 $page = $this->object->getNextPage($_GET["qid"], 0);
610 foreach ($page as $data) {
611 $page_error += $this->saveActiveQuestionData($data);
612 }
613 if ($page_error && (strcmp($navigationDirection, "previous") != 0)) {
614 if ($page_error == 1) {
615 ilUtil::sendFailure($this->lng->txt("svy_page_error"), true);
616 } else {
617 ilUtil::sendFailure($this->lng->txt("svy_page_errors"), true);
618 }
619 } else {
620 $page_error = "";
621 unset($_SESSION["svy_errors"]);
622 }
623 return $page_error;
624 }
625
633 /*
634 function navigate($navigationDirection = "next")
635 {
636 // check users input when it is a metric question
637 unset($_SESSION["svy_errors"]);
638 $page_error = 0;
639 $page = $this->object->getNextPage($_GET["qid"], 0);
640 foreach ($page as $data)
641 {
642 $page_error += $this->saveActiveQuestionData($data);
643 }
644 if ($page_error && (strcmp($navigationDirection, "previous") != 0))
645 {
646 if ($page_error == 1)
647 {
648 ilUtil::sendFailure($this->lng->txt("svy_page_error"));
649 }
650 else
651 {
652 ilUtil::sendFailure($this->lng->txt("svy_page_errors"));
653 }
654 }
655 else
656 {
657 $page_error = "";
658 unset($_SESSION["svy_errors"]);
659 }
660
661 $direction = 0;
662 switch ($navigationDirection)
663 {
664 case "next":
665 default:
666 $activepage = $_GET["qid"];
667 if (!$page_error)
668 {
669 $direction = 1;
670 }
671 break;
672 case "previous":
673 $activepage = $_GET["qid"];
674 if (!$page_error)
675 {
676 $direction = -1;
677 }
678 break;
679 }
680 $this->outSurveyPage($activepage, $direction);
681 }
682*/
683
692 {
694
695 $question = &SurveyQuestion::_instanciateQuestion($data["question_id"]);
696 $error = $question->checkUserInput($_POST, $this->object->getSurveyId());
697 if (strlen($error) == 0) {
698 if (!$this->preview) {
699 // delete old answers
700 $this->object->deleteWorkingData($data["question_id"], $_SESSION["finished_id"][$this->object->getId()]);
701
702 $question->saveUserInput($_POST, $_SESSION["finished_id"][$this->object->getId()]);
703 } else {
704 $_SESSION["preview_data"][$this->object->getId()][$data["question_id"]] =
705 $question->saveUserInput($_POST, $_SESSION["finished_id"][$this->object->getId()], true);
706 }
707 return 0;
708 } else {
709 $_SESSION["svy_errors"][$question->getId()] = $error;
710 return 1;
711 }
712 }
713
721 public function cancel()
722 {
723 $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
724 }
725
733 public function runShowFinishedPage()
734 {
735 $ilToolbar = $this->toolbar;
737
738 $has_button = false;
739
740
741 if (!$this->preview) {
742 if ($this->object->hasViewOwnResults()) {
743 $button = ilLinkButton::getInstance();
744 $button->setCaption("svy_view_own_results");
745 $button->setUrl($this->ctrl->getLinkTarget($this, "viewUserResults"));
746 $ilToolbar->addButtonInstance($button);
747
748 $has_button = true;
749 }
750
751 if ($this->object->hasMailConfirmation()) {
752 if ($has_button) {
753 $ilToolbar->addSeparator();
754 }
755
756 if ($ilUser->getId() == ANONYMOUS_USER_ID ||
757 !$ilUser->getEmail()) {
758 require_once "Services/Form/classes/class.ilTextInputGUI.php";
759 $mail = new ilTextInputGUI($this->lng->txt("email"), "mail");
760 $mail->setSize(25);
761 $ilToolbar->addInputItem($mail, true);
762 }
763
764 $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "mailUserResults"));
765
766 $button = ilSubmitButton::getInstance();
767 $button->setCaption("svy_mail_send_confirmation");
768 $button->setCommand("mailUserResults");
769 $ilToolbar->addButtonInstance($button);
770
771 $has_button = true;
772 }
773
774 // #6307
775 if (ilObjSurveyAccess::_hasEvaluationAccess($this->object->getId(), $ilUser->getId())) {
776 $button = ilLinkButton::getInstance();
777 $button->setCaption("svy_results");
778 $button->setUrl($this->ctrl->getLinkTargetByClass("ilObjSurveyGUI", "evaluation"));
779 $ilToolbar->addButtonInstance($button);
780
781 $has_button = true;
782 }
783 }
784
785 if (!$has_button &&
786 strlen($this->object->getOutro()) == 0) {
787 $this->exitSurvey();
788 } else {
789 if ($has_button) {
790 $ilToolbar->addSeparator();
791 }
792
793 $button = ilLinkButton::getInstance();
794 $button->setCaption("survey_execution_exit");
795 $button->setUrl($this->ctrl->getLinkTarget($this, "exitSurvey"));
796 $ilToolbar->addButtonInstance($button);
797
798 if (strlen($this->object->getOutro())) {
800 $panel->setBody($this->object->prepareTextareaOutput($this->object->getOutro()));
801 $this->tpl->setContent($panel->getHTML());
802 }
803 }
804 }
805
806 public function backToRepository()
807 {
809
810 // #14971
811 if ($this->object->get360Mode()) {
812 $target_ref_id = $this->object->getRefId();
813 } else {
814 // #11534
815 $target_ref_id = $tree->getParentId($this->object->getRefId());
816 }
817
818 ilUtil::redirect(ilLink::_getLink($target_ref_id));
819 }
820
828 public function exitSurvey()
829 {
830 if (!$this->preview) {
831 $this->backToRepository();
832 } else {
833 // #12841
834 $this->ctrl->setParameterByClass("ilsurveyeditorgui", "pgov", $_REQUEST["pgov"]);
835 $this->ctrl->redirectByClass(array("ilobjsurveygui", "ilsurveyeditorgui"), "questions");
836 }
837 }
838
848 public function outNavigationButtons($navigationblock = "top", $page, $stpl)
849 {
850 $prevpage = $this->object->getNextPage($page[0]["question_id"], -1);
851 $stpl->setCurrentBlock($navigationblock . "_prev");
852 if ($prevpage === 0) {
853 $stpl->setVariable("BTN_PREV", $this->lng->txt("survey_start"));
854 } else {
855 $stpl->setVariable("BTN_PREV", $this->lng->txt("survey_previous"));
856 }
857 $stpl->parseCurrentBlock();
858 $nextpage = $this->object->getNextPage($page[0]["question_id"], 1);
859 $stpl->setCurrentBlock($navigationblock . "_next");
860 if ($nextpage === 1) {
861 $stpl->setVariable("BTN_NEXT", $this->lng->txt("survey_finish"));
862 } else {
863 $stpl->setVariable("BTN_NEXT", $this->lng->txt("survey_next"));
864 }
865 $stpl->parseCurrentBlock();
866 }
867
868 public function preview()
869 {
870 $this->outSurveyPage();
871 }
872
873 public function viewUserResults()
874 {
875 $ilToolbar = $this->toolbar;
876
877 if (!$this->object->hasViewOwnResults()) {
878 $this->backToRepository();
879 }
880
881 $this->checkAuth(false, true);
882
883 $button = ilLinkButton::getInstance();
884 $button->setCaption("btn_back");
885 $button->setUrl($this->ctrl->getLinkTarget($this, "runShowFinishedPage"));
886 $ilToolbar->addButtonInstance($button);
887
888 $survey_gui = new ilObjSurveyGUI();
889 $html = $survey_gui->getUserResultsTable($_SESSION["finished_id"][$this->object->getId()]);
890 $this->tpl->setContent($html);
891 }
892
893 public function mailUserResults()
894 {
896
897 if (!$this->object->hasMailConfirmation()) {
898 $this->backToRepository();
899 }
900
901 $this->checkAuth(false, true);
902
903 $recipient = $_POST["mail"];
904 if (!$recipient) {
905 $recipient = $ilUser->getEmail();
906 }
907 if (!ilUtil::is_email($recipient)) {
908 $this->ctrl->redirect($this, "runShowFinishedPage");
909 }
910
911 $survey_gui = new ilObjSurveyGUI();
912 $survey_gui->sendUserResultsMail(
913 $_SESSION["finished_id"][$this->object->getId()],
914 $recipient
915 );
916
917 ilUtil::sendSuccess($this->lng->txt("mail_sent"), true);
918 $this->ctrl->redirect($this, "runShowFinishedPage");
919 }
920
921 public function showFinishConfirmation()
922 {
924
925 $cgui = new ilConfirmationGUI();
926 $cgui->setHeaderText($this->lng->txt("survey_execution_sure_finish"));
927
928 $cgui->setFormAction($this->ctrl->getFormAction($this, "confirmedFinish"));
929 $cgui->setCancel($this->lng->txt("cancel"), "previousNoSave");
930 $cgui->setConfirm($this->lng->txt("confirm"), "confirmedFinish");
931
932 $tpl->setContent($cgui->getHTML());
933 }
934
935 public function confirmedFinish()
936 {
938
939 if (!$this->preview) {
940 $this->object->finishSurvey($_SESSION["finished_id"][$this->object->getId()]);
941
942 if ($ilUser->getId() != ANONYMOUS_USER_ID) {
943 ilLPStatusWrapper::_updateStatus($this->object->getId(), $ilUser->getId());
944 }
945
946 if ($this->object->getMailNotification()) {
947 $this->object->sendNotificationMail(
948 $ilUser->getId(),
949 $_SESSION["anonymous_id"][$this->object->getId()],
950 $_SESSION["appr_id"][$this->object->getId()]
951 );
952 }
953 }
954
955 $this->ctrl->redirect($this, "runShowFinishedPage");
956 }
957}
$result
user()
Definition: user.php:4
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static _recordReadEvent( $a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents=true, $a_ext_rc=false, $a_ext_time=false)
Records a read event and catches up with write events.
Confirmation screen class.
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static _tracProgress($a_user_id, $a_obj_id, $a_ref_id, $a_obj_type='')
static getInstance()
Factory.
static getLogger($a_component_id)
Get component logger.
static _hasEvaluationAccess($a_obj_id, $user_id)
Class ilObjSurveyGUI.
static validateExternalRaterCode($a_ref_id, $a_code)
static getInstance()
Get instance.
static getInstance()
Factory.
static getInstance()
Factory.
Survey exception class.
Survey execution graphical output.
previous($a_save_input=true)
Navigates to the previous pages.
getCommand($cmd)
Retrieves the ilCtrl command.
exitSurvey()
Exits the survey after finishing it.
saveUserInput($navigationDirection="next")
Save the user's input.
outNavigationButtons($navigationblock="top", $page, $stpl)
Creates the navigation buttons for a survey.
outSurveyPage($activepage=null, $direction=null)
Output of the active survey question to the screen.
redirectQuestion()
Called when a user answered a page to perform a redirect after POST.
saveActiveQuestionData(&$data)
Survey navigation.
next()
Navigates to the next pages.
checkAuth($a_may_start=false, $a_ignore_status=false)
gotoPage()
Go to a specific page without saving.
compressQuestion($previous_page, $page)
__construct($a_object)
ilSurveyExecutionGUI constructor
runShowFinishedPage()
Creates the finished page for a running survey.
start($resume=false)
Starts the survey.
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
static redirect($a_script)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static is_email($a_email, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
const ANONYMOUS_USER_ID
Definition: constants.php:25
global $DIC
Definition: goto.php:24
help()
Definition: help.php:2
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
Definition: imgupload.php:138
$ilUser
Definition: imgupload.php:18
$ret
Definition: parser.php:6
$data
Definition: storeScorm.php:23