ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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, $stpl)
 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

 $rbacsystem
 
 $user
 
 $help
 
 $toolbar
 
 $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 public

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

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

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  }
$_SESSION["AccountId"]
static validateExternalRaterCode($a_ref_id, $a_code)
user()
Definition: user.php:4
global $ilCtrl
Definition: ilias.php:18
help()
Definition: help.php:2
$DIC
Definition: xapitoken.php:46
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

Member Function Documentation

◆ backToRepository()

ilSurveyExecutionGUI::backToRepository ( )

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

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

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

761  {
762  $tree = $this->tree;
763 
764  // #14971
765  if ($this->object->get360Mode()) {
766  $target_ref_id = $this->object->getRefId();
767  } else {
768  // #11534
769  $target_ref_id = $tree->getParentId($this->object->getRefId());
770  }
771 
772  ilUtil::redirect(ilLink::_getLink($target_ref_id));
773  }
static redirect($a_script)
+ 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

private

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

676  {
677  $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
678  }

◆ checkAuth()

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

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

References $_SESSION, $ilUser, $rbacsystem, $user, ilObjSurvey\MODE_SELF_EVAL, preview(), and ilUtil\sendFailure().

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

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  }
$_SESSION["AccountId"]
Survey exception class.
$ilUser
Definition: imgupload.php:18
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmedFinish()

ilSurveyExecutionGUI::confirmedFinish ( )

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

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

890  {
892 
893  if (!$this->preview) {
894  $this->object->finishSurvey($_SESSION["finished_id"][$this->object->getId()]);
895 
896  if ($ilUser->getId() != ANONYMOUS_USER_ID) {
897  ilLPStatusWrapper::_updateStatus($this->object->getId(), $ilUser->getId());
898  }
899 
900  if ($this->object->getMailNotification()) {
901  $this->object->sendNotificationMail(
902  $ilUser->getId(),
903  $_SESSION["anonymous_id"][$this->object->getId()],
904  $_SESSION["appr_id"][$this->object->getId()]
905  );
906  }
907  }
908 
909  $this->ctrl->redirect($this, "runShowFinishedPage");
910  }
$_SESSION["AccountId"]
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
$ilUser
Definition: imgupload.php:18
+ Here is the call graph for this function:

◆ executeCommand()

ilSurveyExecutionGUI::executeCommand ( )

execute command

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

References $_GET, $GLOBALS, $ret, ilChangeEvent\_recordReadEvent(), and getCommand().

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  }
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.
getCommand($cmd)
Retrieves the ilCtrl command.
$_GET["client_id"]
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$ret
Definition: parser.php:6
+ Here is the call graph for this function:

◆ exitSurvey()

ilSurveyExecutionGUI::exitSurvey ( )

Exits the survey after finishing it.

Exits the survey after finishing it

public

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

References backToRepository(), and preview().

Referenced by runShowFinishedPage().

783  {
784  if (!$this->preview) {
785  $this->backToRepository();
786  } else {
787  // #12841
788  $this->ctrl->setParameterByClass("ilsurveyeditorgui", "pgov", $_REQUEST["pgov"]);
789  $this->ctrl->redirectByClass(array("ilobjsurveygui", "ilsurveyeditorgui"), "questions");
790  }
791  }
+ 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

public

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

Referenced by executeCommand().

246  {
247  return $cmd;
248  }
+ Here is the caller graph for this function:

◆ gotoPage()

ilSurveyExecutionGUI::gotoPage ( )

Go to a specific page without saving.

private

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

References $_GET.

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  }
$_GET["client_id"]

◆ mailUserResults()

ilSurveyExecutionGUI::mailUserResults ( )

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

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

848  {
850 
851  if (!$this->object->hasMailConfirmation()) {
852  $this->backToRepository();
853  }
854 
855  $this->checkAuth(false, true);
856 
857  $recipient = $_POST["mail"];
858  if (!$recipient) {
859  $recipient = $ilUser->getEmail();
860  }
861  if (!ilUtil::is_email($recipient)) {
862  $this->ctrl->redirect($this, "runShowFinishedPage");
863  }
864 
865  $survey_gui = new ilObjSurveyGUI();
866  $survey_gui->sendUserResultsMail(
867  $_SESSION["finished_id"][$this->object->getId()],
868  $recipient
869  );
870 
871  ilUtil::sendSuccess($this->lng->txt("mail_sent"), true);
872  $this->ctrl->redirect($this, "runShowFinishedPage");
873  }
$_SESSION["AccountId"]
static is_email($a_email, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
Class ilObjSurveyGUI.
checkAuth($a_may_start=false, $a_ignore_status=false)
$ilUser
Definition: imgupload.php:18
$_POST["username"]
+ Here is the call graph for this function:

◆ next()

ilSurveyExecutionGUI::next ( )

Navigates to the next pages.

private

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

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

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  }
$result
$_GET["client_id"]
saveUserInput($navigationDirection="next")
Save the user's input.
+ Here is the call graph for this function:

