ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilSurveyExecutionGUI Class Reference

Survey execution graphical output. More...

+ Collaboration diagram for ilSurveyExecutionGUI:

Public Member Functions

 ilSurveyExecutionGUI ($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
 
 $ilias
 
 $tree
 
 $preview
 

Protected Member Functions

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

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.

Member Function Documentation

◆ backToRepository()

ilSurveyExecutionGUI::backToRepository ( )

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

797 {
798 global $tree;
799
800 // #14971
801 if($this->object->get360Mode())
802 {
803 $target_ref_id = $this->object->getRefId();
804 }
805 else
806 {
807 // #11534
808 $target_ref_id = $tree->getParentId($this->object->getRefId());
809 }
810
811 include_once "Services/Link/classes/class.ilLink.php";
812 ilUtil::redirect(ilLink::_getLink($target_ref_id));
813 }
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 697 of file class.ilSurveyExecutionGUI.php.

698 {
699 $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
700 }

◆ checkAuth()

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

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

103 {
104 global $rbacsystem, $ilUser;
105
106 if($this->preview)
107 {
108 if(!$rbacsystem->checkAccess("write", $this->object->ref_id))
109 {
110 // only with write access it is possible to preview the survey
111 $this->ilias->raiseError($this->lng->txt("survey_cannot_preview_survey"),$this->ilias->error_obj->MESSAGE);
112 }
113
114 return true;
115 }
116
117 if (!$this->external_rater_360 &&
118 !$rbacsystem->checkAccess("read", $this->object->ref_id))
119 {
120 // only with read access it is possible to run the test
121 $this->ilias->raiseError($this->lng->txt("cannot_read_survey"),$this->ilias->error_obj->MESSAGE);
122 }
123
124 $user_id = $ilUser->getId();
125
126 // check existing code
127 // see ilObjSurveyGUI::infoScreen()
128 $anonymous_id = $anonymous_code = null;
129 if ($this->object->getAnonymize() || !$this->object->isAccessibleWithoutCode())
130 {
131 $anonymous_code = $_SESSION["anonymous_id"][$this->object->getId()];
132 $anonymous_id = $this->object->getAnonymousIdByCode($anonymous_code);
133 if(!$anonymous_id)
134 {
135 ilUtil::sendFailure(sprintf($this->lng->txt("error_retrieving_anonymous_survey"), $anonymous_code, true));
136 $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
137 }
138 }
139
140 // appraisee validation
141 $appr_id = 0;
142 if($this->object->get360Mode())
143 {
144 $appr_id = $_REQUEST["appr_id"];
145 if(!$appr_id)
146 {
147 $appr_id = $_SESSION["appr_id"][$this->object->getId()];
148 }
149 // check if appraisee is valid
150 if($anonymous_id)
151 {
152 $appraisees = $this->object->getAppraiseesToRate(0, $anonymous_id);
153 }
154 if(!$appraisees && $user_id != ANONYMOUS_USER_ID)
155 {
156 $appraisees = $this->object->getAppraiseesToRate($user_id);
157 }
158 if(!in_array($appr_id, $appraisees))
159 {
160 ilUtil::sendFailure($this->lng->txt("survey_360_execution_invalid_appraisee"), true);
161 $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
162 }
163 }
164 $_SESSION["appr_id"][$this->object->getId()] = $appr_id;
165
166 if(!$a_ignore_status)
167 {
168 $status = $this->object->isSurveyStarted($user_id, $anonymous_code, $appr_id);
169 // completed
170 if($status === 1)
171 {
172 ilUtil::sendFailure($this->lng->txt("already_completed_survey"), true);
173 $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
174 }
175 // starting
176 else if ($status === false)
177 {
178 if($a_may_start)
179 {
180 $_SESSION["finished_id"][$this->object->getId()] =
181 $this->object->startSurvey($user_id, $anonymous_code, $appr_id);
182 }
183 else
184 {
185 ilUtil::sendFailure($this->lng->txt("survey_use_start_button"), true);
186 $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
187 }
188 }
189 // resuming
190 else
191 {
192 // nothing todo
193 }
194 }
195
196 // validate finished id
197 if($this->object->getActiveID($user_id, $anonymous_code, $appr_id) !=
198 $_SESSION["finished_id"][$this->object->getId()])
199 {
200 ilUtil::sendFailure($this->lng->txt("cannot_read_survey"), true);
201 $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
202 }
203 }
$_SESSION["AccountId"]
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
redirection script todo: (a better solution should control the processing via a xml file)
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
global $ilUser
Definition: imgupload.php:15

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

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 938 of file class.ilSurveyExecutionGUI.php.

939 {
940 global $ilUser;
941
942 if(!$this->preview)
943 {
944 $this->object->finishSurvey($_SESSION["finished_id"][$this->object->getId()]);
945
946 if($ilUser->getId() != ANONYMOUS_USER_ID)
947 {
948 include_once "Services/Tracking/classes/class.ilLPStatusWrapper.php";
949 ilLPStatusWrapper::_updateStatus($this->object->getId(), $ilUser->getId());
950 }
951
952 if ($this->object->getMailNotification())
953 {
954 $this->object->sendNotificationMail($ilUser->getId(),
955 $_SESSION["anonymous_id"][$this->object->getId()],
956 $_SESSION["appr_id"][$this->object->getId()]);
957 }
958 }
959
960 /*
961 unset($_SESSION["anonymous_id"][$this->object->getId()]);
962 unset($_SESSION["appr_id"][$this->object->getId()]);
963 unset($_SESSION["finished_id"][$this->object->getId()]);
964 */
965
966 $this->ctrl->redirect($this, "runShowFinishedPage");
967 }
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 82 of file class.ilSurveyExecutionGUI.php.

83 {
84 $cmd = $this->ctrl->getCmd();
85 $next_class = $this->ctrl->getNextClass($this);
86
87 $cmd = $this->getCommand($cmd);
88 if (strlen($cmd) == 0)
89 {
90 $this->ctrl->setParameter($this, "qid", $_GET["qid"]);
91 $this->ctrl->redirect($this, "gotoPage");
92 }
93 switch($next_class)
94 {
95 default:
96 $ret =& $this->$cmd();
97 break;
98 }
99 return $ret;
100 }
$_GET["client_id"]
getCommand($cmd)
Retrieves the ilCtrl command.
$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 822 of file class.ilSurveyExecutionGUI.php.

823 {
824 if(!$this->preview)
825 {
826 $this->backToRepository();
827 }
828 else
829 {
830 // #12841
831 $this->ctrl->setParameterByClass("ilsurveyeditorgui", "pgov", $_REQUEST["pgov"]);
832 $this->ctrl->redirectByClass(array("ilobjsurveygui", "ilsurveyeditorgui"), "questions");
833 }
834 }

References $_REQUEST, 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 212 of file class.ilSurveyExecutionGUI.php.

213 {
214 return $cmd;
215 }

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 347 of file class.ilSurveyExecutionGUI.php.

348 {
349 $this->ctrl->setParameter($this, "activecommand", "gotoPage");
350 $this->ctrl->setParameter($this, "qid", $_GET["qid"]);
351 $this->ctrl->setParameter($this, "direction", "0");
352 $this->ctrl->redirect($this, "redirectQuestion");
353 }

References $_GET.

◆ ilSurveyExecutionGUI()

ilSurveyExecutionGUI::ilSurveyExecutionGUI (   $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 53 of file class.ilSurveyExecutionGUI.php.

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

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

+ Here is the call graph for this function:

◆ mailUserResults()

ilSurveyExecutionGUI::mailUserResults ( )

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

899 {
900 if(!$this->object->hasMailOwnResults())
901 {
902 $this->backToRepository();
903 }
904
905 $this->checkAuth(false, true);
906
907 $recipient = $_POST["mail"];
908 if(!ilUtil::is_email($recipient))
909 {
910 $this->ctrl->redirect($this, "runShowFinishedPage");
911 }
912
913 $survey_gui = new ilObjSurveyGUI();
914 $survey_gui->sendUserResultsMail(
915 $_SESSION["finished_id"][$this->object->getId()],
916 $recipient
917 );
918
919 ilUtil::sendSuccess($this->lng->txt("mail_sent"), true);
920 $this->ctrl->redirect($this, "runShowFinishedPage");
921 }
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.
$_POST['username']
Definition: cron.php:12

References $_POST, $_SESSION, 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 326 of file class.ilSurveyExecutionGUI.php.

327 {
328 $result = $this->saveUserInput("next");
329 $this->ctrl->setParameter($this, "activecommand", "next");
330 $this->ctrl->setParameter($this, "qid", $_GET["qid"]);
331 if (strlen($result))
332 {
333 $this->ctrl->setParameter($this, "direction", "0");
334 }
335 else
336 {
337 $this->ctrl->setParameter($this, "direction", "1");
338 }
339 $this->ctrl->redirect($this, "redirectQuestion");
340 }
$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 845 of file class.ilSurveyExecutionGUI.php.

846 {
847 $prevpage = $this->object->getNextPage($page[0]["question_id"], -1);
848 $this->tpl->setCurrentBlock($navigationblock . "_prev");
849 if ($prevpage === 0)
850 {
851 $this->tpl->setVariable("BTN_PREV", $this->lng->txt("survey_start"));
852 }
853 else
854 {
855 $this->tpl->setVariable("BTN_PREV", $this->lng->txt("survey_previous"));
856 }
857 $this->tpl->parseCurrentBlock();
858 $nextpage = $this->object->getNextPage($page[0]["question_id"], 1);
859 $this->tpl->setCurrentBlock($navigationblock . "_next");
860 if ($nextpage === 1)
861 {
862 $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("survey_finish"));
863 }
864 else
865 {
866 $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("survey_next"));
867 }
868 $this->tpl->parseCurrentBlock();
869 }

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 362 of file class.ilSurveyExecutionGUI.php.

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

