ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilSurveyExecutionGUI Class Reference

Survey execution graphical output. More...

+ Collaboration diagram for ilSurveyExecutionGUI:

Public Member Functions

 __construct ($a_object)
 ilSurveyExecutionGUI constructor More...
 
 executeCommand ()
 execute command More...
 
 getCommand ($cmd)
 Retrieves the ilCtrl command. More...
 
 resume ()
 Resumes the survey. More...
 
 start ($resume=false)
 Starts the survey. More...
 
 redirectQuestion ()
 Called when a user answered a page to perform a redirect after POST. More...
 
 previousNoSave ()
 
 previous ($a_save_input=true)
 Navigates to the previous pages. More...
 
 next ()
 Navigates to the next pages. More...
 
 gotoPage ()
 Go to a specific page without saving. More...
 
 outSurveyPage ($activepage=NULL, $direction=NULL)
 Output of the active survey question to the screen. More...
 
 saveUserInput ($navigationDirection="next")
 Save the user's input. More...
 
 saveActiveQuestionData (&$data)
 Survey navigation. More...
 
 cancel ()
 Called on cancel. More...
 
 runShowFinishedPage ()
 Creates the finished page for a running survey. More...
 
 backToRepository ()
 
 exitSurvey ()
 Exits the survey after finishing it. More...
 
 outNavigationButtons ($navigationblock="top", $page)
 Creates the navigation buttons for a survey. More...
 
 preview ()
 
 viewUserResults ()
 
 mailUserResults ()
 
 showFinishConfirmation ()
 
 confirmedFinish ()
 

Data Fields

 $object
 
 $lng
 
 $tpl
 
 $ctrl
 
 $tree
 
 $preview
 

Protected Member Functions

 checkAuth ($a_may_start=false, $a_ignore_status=false)
 

Protected Attributes

 $log
 

Detailed Description

Survey execution graphical output.

The ilSurveyExecutionGUI class creates the execution output for the ilObjSurveyGUI class. This saves some heap space because the ilObjSurveyGUI class will be smaller.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
$Id$

Definition at line 35 of file class.ilSurveyExecutionGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilSurveyExecutionGUI::__construct (   $a_object)

ilSurveyExecutionGUI constructor

The constructor takes possible arguments an creates an instance of the ilSurveyExecutionGUI object.

Parameters
object$a_objectAssociated ilObjSurvey class @access public

Definition at line 57 of file class.ilSurveyExecutionGUI.php.

58 {
59 global $lng, $tpl, $ilCtrl, $tree;
60
61 $this->lng = $lng;
62 $this->tpl = $tpl;
63 $this->ctrl = $ilCtrl;
64 $this->object = $a_object;
65 $this->tree = $tree;
66
67 $this->external_rater_360 = false;
68 if($this->object->get360Mode() &&
69 $_SESSION["anonymous_id"][$this->object->getId()] &&
70 ilObjSurvey::validateExternalRaterCode($this->object->getRefId(),
71 $_SESSION["anonymous_id"][$this->object->getId()]))
72 {
73 $this->external_rater_360 = true;
74 }
75
76 // stay in preview mode
77 $this->preview = (bool)$_REQUEST["prvw"];
78 $this->ctrl->saveParameter($this, "prvw");
79 $this->ctrl->saveParameter($this, "pgov");
80
81 $this->log = ilLoggerFactory::getLogger("svy");
82 }
$_SESSION["AccountId"]
static getLogger($a_component_id)
Get component logger.
static validateExternalRaterCode($a_ref_id, $a_code)
global $ilCtrl
Definition: ilias.php:18

References $_SESSION, $ilCtrl, $lng, $tpl, $tree, ilLoggerFactory\getLogger(), preview(), and ilObjSurvey\validateExternalRaterCode().

+ Here is the call graph for this function:

Member Function Documentation

◆ backToRepository()

ilSurveyExecutionGUI::backToRepository ( )

Definition at line 808 of file class.ilSurveyExecutionGUI.php.

809 {
810 global $tree;
811
812 // #14971
813 if($this->object->get360Mode())
814 {
815 $target_ref_id = $this->object->getRefId();
816 }
817 else
818 {
819 // #11534
820 $target_ref_id = $tree->getParentId($this->object->getRefId());
821 }
822
823 include_once "Services/Link/classes/class.ilLink.php";
824 ilUtil::redirect(ilLink::_getLink($target_ref_id));
825 }
static redirect($a_script)
http redirect to other script

References $tree, ilLink\_getLink(), and ilUtil\redirect().

Referenced by exitSurvey(), mailUserResults(), and viewUserResults().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancel()

ilSurveyExecutionGUI::cancel ( )

