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();
88 $tree = $DIC->repositoryTree();
93 $this->
object = $a_object;
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()]
103 $this->external_rater_360 =
true;
107 $this->
preview = (bool) $_REQUEST[
"prvw"];
108 $this->ctrl->saveParameter($this,
"prvw");
109 $this->ctrl->saveParameter($this,
"pgov");
122 $this->object->getRefId(),
123 $this->
object->getId(),
127 $cmd = $this->ctrl->getCmd();
128 $next_class = $this->ctrl->getNextClass($this);
132 $this->log->debug(
"- cmd= " . $cmd);
134 if (strlen($cmd) == 0) {
135 $this->ctrl->setParameter($this,
"qid",
$_GET[
"qid"]);
136 $this->ctrl->redirect($this,
"gotoPage");
138 switch ($next_class) {
140 $ret = &$this->$cmd();
146 protected function checkAuth($a_may_start =
false, $a_ignore_status =
false)
152 if (!
$rbacsystem->checkAccess(
"write", $this->object->ref_id)) {
154 include_once
"Modules/Survey/exceptions/class.ilSurveyException.php";
161 if (!$this->external_rater_360 &&
162 !
$rbacsystem->checkAccess(
"read", $this->object->ref_id)) {
164 include_once
"Modules/Survey/exceptions/class.ilSurveyException.php";
172 $anonymous_id = $anonymous_code = null;
173 if ($this->object->getAnonymize() || !$this->
object->isAccessibleWithoutCode()) {
174 $anonymous_code =
$_SESSION[
"anonymous_id"][$this->
object->getId()];
175 $anonymous_id = $this->
object->getAnonymousIdByCode($anonymous_code);
176 if (!$anonymous_id) {
177 ilUtil::sendFailure(sprintf($this->lng->txt(
"error_retrieving_anonymous_survey"), $anonymous_code,
true));
178 $this->ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
184 if ($this->object->get360Mode()) {
185 $appr_id = $_REQUEST[
"appr_id"];
187 $appr_id =
$_SESSION[
"appr_id"][$this->
object->getId()];
191 $appraisees = $this->
object->getAppraiseesToRate(0, $anonymous_id);
193 if (!$appraisees && $user_id != ANONYMOUS_USER_ID) {
194 $appraisees = $this->
object->getAppraiseesToRate($user_id);
196 if (!in_array($appr_id, $appraisees)) {
198 $this->ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
202 #23575 in self eval the appraisee is the current user. 207 $_SESSION[
"appr_id"][$this->
object->getId()] = $appr_id;
209 if (!$a_ignore_status) {
210 $status = $this->
object->isSurveyStarted($user_id, $anonymous_code, $appr_id);
214 $this->ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
217 elseif ($status ===
false) {
219 $_SESSION[
"finished_id"][$this->
object->getId()] =
220 $this->
object->startSurvey($user_id, $anonymous_code, $appr_id);
223 $this->ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
233 if ($this->object->getActiveID($user_id, $anonymous_code, $appr_id) !=
234 $_SESSION[
"finished_id"][$this->
object->getId()]) {
236 $this->ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
271 public function start($resume =
false)
282 $activepage = $this->
object->getLastActivePage(
$_SESSION[
"finished_id"][$this->object->getId()]);
285 if (strlen($activepage)) {
286 $this->ctrl->setParameter($this,
"qid", $activepage);
288 $this->ctrl->setParameter($this,
"activecommand",
"default");
289 $this->ctrl->redirect($this,
"redirectQuestion");
300 switch (
$_GET[
"activecommand"]) {
338 $this->ctrl->setParameter($this,
"activecommand",
"previous");
339 $this->ctrl->setParameter($this,
"qid",
$_GET[
"qid"]);
340 if (strlen($has_error)) {
341 $this->ctrl->setParameter($this,
"direction",
"0");
343 $this->ctrl->setParameter($this,
"direction",
"-1");
345 $this->ctrl->redirect($this,
"redirectQuestion");
356 $this->ctrl->setParameter($this,
"activecommand",
"next");
357 $this->ctrl->setParameter($this,
"qid",
$_GET[
"qid"]);
359 $this->ctrl->setParameter($this,
"direction",
"0");
361 $this->ctrl->setParameter($this,
"direction",
"1");
363 $this->ctrl->redirect($this,
"redirectQuestion");
373 $this->ctrl->setParameter($this,
"activecommand",
"gotoPage");
374 $this->ctrl->setParameter($this,
"qid",
$_GET[
"qid"]);
375 $this->ctrl->setParameter($this,
"direction",
"0");
376 $this->ctrl->redirect($this,
"redirectQuestion");
392 $page = $this->
object->getNextPage($activepage, $direction);
393 $constraint_true = 0;
396 if (is_array($page[0][
"constraints"]) && count($page[0][
"constraints"])) {
397 $this->log->debug(
"Page constraints= ", $page[0][
"constraints"]);
399 while (is_array($page)
and ($constraint_true == 0)
and (count($page[0][
"constraints"]))) {
400 $constraint_true = ($page[0][
'constraints'][0][
'conjunction'] == 0) ?
true :
false;
401 foreach ($page[0][
"constraints"] as $constraint) {
403 $working_data = $this->
object->loadWorkingData($constraint[
"question"],
$_SESSION[
"finished_id"][$this->object->getId()]);
405 $working_data =
$_SESSION[
"preview_data"][$this->
object->getId()][$constraint[
"question"]];
407 if ($constraint[
'conjunction'] == 0) {
409 $constraint_true = $constraint_true & $this->
object->checkConstraint($constraint, $working_data);
412 $constraint_true = $constraint_true | $this->
object->checkConstraint($constraint, $working_data);
415 if ($constraint_true == 0) {
417 foreach ($page as $page_question) {
418 $qid = $page_question[
"question_id"];
422 $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;
435 $this->ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
436 } elseif ($page === 1) {
437 $state = $this->
object->getUserSurveyExecutionStatus();
439 !
$state[
"runs"][
$_SESSION[
"finished_id"][$this->object->getId()]][
"finished"]) {
447 $ilHelp->setScreenIdComponent(
"svy");
448 $ilHelp->setScreenId(
"quest_presentation");
450 if (
$ilUser->getId() != ANONYMOUS_USER_ID) {
451 include_once
"Services/Tracking/classes/class.ilLearningProgress.php";
456 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_svy_content.html",
"Modules/Survey");
458 if ($this->object->get360Mode()) {
459 $appr_id =
$_SESSION[
"appr_id"][$this->
object->getId()];
461 include_once
"Services/User/classes/class.ilUserUtil.php";
462 $this->tpl->setTitle($this->object->getTitle() .
" (" .
463 $this->lng->txt(
"survey_360_appraisee") .
": " .
467 if (!($this->object->getAnonymize() && $this->
object->isAccessibleWithoutCode() && (
$ilUser->getId() == ANONYMOUS_USER_ID))) {
468 $this->tpl->setCurrentBlock(
"suspend_survey");
471 $this->tpl->setVariable(
"TEXT_SUSPEND", $this->lng->txt(
"cancel_survey"));
472 $this->tpl->setVariable(
"HREF_SUSPEND", $this->ctrl->getLinkTargetByClass(
"ilObjSurveyGUI",
"infoScreen"));
474 $this->ctrl->setParameterByClass(
"ilObjSurveyGUI",
"pgov", $_REQUEST[
"pgov"]);
475 $this->tpl->setVariable(
"TEXT_SUSPEND", $this->lng->txt(
"survey_cancel_preview"));
476 $this->tpl->setVariable(
"HREF_SUSPEND", $this->ctrl->getLinkTargetByClass(array(
"ilObjSurveyGUI",
"ilSurveyEditorGUI"),
"questions"));
479 $this->tpl->setVariable(
"ALT_IMG_SUSPEND", $this->lng->txt(
"cancel_survey"));
480 $this->tpl->setVariable(
"TITLE_IMG_SUSPEND", $this->lng->txt(
"cancel_survey"));
481 $this->tpl->parseCurrentBlock();
486 $this->tpl->setCurrentBlock(
"percentage");
488 $percentage = (int) (($page[0][
"position"]) * 100);
490 include_once
"Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php";
492 $pbar->setCurrent($percentage);
493 $this->tpl->setVariable(
"NEW_PBAR", $pbar->render());
495 $this->tpl->parseCurrentBlock();
498 if (count($page) > 1 && $page[0][
"questionblock_show_blocktitle"]) {
499 $this->tpl->setCurrentBlock(
"questionblock_title");
500 $this->tpl->setVariable(
"TEXT_QUESTIONBLOCK_TITLE", $page[0][
"questionblock_title"]);
501 $this->tpl->parseCurrentBlock();
503 foreach ($page as
$data) {
504 $this->tpl->setCurrentBlock(
"survey_content");
505 if ($data[
"heading"]) {
506 $this->tpl->setVariable(
"QUESTION_HEADING", $data[
"heading"]);
508 if ($first_question == -1) {
509 $first_question = $data[
"question_id"];
511 $question_gui = $this->
object->getQuestionGUI($data[
"type_tag"], $data[
"question_id"]);
513 $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"]);
522 $show_questiontext = ($data[
"questionblock_show_questiontext"]) ? 1 : 0;
523 $question_output = $question_gui->getWorkingForm($working_data, $this->object->getShowQuestionTitles(), $show_questiontext,
$error_messages[$data[
"question_id"]], $this->
object->getSurveyId());
524 $this->tpl->setVariable(
"QUESTION_OUTPUT", $question_output);
525 $this->ctrl->setParameter($this,
"qid", $data[
"question_id"]);
526 $this->tpl->parse(
"survey_content");
527 if ($data[
"obligatory"]) {
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"));
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);
556 $this->
object->setEndTime(
$_SESSION[
"finished_id"][$this->object->getId()]);
563 $page = $this->
object->getNextPage(
$_GET[
"qid"], 0);
564 foreach ($page as
$data) {
567 if ($page_error && (strcmp($navigationDirection,
"previous") != 0)) {
568 if ($page_error == 1) {
649 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
651 $error = $question->checkUserInput(
$_POST, $this->object->getSurveyId());
652 if (strlen($error) == 0) {
655 $this->
object->deleteWorkingData(
$data[
"question_id"],
$_SESSION[
"finished_id"][$this->object->getId()]);
657 $question->saveUserInput(
$_POST,
$_SESSION[
"finished_id"][$this->object->getId()]);
659 $_SESSION[
"preview_data"][$this->
object->getId()][
$data[
"question_id"]] =
660 $question->saveUserInput(
$_POST,
$_SESSION[
"finished_id"][$this->object->getId()],
true);
664 $_SESSION[
"svy_errors"][$question->getId()] = $error;
678 $this->ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
695 include_once
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
698 if ($this->object->hasViewOwnResults()) {
700 $button->setCaption(
"svy_view_own_results");
701 $button->setUrl($this->ctrl->getLinkTarget($this,
"viewUserResults"));
702 $ilToolbar->addButtonInstance($button);
707 if ($this->object->hasMailConfirmation()) {
709 $ilToolbar->addSeparator();
712 if (
$ilUser->getId() == ANONYMOUS_USER_ID ||
714 require_once
"Services/Form/classes/class.ilTextInputGUI.php";
717 $ilToolbar->addInputItem($mail,
true);
720 $ilToolbar->setFormAction($this->ctrl->getFormAction($this,
"mailUserResults"));
722 include_once
"Services/UIComponent/Button/classes/class.ilSubmitButton.php";
724 $button->setCaption(
"svy_mail_send_confirmation");
725 $button->setCommand(
"mailUserResults");
726 $ilToolbar->addButtonInstance($button);
732 include_once
"Modules/Survey/classes/class.ilObjSurveyAccess.php";
735 $button->setCaption(
"svy_results");
736 $button->setUrl($this->ctrl->getLinkTargetByClass(
"ilObjSurveyGUI",
"evaluation"));
737 $ilToolbar->addButtonInstance($button);
744 strlen($this->object->getOutro()) == 0) {
748 $ilToolbar->addSeparator();
752 $button->setCaption(
"survey_execution_exit");
753 $button->setUrl($this->ctrl->getLinkTarget($this,
"exitSurvey"));
754 $ilToolbar->addButtonInstance($button);
756 if (strlen($this->object->getOutro())) {
757 include_once
"Services/UIComponent/Panel/classes/class.ilPanelGUI.php";
759 $panel->setBody($this->object->prepareTextareaOutput($this->object->getOutro()));
760 $this->tpl->setContent($panel->getHTML());
770 if ($this->object->get360Mode()) {
771 $target_ref_id = $this->
object->getRefId();
774 $target_ref_id =
$tree->getParentId($this->object->getRefId());
777 include_once
"Services/Link/classes/class.ilLink.php";
794 $this->ctrl->setParameterByClass(
"ilsurveyeditorgui",
"pgov", $_REQUEST[
"pgov"]);
795 $this->ctrl->redirectByClass(array(
"ilobjsurveygui",
"ilsurveyeditorgui"),
"questions");
810 $prevpage = $this->
object->getNextPage($page[0][
"question_id"], -1);
811 $this->tpl->setCurrentBlock($navigationblock .
"_prev");
812 if ($prevpage === 0) {
813 $this->tpl->setVariable(
"BTN_PREV", $this->lng->txt(
"survey_start"));
815 $this->tpl->setVariable(
"BTN_PREV", $this->lng->txt(
"survey_previous"));
817 $this->tpl->parseCurrentBlock();
818 $nextpage = $this->
object->getNextPage($page[0][
"question_id"], 1);
819 $this->tpl->setCurrentBlock($navigationblock .
"_next");
820 if ($nextpage === 1) {
821 $this->tpl->setVariable(
"BTN_NEXT", $this->lng->txt(
"survey_finish"));
823 $this->tpl->setVariable(
"BTN_NEXT", $this->lng->txt(
"survey_next"));
825 $this->tpl->parseCurrentBlock();
837 if (!$this->object->hasViewOwnResults()) {
843 include_once
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
845 $button->setCaption(
"btn_back");
846 $button->setUrl($this->ctrl->getLinkTarget($this,
"runShowFinishedPage"));
847 $ilToolbar->addButtonInstance($button);
850 $html = $survey_gui->getUserResultsTable(
$_SESSION[
"finished_id"][$this->object->getId()]);
851 $this->tpl->setContent(
$html);
858 if (!$this->object->hasMailConfirmation()) {
864 $recipient =
$_POST[
"mail"];
866 $recipient =
$ilUser->getEmail();
869 $this->ctrl->redirect($this,
"runShowFinishedPage");
873 $survey_gui->sendUserResultsMail(
874 $_SESSION[
"finished_id"][$this->object->getId()],
878 ilUtil::sendSuccess($this->lng->txt(
"mail_sent"),
true);
879 $this->ctrl->redirect($this,
"runShowFinishedPage");
886 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
888 $cgui->setHeaderText($this->lng->txt(
"survey_execution_sure_finish"));
890 $cgui->setFormAction($this->ctrl->getFormAction($this,
"confirmedFinish"));
891 $cgui->setCancel($this->lng->txt(
"cancel"),
"previousNoSave");
892 $cgui->setConfirm($this->lng->txt(
"confirm"),
"confirmedFinish");
894 $tpl->setContent($cgui->getHTML());
902 $this->
object->finishSurvey(
$_SESSION[
"finished_id"][$this->object->getId()]);
904 if (
$ilUser->getId() != ANONYMOUS_USER_ID) {
905 include_once
"Services/Tracking/classes/class.ilLPStatusWrapper.php";
909 if ($this->object->getMailNotification()) {
910 $this->
object->sendNotificationMail(
912 $_SESSION[
"anonymous_id"][$this->
object->getId()],
913 $_SESSION[
"appr_id"][$this->
object->getId()]
924 $this->ctrl->redirect($this,
"runShowFinishedPage");
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.
__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)
static is_email($a_email, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
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 _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.
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
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 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:
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.
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.
executeCommand()
execute command
static getLogger($a_component_id)
Get component logger.
static redirect($a_script)
static _getLink($a_ref_id, $a_type='', $a_params=array(), $append="")
outSurveyPage($activepage=null, $direction=null)
Output of the active survey question to the screen.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
Confirmation screen class.