References $_REQUEST, $_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 871 of file class.ilSurveyExecutionGUI.php.

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

References outSurveyPage().

Referenced by checkAuth(), confirmedFinish(), exitSurvey(), ilSurveyExecutionGUI(), 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 301 of file class.ilSurveyExecutionGUI.php.

302 {
303 if($a_save_input)
304 {
305 // #16209
306 $has_error = $this->saveUserInput("previous");
307 }
308 $this->ctrl->setParameter($this, "activecommand", "previous");
309 $this->ctrl->setParameter($this, "qid", $_GET["qid"]);
310 if (strlen($has_error))
311 {
312 $this->ctrl->setParameter($this, "direction", "0");
313 }
314 else
315 {
316 $this->ctrl->setParameter($this, "direction", "-1");
317 }
318 $this->ctrl->redirect($this, "redirectQuestion");
319 }

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 289 of file class.ilSurveyExecutionGUI.php.

290 {
291 $this->previous(false);
292 }
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 266 of file class.ilSurveyExecutionGUI.php.

267 {
268 switch ($_GET["activecommand"])
269 {
270 case "next":
271 $this->outSurveyPage($_GET["qid"], $_GET["direction"]);
272 break;
273 case "previous":
274 $this->outSurveyPage($_GET["qid"], $_GET["direction"]);
275 break;
276 case "gotoPage":
277 $this->outSurveyPage($_GET["qid"], $_GET["direction"]);
278 break;
279 case "default":
280 $this->outSurveyPage($_GET["qid"]);
281 break;
282 default:
283 // don't save input, go to the first page
284 $this->outSurveyPage();
285 break;
286 }
287 }

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 224 of file class.ilSurveyExecutionGUI.php.