Called on cancel.

Called on cancel

@access private

Definition at line 709 of file class.ilSurveyExecutionGUI.php.

710 {
711 $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
712 }

◆ checkAuth()

ilSurveyExecutionGUI::checkAuth (   $a_may_start = false,
  $a_ignore_status = false 
)
protected

Definition at line 110 of file class.ilSurveyExecutionGUI.php.

111 {
112 global $rbacsystem, $ilUser;
113
114 if($this->preview)
115 {
116 if(!$rbacsystem->checkAccess("write", $this->object->ref_id))
117 {
118 // only with write access it is possible to preview the survey
119 include_once "Modules/Survey/exceptions/class.ilSurveyException.php";
120 throw new ilSurveyException($this->lng->txt("survey_cannot_preview_survey"));
121 }
122
123 return true;
124 }
125
126 if (!$this->external_rater_360 &&
127 !$rbacsystem->checkAccess("read", $this->object->ref_id))
128 {
129 // only with read access it is possible to run the test
130 include_once "Modules/Survey/exceptions/class.ilSurveyException.php";
131 throw new ilSurveyException($this->lng->txt("cannot_read_survey"));
132 }
133
134 $user_id = $ilUser->getId();
135
136 // check existing code
137 // see ilObjSurveyGUI::infoScreen()
138 $anonymous_id = $anonymous_code = null;
139 if ($this->object->getAnonymize() || !$this->object->isAccessibleWithoutCode())
140 {
141 $anonymous_code = $_SESSION["anonymous_id"][$this->object->getId()];
142 $anonymous_id = $this->object->getAnonymousIdByCode($anonymous_code);
143 if(!$anonymous_id)
144 {
145 ilUtil::sendFailure(sprintf($this->lng->txt("error_retrieving_anonymous_survey"), $anonymous_code, true));
146 $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
147 }
148 }
149
150 // appraisee validation
151 $appr_id = 0;
152 if($this->object->get360Mode())
153 {
154 $appr_id = $_REQUEST["appr_id"];
155 if(!$appr_id)
156 {
157 $appr_id = $_SESSION["appr_id"][$this->object->getId()];
158 }
159 // check if appraisee is valid
160 if($anonymous_id)
161 {
162 $appraisees = $this->object->getAppraiseesToRate(0, $anonymous_id);
163 }
164 if(!$appraisees && $user_id != ANONYMOUS_USER_ID)
165 {
166 $appraisees = $this->object->getAppraiseesToRate($user_id);
167 }
168 if(!in_array($appr_id, $appraisees))
169 {
170 ilUtil::sendFailure($this->lng->txt("survey_360_execution_invalid_appraisee"), true);
171 $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
172 }
173 }
174 $_SESSION["appr_id"][$this->object->getId()] = $appr_id;
175
176 if(!$a_ignore_status)
177 {
178 $status = $this->object->isSurveyStarted($user_id, $anonymous_code, $appr_id);
179 // completed
180 if($status === 1)
181 {
182 ilUtil::sendFailure($this->lng->txt("already_completed_survey"), true);
183 $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
184 }
185 // starting
186 else if ($status === false)
187 {
188 if($a_may_start)
189 {
190 $_SESSION["finished_id"][$this->object->getId()] =
191 $this->object->startSurvey($user_id, $anonymous_code, $appr_id);
192 }
193 else
194 {
195 ilUtil::sendFailure($this->lng->txt("survey_use_start_button"), true);
196 $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
197 }
198 }
199 // resuming
200 else
201 {
202 // nothing todo
203 }
204 }
205
206 // validate finished id
207 if($this->object->getActiveID($user_id, $anonymous_code, $appr_id) !=
208 $_SESSION["finished_id"][$this->object->getId()])
209 {
210 ilUtil::sendFailure($this->lng->txt("cannot_read_survey"), true);
211 $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
212 }
213 }
sprintf('%.4f', $callTime)
Survey exception class.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$ilUser
Definition: imgupload.php:18

References $_SESSION, $ilUser, preview(), ilUtil\sendFailure(), and sprintf.

Referenced by mailUserResults(), outSurveyPage(), start(), and viewUserResults().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmedFinish()

ilSurveyExecutionGUI::confirmedFinish ( )

Definition at line 956 of file class.ilSurveyExecutionGUI.php.

