ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilSurveyExecutionGUI Class Reference

Survey execution graphical output. More...

+ Collaboration diagram for ilSurveyExecutionGUI:

Public Member Functions

 __construct (ilObjSurvey $a_object)
 
 executeCommand ()
 
 resume ()
 
 start (bool $resume=false)
 
 redirectQuestion ()
 Called when a user answered a page to perform a redirect after POST. More...
 
 previousNoSave ()
 
 previous (bool $a_save_input=true)
 
 next ()
 Navigates to the next page. More...
 
 gotoPage ()
 Go to a specific page without saving. More...
 
 outSurveyPage (int $activepage=0, int $direction=0)
 Output of the active survey question to the screen. More...
 
 saveUserInput (string $navigationDirection="next")
 Save the user's input. More...
 
 saveActiveQuestionData (array $data)
 Saves the users input of the active page. More...
 
 cancel ()
 
 runShowFinishedPage ()
 Show finish page. More...
 
 backToRepository ()
 
 exitSurvey ()
 Exits the survey after finishing it. More...
 
 outNavigationButtons (string $navigationblock, array $page, ilTemplate $stpl)
 
 preview ()
 
 viewUserResults ()
 
 mailUserResults ()
 
 showFinishConfirmation ()
 
 confirmedFinish ()
 

Protected Member Functions

 checkAuth (bool $a_may_start=false, bool $a_finished_run=false)
 
 getCurrentRunId ()
 

Protected Attributes

ILIAS Survey InternalGUIService $gui
 
array $raw_post_data
 
ILIAS Survey Execution ExecutionGUIRequest $request
 
ilRbacSystem $rbacsystem
 
ilObjUser $user
 
ilHelpGUI $help
 
ilToolbarGUI $toolbar
 
ilObjSurvey $object
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
ilCtrl $ctrl
 
ilTree $tree
 
bool $preview
 
ilLogger $log
 
ILIAS Survey Execution RunManager $run_manager
 
ILIAS Survey Participants StatusManager $participant_manager
 
ILIAS Survey Access AccessManager $access_manager
 
int $requested_appr_id
 
Mode FeatureConfig $feature_config
 

Detailed Description

Survey execution graphical output.

The ilSurveyExecutionGUI class creates the execution output for the ilObjSurveyGUI class. This saves some heap space because the ilObjSurveyGUI class will be smaller.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m

Definition at line 32 of file class.ilSurveyExecutionGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilSurveyExecutionGUI::__construct ( ilObjSurvey  $a_object)

Definition at line 55 of file class.ilSurveyExecutionGUI.php.

56 {
57 global $DIC;
58
59 $this->rbacsystem = $DIC->rbac()->system();
60 $this->user = $DIC->user();
61 $this->help = $DIC["ilHelp"];
62 $this->toolbar = $DIC->toolbar();
63 $lng = $DIC->language();
64 $tpl = $DIC["tpl"];
65 $ilCtrl = $DIC->ctrl();
66 $tree = $DIC->repositoryTree();
67
68 $this->lng = $lng;
69 $this->tpl = $tpl;
70 $this->ctrl = $ilCtrl;
71 $this->object = $a_object;
72 $this->tree = $tree;
73 $this->user = $DIC->user();
74
75 $this->request = $DIC->survey()
76 ->internal()
77 ->gui()
78 ->execution()
79 ->request();
80 $this->gui = $DIC->survey()
81 ->internal()
82 ->gui();
83
84 // stay in preview mode
85 $this->preview = (bool) $this->request->getPreview();
86 $this->requested_appr_id = $this->request->getAppraiseeId();
87 $this->ctrl->saveParameter($this, "prvw");
88 $this->ctrl->saveParameter($this, "appr_id");
89 $this->ctrl->saveParameter($this, "pgov");
90
91 $this->log = ilLoggerFactory::getLogger("svy");
92
93 $domain_service = $DIC->survey()->internal();
94 $appraisee_id = ($a_object->getMode() === ilObjSurvey::MODE_SELF_EVAL)
95 ? $this->user->getId()
97 $this->run_manager = $domain_service->domain()->execution()->run(
98 $a_object,
99 $this->user->getId(),
100 $appraisee_id
101 );
102 $this->participant_manager = $domain_service->domain()->participants()->status(
103 $a_object,
104 $this->user->getId()
105 );
106 $this->access_manager = $domain_service->domain()->access(
107 $a_object->getRefId(),
108 $this->user->getId()
109 );
110
111 $this->feature_config = $domain_service->domain()->modeFeatureConfig($a_object->getMode());
112
113
114 // @todo this is used to store answers in the session, but should
115 // be refactored somehow to avoid the use of the complete post body
116 $parsed_body = $DIC->http()->request()->getParsedBody();
117 $this->raw_post_data = is_array($parsed_body) ? $parsed_body : [];
118 }
static getLogger(string $a_component_id)
Get component logger.
ilGlobalTemplateInterface $tpl
global $DIC
Definition: shib_login.php:26