225 {
226 $this->start(true);
227 }
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 709 of file class.ilSurveyExecutionGUI.php.

710 {
711 global $ilToolbar, $ilUser;
712
713 $has_button = false;
714
715 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
716
717 if(!$this->preview)
718 {
719 if($this->object->hasViewOwnResults())
720 {
721 $button = ilLinkButton::getInstance();
722 $button->setCaption("svy_view_own_results");
723 $button->setUrl($this->ctrl->getLinkTarget($this, "viewUserResults"));
724 $ilToolbar->addButtonInstance($button);
725
726 $has_button = true;
727 }
728
729 if($this->object->hasMailOwnResults())
730 {
731 if($has_button)
732 {
733 $ilToolbar->addSeparator();
734 }
735
736 require_once "Services/Form/classes/class.ilTextInputGUI.php";
737 $mail = new ilTextInputGUI($this->lng->txt("email"), "mail");
738 $mail->setSize(25);
739 if($ilUser->getId() != ANONYMOUS_USER_ID)
740 {
741 $mail->setValue($ilUser->getEmail());
742 }
743 $ilToolbar->addInputItem($mail, true);
744
745 $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "mailUserResults"));
746
747 include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
748 $button = ilSubmitButton::getInstance();
749 $button->setCaption("svy_mail_own_results");
750 $button->setCommand("mailUserResults");
751 $ilToolbar->addButtonInstance($button);
752
753 $has_button = true;
754 }
755
756 // #6307
757 include_once "Modules/Survey/classes/class.ilObjSurveyAccess.php";
758 if(ilObjSurveyAccess::_hasEvaluationAccess($this->object->getId(), $ilUser->getId()))
759 {
760 $button = ilLinkButton::getInstance();
761 $button->setCaption("svy_results");
762 $button->setUrl($this->ctrl->getLinkTargetByClass("ilObjSurveyGUI", "evaluation"));
763 $ilToolbar->addButtonInstance($button);
764
765 $has_button = true;
766 }
767 }
768
769 if (!$has_button &&
770 strlen($this->object->getOutro()) == 0)
771 {
772 $this->exitSurvey();
773 }
774 else
775 {
776 if($has_button)
777 {
778 $ilToolbar->addSeparator();
779 }
780
781 $button = ilLinkButton::getInstance();
782 $button->setCaption("survey_execution_exit");
783 $button->setUrl($this->ctrl->getLinkTarget($this, "exitSurvey"));
784 $ilToolbar->addButtonInstance($button);
785
786 if(strlen($this->object->getOutro()))
787 {
788 include_once "Services/UIComponent/Panel/classes/class.ilPanelGUI.php";
789 $panel = ilPanelGUI::getInstance();
790 $panel->setBody($this->object->prepareTextareaOutput($this->object->getOutro()));
791 $this->tpl->setContent($panel->getHTML());
792 }
793 }
794 }
static getInstance()
Factory.
_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 660 of file class.ilSurveyExecutionGUI.php.