957 {
958 global $ilUser;
959
960 if(!$this->preview)
961 {
962 $this->object->finishSurvey($_SESSION["finished_id"][$this->object->getId()]);
963
964 if($ilUser->getId() != ANONYMOUS_USER_ID)
965 {
966 include_once "Services/Tracking/classes/class.ilLPStatusWrapper.php";
967 ilLPStatusWrapper::_updateStatus($this->object->getId(), $ilUser->getId());
968 }
969
970 if ($this->object->getMailNotification())
971 {
972 $this->object->sendNotificationMail($ilUser->getId(),
973 $_SESSION["anonymous_id"][$this->object->getId()],
974 $_SESSION["appr_id"][$this->object->getId()]);
975 }
976 }
977
978 /*
979 unset($_SESSION["anonymous_id"][$this->object->getId()]);
980 unset($_SESSION["appr_id"][$this->object->getId()]);
981 unset($_SESSION["finished_id"][$this->object->getId()]);
982 */
983
984 $this->ctrl->redirect($this, "runShowFinishedPage");
985 }
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.

References $_SESSION, $ilUser, ilLPStatusWrapper\_updateStatus(), and preview().

+ Here is the call graph for this function:

◆ executeCommand()

ilSurveyExecutionGUI::executeCommand ( )

execute command

Definition at line 87 of file class.ilSurveyExecutionGUI.php.

88 {
89 $cmd = $this->ctrl->getCmd();
90 $next_class = $this->ctrl->getNextClass($this);
91
92 $cmd = $this->getCommand($cmd);
93
94 $this->log->debug("- cmd= ".$cmd);
95
96 if (strlen($cmd) == 0)
97 {
98 $this->ctrl->setParameter($this, "qid", $_GET["qid"]);
99 $this->ctrl->redirect($this, "gotoPage");
100 }
101 switch($next_class)
102 {
103 default:
104 $ret =& $this->$cmd();
105 break;
106 }
107 return $ret;
108 }
$_GET["client_id"]
getCommand($cmd)
Retrieves the ilCtrl command.
$ret
Definition: parser.php:6
$cmd
Definition: sahs_server.php:35

References $_GET, $cmd, $ret, and getCommand().

+ Here is the call graph for this function:

◆ exitSurvey()

ilSurveyExecutionGUI::exitSurvey ( )

Exits the survey after finishing it.

Exits the survey after finishing it

@access public

Definition at line 834 of file class.ilSurveyExecutionGUI.php.

835 {
836 if(!$this->preview)
837 {
838 $this->backToRepository();
839 }
840 else
841 {
842 // #12841
843 $this->ctrl->setParameterByClass("ilsurveyeditorgui", "pgov", $_REQUEST["pgov"]);
844 $this->ctrl->redirectByClass(array("ilobjsurveygui", "ilsurveyeditorgui"), "questions");
845 }
846 }

References backToRepository(), and preview().

Referenced by runShowFinishedPage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCommand()

ilSurveyExecutionGUI::getCommand (   $cmd)

Retrieves the ilCtrl command.

Retrieves the ilCtrl command

@access public

Definition at line 222 of file class.ilSurveyExecutionGUI.php.

223 {
224 return $cmd;
225 }

References $cmd.

Referenced by executeCommand().

+ Here is the caller graph for this function:

◆ gotoPage()

ilSurveyExecutionGUI::gotoPage ( )

Go to a specific page without saving.

@access private

Definition at line 357 of file class.ilSurveyExecutionGUI.php.

358 {
359 $this->ctrl->setParameter($this, "activecommand", "gotoPage");
360 $this->ctrl->setParameter($this, "qid", $_GET["qid"]);
361 $this->ctrl->setParameter($this, "direction", "0");
362 $this->ctrl->redirect($this, "redirectQuestion");
363 }

References $_GET.

◆ mailUserResults()

ilSurveyExecutionGUI::mailUserResults ( )

Definition at line 910 of file class.ilSurveyExecutionGUI.php.

911 {
912 global $ilUser;
913
914 if(!$this->object->hasMailConfirmation())
915 {
916 $this->backToRepository();
917 }
918
919 $this->checkAuth(false, true);
920
921 $recipient = $_POST["mail"];
922 if(!$recipient)
923 {
924 $recipient = $ilUser->getEmail();
925 }
926 if(!ilUtil::is_email($recipient))
927 {
928 $this->ctrl->redirect($this, "runShowFinishedPage");
929 }
930
931 $survey_gui = new ilObjSurveyGUI();
932 $survey_gui->sendUserResultsMail(
933 $_SESSION["finished_id"][$this->object->getId()],
934 $recipient
935 );
936
937 ilUtil::sendSuccess($this->lng->txt("mail_sent"), true);
938 $this->ctrl->redirect($this, "runShowFinishedPage");
939 }
$_POST["username"]
Class ilObjSurveyGUI.
checkAuth($a_may_start=false, $a_ignore_status=false)
static is_email($a_email)
This preg-based function checks whether an e-mail address is formally valid.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.