References $DIC, $lng, $requested_appr_id, $tpl, $tree, ILIAS\Repository\ctrl(), ilLoggerFactory\getLogger(), ilObjSurvey\getMode(), ilObject\getRefId(), ILIAS\Repository\help(), ILIAS\Repository\lng(), ilObjSurvey\MODE_SELF_EVAL, preview(), ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ backToRepository()

ilSurveyExecutionGUI::backToRepository ( )

Definition at line 685 of file class.ilSurveyExecutionGUI.php.

685 : void
686 {
688
689 // #14971
690 if ($this->object->getMode() === ilObjSurvey::MODE_360) {
691 $target_ref_id = $this->object->getRefId();
692 } else {
693 // #11534
694 $target_ref_id = $tree->getParentId($this->object->getRefId());
695 }
696
697 ilUtil::redirect(ilLink::_getLink($target_ref_id));
698 }
getParentId(int $a_node_id)
get parent id of given node
static redirect(string $a_script)

References ilTree\getParentId(), ilObjSurvey\MODE_360, ILIAS\Repository\object(), and ilUtil\redirect().

+ Here is the call graph for this function:

◆ cancel()

ilSurveyExecutionGUI::cancel ( )

Definition at line 595 of file class.ilSurveyExecutionGUI.php.

595 : void
596 {
597 $this->ctrl->redirectByClass("ilobjsurveygui", "run");
598 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ checkAuth()

ilSurveyExecutionGUI::checkAuth ( bool  $a_may_start = false,
bool  $a_finished_run = false 
)
protected

Definition at line 151 of file class.ilSurveyExecutionGUI.php.

154 : void {
156 $ilUser = $this->user;
157 if ($this->preview) {
158 if (!$rbacsystem->checkAccess("write", $this->object->getRefId())) {
159 // only with write access it is possible to preview the survey
160 throw new ilSurveyException($this->lng->txt("survey_cannot_preview_survey"));
161 }
162 return;
163 }
164
165
166 if ($a_finished_run &&
167 !$this->access_manager->canRead() &&
168 !$this->participant_manager->isExternalRater()) {
169 throw new ilSurveyException($this->lng->txt("cannot_read_survey"));
170 }
171 if (!$a_finished_run && !$this->access_manager->canStartSurvey()) {
172 throw new ilSurveyException($this->lng->txt("cannot_read_survey"));
173 }
174
175 $user_id = $ilUser->getId();
176
177 // check existing code
178 // see ilObjSurveyGUI::infoScreen()
179 $anonymous_id = null;
180 $anonymous_code = "";
181 if ($this->access_manager->useCodeFromSession()) {
182 // get code from session
183 $anonymous_code = $this->run_manager->getCode();
184 $anonymous_id = $this->object->getAnonymousIdByCode($anonymous_code);
185 if (!$anonymous_id) {
186 $this->tpl->setOnScreenMessage('failure', sprintf($this->lng->txt("error_retrieving_anonymous_survey"), $anonymous_code, true));
187 $this->ctrl->redirectByClass("ilobjsurveygui", "run");
188 }
189 }
190
191 // appraisee validation
192 $appr_id = 0;
193 $appraisees = [];
194 if ($this->feature_config->usesAppraisees()) {
195 $appr_id = $this->requested_appr_id;
196 //if (!$appr_id) {
197 // $appr_id = $_SESSION["appr_id"][$this->object->getId()];
198 //}
199 // check if appraisee is valid
200 if ($anonymous_id) {
201 $appraisees = $this->object->getAppraiseesToRate(0, $anonymous_id);
202 }
203 if (!$appraisees && $user_id !== ANONYMOUS_USER_ID) {
204 $appraisees = $this->object->getAppraiseesToRate($user_id);
205 }
206 if (!in_array($appr_id, $appraisees)) {
207 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("survey_360_execution_invalid_appraisee"), true);
208 $this->ctrl->redirectByClass("ilobjsurveygui", "run");
209 }
210 }
211 //Self evaluation mode
212 #23575 in self eval the appraisee is the current user.
213 if ($this->object->getMode() === ilObjSurvey::MODE_SELF_EVAL) {
214 $appr_id = $ilUser->getId();
215 }
216
217 //$_SESSION["appr_id"][$this->object->getId()] = $appr_id;
218
219 if ($a_finished_run) {
220 if (!$this->run_manager->hasFinished()) {
221 throw new ilSurveyException($this->lng->txt("cannot_read_survey"));
222 }
223 } else {
224 // completed
225 if ($this->run_manager->hasFinished()) {
226 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("already_completed_survey"), true);
227 $this->ctrl->redirectByClass("ilobjsurveygui", "run");
228 }
229 // starting
230 elseif (!$this->run_manager->hasStarted()) {
231 if ($a_may_start) {
232 //$_SESSION["finished_id"][$this->object->getId()] =
233 // $this->object->startSurvey($user_id, $anonymous_code, $appr_id);
234 $this->run_manager->start($appr_id);
235 } else {
236 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("survey_use_start_button"), true);
237 $this->ctrl->redirectByClass("ilobjsurveygui", "run");
238 }
239 }
240 // resuming
241 else {
242 // nothing todo
243 }
244 }
245 // validate finished id
246 //var_dump($this->run_manager->getCurrentRunId());
247 //var_dump($this->object->getActiveID($user_id, $anonymous_code, $appr_id));
248 //exit;
249 // if anonymous read, without names, no codes, this succeedes, if second start (no resume button)
250 // - getCurrentRunId will use CODE (from session) to get run
251 // - getActiveID will use $anonymous_code set to get the same run id
252 // - $this->access_manager->isCodeInputAllowed() returns TRUE ($survey->getAnonymize() is 2)
253 // if anonymous read, with names, no codes, this fails here, if second start (resume button)
254 // - $this->access_manager->isCodeInputAllowed() returns FALSE
255 if ($this->object->getActiveID($user_id, $anonymous_code, $appr_id) !==
256 $this->run_manager->getCurrentRunId()) {
257 throw new ilSurveyException("Run ID mismatch");
258 }
259 }
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const ANONYMOUS_USER_ID
Definition: constants.php:27