◆ outNavigationButtons()

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

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.

public

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

Referenced by outSurveyPage().

803  {
804  $prevpage = $this->object->getNextPage($page[0]["question_id"], -1);
805  $stpl->setCurrentBlock($navigationblock . "_prev");
806  if ($prevpage === 0) {
807  $stpl->setVariable("BTN_PREV", $this->lng->txt("survey_start"));
808  } else {
809  $stpl->setVariable("BTN_PREV", $this->lng->txt("survey_previous"));
810  }
811  $stpl->parseCurrentBlock();
812  $nextpage = $this->object->getNextPage($page[0]["question_id"], 1);
813  $stpl->setCurrentBlock($navigationblock . "_next");
814  if ($nextpage === 1) {
815  $stpl->setVariable("BTN_NEXT", $this->lng->txt("survey_finish"));
816  } else {
817  $stpl->setVariable("BTN_NEXT", $this->lng->txt("survey_next"));
818  }
819  $stpl->parseCurrentBlock();
820  }
+ 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

private

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

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

Referenced by preview(), and redirectQuestion().

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 
487  $pbar = ilProgressBar::getInstance();
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  foreach ($page as $data) {
500  if ($data["heading"]) {
501  $stpl->setCurrentBlock("heading");
502  $stpl->setVariable("QUESTION_HEADING", $data["heading"]);
503  $stpl->parseCurrentBlock();
504  }
505  $stpl->setCurrentBlock("survey_content");
506  if ($first_question == -1) {
507  $first_question = $data["question_id"];
508  }
509  $question_gui = $this->object->getQuestionGUI($data["type_tag"], $data["question_id"]);
510  if (is_array($_SESSION["svy_errors"])) {
511  $working_data = &$question_gui->object->getWorkingDataFromUserInput($_SESSION["postdata"]);
512  } else {
513  $working_data = $this->object->loadWorkingData($data["question_id"], $_SESSION["finished_id"][$this->object->getId()]);
514  }
515  $question_gui->object->setObligatory($data["obligatory"]);
516  $error_messages = array();
517  if (is_array($_SESSION["svy_errors"])) {
518  $error_messages = $_SESSION["svy_errors"];
519  }
520  $show_questiontext = ($data["questionblock_show_questiontext"]) ? 1 : 0;
521  $question_output = $question_gui->getWorkingForm($working_data, $this->object->getShowQuestionTitles(), $show_questiontext, $error_messages[$data["question_id"]], $this->object->getSurveyId());
522  $stpl->setVariable("QUESTION_OUTPUT", $question_output);
523  $this->ctrl->setParameter($this, "qid", $data["question_id"]);
524  //$this->tpl->parse("survey_content");
525  if ($data["obligatory"]) {
526  $required = true;
527  }
528  $stpl->parseCurrentBlock();
529  }
530  if ($required) {
531  $stpl->setCurrentBlock("required");
532  $stpl->setVariable("TEXT_REQUIRED", $this->lng->txt("required_field"));
533  $stpl->parseCurrentBlock();
534  }
535 
536  $this->outNavigationButtons("bottom", $page, $stpl);
537 
538  $stpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "redirectQuestion"));
539  }
540  $this->tpl->setContent($stpl->get());
541 
542  if (!$this->preview) {
543  $this->object->setPage($_SESSION["finished_id"][$this->object->getId()], $page[0]['question_id']);
544  $this->object->setStartTime($_SESSION["finished_id"][$this->object->getId()], $first_question);
545  }
546  }
outNavigationButtons($navigationblock="top", $page, $stpl)
Creates the navigation buttons for a survey.
$error_messages
$data
Definition: storeScorm.php:23
$_SESSION["AccountId"]
static _tracProgress($a_user_id, $a_obj_id, $a_ref_id, $a_obj_type='')
static getInstance()
Factory.
checkAuth($a_may_start=false, $a_ignore_status=false)
runShowFinishedPage()
Creates the finished page for a running survey.
$ilUser
Definition: imgupload.php:18
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:
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ preview()

ilSurveyExecutionGUI::preview ( )

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

References outSurveyPage().

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