References $_POST, $_SESSION, $ilUser, backToRepository(), checkAuth(), ilUtil\is_email(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ next()

ilSurveyExecutionGUI::next ( )

Navigates to the next pages.

@access private

Definition at line 336 of file class.ilSurveyExecutionGUI.php.

337 {
338 $result = $this->saveUserInput("next");
339 $this->ctrl->setParameter($this, "activecommand", "next");
340 $this->ctrl->setParameter($this, "qid", $_GET["qid"]);
341 if (strlen($result))
342 {
343 $this->ctrl->setParameter($this, "direction", "0");
344 }
345 else
346 {
347 $this->ctrl->setParameter($this, "direction", "1");
348 }
349 $this->ctrl->redirect($this, "redirectQuestion");
350 }
$result
saveUserInput($navigationDirection="next")
Save the user's input.

References $_GET, $result, and saveUserInput().

+ Here is the call graph for this function:

◆ outNavigationButtons()

ilSurveyExecutionGUI::outNavigationButtons (   $navigationblock = "top",
  $page 
)

Creates the navigation buttons for a survey.

Creates the navigation buttons for a survey. Runs twice to generate a top and a bottom navigation to ease the use of long forms.

@access public

Definition at line 857 of file class.ilSurveyExecutionGUI.php.

858 {
859 $prevpage = $this->object->getNextPage($page[0]["question_id"], -1);
860 $this->tpl->setCurrentBlock($navigationblock . "_prev");
861 if ($prevpage === 0)
862 {
863 $this->tpl->setVariable("BTN_PREV", $this->lng->txt("survey_start"));
864 }
865 else
866 {
867 $this->tpl->setVariable("BTN_PREV", $this->lng->txt("survey_previous"));
868 }
869 $this->tpl->parseCurrentBlock();
870 $nextpage = $this->object->getNextPage($page[0]["question_id"], 1);
871 $this->tpl->setCurrentBlock($navigationblock . "_next");
872 if ($nextpage === 1)
873 {
874 $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("survey_finish"));
875 }
876 else
877 {
878 $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("survey_next"));
879 }
880 $this->tpl->parseCurrentBlock();
881 }

Referenced by outSurveyPage().

+ Here is the caller graph for this function:

◆ outSurveyPage()

ilSurveyExecutionGUI::outSurveyPage (   $activepage = NULL,
  $direction = NULL 
)

Output of the active survey question to the screen.

Output of the active survey question to the screen

@access private

Definition at line 372 of file class.ilSurveyExecutionGUI.php.