References ilRbacSystem\checkAccess(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ confirmedFinish()

ilSurveyExecutionGUI::confirmedFinish ( )

Definition at line 805 of file class.ilSurveyExecutionGUI.php.

805 : void
806 {
807 $ilUser = $this->user;
808
809 if (!$this->preview) {
810 $this->object->finishSurvey($this->getCurrentRunId(), $this->requested_appr_id);
811
812 if ($ilUser->getId() !== ANONYMOUS_USER_ID) {
813 ilLPStatusWrapper::_updateStatus($this->object->getId(), $ilUser->getId());
814 }
815
816 // send "single participant has finished" mail to tutors
817 if ($this->object->getMailNotification()) {
818 $this->object->sendNotificationMail(
819 $ilUser->getId(),
820 $this->run_manager->getCode(),
821 $this->requested_appr_id
822 );
823 }
824 }
825
826 $this->ctrl->redirect($this, "runShowFinishedPage");
827 }
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)

References ilLPStatusWrapper\_updateStatus(), ANONYMOUS_USER_ID, ILIAS\Repository\ctrl(), ILIAS\Repository\object(), and ILIAS\UI\examples\Symbol\Glyph\Preview\preview().

+ Here is the call graph for this function:

◆ executeCommand()

ilSurveyExecutionGUI::executeCommand ( )

Definition at line 120 of file class.ilSurveyExecutionGUI.php.

120 : string
121 {
122 // record read event for lp
124 'svy',
125 $this->object->getRefId(),
126 $this->object->getId(),
127 $GLOBALS['DIC']->user()->getId()
128 );
129
130 $cmd = $this->ctrl->getCmd();
131 $next_class = $this->ctrl->getNextClass($this);
132
133 $this->log->debug("- cmd= " . $cmd);
134
135 if ($cmd === null || $cmd === '') {
136 $this->ctrl->setParameter(
137 $this,
138 "qid",
139 $this->request->getQuestionId()
140 );
141 $this->ctrl->redirect($this, "gotoPage");
142 }
143 switch ($next_class) {
144 default:
145 $ret = $this->$cmd();
146 break;
147 }
148 return (string) $ret;
149 }
static _recordReadEvent(string $a_type, int $a_ref_id, int $obj_id, int $usr_id, $a_ext_rc=null, $a_ext_time=null)
$GLOBALS["DIC"]
Definition: wac.php:66

References $GLOBALS, ilChangeEvent\_recordReadEvent(), ILIAS\Repository\ctrl(), and ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ exitSurvey()

ilSurveyExecutionGUI::exitSurvey ( )

Exits the survey after finishing it.

Definition at line 703 of file class.ilSurveyExecutionGUI.php.

703 : void
704 {
705 if (!$this->preview) {
706 $this->backToRepository();
707 } else {
708 // #12841
709 $this->ctrl->setParameterByClass("ilsurveyeditorgui", "pgov", $this->request->getTargetPosition());
710 $this->ctrl->redirectByClass(array("ilobjsurveygui", "ilsurveyeditorgui"), "questions");
711 }
712 }

References ILIAS\Repository\ctrl(), and ILIAS\UI\examples\Symbol\Glyph\Preview\preview().

+ Here is the call graph for this function:

◆ getCurrentRunId()

ilSurveyExecutionGUI::getCurrentRunId ( )
protected

Definition at line 529 of file class.ilSurveyExecutionGUI.php.

529 : int
530 {
531 return $this->run_manager->getCurrentRunId();
532 }

◆ gotoPage()

ilSurveyExecutionGUI::gotoPage ( )

Go to a specific page without saving.

Definition at line 356 of file class.ilSurveyExecutionGUI.php.

