ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilSurveyExecutionGUI.php
Go to the documentation of this file.
1 <?php
2  /*
3  +----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +----------------------------------------------------------------------------+
22 */
23 
36 {
37  var $object;
38  var $lng;
39  var $tpl;
40  var $ctrl;
41  var $ilias;
42  var $tree;
43  var $preview;
44 
53  function ilSurveyExecutionGUI($a_object)
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  }
78 
82  function &executeCommand()
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  }
101 
102  protected function checkAuth($a_may_start = false, $a_ignore_status = false)
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  }
204 
212  function getCommand($cmd)
213  {
214  return $cmd;
215  }
216 
224  function resume()
225  {
226  $this->start(true);
227  }
228 
236  function start($resume = false)
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  }
259 
266  function redirectQuestion()
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  }
288 
289  function previousNoSave()
290  {
291  $this->previous(false);
292  }
293 
301  function previous($a_save_input = true)
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  }
320 
326  function next()
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  }
341 
347  function gotoPage()
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  }
354 
362  function outSurveyPage($activepage = NULL, $direction = NULL)
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";
493  $pbar = ilProgressBar::getInstance();
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  }
554 
560  function saveUserInput($navigationDirection = "next")
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  }
594 
602  /*
603  function navigate($navigationDirection = "next")
604  {
605  // check users input when it is a metric question
606  unset($_SESSION["svy_errors"]);
607  $page_error = 0;
608  $page = $this->object->getNextPage($_GET["qid"], 0);
609  foreach ($page as $data)
610  {
611  $page_error += $this->saveActiveQuestionData($data);
612  }
613  if ($page_error && (strcmp($navigationDirection, "previous") != 0))
614  {
615  if ($page_error == 1)
616  {
617  ilUtil::sendFailure($this->lng->txt("svy_page_error"));
618  }
619  else
620  {
621  ilUtil::sendFailure($this->lng->txt("svy_page_errors"));
622  }
623  }
624  else
625  {
626  $page_error = "";
627  unset($_SESSION["svy_errors"]);
628  }
629 
630  $direction = 0;
631  switch ($navigationDirection)
632  {
633  case "next":
634  default:
635  $activepage = $_GET["qid"];
636  if (!$page_error)
637  {
638  $direction = 1;
639  }
640  break;
641  case "previous":
642  $activepage = $_GET["qid"];
643  if (!$page_error)
644  {
645  $direction = -1;
646  }
647  break;
648  }
649  $this->outSurveyPage($activepage, $direction);
650  }
651 */
652 
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  }
689 
697  function cancel()
698  {
699  $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
700  }
701 
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  }
795 
796  function backToRepository()
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  }
814 
822  function exitSurvey()
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  }
835 
845  function outNavigationButtons($navigationblock = "top", $page)
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  }
870 
871  function preview()
872  {
873  $this->outSurveyPage();
874  }
875 
876  function viewUserResults()
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  }
897 
898  function mailUserResults()
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  }
922 
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  }
937 
938  function confirmedFinish()
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  }
968 }
969 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
getCommand($cmd)
Retrieves the ilCtrl command.
$error_messages
$_POST['username']
Definition: cron.php:12
$_SESSION["AccountId"]
$result
outNavigationButtons($navigationblock="top", $page)
Creates the navigation buttons for a survey.
static validateExternalRaterCode($a_ref_id, $a_code)
$_GET["client_id"]
saveActiveQuestionData(&$data)
Survey navigation.
exitSurvey()
Exits the survey after finishing it.
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
$cmd
Definition: sahs_server.php:35
saveUserInput($navigationDirection="next")
Save the user&#39;s input.
static is_email($a_email)
This preg-based function checks whether an e-mail address is formally valid.
static _tracProgress($a_user_id, $a_obj_id, $a_ref_id, $a_obj_type='')
ilSurveyExecutionGUI($a_object)
ilSurveyExecutionGUI constructor
redirectQuestion()
Called when a user answered a page to perform a redirect after POST.
outSurveyPage($activepage=NULL, $direction=NULL)
Output of the active survey question to the screen.
global $ilCtrl
Definition: ilias.php:18
Class ilObjSurveyGUI.
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:
next()
Navigates to the next pages.
$data
static getInstance()
Factory.
gotoPage()
Go to a specific page without saving.
Survey execution graphical output.
checkAuth($a_may_start=false, $a_ignore_status=false)
runShowFinishedPage()
Creates the finished page for a running survey.
setSize($a_size)
Set Size.
This class represents a text property in a property form.
redirection script todo: (a better solution should control the processing via a xml file) ...
previous($a_save_input=true)
Navigates to the previous pages.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static getInstance()
Get instance.
global $ilUser
Definition: imgupload.php:15
start($resume=false)
Starts the survey.
_hasEvaluationAccess($a_obj_id, $user_id)
& executeCommand()
execute command
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
& _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static redirect($a_script)
http redirect to other script
$html
Definition: example_001.php:87
Confirmation screen class.