373 {
374 global $ilUser;
375
376 $this->checkAuth();
377
378 $page = $this->object->getNextPage($activepage, $direction);
379 $constraint_true = 0;
380
381 // check for constraints
382 if (count($page[0]["constraints"]))
383 {
384 $this->log->debug("Page constraints= ", $page[0]["constraints"]);
385
386 while (is_array($page) and ($constraint_true == 0) and (count($page[0]["constraints"])))
387 {
388 $constraint_true = ($page[0]['constraints'][0]['conjunction'] == 0) ? true : false;
389 foreach ($page[0]["constraints"] as $constraint)
390 {
391 if(!$this->preview)
392 {
393 $working_data = $this->object->loadWorkingData($constraint["question"], $_SESSION["finished_id"][$this->object->getId()]);
394 }
395 else
396 {
397 $working_data = $_SESSION["preview_data"][$this->object->getId()][$constraint["question"]];
398 }
399 if ($constraint['conjunction'] == 0)
400 {
401 // and
402 $constraint_true = $constraint_true & $this->object->checkConstraint($constraint, $working_data);
403 }
404 else
405 {
406 // or
407 $constraint_true = $constraint_true | $this->object->checkConstraint($constraint, $working_data);
408 }
409 }
410 if ($constraint_true == 0)
411 {
412 // #11047 - we are skipping the page, so we have to get rid of existing answers for that question(s)
413 foreach($page as $page_question)
414 {
415 $qid = $page_question["question_id"];
416
417 // see saveActiveQuestionData()
418 if(!$this->preview)
419 {
420 $this->object->deleteWorkingData($qid, $_SESSION["finished_id"][$this->object->getId()]);
421 }
422 else
423 {
424 $_SESSION["preview_data"][$this->object->getId()][$qid] = null;
425 }
426 }
427
428 $page = $this->object->getNextPage($page[0]["question_id"], $direction);
429 }
430 }
431 }
432
433 $first_question = -1;
434 if ($page === 0)
435 {
436 $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
437 }
438 else if ($page === 1)
439 {
440 $state = $this->object->getUserSurveyExecutionStatus();
441 if($this->preview ||
442 !$state["runs"][$_SESSION["finished_id"][$this->object->getId()]]["finished"])
443 {
444 $this->showFinishConfirmation();
445 }
446 else
447 {
448 $this->runShowFinishedPage();
449 }
450 return;
451 }
452 else
453 {
454 global $ilHelp;
455 $ilHelp->setScreenIdComponent("svy");
456 $ilHelp->setScreenId("quest_presentation");
457
458 if($ilUser->getId() != ANONYMOUS_USER_ID)
459 {
460 include_once "Services/Tracking/classes/class.ilLearningProgress.php";
461 ilLearningProgress::_tracProgress($ilUser->getId(), $this->object->getId(), $this->object->ref_id, "svy");
462 }
463
464 $required = false;
465 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_content.html", "Modules/Survey");
466
467 if($this->object->get360Mode())
468 {
469 $appr_id = $_SESSION["appr_id"][$this->object->getId()];
470
471 include_once "Services/User/classes/class.ilUserUtil.php";
472 $this->tpl->setTitle($this->object->getTitle()." (".
473 $this->lng->txt("survey_360_appraisee").": ".
474 ilUserUtil::getNamePresentation($appr_id).")");
475 }
476
477 if (!($this->object->getAnonymize() && $this->object->isAccessibleWithoutCode() && ($ilUser->getId() == ANONYMOUS_USER_ID)))
478 {
479 $this->tpl->setCurrentBlock("suspend_survey");
480
481 if(!$this->preview)
482 {
483 $this->tpl->setVariable("TEXT_SUSPEND", $this->lng->txt("cancel_survey"));
484 $this->tpl->setVariable("HREF_SUSPEND", $this->ctrl->getLinkTargetByClass("ilObjSurveyGUI", "infoScreen"));
485 }
486 else
487 {
488 $this->ctrl->setParameterByClass("ilObjSurveyGUI", "pgov", $_REQUEST["pgov"]);
489 $this->tpl->setVariable("TEXT_SUSPEND", $this->lng->txt("survey_cancel_preview"));
490 $this->tpl->setVariable("HREF_SUSPEND", $this->ctrl->getLinkTargetByClass(array("ilObjSurveyGUI", "ilSurveyEditorGUI"), "questions"));
491 }
492
493 $this->tpl->setVariable("ALT_IMG_SUSPEND", $this->lng->txt("cancel_survey"));
494 $this->tpl->setVariable("TITLE_IMG_SUSPEND", $this->lng->txt("cancel_survey"));
495 $this->tpl->parseCurrentBlock();
496 }
497 $this->outNavigationButtons("top", $page);
498
499
500 $this->tpl->setCurrentBlock("percentage");
501
502 $percentage = (int)(($page[0]["position"])*100);
503
504 include_once "Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php";
506 $pbar->setCurrent($percentage);
507 $this->tpl->setVariable("NEW_PBAR", $pbar->render());
508
509 $this->tpl->parseCurrentBlock();
510
511
512 if (count($page) > 1 && $page[0]["questionblock_show_blocktitle"])
513 {
514 $this->tpl->setCurrentBlock("questionblock_title");
515 $this->tpl->setVariable("TEXT_QUESTIONBLOCK_TITLE", $page[0]["questionblock_title"]);
516 $this->tpl->parseCurrentBlock();
517 }
518 foreach ($page as $data)
519 {
520 $this->tpl->setCurrentBlock("survey_content");
521 if ($data["heading"])
522 {
523 $this->tpl->setVariable("QUESTION_HEADING", $data["heading"]);
524 }
525 if ($first_question == -1) $first_question = $data["question_id"];
526 $question_gui = $this->object->getQuestionGUI($data["type_tag"], $data["question_id"]);
527 if (is_array($_SESSION["svy_errors"]))
528 {
529 $working_data =& $question_gui->object->getWorkingDataFromUserInput($_SESSION["postdata"]);
530 }
531 else
532 {
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 {
539 $error_messages = $_SESSION["svy_errors"];
540 }
541 $show_questiontext = ($data["questionblock_show_questiontext"]) ? 1 : 0;
542 $question_output = $question_gui->getWorkingForm($working_data, $this->object->getShowQuestionTitles(), $show_questiontext, $error_messages[$data["question_id"]], $this->object->getSurveyId());
543 $this->tpl->setVariable("QUESTION_OUTPUT", $question_output);
544 $this->ctrl->setParameter($this, "qid", $data["question_id"]);
545 $this->tpl->parse("survey_content");
546 if ($data["obligatory"]) $required = true;
547 }
548 if ($required)
549 {
550 $this->tpl->setCurrentBlock("required");
551 $this->tpl->setVariable("TEXT_REQUIRED", $this->lng->txt("required_field"));
552 $this->tpl->parseCurrentBlock();
553 }
554
555 $this->outNavigationButtons("bottom", $page);
556
557 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "redirectQuestion"));
558 }
559
560 if(!$this->preview)
561 {
562 $this->object->setPage($_SESSION["finished_id"][$this->object->getId()], $page[0]['question_id']);
563 $this->object->setStartTime($_SESSION["finished_id"][$this->object->getId()], $first_question);
564 }
565 }
static _tracProgress($a_user_id, $a_obj_id, $a_ref_id, $a_obj_type='')
static getInstance()
Factory.
outNavigationButtons($navigationblock="top", $page)
Creates the navigation buttons for a survey.
runShowFinishedPage()
Creates the finished page for a running survey.
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)
Default behaviour is:
$error_messages

