61 $this->
object =& $a_object;
64 $this->external_rater_360 =
false;
65 if($this->object->get360Mode() &&
66 $_SESSION[
"anonymous_id"][$this->
object->getId()] &&
68 $_SESSION[
"anonymous_id"][$this->
object->getId()]))
70 $this->external_rater_360 =
true;
75 $this->ctrl->saveParameter($this,
"prvw");
76 $this->ctrl->saveParameter($this,
"pgov");
84 $cmd = $this->ctrl->getCmd();
85 $next_class = $this->ctrl->getNextClass($this);
88 if (strlen(
$cmd) == 0)
90 $this->ctrl->setParameter($this,
"qid",
$_GET[
"qid"]);
91 $this->ctrl->redirect($this,
"gotoPage");
102 protected function checkAuth($a_may_start =
false, $a_ignore_status =
false)
108 if(!$rbacsystem->checkAccess(
"write", $this->object->ref_id))
111 $this->ilias->raiseError($this->lng->txt(
"survey_cannot_preview_survey"),$this->ilias->error_obj->MESSAGE);
117 if (!$this->external_rater_360 &&
118 !$rbacsystem->checkAccess(
"read", $this->object->ref_id))
121 $this->ilias->raiseError($this->lng->txt(
"cannot_read_survey"),$this->ilias->error_obj->MESSAGE);
124 $user_id = $ilUser->getId();
128 $anonymous_id = $anonymous_code = null;
129 if ($this->object->getAnonymize() || !$this->
object->isAccessibleWithoutCode())
131 $anonymous_code =
$_SESSION[
"anonymous_id"][$this->
object->getId()];
132 $anonymous_id = $this->
object->getAnonymousIdByCode($anonymous_code);
135 ilUtil::sendFailure(sprintf($this->lng->txt(
"error_retrieving_anonymous_survey"), $anonymous_code,
true));
136 $this->ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
142 if($this->object->get360Mode())
147 $appr_id =
$_SESSION[
"appr_id"][$this->
object->getId()];
152 $appraisees = $this->
object->getAppraiseesToRate(0, $anonymous_id);
154 if(!$appraisees && $user_id != ANONYMOUS_USER_ID)
156 $appraisees = $this->
object->getAppraiseesToRate($user_id);
158 if(!in_array($appr_id, $appraisees))
161 $this->ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
164 $_SESSION[
"appr_id"][$this->
object->getId()] = $appr_id;
166 if(!$a_ignore_status)
168 $status = $this->
object->isSurveyStarted($user_id, $anonymous_code, $appr_id);
173 $this->ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
176 else if ($status ===
false)
180 $_SESSION[
"finished_id"][$this->
object->getId()] =
181 $this->
object->startSurvey($user_id, $anonymous_code, $appr_id);
186 $this->ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
197 if($this->object->getActiveID($user_id, $anonymous_code, $appr_id) !=
198 $_SESSION[
"finished_id"][$this->
object->getId()])
201 $this->ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
249 $activepage = $this->
object->getLastActivePage(
$_SESSION[
"finished_id"][$this->object->getId()]);
252 if (strlen($activepage))
254 $this->ctrl->setParameter($this,
"qid", $activepage);
256 $this->ctrl->setParameter($this,
"activecommand",
"default");
257 $this->ctrl->redirect($this,
"redirectQuestion");
268 switch (
$_GET[
"activecommand"])
308 $this->ctrl->setParameter($this,
"activecommand",
"previous");
309 $this->ctrl->setParameter($this,
"qid",
$_GET[
"qid"]);
310 if (strlen($has_error))
312 $this->ctrl->setParameter($this,
"direction",
"0");
316 $this->ctrl->setParameter($this,
"direction",
"-1");
318 $this->ctrl->redirect($this,
"redirectQuestion");
329 $this->ctrl->setParameter($this,
"activecommand",
"next");
330 $this->ctrl->setParameter($this,
"qid",
$_GET[
"qid"]);
333 $this->ctrl->setParameter($this,
"direction",
"0");
337 $this->ctrl->setParameter($this,
"direction",
"1");
339 $this->ctrl->redirect($this,
"redirectQuestion");
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");
368 $page = $this->
object->getNextPage($activepage, $direction);
369 $constraint_true = 0;
372 if (count($page[0][
"constraints"]))
374 while (is_array($page) and ($constraint_true == 0) and (count($page[0][
"constraints"])))
376 $constraint_true = ($page[0][
'constraints'][0][
'conjunction'] == 0) ?
true :
false;
377 foreach ($page[0][
"constraints"] as $constraint)
381 $working_data = $this->
object->loadWorkingData($constraint[
"question"],
$_SESSION[
"finished_id"][$this->object->getId()]);
385 $working_data =
$_SESSION[
"preview_data"][$this->
object->getId()][$constraint[
"question"]];
387 if ($constraint[
'conjunction'] == 0)
390 $constraint_true = $constraint_true & $this->
object->checkConstraint($constraint, $working_data);
395 $constraint_true = $constraint_true | $this->
object->checkConstraint($constraint, $working_data);
398 if ($constraint_true == 0)
401 foreach($page as $page_question)
403 $qid = $page_question[
"question_id"];
408 $this->
object->deleteWorkingData($qid,
$_SESSION[
"finished_id"][$this->object->getId()]);
412 $_SESSION[
"preview_data"][$this->
object->getId()][$qid] = null;
416 $page = $this->
object->getNextPage($page[0][
"question_id"], $direction);
421 $first_question = -1;
424 $this->ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
426 else if ($page === 1)
428 $state = $this->
object->getUserSurveyExecutionStatus();
430 !$state[
"runs"][
$_SESSION[
"finished_id"][$this->object->getId()]][
"finished"])
443 $ilHelp->setScreenIdComponent(
"svy");
444 $ilHelp->setScreenId(
"quest_presentation");
447 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_svy_content.html",
"Modules/Survey");
449 if($this->object->get360Mode())
451 $appr_id =
$_SESSION[
"appr_id"][$this->
object->getId()];
453 include_once
"Services/User/classes/class.ilUserUtil.php";
454 $this->tpl->setTitle($this->object->getTitle().
" (".
455 $this->lng->txt(
"survey_360_appraisee").
": ".
459 if (!($this->object->getAnonymize() && $this->
object->isAccessibleWithoutCode() && ($ilUser->getId() == ANONYMOUS_USER_ID)))
461 $this->tpl->setCurrentBlock(
"suspend_survey");
465 $this->tpl->setVariable(
"TEXT_SUSPEND", $this->lng->txt(
"cancel_survey"));
466 $this->tpl->setVariable(
"HREF_SUSPEND", $this->ctrl->getLinkTargetByClass(
"ilObjSurveyGUI",
"infoScreen"));
470 $this->ctrl->setParameterByClass(
"ilObjSurveyGUI",
"pgov",
$_REQUEST[
"pgov"]);
471 $this->tpl->setVariable(
"TEXT_SUSPEND", $this->lng->txt(
"survey_cancel_preview"));
472 $this->tpl->setVariable(
"HREF_SUSPEND", $this->ctrl->getLinkTargetByClass(array(
"ilObjSurveyGUI",
"ilSurveyEditorGUI"),
"questions"));
475 $this->tpl->setVariable(
"ALT_IMG_SUSPEND", $this->lng->txt(
"cancel_survey"));
476 $this->tpl->setVariable(
"TITLE_IMG_SUSPEND", $this->lng->txt(
"cancel_survey"));
477 $this->tpl->parseCurrentBlock();
482 $this->tpl->setCurrentBlock(
"percentage");
484 $percentage = (int)(($page[0][
"position"])*100);
486 include_once
"Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php";
488 $pbar->setCurrent($percentage);
489 $this->tpl->setVariable(
"NEW_PBAR", $pbar->render());
491 $this->tpl->parseCurrentBlock();
494 if (count($page) > 1 && $page[0][
"questionblock_show_blocktitle"])
496 $this->tpl->setCurrentBlock(
"questionblock_title");
497 $this->tpl->setVariable(
"TEXT_QUESTIONBLOCK_TITLE", $page[0][
"questionblock_title"]);
498 $this->tpl->parseCurrentBlock();
500 foreach ($page as $data)
502 $this->tpl->setCurrentBlock(
"survey_content");
503 if ($data[
"heading"])
505 $this->tpl->setVariable(
"QUESTION_HEADING", $data[
"heading"]);
507 if ($first_question == -1) $first_question = $data[
"question_id"];
508 $question_gui = $this->
object->getQuestionGUI($data[
"type_tag"], $data[
"question_id"]);
511 $working_data =& $question_gui->object->getWorkingDataFromUserInput(
$_SESSION[
"postdata"]);
515 $working_data = $this->
object->loadWorkingData($data[
"question_id"],
$_SESSION[
"finished_id"][$this->object->getId()]);
517 $question_gui->object->setObligatory($data[
"obligatory"]);
523 $show_questiontext = ($data[
"questionblock_show_questiontext"]) ? 1 : 0;
524 $question_output = $question_gui->getWorkingForm($working_data, $this->object->getShowQuestionTitles(), $show_questiontext,
$error_messages[$data[
"question_id"]], $this->
object->getSurveyId());
525 $this->tpl->setVariable(
"QUESTION_OUTPUT", $question_output);
526 $this->ctrl->setParameter($this,
"qid", $data[
"question_id"]);
527 $this->tpl->parse(
"survey_content");
528 if ($data[
"obligatory"]) $required =
true;
532 $this->tpl->setCurrentBlock(
"required");
533 $this->tpl->setVariable(
"TEXT_REQUIRED", $this->lng->txt(
"required_field"));
534 $this->tpl->parseCurrentBlock();
539 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this,
"redirectQuestion"));
544 $this->
object->setPage(
$_SESSION[
"finished_id"][$this->object->getId()], $page[0][
'question_id']);
545 $this->
object->setStartTime(
$_SESSION[
"finished_id"][$this->object->getId()], $first_question);
558 $this->
object->setEndTime(
$_SESSION[
"finished_id"][$this->object->getId()]);
565 $page = $this->
object->getNextPage(
$_GET[
"qid"], 0);
566 foreach ($page as $data)
570 if ($page_error && (strcmp($navigationDirection,
"previous") != 0))
572 if ($page_error == 1)
658 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
660 $error = $question->checkUserInput(
$_POST, $this->object->getSurveyId());
661 if (strlen($error) == 0)
666 $this->
object->deleteWorkingData($data[
"question_id"],
$_SESSION[
"finished_id"][$this->object->getId()]);
668 $question->saveUserInput(
$_POST,
$_SESSION[
"finished_id"][$this->object->getId()]);
672 $_SESSION[
"preview_data"][$this->
object->getId()][$data[
"question_id"]] =
673 $question->saveUserInput(
$_POST,
$_SESSION[
"finished_id"][$this->object->getId()],
true);
679 $_SESSION[
"svy_errors"][$question->getId()] = $error;
693 $this->ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
709 include_once
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
713 if($this->object->hasViewOwnResults())
716 $button->setCaption(
"svy_view_own_results");
717 $button->setUrl($this->ctrl->getLinkTarget($this,
"viewUserResults"));
718 $ilToolbar->addButtonInstance($button);
723 if($this->object->hasMailOwnResults())
727 $ilToolbar->addSeparator();
730 require_once
"Services/Form/classes/class.ilTextInputGUI.php";
733 if($ilUser->getId() != ANONYMOUS_USER_ID)
735 $mail->setValue($ilUser->getEmail());
737 $ilToolbar->addInputItem($mail,
true);
739 $ilToolbar->setFormAction($this->ctrl->getFormAction($this,
"mailUserResults"));
741 include_once
"Services/UIComponent/Button/classes/class.ilSubmitButton.php";
743 $button->setCaption(
"svy_mail_own_results");
744 $button->setCommand(
"mailUserResults");
745 $ilToolbar->addButtonInstance($button);
752 strlen($this->object->getOutro()) == 0)
760 $ilToolbar->addSeparator();
764 $button->setCaption(
"survey_execution_exit");
765 $button->setUrl($this->ctrl->getLinkTarget($this,
"exitSurvey"));
766 $ilToolbar->addButtonInstance($button);
768 if(strlen($this->object->getOutro()))
770 include_once
"Services/UIComponent/Panel/classes/class.ilPanelGUI.php";
772 $panel->setBody($this->object->prepareTextareaOutput($this->object->getOutro()));
773 $this->tpl->setContent($panel->getHTML());
783 if($this->object->get360Mode())
785 $target_ref_id = $this->
object->getRefId();
790 $target_ref_id = $tree->getParentId($this->object->getRefId());
793 include_once
"Services/Link/classes/class.ilLink.php";
813 $this->ctrl->setParameterByClass(
"ilsurveyeditorgui",
"pgov",
$_REQUEST[
"pgov"]);
814 $this->ctrl->redirectByClass(array(
"ilobjsurveygui",
"ilsurveyeditorgui"),
"questions");
829 $prevpage = $this->
object->getNextPage($page[0][
"question_id"], -1);
830 $this->tpl->setCurrentBlock($navigationblock .
"_prev");
833 $this->tpl->setVariable(
"BTN_PREV", $this->lng->txt(
"survey_start"));
837 $this->tpl->setVariable(
"BTN_PREV", $this->lng->txt(
"survey_previous"));
839 $this->tpl->parseCurrentBlock();
840 $nextpage = $this->
object->getNextPage($page[0][
"question_id"], 1);
841 $this->tpl->setCurrentBlock($navigationblock .
"_next");
844 $this->tpl->setVariable(
"BTN_NEXT", $this->lng->txt(
"survey_finish"));
848 $this->tpl->setVariable(
"BTN_NEXT", $this->lng->txt(
"survey_next"));
850 $this->tpl->parseCurrentBlock();
862 if(!$this->object->hasViewOwnResults())
869 include_once
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
871 $button->setCaption(
"btn_back");
872 $button->setUrl($this->ctrl->getLinkTarget($this,
"runShowFinishedPage"));
873 $ilToolbar->addButtonInstance($button);
876 $html = $survey_gui->getUserResultsTable(
$_SESSION[
"finished_id"][$this->object->getId()]);
877 $this->tpl->setContent($html);
882 if(!$this->object->hasMailOwnResults())
889 $recipient =
$_POST[
"mail"];
892 $this->ctrl->redirect($this,
"runShowFinishedPage");
896 $survey_gui->sendUserResultsMail(
897 $_SESSION[
"finished_id"][$this->object->getId()],
902 $this->ctrl->redirect($this,
"runShowFinishedPage");
909 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
911 $cgui->setHeaderText($this->lng->txt(
"survey_execution_sure_finish"));
913 $cgui->setFormAction($this->ctrl->getFormAction($this,
"confirmedFinish"));
914 $cgui->setCancel($this->lng->txt(
"cancel"),
"previousNoSave");
915 $cgui->setConfirm($this->lng->txt(
"confirm"),
"confirmedFinish");
917 $tpl->setContent($cgui->getHTML());
926 $this->
object->finishSurvey(
$_SESSION[
"finished_id"][$this->object->getId()]);
928 if ($this->object->getMailNotification())
930 $this->
object->sendNotificationMail($ilUser->getId(),
931 $_SESSION[
"anonymous_id"][$this->
object->getId()],
932 $_SESSION[
"appr_id"][$this->
object->getId()]);
942 $this->ctrl->redirect($this,
"runShowFinishedPage");