823  {
824  $this->outSurveyPage();
825  }
outSurveyPage($activepage=null, $direction=null)
Output of the active survey question to the screen.
+ 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

private

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

References $_GET, and saveUserInput().

Referenced by previousNoSave().

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  }
$_GET["client_id"]
saveUserInput($navigationDirection="next")
Save the user's input.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ previousNoSave()

ilSurveyExecutionGUI::previousNoSave ( )

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

References previous().

319  {
320  $this->previous(false);
321  }
previous($a_save_input=true)
Navigates to the previous pages.
+ 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.

public

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

References $_GET, and outSurveyPage().

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  }
$_GET["client_id"]
outSurveyPage($activepage=null, $direction=null)
Output of the active survey question to the screen.
+ Here is the call graph for this function:

◆ resume()

ilSurveyExecutionGUI::resume ( )

Resumes the survey.

Resumes the survey

private

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

References start().

258  {
259  $this->start(true);
260  }
start($resume=false)
Starts the survey.
+ 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

public

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

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

Referenced by outSurveyPage().

688  {
689  $ilToolbar = $this->toolbar;
691 
692  $has_button = false;
693 
694 
695  if (!$this->preview) {
696  if ($this->object->hasViewOwnResults()) {
697  $button = ilLinkButton::getInstance();
698  $button->setCaption("svy_view_own_results");
699  $button->setUrl($this->ctrl->getLinkTarget($this, "viewUserResults"));
700  $ilToolbar->addButtonInstance($button);
701 
702  $has_button = true;
703  }
704 
705  if ($this->object->hasMailConfirmation()) {
706  if ($has_button) {
707  $ilToolbar->addSeparator();
708  }
709 
710  if ($ilUser->getId() == ANONYMOUS_USER_ID ||
711  !$ilUser->getEmail()) {
712  require_once "Services/Form/classes/class.ilTextInputGUI.php";
713  $mail = new ilTextInputGUI($this->lng->txt("email"), "mail");
714  $mail->setSize(25);
715  $ilToolbar->addInputItem($mail, true);
716  }
717 
718  $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "mailUserResults"));
719 
720  $button = ilSubmitButton::getInstance();
721  $button->setCaption("svy_mail_send_confirmation");
722  $button->setCommand("mailUserResults");
723  $ilToolbar->addButtonInstance($button);
724 
725  $has_button = true;
726  }
727 
728  // #6307
729  if (ilObjSurveyAccess::_hasEvaluationAccess($this->object->getId(), $ilUser->getId())) {
730  $button = ilLinkButton::getInstance();
731  $button->setCaption("svy_results");
732  $button->setUrl($this->ctrl->getLinkTargetByClass("ilObjSurveyGUI", "evaluation"));
733  $ilToolbar->addButtonInstance($button);
734 
735  $has_button = true;
736  }
737  }
738 
739  if (!$has_button &&
740  strlen($this->object->getOutro()) == 0) {
741  $this->exitSurvey();
742  } else {
743  if ($has_button) {
744  $ilToolbar->addSeparator();
745  }
746 
747  $button = ilLinkButton::getInstance();
748  $button->setCaption("survey_execution_exit");
749  $button->setUrl($this->ctrl->getLinkTarget($this, "exitSurvey"));
750  $ilToolbar->addButtonInstance($button);
751 
752  if (strlen($this->object->getOutro())) {
753  $panel = ilPanelGUI::getInstance();
754  $panel->setBody($this->object->prepareTextareaOutput($this->object->getOutro()));
755  $this->tpl->setContent($panel->getHTML());
756  }
757  }
758  }
exitSurvey()
Exits the survey after finishing it.
$ilUser
Definition: imgupload.php:18
static _hasEvaluationAccess($a_obj_id, $user_id)
static getInstance()
Get instance.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveActiveQuestionData()

ilSurveyExecutionGUI::saveActiveQuestionData ( $data)

Survey navigation.

Survey navigation

private Saves the users input of the active page

Saves the users input of the active page

private

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

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

Referenced by saveUserInput().

646  {
648 
649  $question = &SurveyQuestion::_instanciateQuestion($data["question_id"]);
650  $error = $question->checkUserInput($_POST, $this->object->getSurveyId());
651  if (strlen($error) == 0) {
652  if (!$this->preview) {
653  // delete old answers
654  $this->object->deleteWorkingData($data["question_id"], $_SESSION["finished_id"][$this->object->getId()]);
655 
656  $question->saveUserInput($_POST, $_SESSION["finished_id"][$this->object->getId()]);
657  } else {
658  $_SESSION["preview_data"][$this->object->getId()][$data["question_id"]] =
659  $question->saveUserInput($_POST, $_SESSION["finished_id"][$this->object->getId()], true);
660  }
661  return 0;
662  } else {
663  $_SESSION["svy_errors"][$question->getId()] = $error;
664  return 1;
665  }
666  }
$data
Definition: storeScorm.php:23
$_SESSION["AccountId"]
$ilUser
Definition: imgupload.php:18
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
$_POST["username"]
+ 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.