References $_SESSION, $data, $error_messages, $ilUser, ilLearningProgress\_tracProgress(), checkAuth(), ilProgressBar\getInstance(), ilUserUtil\getNamePresentation(), outNavigationButtons(), preview(), runShowFinishedPage(), and showFinishConfirmation().

Referenced by preview(), and redirectQuestion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ preview()

ilSurveyExecutionGUI::preview ( )

Definition at line 883 of file class.ilSurveyExecutionGUI.php.

884 {
885 $this->outSurveyPage();
886 }
outSurveyPage($activepage=NULL, $direction=NULL)
Output of the active survey question to the screen.

References outSurveyPage().

Referenced by __construct(), checkAuth(), confirmedFinish(), exitSurvey(), outSurveyPage(), runShowFinishedPage(), saveActiveQuestionData(), saveUserInput(), and start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ previous()

ilSurveyExecutionGUI::previous (   $a_save_input = true)

Navigates to the previous pages.

Navigates to the previous pages

@access private

Definition at line 311 of file class.ilSurveyExecutionGUI.php.

312 {
313 if($a_save_input)
314 {
315 // #16209
316 $has_error = $this->saveUserInput("previous");
317 }
318 $this->ctrl->setParameter($this, "activecommand", "previous");
319 $this->ctrl->setParameter($this, "qid", $_GET["qid"]);
320 if (strlen($has_error))
321 {
322 $this->ctrl->setParameter($this, "direction", "0");
323 }
324 else
325 {
326 $this->ctrl->setParameter($this, "direction", "-1");
327 }
328 $this->ctrl->redirect($this, "redirectQuestion");
329 }

References $_GET, and saveUserInput().

Referenced by previousNoSave().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ previousNoSave()

ilSurveyExecutionGUI::previousNoSave ( )

Definition at line 299 of file class.ilSurveyExecutionGUI.php.

300 {
301 $this->previous(false);
302 }
previous($a_save_input=true)
Navigates to the previous pages.

References previous().

+ Here is the call graph for this function:

◆ redirectQuestion()

ilSurveyExecutionGUI::redirectQuestion ( )

Called when a user answered a page to perform a redirect after POST.

This is called for security reasons to prevent users sending a form twice.

@access public

Definition at line 276 of file class.ilSurveyExecutionGUI.php.

277 {
278 switch ($_GET["activecommand"])
279 {
280 case "next":
281 $this->outSurveyPage($_GET["qid"], $_GET["direction"]);
282 break;
283 case "previous":
284 $this->outSurveyPage($_GET["qid"], $_GET["direction"]);
285 break;
286 case "gotoPage":
287 $this->outSurveyPage($_GET["qid"], $_GET["direction"]);
288 break;
289 case "default":
290 $this->outSurveyPage($_GET["qid"]);
291 break;
292 default:
293 // don't save input, go to the first page
294 $this->outSurveyPage();
295 break;
296 }
297 }

References $_GET, and outSurveyPage().

+ Here is the call graph for this function:

◆ resume()

ilSurveyExecutionGUI::resume ( )

Resumes the survey.

Resumes the survey

@access private

Definition at line 234 of file class.ilSurveyExecutionGUI.php.

235 {
236 $this->start(true);
237 }
start($resume=false)
Starts the survey.

References start().

+ Here is the call graph for this function:

◆ runShowFinishedPage()

ilSurveyExecutionGUI::runShowFinishedPage ( )

Creates the finished page for a running survey.

Creates the finished page for a running survey

@access public

Definition at line 721 of file class.ilSurveyExecutionGUI.php.

