64 $this->
object = $a_object;
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()]))
73 $this->external_rater_360 =
true;
77 $this->
preview = (bool)$_REQUEST[
"prvw"];
78 $this->ctrl->saveParameter($this,
"prvw");
79 $this->ctrl->saveParameter($this,
"pgov");
89 $cmd = $this->ctrl->getCmd();
90 $next_class = $this->ctrl->getNextClass($this);
94 $this->log->debug(
"- cmd= ".
$cmd);
96 if (strlen(
$cmd) == 0)
98 $this->ctrl->setParameter($this,
"qid",
$_GET[
"qid"]);
99 $this->ctrl->redirect($this,
"gotoPage");
110 protected function checkAuth($a_may_start =
false, $a_ignore_status =
false)
116 if(!$rbacsystem->checkAccess(
"write", $this->object->ref_id))
119 include_once
"Modules/Survey/exceptions/class.ilSurveyException.php";
126 if (!$this->external_rater_360 &&
127 !$rbacsystem->checkAccess(
"read", $this->object->ref_id))
130 include_once
"Modules/Survey/exceptions/class.ilSurveyException.php";
134 $user_id = $ilUser->getId();
138 $anonymous_id = $anonymous_code = null;
139 if ($this->
object->getAnonymize() || !$this->
object->isAccessibleWithoutCode())
141 $anonymous_code =
$_SESSION[
"anonymous_id"][$this->
object->getId()];
142 $anonymous_id = $this->
object->getAnonymousIdByCode($anonymous_code);
145 ilUtil::sendFailure(sprintf($this->lng->txt(
"error_retrieving_anonymous_survey"), $anonymous_code,
true));
146 $this->ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
152 if($this->
object->get360Mode())
154 $appr_id = $_REQUEST[
"appr_id"];
157 $appr_id =
$_SESSION[
"appr_id"][$this->
object->getId()];
162 $appraisees = $this->
object->getAppraiseesToRate(0, $anonymous_id);
164 if(!$appraisees && $user_id != ANONYMOUS_USER_ID)
166 $appraisees = $this->
object->getAppraiseesToRate($user_id);
168 if(!in_array($appr_id, $appraisees))
171 $this->ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
174 $_SESSION[
"appr_id"][$this->
object->getId()] = $appr_id;
176 if(!$a_ignore_status)
178 $status = $this->
object->isSurveyStarted($user_id, $anonymous_code, $appr_id);
183 $this->ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
186 else if ($status ===
false)
190 $_SESSION[
"finished_id"][$this->
object->getId()] =
191 $this->
object->startSurvey($user_id, $anonymous_code, $appr_id);
196 $this->ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
207 if($this->
object->getActiveID($user_id, $anonymous_code, $appr_id) !=
208 $_SESSION[
"finished_id"][$this->
object->getId()])
211 $this->ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
259 $activepage = $this->
object->getLastActivePage(
$_SESSION[
"finished_id"][$this->
object->getId()]);
262 if (strlen($activepage))
264 $this->ctrl->setParameter($this,
"qid", $activepage);
266 $this->ctrl->setParameter($this,
"activecommand",
"default");
267 $this->ctrl->redirect($this,
"redirectQuestion");
278 switch (
$_GET[
"activecommand"])
318 $this->ctrl->setParameter($this,
"activecommand",
"previous");
319 $this->ctrl->setParameter($this,
"qid",
$_GET[
"qid"]);
320 if (strlen($has_error))
322 $this->ctrl->setParameter($this,
"direction",
"0");
326 $this->ctrl->setParameter($this,
"direction",
"-1");
328 $this->ctrl->redirect($this,
"redirectQuestion");
339 $this->ctrl->setParameter($this,
"activecommand",
"next");
340 $this->ctrl->setParameter($this,
"qid",
$_GET[
"qid"]);
343 $this->ctrl->setParameter($this,
"direction",
"0");
347 $this->ctrl->setParameter($this,
"direction",
"1");
349 $this->ctrl->redirect($this,
"redirectQuestion");
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");
378 $page = $this->
object->getNextPage($activepage, $direction);
379 $constraint_true = 0;
382 if (count($page[0][
"constraints"]))
384 $this->log->debug(
"Page constraints= ", $page[0][
"constraints"]);
386 while (is_array($page)
and ($constraint_true == 0)
and (count($page[0][
"constraints"])))
388 $constraint_true = ($page[0][
'constraints'][0][
'conjunction'] == 0) ?
true :
false;
389 foreach ($page[0][
"constraints"] as $constraint)
393 $working_data = $this->
object->loadWorkingData($constraint[
"question"],
$_SESSION[
"finished_id"][$this->
object->getId()]);
397 $working_data =
$_SESSION[
"preview_data"][$this->
object->getId()][$constraint[
"question"]];
399 if ($constraint[
'conjunction'] == 0)
402 $constraint_true = $constraint_true & $this->
object->checkConstraint($constraint, $working_data);
407 $constraint_true = $constraint_true | $this->
object->checkConstraint($constraint, $working_data);
410 if ($constraint_true == 0)
413 foreach($page as $page_question)
415 $qid = $page_question[
"question_id"];
420 $this->
object->deleteWorkingData($qid,
$_SESSION[
"finished_id"][$this->
object->getId()]);
424 $_SESSION[
"preview_data"][$this->
object->getId()][$qid] = null;
428 $page = $this->
object->getNextPage($page[0][
"question_id"], $direction);
433 $first_question = -1;
436 $this->ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
438 else if ($page === 1)
440 $state = $this->
object->getUserSurveyExecutionStatus();
442 !$state[
"runs"][
$_SESSION[
"finished_id"][$this->
object->getId()]][
"finished"])
455 $ilHelp->setScreenIdComponent(
"svy");
456 $ilHelp->setScreenId(
"quest_presentation");
458 if($ilUser->getId() != ANONYMOUS_USER_ID)
460 include_once
"Services/Tracking/classes/class.ilLearningProgress.php";
465 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_svy_content.html",
"Modules/Survey");
467 if($this->
object->get360Mode())
469 $appr_id =
$_SESSION[
"appr_id"][$this->
object->getId()];
471 include_once
"Services/User/classes/class.ilUserUtil.php";
472 $this->tpl->setTitle($this->
object->getTitle().
" (".
473 $this->lng->txt(
"survey_360_appraisee").
": ".
477 if (!($this->
object->getAnonymize() && $this->
object->isAccessibleWithoutCode() && ($ilUser->getId() == ANONYMOUS_USER_ID)))
479 $this->tpl->setCurrentBlock(
"suspend_survey");
483 $this->tpl->setVariable(
"TEXT_SUSPEND", $this->lng->txt(
"cancel_survey"));
484 $this->tpl->setVariable(
"HREF_SUSPEND", $this->ctrl->getLinkTargetByClass(
"ilObjSurveyGUI",
"infoScreen"));
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"));
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();
500 $this->tpl->setCurrentBlock(
"percentage");
502 $percentage = (int)(($page[0][
"position"])*100);
504 include_once
"Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php";
506 $pbar->setCurrent($percentage);
507 $this->tpl->setVariable(
"NEW_PBAR", $pbar->render());
509 $this->tpl->parseCurrentBlock();
512 if (count($page) > 1 && $page[0][
"questionblock_show_blocktitle"])
514 $this->tpl->setCurrentBlock(
"questionblock_title");
515 $this->tpl->setVariable(
"TEXT_QUESTIONBLOCK_TITLE", $page[0][
"questionblock_title"]);
516 $this->tpl->parseCurrentBlock();
518 foreach ($page as
$data)
520 $this->tpl->setCurrentBlock(
"survey_content");
521 if ($data[
"heading"])
523 $this->tpl->setVariable(
"QUESTION_HEADING", $data[
"heading"]);
525 if ($first_question == -1) $first_question = $data[
"question_id"];
526 $question_gui = $this->
object->getQuestionGUI($data[
"type_tag"], $data[
"question_id"]);
529 $working_data =& $question_gui->object->getWorkingDataFromUserInput(
$_SESSION[
"postdata"]);
533 $working_data = $this->
object->loadWorkingData($data[
"question_id"],
$_SESSION[
"finished_id"][$this->
object->getId()]);
535 $question_gui->object->setObligatory($data[
"obligatory"]);
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;
550 $this->tpl->setCurrentBlock(
"required");
551 $this->tpl->setVariable(
"TEXT_REQUIRED", $this->lng->txt(
"required_field"));
552 $this->tpl->parseCurrentBlock();
557 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this,
"redirectQuestion"));
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);
576 $this->
object->setEndTime(
$_SESSION[
"finished_id"][$this->
object->getId()]);
583 $page = $this->
object->getNextPage(
$_GET[
"qid"], 0);
584 foreach ($page as
$data)
588 if ($page_error && (strcmp($navigationDirection,
"previous") != 0))
590 if ($page_error == 1)
676 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
684 $this->
object->deleteWorkingData(
$data[
"question_id"],
$_SESSION[
"finished_id"][$this->
object->getId()]);
690 $_SESSION[
"preview_data"][$this->
object->getId()][
$data[
"question_id"]] =
711 $this->ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
727 include_once
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
731 if($this->
object->hasViewOwnResults())
734 $button->setCaption(
"svy_view_own_results");
735 $button->setUrl($this->ctrl->getLinkTarget($this,
"viewUserResults"));
736 $ilToolbar->addButtonInstance($button);
741 if($this->
object->hasMailConfirmation())
745 $ilToolbar->addSeparator();
748 if($ilUser->getId() == ANONYMOUS_USER_ID ||
749 !$ilUser->getEmail())
751 require_once
"Services/Form/classes/class.ilTextInputGUI.php";
754 $ilToolbar->addInputItem($mail,
true);
757 $ilToolbar->setFormAction($this->ctrl->getFormAction($this,
"mailUserResults"));
759 include_once
"Services/UIComponent/Button/classes/class.ilSubmitButton.php";
761 $button->setCaption(
"svy_mail_send_confirmation");
762 $button->setCommand(
"mailUserResults");
763 $ilToolbar->addButtonInstance($button);
769 include_once
"Modules/Survey/classes/class.ilObjSurveyAccess.php";
773 $button->setCaption(
"svy_results");
774 $button->setUrl($this->ctrl->getLinkTargetByClass(
"ilObjSurveyGUI",
"evaluation"));
775 $ilToolbar->addButtonInstance($button);
782 strlen($this->
object->getOutro()) == 0)
790 $ilToolbar->addSeparator();
794 $button->setCaption(
"survey_execution_exit");
795 $button->setUrl($this->ctrl->getLinkTarget($this,
"exitSurvey"));
796 $ilToolbar->addButtonInstance($button);
798 if(strlen($this->
object->getOutro()))
800 include_once
"Services/UIComponent/Panel/classes/class.ilPanelGUI.php";
802 $panel->setBody($this->
object->prepareTextareaOutput($this->object->getOutro()));
803 $this->tpl->setContent($panel->getHTML());
813 if($this->
object->get360Mode())
815 $target_ref_id = $this->
object->getRefId();
820 $target_ref_id = $tree->getParentId($this->
object->getRefId());
823 include_once
"Services/Link/classes/class.ilLink.php";
843 $this->ctrl->setParameterByClass(
"ilsurveyeditorgui",
"pgov", $_REQUEST[
"pgov"]);
844 $this->ctrl->redirectByClass(
array(
"ilobjsurveygui",
"ilsurveyeditorgui"),
"questions");
859 $prevpage = $this->
object->getNextPage($page[0][
"question_id"], -1);
860 $this->tpl->setCurrentBlock($navigationblock .
"_prev");
863 $this->tpl->setVariable(
"BTN_PREV", $this->lng->txt(
"survey_start"));
867 $this->tpl->setVariable(
"BTN_PREV", $this->lng->txt(
"survey_previous"));
869 $this->tpl->parseCurrentBlock();
870 $nextpage = $this->
object->getNextPage($page[0][
"question_id"], 1);
871 $this->tpl->setCurrentBlock($navigationblock .
"_next");
874 $this->tpl->setVariable(
"BTN_NEXT", $this->lng->txt(
"survey_finish"));
878 $this->tpl->setVariable(
"BTN_NEXT", $this->lng->txt(
"survey_next"));
880 $this->tpl->parseCurrentBlock();
892 if(!$this->
object->hasViewOwnResults())
899 include_once
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
901 $button->setCaption(
"btn_back");
902 $button->setUrl($this->ctrl->getLinkTarget($this,
"runShowFinishedPage"));
903 $ilToolbar->addButtonInstance($button);
907 $this->tpl->setContent(
$html);
914 if(!$this->
object->hasMailConfirmation())
921 $recipient =
$_POST[
"mail"];
924 $recipient = $ilUser->getEmail();
928 $this->ctrl->redirect($this,
"runShowFinishedPage");
932 $survey_gui->sendUserResultsMail(
938 $this->ctrl->redirect($this,
"runShowFinishedPage");
945 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
947 $cgui->setHeaderText($this->lng->txt(
"survey_execution_sure_finish"));
949 $cgui->setFormAction($this->ctrl->getFormAction($this,
"confirmedFinish"));
950 $cgui->setCancel($this->lng->txt(
"cancel"),
"previousNoSave");
951 $cgui->setConfirm($this->lng->txt(
"confirm"),
"confirmedFinish");
953 $tpl->setContent($cgui->getHTML());
962 $this->
object->finishSurvey(
$_SESSION[
"finished_id"][$this->
object->getId()]);
964 if($ilUser->getId() != ANONYMOUS_USER_ID)
966 include_once
"Services/Tracking/classes/class.ilLPStatusWrapper.php";
970 if ($this->
object->getMailNotification())
972 $this->
object->sendNotificationMail($ilUser->getId(),
973 $_SESSION[
"anonymous_id"][$this->
object->getId()],
974 $_SESSION[
"appr_id"][$this->
object->getId()]);
984 $this->ctrl->redirect($this,
"runShowFinishedPage");
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
getCommand($cmd)
Retrieves the ilCtrl command.
__construct($a_object)
ilSurveyExecutionGUI constructor
cancel()
Called on cancel.
outNavigationButtons($navigationblock="top", $page)
Creates the navigation buttons for a survey.
static validateExternalRaterCode($a_ref_id, $a_code)
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.
saveUserInput($navigationDirection="next")
Save the user'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='')
resume()
Resumes the survey.
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.
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.
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
executeCommand()
execute command
static getLogger($a_component_id)
Get component logger.
static redirect($a_script)
http redirect to other script
static _getLink($a_ref_id, $a_type='', $a_params=array(), $append="")
Confirmation screen class.