356 : void
357 {
358 $this->ctrl->setParameter($this, "activecommand", "gotoPage");
359 $this->ctrl->setParameter($this, "qid", $this->request->getQuestionId());
360 $this->ctrl->setParameter($this, "direction", "0");
361 $this->ctrl->redirect($this, "redirectQuestion");
362 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ mailUserResults()

ilSurveyExecutionGUI::mailUserResults ( )

Definition at line 763 of file class.ilSurveyExecutionGUI.php.

763 : void
764 {
765 $ilUser = $this->user;
766
767 if (!$this->object->hasMailConfirmation()) {
768 $this->backToRepository();
769 }
770
771 $this->checkAuth(false, true);
772
773 $recipient = $this->request->getMail();
774 if (!$recipient) {
775 $recipient = $ilUser->getEmail();
776 }
777 if (!ilUtil::is_email($recipient)) {
778 $this->ctrl->redirect($this, "runShowFinishedPage");
779 }
780
781 $survey_gui = new ilObjSurveyGUI();
782 $survey_gui->sendUserResultsMail(
783 $this->getCurrentRunId(),
784 $recipient
785 );
786
787 $this->tpl->setOnScreenMessage('success', $this->lng->txt("mail_sent"), true);
788 $this->ctrl->redirect($this, "runShowFinishedPage");
789 }
@ilCtrl_Calls ilObjSurveyGUI: ilSurveyEvaluationGUI, ilSurveyExecutionGUI @ilCtrl_Calls ilObjSurveyGU...
checkAuth(bool $a_may_start=false, bool $a_finished_run=false)
static is_email(string $a_email, ?ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.

References ILIAS\Repository\ctrl(), ilUtil\is_email(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ next()

ilSurveyExecutionGUI::next ( )

Navigates to the next page.

Definition at line 340 of file class.ilSurveyExecutionGUI.php.

340 : void
341 {
342 $result = $this->saveUserInput("next");
343 $this->ctrl->setParameter($this, "activecommand", "next");
344 $this->ctrl->setParameter($this, "qid", $this->request->getQuestionId());
345 if ($result > 0) {
346 $this->ctrl->setParameter($this, "direction", "0");
347 } else {
348 $this->ctrl->setParameter($this, "direction", "1");
349 }
350 $this->ctrl->redirect($this, "redirectQuestion");
351 }
saveUserInput(string $navigationDirection="next")
Save the user's input.

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ outNavigationButtons()

ilSurveyExecutionGUI::outNavigationButtons ( string  $navigationblock,
array  $page,
ilTemplate  $stpl 
)

Definition at line 714 of file class.ilSurveyExecutionGUI.php.

718 : void {
719 $question_id = (int) $page[0]["question_id"];
720 $prevpage = $this->object->getNextPage($question_id, -1);
721 $stpl->setCurrentBlock($navigationblock . "_prev");
722 if (is_null($prevpage)) {
723 $stpl->setVariable("BTN_PREV", $this->lng->txt("survey_start"));
724 } else {
725 $stpl->setVariable("BTN_PREV", $this->lng->txt("survey_previous"));
726 }
727 $stpl->parseCurrentBlock();
728 $nextpage = $this->object->getNextPage($question_id, 1);
729 $stpl->setCurrentBlock($navigationblock . "_next");
730 if (is_null($nextpage)) {
731 $stpl->setVariable("BTN_NEXT", $this->lng->txt("survey_finish"));
732 } else {
733 $stpl->setVariable("BTN_NEXT", $this->lng->txt("survey_next"));
734 }
735 $stpl->parseCurrentBlock();
736 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)

References ILIAS\Repository\lng(), and HTML_Template_IT\setVariable().

+ Here is the call graph for this function:

◆ outSurveyPage()

ilSurveyExecutionGUI::outSurveyPage ( int  $activepage = 0,
int  $direction = 0 
)

Output of the active survey question to the screen.

Exceptions
ilCtrlException
ilSurveyException

Definition at line 369 of file class.ilSurveyExecutionGUI.php.

372 : void {
373 $ilUser = $this->user;
374
375 $this->checkAuth();
376 $page = $this->object->getNextPage($activepage, $direction);
377 $constraint_true = 0;
378
379 // check for constraints
380 if (!is_null($page) && is_array($page[0]["constraints"]) && count($page[0]["constraints"])) {
381 $this->log->debug("Page constraints= ", $page[0]["constraints"]);
382
383 while (!is_null($page) and ($constraint_true == 0) and (count($page[0]["constraints"]))) {
384 $constraint_true = $page[0]['constraints'][0]['conjunction'] == 0;
385 foreach ($page[0]["constraints"] as $constraint) {
386 $constraint_question_id = (int) $constraint["question"];
387 if (!$this->preview) {
388 $working_data = $this->object->loadWorkingData(
389 $constraint_question_id,
390 $this->getCurrentRunId()
391 );
392 } else {
393 $working_data = $this->run_manager->getPreviewData($constraint_question_id);
394 }
395 if ($constraint['conjunction'] == 0) {
396 // and
397 $constraint_true &= $this->object->checkConstraint($constraint, $working_data);
398 } else {
399 // or
400 $constraint_true |= $this->object->checkConstraint($constraint, $working_data);
401 }
402 }
403 if ($constraint_true == 0) {
404 // #11047 - we are skipping the page, so we have to get rid of existing answers for that question(s)
405 foreach ($page as $page_question) {
406 $qid = (int) $page_question["question_id"];
407
408 // see saveActiveQuestionData()
409 if (!$this->preview) {
410 $this->object->deleteWorkingData($qid, $this->getCurrentRunId());
411 } else {
412 $this->run_manager->clearPreviewData($qid);
413 }
414 }
415
416 $page = $this->object->getNextPage((int) $page[0]["question_id"], $direction);
417 }
418 }
419 }
420 $first_question = -1;
421 if (is_null($page) && $direction === -1) {
422 $this->ctrl->redirectByClass("ilobjsurveygui", "run");
423 } elseif (is_null($page) && $direction === 1) {
424 $state = $this->object->getUserSurveyExecutionStatus();
425 if ($this->preview ||
426 !($state["runs"][$this->getCurrentRunId()]["finished"] ?? false)) {
427 $this->showFinishConfirmation();
428 } else {
429 $this->runShowFinishedPage();
430 }
431 return;
432 } else {
433 $ilHelp = $this->help;
434 $ilHelp->setScreenIdComponent("svy");
435 $ilHelp->setScreenId("quest_presentation");
436
437 if ($ilUser->getId() !== ANONYMOUS_USER_ID) {
438 ilLearningProgress::_tracProgress($ilUser->getId(), $this->object->getId(), $this->object->getRefId(), "svy");
439 }
440
441 $required = false;
442 //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_content.html", "components/ILIAS/Survey");
443 $stpl = new ilTemplate("tpl.il_svy_svy_content.html", true, true, "components/ILIAS/Survey");
444
445 // title / appraisee
446 if ($this->feature_config->usesAppraisees()) {
447 $appr_id = $this->requested_appr_id;
448
449 $this->tpl->setTitle($this->object->getTitle() . " (" .
450 $this->lng->txt("survey_360_appraisee") . ": " .
451 ilUserUtil::getNamePresentation($appr_id) . ")");
452 }
453
454 // top / bottom nav
455 // removed check for getAnonymize() due to #0045475
456 if (!($this->object->isAccessibleWithoutCode() && ($ilUser->getId() === ANONYMOUS_USER_ID))) {
457 $stpl->setCurrentBlock("suspend_survey");
458
459 if (!$this->preview) {
460 $stpl->setVariable("TEXT_SUSPEND", $this->lng->txt("cancel_survey"));
461 $stpl->setVariable("HREF_SUSPEND", $this->ctrl->getLinkTargetByClass("ilObjSurveyGUI", "run"));
462 } else {
463 $this->ctrl->setParameterByClass("ilObjSurveyGUI", "pgov", $this->request->getTargetPosition());
464 $stpl->setVariable("TEXT_SUSPEND", $this->lng->txt("survey_cancel_preview"));
465 $stpl->setVariable("HREF_SUSPEND", $this->ctrl->getLinkTargetByClass(array("ilObjSurveyGUI", "ilSurveyEditorGUI"), "questions"));
466 }
467
468 $stpl->setVariable("ALT_IMG_SUSPEND", $this->lng->txt("cancel_survey"));
469 $stpl->setVariable("TITLE_IMG_SUSPEND", $this->lng->txt("cancel_survey"));
470 $stpl->parseCurrentBlock();
471 }
472 $this->outNavigationButtons("top", $page, $stpl);
473 $this->outNavigationButtons("bottom", $page, $stpl);
474
475 // progress
476 $stpl->setCurrentBlock("percentage");
477 $percentage = (int) (($page[0]["position"]) * 100);
479 $pbar->setCurrent($percentage);
480 $stpl->setVariable("NEW_PBAR", $pbar->render());
481 $stpl->parseCurrentBlock();
482
483 // questions
484 $working_data = [];
485 $errors = $this->run_manager->getErrors();
486 foreach ($page as $data) {
487 $question_id = (int) $data["question_id"];
488 if ($first_question === -1) {
489 $first_question = $question_id;
490 }
491 $question_gui = $this->object->getQuestionGUI((string) $data["type_tag"], $question_id);
492
493 if (count($errors) > 0) {
494 $working_data[$question_id] = $question_gui->object->getWorkingDataFromUserInput(
495 $this->run_manager->getPostData()
496 );
497 } else {
498 if (!$this->preview) {
499 $working_data[$question_id] = $this->object->loadWorkingData(
500 $question_id,
501 $this->run_manager->getCurrentRunId()
502 );
503 } else {
504 $working_data[$question_id] = $this->run_manager->getPreviewData($question_id);
505 }
506 }
507 }
508
509 $page_renderer = new \ILIAS\Survey\Page\PageRenderer(
510 $this->object,
511 $page,
512 $working_data,
513 $errors
514 );
515
516 $stpl->setVariable("PAGE", $page_renderer->render());
517
518 $this->ctrl->setParameter($this, "qid", $first_question);
519 $stpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "redirectQuestion"));
520 $this->tpl->setContent($stpl->get());
521 }
522
523 if (!$this->preview) {
524 $this->object->setPage($this->getCurrentRunId(), (int) $page[0]['question_id']);
525 $this->run_manager->setStartTime($first_question);
526 }
527 }
setScreenIdComponent(string $a_comp)
static _tracProgress(int $a_user_id, int $a_obj_id, int $a_ref_id, string $a_obj_type='')
outNavigationButtons(string $navigationblock, array $page, ilTemplate $stpl)
runShowFinishedPage()
Show finish page.
special template class to simplify handling of ITX/PEAR
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
Default behaviour is:
$data
Definition: storeScorm.php:45

◆ preview()

ilSurveyExecutionGUI::preview ( )

Definition at line 738 of file class.ilSurveyExecutionGUI.php.

738 : void
739 {
740 $this->outSurveyPage();
741 }
outSurveyPage(int $activepage=0, int $direction=0)
Output of the active survey question to the screen.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ previous()

ilSurveyExecutionGUI::previous ( bool  $a_save_input = true)

Definition at line 319 of file class.ilSurveyExecutionGUI.php.

321 : void {
322 $has_error = "";
323 if ($a_save_input) {
324 // #16209
325 $has_error = $this->saveUserInput("previous");
326 }
327 $this->ctrl->setParameter($this, "activecommand", "previous");
328 $this->ctrl->setParameter($this, "qid", $this->request->getQuestionId());
329 if ($has_error > 0) {
330 $this->ctrl->setParameter($this, "direction", "0");
331 } else {
332 $this->ctrl->setParameter($this, "direction", "-1");
333 }
334 $this->ctrl->redirect($this, "redirectQuestion");
335 }

◆ previousNoSave()

ilSurveyExecutionGUI::previousNoSave ( )

Definition at line 314 of file class.ilSurveyExecutionGUI.php.

314 : void
315 {
316 $this->previous(false);
317 }
previous(bool $a_save_input=true)

◆ redirectQuestion()

ilSurveyExecutionGUI::redirectQuestion ( )

Called when a user answered a page to perform a redirect after POST.

This is called for security reasons to prevent users sending a form twice.

Definition at line 293 of file class.ilSurveyExecutionGUI.php.

293 : void
294 {
295 switch ($this->request->getActiveCommand()) {
296 case "previous":
297 case "gotoPage":
298 case "next":
299 $this->outSurveyPage(
300 $this->request->getQuestionId(),
301 $this->request->getDirection()
302 );
303 break;
304 case "default":
305 $this->outSurveyPage($this->request->getQuestionId());
306 break;
307 default:
308 // don't save input, go to the first page
309 $this->outSurveyPage();
310 break;
311 }
312 }

◆ resume()

ilSurveyExecutionGUI::resume ( )

Definition at line 261 of file class.ilSurveyExecutionGUI.php.

261 : void
262 {
263 $this->start(true);
264 }

◆ runShowFinishedPage()

ilSurveyExecutionGUI::runShowFinishedPage ( )

Show finish page.

Definition at line 603 of file class.ilSurveyExecutionGUI.php.

603 : void
604 {
605 $ilToolbar = $this->toolbar;
606 $ilUser = $this->user;
607
608 $has_button = false;
609
610
611 if (!$this->preview) {
612 if ($this->object->hasViewOwnResults()) {
613 $this->gui->link(
614 $this->lng->txt("svy_view_own_results"),
615 $this->ctrl->getLinkTarget($this, "viewUserResults")
616 )->toToolbar();
617
618 $has_button = true;
619 }
620
621 if ($this->object->hasMailConfirmation()) {
622 if ($has_button) {
623 $ilToolbar->addSeparator();
624 }
625
626 if ($ilUser->getId() === ANONYMOUS_USER_ID ||
627 !$ilUser->getEmail()) {
628 $mail = new ilTextInputGUI($this->lng->txt("email"), "mail");
629 $mail->setSize(25);
630 $ilToolbar->addInputItem($mail, true);
631 }
632
633 $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "mailUserResults"));
634
635 $this->gui->button(
636 $this->lng->txt("svy_mail_send_confirmation"),
637 "mailUserResults"
638 )->submit()->toToolbar();
639
640 $has_button = true;
641 }
642
643 // #6307
644 if (ilObjSurveyAccess::_hasEvaluationAccess($this->object->getId(), $ilUser->getId())) {
645 $this->gui->link(
646 $this->lng->txt("svy_results"),
647 $this->ctrl->getLinkTargetByClass("ilObjSurveyGUI", "evaluation")
648 )->toToolbar();
649
650 $has_button = true;
651 }
652 }
653
654 if (!$has_button &&
655 $this->object->getOutro() === '') {
656 $this->exitSurvey();
657 } else {
658 if ($has_button) {
659 $ilToolbar->addSeparator();
660 }
661
662 if ($this->object->getMode() === ilObjSurvey::MODE_360) {
663 $txt = $this->lng->txt("survey_execution_exit_360");
664 } else {
665 $txt = $this->lng->txt("survey_execution_exit");
666 }
667 $this->gui->button(
668 $txt,
669 $this->ctrl->getLinkTarget($this, "exitSurvey")
670 )->toToolbar();
671
672 if ($this->object->getOutro() !== '') {
673 $f = $this->gui->ui()->factory();
674 $r = $this->gui->ui()->renderer();
675 $p = $f->panel()->standard(
676 "",
677 $f->legacy()->content($this->object->prepareTextareaOutput($this->object->getOutro()))
678 );
679
680 $this->tpl->setContent($r->render($p));
681 }
682 }
683 }
static _hasEvaluationAccess(int $a_obj_id, int $user_id)
exitSurvey()
Exits the survey after finishing it.
This class represents a text property in a property form.