722 {
723 global $ilToolbar, $ilUser;
724
725 $has_button = false;
726
727 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
728
729 if(!$this->preview)
730 {
731 if($this->object->hasViewOwnResults())
732 {
733 $button = ilLinkButton::getInstance();
734 $button->setCaption("svy_view_own_results");
735 $button->setUrl($this->ctrl->getLinkTarget($this, "viewUserResults"));
736 $ilToolbar->addButtonInstance($button);
737
738 $has_button = true;
739 }
740
741 if($this->object->hasMailConfirmation())
742 {
743 if($has_button)
744 {
745 $ilToolbar->addSeparator();
746 }
747
748 if($ilUser->getId() == ANONYMOUS_USER_ID ||
749 !$ilUser->getEmail())
750 {
751 require_once "Services/Form/classes/class.ilTextInputGUI.php";
752 $mail = new ilTextInputGUI($this->lng->txt("email"), "mail");
753 $mail->setSize(25);
754 $ilToolbar->addInputItem($mail, true);
755 }
756
757 $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "mailUserResults"));
758
759 include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
760 $button = ilSubmitButton::getInstance();
761 $button->setCaption("svy_mail_send_confirmation");
762 $button->setCommand("mailUserResults");
763 $ilToolbar->addButtonInstance($button);
764
765 $has_button = true;
766 }
767
768 // #6307
769 include_once "Modules/Survey/classes/class.ilObjSurveyAccess.php";
770 if(ilObjSurveyAccess::_hasEvaluationAccess($this->object->getId(), $ilUser->getId()))
771 {
772 $button = ilLinkButton::getInstance();
773 $button->setCaption("svy_results");
774 $button->setUrl($this->ctrl->getLinkTargetByClass("ilObjSurveyGUI", "evaluation"));
775 $ilToolbar->addButtonInstance($button);
776
777 $has_button = true;
778 }
779 }
780
781 if (!$has_button &&
782 strlen($this->object->getOutro()) == 0)
783 {
784 $this->exitSurvey();
785 }
786 else
787 {
788 if($has_button)
789 {
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()))
799 {
800 include_once "Services/UIComponent/Panel/classes/class.ilPanelGUI.php";
801 $panel = ilPanelGUI::getInstance();
802 $panel->setBody($this->object->prepareTextareaOutput($this->object->getOutro()));
803 $this->tpl->setContent($panel->getHTML());
804 }
805 }
806 }
static getInstance()
Factory.
static _hasEvaluationAccess($a_obj_id, $user_id)
static getInstance()
Get instance.
static getInstance()
Factory.
exitSurvey()
Exits the survey after finishing it.
This class represents a text property in a property form.

References $ilUser, ilObjSurveyAccess\_hasEvaluationAccess(), exitSurvey(), ilLinkButton\getInstance(), ilSubmitButton\getInstance(), ilPanelGUI\getInstance(), and preview().

Referenced by outSurveyPage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveActiveQuestionData()

ilSurveyExecutionGUI::saveActiveQuestionData ( $data)

Survey navigation.

Survey navigation

@access private Saves the users input of the active page

Saves the users input of the active page

@access private

Definition at line 672 of file class.ilSurveyExecutionGUI.php.

673 {
674 global $ilUser;
675
676 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
677 $question =& SurveyQuestion::_instanciateQuestion($data["question_id"]);
678 $error = $question->checkUserInput($_POST, $this->object->getSurveyId());
679 if (strlen($error) == 0)
680 {
681 if(!$this->preview)
682 {
683 // delete old answers
684 $this->object->deleteWorkingData($data["question_id"], $_SESSION["finished_id"][$this->object->getId()]);
685
686 $question->saveUserInput($_POST, $_SESSION["finished_id"][$this->object->getId()]);
687 }
688 else
689 {
690 $_SESSION["preview_data"][$this->object->getId()][$data["question_id"]] =
691 $question->saveUserInput($_POST, $_SESSION["finished_id"][$this->object->getId()], true);
692 }
693 return 0;
694 }
695 else
696 {
697 $_SESSION["svy_errors"][$question->getId()] = $error;
698 return 1;
699 }
700 }
$error
Definition: Error.php:17
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.

References $_POST, $_SESSION, $data, $error, $ilUser, SurveyQuestion\_instanciateQuestion(), and preview().

Referenced by saveUserInput().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveUserInput()

ilSurveyExecutionGUI::saveUserInput (   $navigationDirection = "next")

Save the user's input.

@access private

Definition at line 572 of file class.ilSurveyExecutionGUI.php.