661 {
662 global $ilUser;
663
664 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
665 $question =& SurveyQuestion::_instanciateQuestion($data["question_id"]);
666 $error = $question->checkUserInput($_POST, $this->object->getSurveyId());
667 if (strlen($error) == 0)
668 {
669 if(!$this->preview)
670 {
671 // delete old answers
672 $this->object->deleteWorkingData($data["question_id"], $_SESSION["finished_id"][$this->object->getId()]);
673
674 $question->saveUserInput($_POST, $_SESSION["finished_id"][$this->object->getId()]);
675 }
676 else
677 {
678 $_SESSION["preview_data"][$this->object->getId()][$data["question_id"]] =
679 $question->saveUserInput($_POST, $_SESSION["finished_id"][$this->object->getId()], true);
680 }
681 return 0;
682 }
683 else
684 {
685 $_SESSION["svy_errors"][$question->getId()] = $error;
686 return 1;
687 }
688 }
& _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.

References $_POST, $_SESSION, $data, $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 560 of file class.ilSurveyExecutionGUI.php.

561 {
562 if(!$this->preview)
563 {
564 $this->object->setEndTime($_SESSION["finished_id"][$this->object->getId()]);
565 }
566
567 // check users input when it is a metric question
568 unset($_SESSION["svy_errors"]);
569 $_SESSION["postdata"] = $_POST;
570 $page_error = 0;
571 $page = $this->object->getNextPage($_GET["qid"], 0);
572 foreach ($page as $data)
573 {
574 $page_error += $this->saveActiveQuestionData($data);
575 }
576 if ($page_error && (strcmp($navigationDirection, "previous") != 0))
577 {
578 if ($page_error == 1)
579 {
580 ilUtil::sendFailure($this->lng->txt("svy_page_error"), TRUE);
581 }
582 else
583 {
584 ilUtil::sendFailure($this->lng->txt("svy_page_errors"), TRUE);
585 }
586 }
587 else
588 {
589 $page_error = "";
590 unset($_SESSION["svy_errors"]);
591 }
592 return $page_error;
593 }
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 923 of file class.ilSurveyExecutionGUI.php.