References Vendor\Package\$f, ilObjSurveyAccess\_hasEvaluationAccess(), ANONYMOUS_USER_ID, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ilObjSurvey\MODE_360, ILIAS\Repository\object(), and ILIAS\UI\examples\Symbol\Glyph\Preview\preview().

+ Here is the call graph for this function:

◆ saveActiveQuestionData()

ilSurveyExecutionGUI::saveActiveQuestionData ( array  $data)

Saves the users input of the active page.

Definition at line 569 of file class.ilSurveyExecutionGUI.php.

569 : int
570 {
571 $question_id = (int) $data["question_id"];
572 $question = SurveyQuestion::_instanciateQuestion($question_id);
573 $error = $question->checkUserInput($this->raw_post_data, $this->object->getSurveyId());
574 if (strlen($error) === 0) {
575 if (!$this->preview) {
576 // delete old answers
577 $this->object->deleteWorkingData($question_id, $this->getCurrentRunId());
578
579 $question->saveUserInput($this->raw_post_data, $this->getCurrentRunId());
580 } else {
581 $this->run_manager->setPreviewData(
582 $question_id,
583 $question->saveUserInput($this->raw_post_data, 0, true)
584 );
585 }
586 return 0;
587 } else {
588 $errors = $this->run_manager->getErrors();
589 $errors[$question->getId()] = $error;
590 $this->run_manager->setErrors($errors);
591 return 1;
592 }
593 }
static _instanciateQuestion(int $question_id)
Get question object.