573 {
574 if(!$this->preview)
575 {
576 $this->object->setEndTime($_SESSION["finished_id"][$this->object->getId()]);
577 }
578
579 // check users input when it is a metric question
580 unset($_SESSION["svy_errors"]);
581 $_SESSION["postdata"] = $_POST;
582 $page_error = 0;
583 $page = $this->object->getNextPage($_GET["qid"], 0);
584 foreach ($page as $data)
585 {
586 $page_error += $this->saveActiveQuestionData($data);
587 }
588 if ($page_error && (strcmp($navigationDirection, "previous") != 0))
589 {
590 if ($page_error == 1)
591 {
592 ilUtil::sendFailure($this->lng->txt("svy_page_error"), TRUE);
593 }
594 else
595 {
596 ilUtil::sendFailure($this->lng->txt("svy_page_errors"), TRUE);
597 }
598 }
599 else
600 {
601 $page_error = "";
602 unset($_SESSION["svy_errors"]);
603 }
604 return $page_error;
605 }
saveActiveQuestionData(&$data)
Survey navigation.

References $_GET, $_POST, $_SESSION, $data, preview(), saveActiveQuestionData(), and ilUtil\sendFailure().

Referenced by next(), and previous().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showFinishConfirmation()

ilSurveyExecutionGUI::showFinishConfirmation ( )

Definition at line 941 of file class.ilSurveyExecutionGUI.php.

942 {
943 global $tpl;
944
945 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
946 $cgui = new ilConfirmationGUI();
947 $cgui->setHeaderText($this->lng->txt("survey_execution_sure_finish"));
948
949 $cgui->setFormAction($this->ctrl->getFormAction($this, "confirmedFinish"));
950 $cgui->setCancel($this->lng->txt("cancel"), "previousNoSave");
951 $cgui->setConfirm($this->lng->txt("confirm"), "confirmedFinish");
952
953 $tpl->setContent($cgui->getHTML());
954 }
Confirmation screen class.

References $tpl.

Referenced by outSurveyPage().

+ Here is the caller graph for this function:

◆ start()

ilSurveyExecutionGUI::start (   $resume = false)

Starts the survey.

Starts the survey

@access private

Definition at line 246 of file class.ilSurveyExecutionGUI.php.

247 {
248 if($this->preview)
249 {
250 unset($_SESSION["preview_data"]);
251 }
252 unset($_SESSION["svy_errors"]);
253
254 $this->checkAuth(!$resume);
255
256 $activepage = "";
257 if ($resume)
258 {
259 $activepage = $this->object->getLastActivePage($_SESSION["finished_id"][$this->object->getId()]);
260 }
261
262 if (strlen($activepage))
263 {
264 $this->ctrl->setParameter($this, "qid", $activepage);
265 }
266 $this->ctrl->setParameter($this, "activecommand", "default");
267 $this->ctrl->redirect($this, "redirectQuestion");
268 }

References $_SESSION, checkAuth(), and preview().

Referenced by resume().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ viewUserResults()

ilSurveyExecutionGUI::viewUserResults ( )

Definition at line 888 of file class.ilSurveyExecutionGUI.php.

889 {
890 global $ilToolbar;
891
892 if(!$this->object->hasViewOwnResults())
893 {
894 $this->backToRepository();
895 }
896
897 $this->checkAuth(false, true);
898
899 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
900 $button = ilLinkButton::getInstance();
901 $button->setCaption("btn_back");
902 $button->setUrl($this->ctrl->getLinkTarget($this, "runShowFinishedPage"));
903 $ilToolbar->addButtonInstance($button);
904
905 $survey_gui = new ilObjSurveyGUI();
906 $html = $survey_gui->getUserResultsTable($_SESSION["finished_id"][$this->object->getId()]);
907 $this->tpl->setContent($html);
908 }
$html
Definition: example_001.php:87

References $_SESSION, $html, backToRepository(), checkAuth(), and ilLinkButton\getInstance().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilSurveyExecutionGUI::$ctrl

Definition at line 40 of file class.ilSurveyExecutionGUI.php.

◆ $lng

ilSurveyExecutionGUI::$lng

Definition at line 38 of file class.ilSurveyExecutionGUI.php.

Referenced by __construct().

◆ $log

ilSurveyExecutionGUI::$log
protected

Definition at line 47 of file class.ilSurveyExecutionGUI.php.

◆ $object

ilSurveyExecutionGUI::$object

Definition at line 37 of file class.ilSurveyExecutionGUI.php.

◆ $preview

ilSurveyExecutionGUI::$preview

Definition at line 42 of file class.ilSurveyExecutionGUI.php.

◆ $tpl

ilSurveyExecutionGUI::$tpl

Definition at line 39 of file class.ilSurveyExecutionGUI.php.

Referenced by __construct(), and showFinishConfirmation().

◆ $tree

ilSurveyExecutionGUI::$tree

Definition at line 41 of file class.ilSurveyExecutionGUI.php.

Referenced by __construct(), and backToRepository().


The documentation for this class was generated from the following file: