ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 $tree;
42  var $preview;
43 
47  protected $log;
48 
57  function __construct($a_object)
58  {
59  global $lng, $tpl, $ilCtrl, $tree;
60 
61  $this->lng = $lng;
62  $this->tpl = $tpl;
63  $this->ctrl = $ilCtrl;
64  $this->object = $a_object;
65  $this->tree = $tree;
66 
67  $this->external_rater_360 = false;
68  if($this->object->get360Mode() &&
69  $_SESSION["anonymous_id"][$this->object->getId()] &&
71  $_SESSION["anonymous_id"][$this->object->getId()]))
72  {
73  $this->external_rater_360 = true;
74  }
75 
76  // stay in preview mode
77  $this->preview = (bool)$_REQUEST["prvw"];
78  $this->ctrl->saveParameter($this, "prvw");
79  $this->ctrl->saveParameter($this, "pgov");
80 
81  $this->log = ilLoggerFactory::getLogger("svy");
82  }
83 
87  function executeCommand()
88  {
89  $cmd = $this->ctrl->getCmd();
90  $next_class = $this->ctrl->getNextClass($this);
91 
92  $cmd = $this->getCommand($cmd);
93 
94  $this->log->debug("- cmd= ".$cmd);
95 
96  if (strlen($cmd) == 0)
97  {
98  $this->ctrl->setParameter($this, "qid", $_GET["qid"]);
99  $this->ctrl->redirect($this, "gotoPage");
100  }
101  switch($next_class)
102  {
103  default:
104  $ret =& $this->$cmd();
105  break;
106  }
107  return $ret;
108  }
109 
110  protected function checkAuth($a_may_start = false, $a_ignore_status = false)
111  {
112  global $rbacsystem, $ilUser;
113 
114  if($this->preview)
115  {
116  if(!$rbacsystem->checkAccess("write", $this->object->ref_id))
117  {
118  // only with write access it is possible to preview the survey
119  include_once "Modules/Survey/exceptions/class.ilSurveyException.php";
120  throw new ilSurveyException($this->lng->txt("survey_cannot_preview_survey"));
121  }
122 
123  return true;
124  }
125 
126  if (!$this->external_rater_360 &&
127  !$rbacsystem->checkAccess("read", $this->object->ref_id))
128  {
129  // only with read access it is possible to run the test
130  include_once "Modules/Survey/exceptions/class.ilSurveyException.php";
131  throw new ilSurveyException($this->lng->txt("cannot_read_survey"));
132  }
133 
134  $user_id = $ilUser->getId();
135 
136  // check existing code
137  // see ilObjSurveyGUI::infoScreen()
138  $anonymous_id = $anonymous_code = null;
139  if ($this->object->getAnonymize() || !$this->object->isAccessibleWithoutCode())
140  {
141  $anonymous_code = $_SESSION["anonymous_id"][$this->object->getId()];
142  $anonymous_id = $this->object->getAnonymousIdByCode($anonymous_code);
143  if(!$anonymous_id)
144  {
145  ilUtil::sendFailure(sprintf($this->lng->txt("error_retrieving_anonymous_survey"), $anonymous_code, true));
146  $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
147  }
148  }
149 
150  // appraisee validation
151  $appr_id = 0;
152  if($this->object->get360Mode())
153  {
154  $appr_id = $_REQUEST["appr_id"];
155  if(!$appr_id)
156  {
157  $appr_id = $_SESSION["appr_id"][$this->object->getId()];
158  }
159  // check if appraisee is valid
160  if($anonymous_id)
161  {
162  $appraisees = $this->object->getAppraiseesToRate(0, $anonymous_id);
163  }
164  if(!$appraisees && $user_id != ANONYMOUS_USER_ID)
165  {
166  $appraisees = $this->object->getAppraiseesToRate($user_id);
167  }
168  if(!in_array($appr_id, $appraisees))
169  {
170  ilUtil::sendFailure($this->lng->txt("survey_360_execution_invalid_appraisee"), true);
171  $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
172  }
173  }
174  $_SESSION["appr_id"][$this->object->getId()] = $appr_id;
175 
176  if(!$a_ignore_status)
177  {
178  $status = $this->object->isSurveyStarted($user_id, $anonymous_code, $appr_id);
179  // completed
180  if($status === 1)
181  {
182  ilUtil::sendFailure($this->lng->txt("already_completed_survey"), true);
183  $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
184  }
185  // starting
186  else if ($status === false)
187  {
188  if($a_may_start)
189  {
190  $_SESSION["finished_id"][$this->object->getId()] =
191  $this->object->startSurvey($user_id, $anonymous_code, $appr_id);
192  }
193  else
194  {
195  ilUtil::sendFailure($this->lng->txt("survey_use_start_button"), true);
196  $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
197  }
198  }
199  // resuming
200  else
201  {
202  // nothing todo
203  }
204  }
205 
206  // validate finished id
207  if($this->object->getActiveID($user_id, $anonymous_code, $appr_id) !=
208  $_SESSION["finished_id"][$this->object->getId()])
209  {
210  ilUtil::sendFailure($this->lng->txt("cannot_read_survey"), true);
211  $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
212  }
213  }
214 
222  function getCommand($cmd)
223  {
224  return $cmd;
225  }
226 
234  function resume()
235  {
236  $this->start(true);
237  }
238 
246  function start($resume = false)
247  {
248  if($this->preview)
249  {
250  unset($_SESSION["preview_data"]);
251  }
252  unset($_SESSION["svy_errors"]);
253 
254  $this->checkAuth(!$resume);
255 
256  $activepage = "";
257  if ($resume)
258  {
259  $activepage = $this->object->getLastActivePage($_SESSION["finished_id"][$this->object->getId()]);
260  }
261 
262  if (strlen($activepage))
263  {
264  $this->ctrl->setParameter($this, "qid", $activepage);
265  }
266  $this->ctrl->setParameter($this, "activecommand", "default");
267  $this->ctrl->redirect($this, "redirectQuestion");
268  }
269 
276  function redirectQuestion()
277  {
278  switch ($_GET["activecommand"])
279  {
280  case "next":
281  $this->outSurveyPage($_GET["qid"], $_GET["direction"]);
282  break;
283  case "previous":
284  $this->outSurveyPage($_GET["qid"], $_GET["direction"]);
285  break;
286  case "gotoPage":
287  $this->outSurveyPage($_GET["qid"], $_GET["direction"]);
288  break;
289  case "default":
290  $this->outSurveyPage($_GET["qid"]);
291  break;
292  default:
293  // don't save input, go to the first page
294  $this->outSurveyPage();
295  break;
296  }
297  }
298 
299  function previousNoSave()
300  {
301  $this->previous(false);
302  }
303 
311  function previous($a_save_input = true)
312  {
313  if($a_save_input)
314  {
315  // #16209
316  $has_error = $this->saveUserInput("previous");
317  }
318  $this->ctrl->setParameter($this, "activecommand", "previous");
319  $this->ctrl->setParameter($this, "qid", $_GET["qid"]);
320  if (strlen($has_error))
321  {
322  $this->ctrl->setParameter($this, "direction", "0");
323  }
324  else
325  {
326  $this->ctrl->setParameter($this, "direction", "-1");
327  }
328  $this->ctrl->redirect($this, "redirectQuestion");
329  }
330 
336  function next()
337  {
338  $result = $this->saveUserInput("next");
339  $this->ctrl->setParameter($this, "activecommand", "next");
340  $this->ctrl->setParameter($this, "qid", $_GET["qid"]);
341  if (strlen($result))
342  {
343  $this->ctrl->setParameter($this, "direction", "0");
344  }
345  else
346  {
347  $this->ctrl->setParameter($this, "direction", "1");
348  }
349  $this->ctrl->redirect($this, "redirectQuestion");
350  }
351 
357  function gotoPage()
358  {
359  $this->ctrl->setParameter($this, "activecommand", "gotoPage");
360  $this->ctrl->setParameter($this, "qid", $_GET["qid"]);
361  $this->ctrl->setParameter($this, "direction", "0");
362  $this->ctrl->redirect($this, "redirectQuestion");
363  }
364 
372  function outSurveyPage($activepage = NULL, $direction = NULL)
373  {
374  global $ilUser;
375 
376  $this->checkAuth();
377 
378  $page = $this->object->getNextPage($activepage, $direction);
379  $constraint_true = 0;
380 
381  // check for constraints
382  if (count($page[0]["constraints"]))
383  {
384  $this->log->debug("Page constraints= ", $page[0]["constraints"]);
385 
386  while (is_array($page) and ($constraint_true == 0) and (count($page[0]["constraints"])))
387  {
388  $constraint_true = ($page[0]['constraints'][0]['conjunction'] == 0) ? true : false;
389  foreach ($page[0]["constraints"] as $constraint)
390  {
391  if(!$this->preview)
392  {
393  $working_data = $this->object->loadWorkingData($constraint["question"], $_SESSION["finished_id"][$this->object->getId()]);
394  }
395  else
396  {
397  $working_data = $_SESSION["preview_data"][$this->object->getId()][$constraint["question"]];
398  }
399  if ($constraint['conjunction'] == 0)
400  {
401  // and
402  $constraint_true = $constraint_true & $this->object->checkConstraint($constraint, $working_data);
403  }
404  else
405  {
406  // or
407  $constraint_true = $constraint_true | $this->object->checkConstraint($constraint, $working_data);
408  }
409  }
410  if ($constraint_true == 0)
411  {
412  // #11047 - we are skipping the page, so we have to get rid of existing answers for that question(s)
413  foreach($page as $page_question)
414  {
415  $qid = $page_question["question_id"];
416 
417  // see saveActiveQuestionData()
418  if(!$this->preview)
419  {
420  $this->object->deleteWorkingData($qid, $_SESSION["finished_id"][$this->object->getId()]);
421  }
422  else
423  {
424  $_SESSION["preview_data"][$this->object->getId()][$qid] = null;
425  }
426  }
427 
428  $page = $this->object->getNextPage($page[0]["question_id"], $direction);
429  }
430  }
431  }
432 
433  $first_question = -1;
434  if ($page === 0)
435  {
436  $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
437  }
438  else if ($page === 1)
439  {
440  $state = $this->object->getUserSurveyExecutionStatus();
441  if($this->preview ||
442  !$state["runs"][$_SESSION["finished_id"][$this->object->getId()]]["finished"])
443  {
444  $this->showFinishConfirmation();
445  }
446  else
447  {
448  $this->runShowFinishedPage();
449  }
450  return;
451  }
452  else
453  {
454  global $ilHelp;
455  $ilHelp->setScreenIdComponent("svy");
456  $ilHelp->setScreenId("quest_presentation");
457 
458  if($ilUser->getId() != ANONYMOUS_USER_ID)
459  {
460  include_once "Services/Tracking/classes/class.ilLearningProgress.php";
461  ilLearningProgress::_tracProgress($ilUser->getId(), $this->object->getId(), $this->object->ref_id, "svy");
462  }
463 
464  $required = false;
465  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_content.html", "Modules/Survey");
466 
467  if($this->object->get360Mode())
468  {
469  $appr_id = $_SESSION["appr_id"][$this->object->getId()];
470 
471  include_once "Services/User/classes/class.ilUserUtil.php";
472  $this->tpl->setTitle($this->object->getTitle()." (".
473  $this->lng->txt("survey_360_appraisee").": ".
474  ilUserUtil::getNamePresentation($appr_id).")");
475  }
476 
477  if (!($this->object->getAnonymize() && $this->object->isAccessibleWithoutCode() && ($ilUser->getId() == ANONYMOUS_USER_ID)))
478  {
479  $this->tpl->setCurrentBlock("suspend_survey");
480 
481  if(!$this->preview)
482  {
483  $this->tpl->setVariable("TEXT_SUSPEND", $this->lng->txt("cancel_survey"));
484  $this->tpl->setVariable("HREF_SUSPEND", $this->ctrl->getLinkTargetByClass("ilObjSurveyGUI", "infoScreen"));
485  }
486  else
487  {
488  $this->ctrl->setParameterByClass("ilObjSurveyGUI", "pgov", $_REQUEST["pgov"]);
489  $this->tpl->setVariable("TEXT_SUSPEND", $this->lng->txt("survey_cancel_preview"));
490  $this->tpl->setVariable("HREF_SUSPEND", $this->ctrl->getLinkTargetByClass(array("ilObjSurveyGUI", "ilSurveyEditorGUI"), "questions"));
491  }
492 
493  $this->tpl->setVariable("ALT_IMG_SUSPEND", $this->lng->txt("cancel_survey"));
494  $this->tpl->setVariable("TITLE_IMG_SUSPEND", $this->lng->txt("cancel_survey"));
495  $this->tpl->parseCurrentBlock();
496  }
497  $this->outNavigationButtons("top", $page);
498 
499 
500  $this->tpl->setCurrentBlock("percentage");
501 
502  $percentage = (int)(($page[0]["position"])*100);
503 
504  include_once "Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php";
505  $pbar = ilProgressBar::getInstance();
506  $pbar->setCurrent($percentage);
507  $this->tpl->setVariable("NEW_PBAR", $pbar->render());
508 
509  $this->tpl->parseCurrentBlock();
510 
511 
512  if (count($page) > 1 && $page[0]["questionblock_show_blocktitle"])
513  {
514  $this->tpl->setCurrentBlock("questionblock_title");
515  $this->tpl->setVariable("TEXT_QUESTIONBLOCK_TITLE", $page[0]["questionblock_title"]);
516  $this->tpl->parseCurrentBlock();
517  }
518  foreach ($page as $data)
519  {
520  $this->tpl->setCurrentBlock("survey_content");
521  if ($data["heading"])
522  {
523  $this->tpl->setVariable("QUESTION_HEADING", $data["heading"]);
524  }
525  if ($first_question == -1) $first_question = $data["question_id"];
526  $question_gui = $this->object->getQuestionGUI($data["type_tag"], $data["question_id"]);
527  if (is_array($_SESSION["svy_errors"]))
528  {
529  $working_data =& $question_gui->object->getWorkingDataFromUserInput($_SESSION["postdata"]);
530  }
531  else
532  {
533  $working_data = $this->object->loadWorkingData($data["question_id"], $_SESSION["finished_id"][$this->object->getId()]);
534  }
535  $question_gui->object->setObligatory($data["obligatory"]);
537  if (is_array($_SESSION["svy_errors"]))
538  {
539  $error_messages = $_SESSION["svy_errors"];
540  }
541  $show_questiontext = ($data["questionblock_show_questiontext"]) ? 1 : 0;
542  $question_output = $question_gui->getWorkingForm($working_data, $this->object->getShowQuestionTitles(), $show_questiontext, $error_messages[$data["question_id"]], $this->object->getSurveyId());
543  $this->tpl->setVariable("QUESTION_OUTPUT", $question_output);
544  $this->ctrl->setParameter($this, "qid", $data["question_id"]);
545  $this->tpl->parse("survey_content");
546  if ($data["obligatory"]) $required = true;
547  }
548  if ($required)
549  {
550  $this->tpl->setCurrentBlock("required");
551  $this->tpl->setVariable("TEXT_REQUIRED", $this->lng->txt("required_field"));
552  $this->tpl->parseCurrentBlock();
553  }
554 
555  $this->outNavigationButtons("bottom", $page);
556 
557  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "redirectQuestion"));
558  }
559 
560  if(!$this->preview)
561  {
562  $this->object->setPage($_SESSION["finished_id"][$this->object->getId()], $page[0]['question_id']);
563  $this->object->setStartTime($_SESSION["finished_id"][$this->object->getId()], $first_question);
564  }
565  }
566 
572  function saveUserInput($navigationDirection = "next")
573  {
574  if(!$this->preview)
575  {
576  $this->object->setEndTime($_SESSION["finished_id"][$this->object->getId()]);
577  }
578 
579  // check users input when it is a metric question
580  unset($_SESSION["svy_errors"]);
581  $_SESSION["postdata"] = $_POST;
582  $page_error = 0;
583  $page = $this->object->getNextPage($_GET["qid"], 0);
584  foreach ($page as $data)
585  {
586  $page_error += $this->saveActiveQuestionData($data);
587  }
588  if ($page_error && (strcmp($navigationDirection, "previous") != 0))
589  {
590  if ($page_error == 1)
591  {
592  ilUtil::sendFailure($this->lng->txt("svy_page_error"), TRUE);
593  }
594  else
595  {
596  ilUtil::sendFailure($this->lng->txt("svy_page_errors"), TRUE);
597  }
598  }
599  else
600  {
601  $page_error = "";
602  unset($_SESSION["svy_errors"]);
603  }
604  return $page_error;
605  }
606 
614  /*
615  function navigate($navigationDirection = "next")
616  {
617  // check users input when it is a metric question
618  unset($_SESSION["svy_errors"]);
619  $page_error = 0;
620  $page = $this->object->getNextPage($_GET["qid"], 0);
621  foreach ($page as $data)
622  {
623  $page_error += $this->saveActiveQuestionData($data);
624  }
625  if ($page_error && (strcmp($navigationDirection, "previous") != 0))
626  {
627  if ($page_error == 1)
628  {
629  ilUtil::sendFailure($this->lng->txt("svy_page_error"));
630  }
631  else
632  {
633  ilUtil::sendFailure($this->lng->txt("svy_page_errors"));
634  }
635  }
636  else
637  {
638  $page_error = "";
639  unset($_SESSION["svy_errors"]);
640  }
641 
642  $direction = 0;
643  switch ($navigationDirection)
644  {
645  case "next":
646  default:
647  $activepage = $_GET["qid"];
648  if (!$page_error)
649  {
650  $direction = 1;
651  }
652  break;
653  case "previous":
654  $activepage = $_GET["qid"];
655  if (!$page_error)
656  {
657  $direction = -1;
658  }
659  break;
660  }
661  $this->outSurveyPage($activepage, $direction);
662  }
663 */
664 
673  {
674  global $ilUser;
675 
676  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
677  $question =& SurveyQuestion::_instanciateQuestion($data["question_id"]);
678  $error = $question->checkUserInput($_POST, $this->object->getSurveyId());
679  if (strlen($error) == 0)
680  {
681  if(!$this->preview)
682  {
683  // delete old answers
684  $this->object->deleteWorkingData($data["question_id"], $_SESSION["finished_id"][$this->object->getId()]);
685 
686  $question->saveUserInput($_POST, $_SESSION["finished_id"][$this->object->getId()]);
687  }
688  else
689  {
690  $_SESSION["preview_data"][$this->object->getId()][$data["question_id"]] =
691  $question->saveUserInput($_POST, $_SESSION["finished_id"][$this->object->getId()], true);
692  }
693  return 0;
694  }
695  else
696  {
697  $_SESSION["svy_errors"][$question->getId()] = $error;
698  return 1;
699  }
700  }
701 
709  function cancel()
710  {
711  $this->ctrl->redirectByClass("ilobjsurveygui", "infoScreen");
712  }
713 
722  {
723  global $ilToolbar, $ilUser;
724 
725  $has_button = false;
726 
727  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
728 
729  if(!$this->preview)
730  {
731  if($this->object->hasViewOwnResults())
732  {
733  $button = ilLinkButton::getInstance();
734  $button->setCaption("svy_view_own_results");
735  $button->setUrl($this->ctrl->getLinkTarget($this, "viewUserResults"));
736  $ilToolbar->addButtonInstance($button);
737 
738  $has_button = true;
739  }
740 
741  if($this->object->hasMailConfirmation())
742  {
743  if($has_button)
744  {
745  $ilToolbar->addSeparator();
746  }
747 
748  if($ilUser->getId() == ANONYMOUS_USER_ID ||
749  !$ilUser->getEmail())
750  {
751  require_once "Services/Form/classes/class.ilTextInputGUI.php";
752  $mail = new ilTextInputGUI($this->lng->txt("email"), "mail");
753  $mail->setSize(25);
754  $ilToolbar->addInputItem($mail, true);
755  }
756 
757  $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "mailUserResults"));
758 
759  include_once "Services/UIComponent/Button/classes/class.ilSubmitButton.php";
760  $button = ilSubmitButton::getInstance();
761  $button->setCaption("svy_mail_send_confirmation");
762  $button->setCommand("mailUserResults");
763  $ilToolbar->addButtonInstance($button);
764 
765  $has_button = true;
766  }
767 
768  // #6307
769  include_once "Modules/Survey/classes/class.ilObjSurveyAccess.php";
770  if(ilObjSurveyAccess::_hasEvaluationAccess($this->object->getId(), $ilUser->getId()))
771  {
772  $button = ilLinkButton::getInstance();
773  $button->setCaption("svy_results");
774  $button->setUrl($this->ctrl->getLinkTargetByClass("ilObjSurveyGUI", "evaluation"));
775  $ilToolbar->addButtonInstance($button);
776 
777  $has_button = true;
778  }
779  }
780 
781  if (!$has_button &&
782  strlen($this->object->getOutro()) == 0)
783  {
784  $this->exitSurvey();
785  }
786  else
787  {
788  if($has_button)
789  {
790  $ilToolbar->addSeparator();
791  }
792 
793  $button = ilLinkButton::getInstance();
794  $button->setCaption("survey_execution_exit");
795  $button->setUrl($this->ctrl->getLinkTarget($this, "exitSurvey"));
796  $ilToolbar->addButtonInstance($button);
797 
798  if(strlen($this->object->getOutro()))
799  {
800  include_once "Services/UIComponent/Panel/classes/class.ilPanelGUI.php";
801  $panel = ilPanelGUI::getInstance();
802  $panel->setBody($this->object->prepareTextareaOutput($this->object->getOutro()));
803  $this->tpl->setContent($panel->getHTML());
804  }
805  }
806  }
807 
808  function backToRepository()
809  {
810  global $tree;
811 
812  // #14971
813  if($this->object->get360Mode())
814  {
815  $target_ref_id = $this->object->getRefId();
816  }
817  else
818  {
819  // #11534
820  $target_ref_id = $tree->getParentId($this->object->getRefId());
821  }
822 
823  include_once "Services/Link/classes/class.ilLink.php";
824  ilUtil::redirect(ilLink::_getLink($target_ref_id));
825  }
826 
834  function exitSurvey()
835  {
836  if(!$this->preview)
837  {
838  $this->backToRepository();
839  }
840  else
841  {
842  // #12841
843  $this->ctrl->setParameterByClass("ilsurveyeditorgui", "pgov", $_REQUEST["pgov"]);
844  $this->ctrl->redirectByClass(array("ilobjsurveygui", "ilsurveyeditorgui"), "questions");
845  }
846  }
847 
857  function outNavigationButtons($navigationblock = "top", $page)
858  {
859  $prevpage = $this->object->getNextPage($page[0]["question_id"], -1);
860  $this->tpl->setCurrentBlock($navigationblock . "_prev");
861  if ($prevpage === 0)
862  {
863  $this->tpl->setVariable("BTN_PREV", $this->lng->txt("survey_start"));
864  }
865  else
866  {
867  $this->tpl->setVariable("BTN_PREV", $this->lng->txt("survey_previous"));
868  }
869  $this->tpl->parseCurrentBlock();
870  $nextpage = $this->object->getNextPage($page[0]["question_id"], 1);
871  $this->tpl->setCurrentBlock($navigationblock . "_next");
872  if ($nextpage === 1)
873  {
874  $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("survey_finish"));
875  }
876  else
877  {
878  $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("survey_next"));
879  }
880  $this->tpl->parseCurrentBlock();
881  }
882 
883  function preview()
884  {
885  $this->outSurveyPage();
886  }
887 
888  function viewUserResults()
889  {
890  global $ilToolbar;
891 
892  if(!$this->object->hasViewOwnResults())
893  {
894  $this->backToRepository();
895  }
896 
897  $this->checkAuth(false, true);
898 
899  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
900  $button = ilLinkButton::getInstance();
901  $button->setCaption("btn_back");
902  $button->setUrl($this->ctrl->getLinkTarget($this, "runShowFinishedPage"));
903  $ilToolbar->addButtonInstance($button);
904 
905  $survey_gui = new ilObjSurveyGUI();
906  $html = $survey_gui->getUserResultsTable($_SESSION["finished_id"][$this->object->getId()]);
907  $this->tpl->setContent($html);
908  }
909 
910  function mailUserResults()
911  {
912  global $ilUser;
913 
914  if(!$this->object->hasMailConfirmation())
915  {
916  $this->backToRepository();
917  }
918 
919  $this->checkAuth(false, true);
920 
921  $recipient = $_POST["mail"];
922  if(!$recipient)
923  {
924  $recipient = $ilUser->getEmail();
925  }
926  if(!ilUtil::is_email($recipient))
927  {
928  $this->ctrl->redirect($this, "runShowFinishedPage");
929  }
930 
931  $survey_gui = new ilObjSurveyGUI();
932  $survey_gui->sendUserResultsMail(
933  $_SESSION["finished_id"][$this->object->getId()],
934  $recipient
935  );
936 
937  ilUtil::sendSuccess($this->lng->txt("mail_sent"), true);
938  $this->ctrl->redirect($this, "runShowFinishedPage");
939  }
940 
942  {
943  global $tpl;
944 
945  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
946  $cgui = new ilConfirmationGUI();
947  $cgui->setHeaderText($this->lng->txt("survey_execution_sure_finish"));
948 
949  $cgui->setFormAction($this->ctrl->getFormAction($this, "confirmedFinish"));
950  $cgui->setCancel($this->lng->txt("cancel"), "previousNoSave");
951  $cgui->setConfirm($this->lng->txt("confirm"), "confirmedFinish");
952 
953  $tpl->setContent($cgui->getHTML());
954  }
955 
956  function confirmedFinish()
957  {
958  global $ilUser;
959 
960  if(!$this->preview)
961  {
962  $this->object->finishSurvey($_SESSION["finished_id"][$this->object->getId()]);
963 
964  if($ilUser->getId() != ANONYMOUS_USER_ID)
965  {
966  include_once "Services/Tracking/classes/class.ilLPStatusWrapper.php";
967  ilLPStatusWrapper::_updateStatus($this->object->getId(), $ilUser->getId());
968  }
969 
970  if ($this->object->getMailNotification())
971  {
972  $this->object->sendNotificationMail($ilUser->getId(),
973  $_SESSION["anonymous_id"][$this->object->getId()],
974  $_SESSION["appr_id"][$this->object->getId()]);
975  }
976  }
977 
978  /*
979  unset($_SESSION["anonymous_id"][$this->object->getId()]);
980  unset($_SESSION["appr_id"][$this->object->getId()]);
981  unset($_SESSION["finished_id"][$this->object->getId()]);
982  */
983 
984  $this->ctrl->redirect($this, "runShowFinishedPage");
985  }
986 }
987 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$error
Definition: Error.php:17
getCommand($cmd)
Retrieves the ilCtrl command.
$error_messages
__construct($a_object)
ilSurveyExecutionGUI constructor
$_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='')
redirectQuestion()
Called when a user answered a page to perform a redirect after POST.
Survey exception class.
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.
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.
$ilUser
Definition: imgupload.php:18
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
previous($a_save_input=true)
Navigates to the previous pages.
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static _hasEvaluationAccess($a_obj_id, $user_id)
static getInstance()
Get instance.
start($resume=false)
Starts the survey.
Create new PHPExcel object
obj_idprivate
$ret
Definition: parser.php:6
static getLogger($a_component_id)
Get component logger.
static redirect($a_script)
http redirect to other script
$_POST["username"]
$html
Definition: example_001.php:87
Confirmation screen class.