References $data, SurveyQuestion\_instanciateQuestion(), ILIAS\Repository\int(), ILIAS\Repository\object(), and ILIAS\UI\examples\Symbol\Glyph\Preview\preview().

+ Here is the call graph for this function:

◆ saveUserInput()

ilSurveyExecutionGUI::saveUserInput ( string  $navigationDirection = "next")

Save the user's input.

Definition at line 537 of file class.ilSurveyExecutionGUI.php.

539 : int {
540 if (!$this->preview) {
541 $this->run_manager->setEndTime();
542 }
543
544 // check users input when it is a metric question
545 $this->run_manager->clearErrors();
546 $this->run_manager->setPostData($this->raw_post_data);
547
548 $page_error = 0;
549 $page = $this->object->getNextPage($this->request->getQuestionId(), 0);
550 foreach ($page as $data) {
551 $page_error += $this->saveActiveQuestionData($data);
552 }
553 if ($page_error && (strcmp($navigationDirection, "previous") !== 0)) {
554 if ($page_error === 1) {
555 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("svy_page_error"), true);
556 } else {
557 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("svy_page_errors"), true);
558 }
559 } else {
560 $page_error = 0;
561 $this->run_manager->clearErrors();
562 }
563 return $page_error;
564 }
saveActiveQuestionData(array $data)
Saves the users input of the active page.