924 {
925 global $tpl;
926
927 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
928 $cgui = new ilConfirmationGUI();
929 $cgui->setHeaderText($this->lng->txt("survey_execution_sure_finish"));
930
931 $cgui->setFormAction($this->ctrl->getFormAction($this, "confirmedFinish"));
932 $cgui->setCancel($this->lng->txt("cancel"), "previousNoSave");
933 $cgui->setConfirm($this->lng->txt("confirm"), "confirmedFinish");
934
935 $tpl->setContent($cgui->getHTML());
936 }
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 236 of file class.ilSurveyExecutionGUI.php.

237 {
238 if($this->preview)
239 {
240 unset($_SESSION["preview_data"]);
241 }
242 unset($_SESSION["svy_errors"]);
243
244 $this->checkAuth(!$resume);
245
246 $activepage = "";
247 if ($resume)
248 {
249 $activepage = $this->object->getLastActivePage($_SESSION["finished_id"][$this->object->getId()]);
250 }
251
252 if (strlen($activepage))
253 {
254 $this->ctrl->setParameter($this, "qid", $activepage);
255 }
256 $this->ctrl->setParameter($this, "activecommand", "default");
257 $this->ctrl->redirect($this, "redirectQuestion");
258 }

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 876 of file class.ilSurveyExecutionGUI.php.

877 {
878 global $ilToolbar;
879
880 if(!$this->object->hasViewOwnResults())
881 {
882 $this->backToRepository();
883 }
884
885 $this->checkAuth(false, true);
886
887 include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
888 $button = ilLinkButton::getInstance();
889 $button->setCaption("btn_back");
890 $button->setUrl($this->ctrl->getLinkTarget($this, "runShowFinishedPage"));
891 $ilToolbar->addButtonInstance($button);
892
893 $survey_gui = new ilObjSurveyGUI();
894 $html = $survey_gui->getUserResultsTable($_SESSION["finished_id"][$this->object->getId()]);
895 $this->tpl->setContent($html);
896 }
$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.

◆ $ilias

ilSurveyExecutionGUI::$ilias

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

Referenced by ilSurveyExecutionGUI().

◆ $lng

ilSurveyExecutionGUI::$lng

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

Referenced by ilSurveyExecutionGUI().

◆ $object

ilSurveyExecutionGUI::$object

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

◆ $preview

ilSurveyExecutionGUI::$preview

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

◆ $tpl

ilSurveyExecutionGUI::$tpl

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

Referenced by ilSurveyExecutionGUI(), and showFinishConfirmation().

◆ $tree

ilSurveyExecutionGUI::$tree

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

Referenced by backToRepository(), and ilSurveyExecutionGUI().


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