private

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

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

Referenced by next(), and previous().

554  {
555  if (!$this->preview) {
556  $this->object->setEndTime($_SESSION["finished_id"][$this->object->getId()]);
557  }
558 
559  // check users input when it is a metric question
560  unset($_SESSION["svy_errors"]);
561  $_SESSION["postdata"] = $_POST;
562  $page_error = 0;
563  $page = $this->object->getNextPage($_GET["qid"], 0);
564  foreach ($page as $data) {
565  $page_error += $this->saveActiveQuestionData($data);
566  }
567  if ($page_error && (strcmp($navigationDirection, "previous") != 0)) {
568  if ($page_error == 1) {
569  ilUtil::sendFailure($this->lng->txt("svy_page_error"), true);
570  } else {
571  ilUtil::sendFailure($this->lng->txt("svy_page_errors"), true);
572  }
573  } else {
574  $page_error = "";
575  unset($_SESSION["svy_errors"]);
576  }
577  return $page_error;
578  }
$data
Definition: storeScorm.php:23
$_SESSION["AccountId"]
$_GET["client_id"]
saveActiveQuestionData(&$data)
Survey navigation.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showFinishConfirmation()

ilSurveyExecutionGUI::showFinishConfirmation ( )

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

References $tpl.

Referenced by outSurveyPage().

876  {
877  $tpl = $this->tpl;
878 
879  $cgui = new ilConfirmationGUI();
880  $cgui->setHeaderText($this->lng->txt("survey_execution_sure_finish"));
881 
882  $cgui->setFormAction($this->ctrl->getFormAction($this, "confirmedFinish"));
883  $cgui->setCancel($this->lng->txt("cancel"), "previousNoSave");
884  $cgui->setConfirm($this->lng->txt("confirm"), "confirmedFinish");
885 
886  $tpl->setContent($cgui->getHTML());
887  }
Confirmation screen class.
+ Here is the caller graph for this function:

◆ start()

ilSurveyExecutionGUI::start (   $resume = false)

Starts the survey.

Starts the survey

private

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

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

Referenced by resume().

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  }
$_SESSION["AccountId"]
checkAuth($a_may_start=false, $a_ignore_status=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ viewUserResults()

ilSurveyExecutionGUI::viewUserResults ( )

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

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

828  {
829  $ilToolbar = $this->toolbar;
830 
831  if (!$this->object->hasViewOwnResults()) {
832  $this->backToRepository();
833  }
834 
835  $this->checkAuth(false, true);
836 
837  $button = ilLinkButton::getInstance();
838  $button->setCaption("btn_back");
839  $button->setUrl($this->ctrl->getLinkTarget($this, "runShowFinishedPage"));
840  $ilToolbar->addButtonInstance($button);
841 
842  $survey_gui = new ilObjSurveyGUI();
843  $html = $survey_gui->getUserResultsTable($_SESSION["finished_id"][$this->object->getId()]);
844  $this->tpl->setContent($html);
845  }
$_SESSION["AccountId"]
Class ilObjSurveyGUI.
checkAuth($a_may_start=false, $a_ignore_status=false)
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilSurveyExecutionGUI::$ctrl

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

◆ $help

ilSurveyExecutionGUI::$help
protected

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

Referenced by outSurveyPage().

◆ $lng

ilSurveyExecutionGUI::$lng

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

Referenced by __construct().

◆ $log

ilSurveyExecutionGUI::$log
protected

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

◆ $object

ilSurveyExecutionGUI::$object

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

◆ $preview

ilSurveyExecutionGUI::$preview

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

◆ $rbacsystem

ilSurveyExecutionGUI::$rbacsystem
protected

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

Referenced by checkAuth().

◆ $toolbar

ilSurveyExecutionGUI::$toolbar
protected

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

Referenced by runShowFinishedPage(), and viewUserResults().

◆ $tpl

ilSurveyExecutionGUI::$tpl

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

Referenced by __construct(), and showFinishConfirmation().

◆ $tree

ilSurveyExecutionGUI::$tree

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

Referenced by __construct(), and backToRepository().

◆ $user

ilSurveyExecutionGUI::$user
protected

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