◆ showFinishConfirmation()

ilSurveyExecutionGUI::showFinishConfirmation ( )

Definition at line 791 of file class.ilSurveyExecutionGUI.php.

791 : void
792 {
794
795 $cgui = new ilConfirmationGUI();
796 $cgui->setHeaderText($this->lng->txt("survey_execution_sure_finish"));
797
798 $cgui->setFormAction($this->ctrl->getFormAction($this, "confirmedFinish"));
799 $cgui->setCancel($this->lng->txt("cancel"), "previousNoSave");
800 $cgui->setConfirm($this->lng->txt("confirm"), "confirmedFinish");
801
802 $tpl->setContent($cgui->getHTML());
803 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setContent(string $a_html)
Sets content for standard template.

References ILIAS\News\Common\Table\$tpl, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\UICore\GlobalTemplate\setContent().

+ Here is the call graph for this function:

◆ start()

ilSurveyExecutionGUI::start ( bool  $resume = false)

Definition at line 266 of file class.ilSurveyExecutionGUI.php.

266 : void
267 {
268 if ($this->preview) {
269 $this->run_manager->clearAllPreviewData();
270 }
271 $this->run_manager->clearErrors();
272
273 $this->checkAuth(!$resume);
274
275 $activepage = "";
276 if ($resume) {
277 $activepage = $this->object->getLastActivePage(
278 $this->getCurrentRunId()
279 );
280 }
281
282 if ((string) $activepage !== '') {
283 $this->ctrl->setParameter($this, "qid", (string) $activepage);
284 }
285 $this->ctrl->setParameter($this, "activecommand", "default");
286 $this->ctrl->redirect($this, "redirectQuestion");
287 }

References ILIAS\Repository\ctrl(), and ILIAS\UI\examples\Symbol\Glyph\Preview\preview().

+ Here is the call graph for this function:

◆ viewUserResults()

ilSurveyExecutionGUI::viewUserResults ( )

Definition at line 743 of file class.ilSurveyExecutionGUI.php.

743 : void
744 {
745 $ilToolbar = $this->toolbar;
746
747 if (!$this->object->hasViewOwnResults()) {
748 $this->backToRepository();
749 }
750
751 $this->checkAuth(false, true);
752
753 $this->gui->link(
754 $this->lng->txt("btn_back"),
755 $this->ctrl->getLinkTarget($this, "runShowFinishedPage")
756 )->toToolbar();
757
758 $survey_gui = new ilObjSurveyGUI();
759 $html = $survey_gui->getUserResultsTable($this->getCurrentRunId());
760 $this->tpl->setContent($html);
761 }

References ILIAS\Repository\lng(), and ILIAS\Repository\object().

+ Here is the call graph for this function:

Field Documentation

◆ $access_manager

ILIAS Survey Access AccessManager ilSurveyExecutionGUI::$access_manager
protected

Definition at line 51 of file class.ilSurveyExecutionGUI.php.

◆ $ctrl

ilCtrl ilSurveyExecutionGUI::$ctrl
protected

Definition at line 45 of file class.ilSurveyExecutionGUI.php.

◆ $feature_config

Mode FeatureConfig ilSurveyExecutionGUI::$feature_config
protected

Definition at line 53 of file class.ilSurveyExecutionGUI.php.

◆ $gui

ILIAS Survey InternalGUIService ilSurveyExecutionGUI::$gui
protected

Definition at line 34 of file class.ilSurveyExecutionGUI.php.

◆ $help

ilHelpGUI ilSurveyExecutionGUI::$help
protected

Definition at line 40 of file class.ilSurveyExecutionGUI.php.

◆ $lng

ilLanguage ilSurveyExecutionGUI::$lng
protected

Definition at line 43 of file class.ilSurveyExecutionGUI.php.

Referenced by __construct().

◆ $log

ilLogger ilSurveyExecutionGUI::$log
protected

Definition at line 48 of file class.ilSurveyExecutionGUI.php.

◆ $object

ilObjSurvey ilSurveyExecutionGUI::$object
protected

Definition at line 42 of file class.ilSurveyExecutionGUI.php.

◆ $participant_manager

ILIAS Survey Participants StatusManager ilSurveyExecutionGUI::$participant_manager
protected

Definition at line 50 of file class.ilSurveyExecutionGUI.php.

◆ $preview

bool ilSurveyExecutionGUI::$preview
protected

Definition at line 47 of file class.ilSurveyExecutionGUI.php.

◆ $raw_post_data

array ilSurveyExecutionGUI::$raw_post_data
protected

Definition at line 36 of file class.ilSurveyExecutionGUI.php.

◆ $rbacsystem

ilRbacSystem ilSurveyExecutionGUI::$rbacsystem
protected

Definition at line 38 of file class.ilSurveyExecutionGUI.php.

◆ $request

ILIAS Survey Execution ExecutionGUIRequest ilSurveyExecutionGUI::$request
protected

Definition at line 37 of file class.ilSurveyExecutionGUI.php.

◆ $requested_appr_id

int ilSurveyExecutionGUI::$requested_appr_id
protected

Definition at line 52 of file class.ilSurveyExecutionGUI.php.

Referenced by __construct().

◆ $run_manager

ILIAS Survey Execution RunManager ilSurveyExecutionGUI::$run_manager
protected

Definition at line 49 of file class.ilSurveyExecutionGUI.php.

◆ $toolbar

ilToolbarGUI ilSurveyExecutionGUI::$toolbar
protected

Definition at line 41 of file class.ilSurveyExecutionGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilSurveyExecutionGUI::$tpl
protected

Definition at line 44 of file class.ilSurveyExecutionGUI.php.

Referenced by __construct().

◆ $tree

ilTree ilSurveyExecutionGUI::$tree
protected

Definition at line 46 of file class.ilSurveyExecutionGUI.php.

Referenced by __construct().

◆ $user

ilObjUser ilSurveyExecutionGUI::$user
protected

Definition at line 39 of file class.ilSurveyExecutionGUI.php.


The documentation for this class was generated from the following file: