ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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_ignore_status=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 30 of file class.ilSurveyExecutionGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilSurveyExecutionGUI::__construct ( ilObjSurvey  $a_object)

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

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().

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  $this->raw_post_data = $DIC->http()->request()->getParsedBody() ?? [];
117  }
static getLogger(string $a_component_id)
Get component logger.
ilGlobalTemplateInterface $tpl
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ backToRepository()

ilSurveyExecutionGUI::backToRepository ( )

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

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

Referenced by exitSurvey(), mailUserResults(), and viewUserResults().

662  : void
663  {
664  $tree = $this->tree;
665 
666  // #14971
667  if ($this->object->getMode() === ilObjSurvey::MODE_360) {
668  $target_ref_id = $this->object->getRefId();
669  } else {
670  // #11534
671  $target_ref_id = $tree->getParentId($this->object->getRefId());
672  }
673 
674  ilUtil::redirect(ilLink::_getLink($target_ref_id));
675  }
getParentId(int $a_node_id)
get parent id of given node
static redirect(string $a_script)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancel()

ilSurveyExecutionGUI::cancel ( )

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

References ILIAS\Repository\ctrl().

572  : void
573  {
574  $this->ctrl->redirectByClass("ilobjsurveygui", "run");
575  }
+ Here is the call graph for this function:

◆ checkAuth()

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

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

References $rbacsystem, $requested_appr_id, $user, $user_id, ANONYMOUS_USER_ID, ilRbacSystem\checkAccess(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ilObjSurvey\MODE_SELF_EVAL, null, ILIAS\Repository\object(), and preview().

Referenced by mailUserResults(), outSurveyPage(), start(), and viewUserResults().

153  : void {
155  $ilUser = $this->user;
156 
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 (!$this->access_manager->canStartSurvey()) {
167  // only with read access it is possible to run the test
168  throw new ilSurveyException($this->lng->txt("cannot_read_survey"));
169  }
170 
171  $user_id = $ilUser->getId();
172 
173  // check existing code
174  // see ilObjSurveyGUI::infoScreen()
175  $anonymous_id = null;
176  $anonymous_code = "";
177  if ($this->access_manager->isCodeInputAllowed()) {
178  $anonymous_code = $this->run_manager->getCode();
179  $anonymous_id = $this->object->getAnonymousIdByCode($anonymous_code);
180  if (!$anonymous_id) {
181  $this->tpl->setOnScreenMessage('failure', sprintf($this->lng->txt("error_retrieving_anonymous_survey"), $anonymous_code, true));
182  $this->ctrl->redirectByClass("ilobjsurveygui", "run");
183  }
184  }
185 
186  // appraisee validation
187  $appr_id = 0;
188  $appraisees = [];
189  if ($this->feature_config->usesAppraisees()) {
190  $appr_id = $this->requested_appr_id;
191  //if (!$appr_id) {
192  // $appr_id = $_SESSION["appr_id"][$this->object->getId()];
193  //}
194  // check if appraisee is valid
195  if ($anonymous_id) {
196  $appraisees = $this->object->getAppraiseesToRate(0, $anonymous_id);
197  }
198  if (!$appraisees && $user_id !== ANONYMOUS_USER_ID) {
199  $appraisees = $this->object->getAppraiseesToRate($user_id);
200  }
201  if (!in_array($appr_id, $appraisees)) {
202  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("survey_360_execution_invalid_appraisee"), true);
203  $this->ctrl->redirectByClass("ilobjsurveygui", "run");
204  }
205  }
206  //Self evaluation mode
207  #23575 in self eval the appraisee is the current user.
208  if ($this->object->getMode() === ilObjSurvey::MODE_SELF_EVAL) {
209  $appr_id = $ilUser->getId();
210  }
211 
212  //$_SESSION["appr_id"][$this->object->getId()] = $appr_id;
213 
214  if (!$a_ignore_status) {
215  // completed
216  if ($this->run_manager->hasFinished()) {
217  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("already_completed_survey"), true);
218  $this->ctrl->redirectByClass("ilobjsurveygui", "run");
219  }
220  // starting
221  elseif (!$this->run_manager->hasStarted()) {
222  if ($a_may_start) {
223  //$_SESSION["finished_id"][$this->object->getId()] =
224  // $this->object->startSurvey($user_id, $anonymous_code, $appr_id);
225  $this->run_manager->start($appr_id);
226  } else {
227  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("survey_use_start_button"), true);
228  $this->ctrl->redirectByClass("ilobjsurveygui", "run");
229  }
230  }
231  // resuming
232  else {
233  // nothing todo
234  }
235  }
236 
237  // validate finished id
238  if ($this->object->getActiveID($user_id, $anonymous_code, $appr_id) !==
239  $this->run_manager->getCurrentRunId()) {
240  throw new ilSurveyException("Run ID mismatch");
241  }
242  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 ...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmedFinish()

ilSurveyExecutionGUI::confirmedFinish ( )

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

References $requested_appr_id, $user, ilLPStatusWrapper\_updateStatus(), ANONYMOUS_USER_ID, ILIAS\Repository\ctrl(), getCurrentRunId(), ILIAS\Repository\object(), and preview().

781  : void
782  {
783  $ilUser = $this->user;
784 
785  if (!$this->preview) {
786  $this->object->finishSurvey($this->getCurrentRunId(), $this->requested_appr_id);
787 
788  if ($ilUser->getId() !== ANONYMOUS_USER_ID) {
789  ilLPStatusWrapper::_updateStatus($this->object->getId(), $ilUser->getId());
790  }
791 
792  // send "single participant has finished" mail to tutors
793  if ($this->object->getMailNotification()) {
794  $this->object->sendNotificationMail(
795  $ilUser->getId(),
796  $this->run_manager->getCode(),
798  );
799  }
800  }
801 
802  $this->ctrl->redirect($this, "runShowFinishedPage");
803  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
+ Here is the call graph for this function:

◆ executeCommand()

ilSurveyExecutionGUI::executeCommand ( )

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

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

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

◆ exitSurvey()

ilSurveyExecutionGUI::exitSurvey ( )

Exits the survey after finishing it.

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

References backToRepository(), ILIAS\Repository\ctrl(), and preview().

Referenced by runShowFinishedPage().

680  : void
681  {
682  if (!$this->preview) {
683  $this->backToRepository();
684  } else {
685  // #12841
686  $this->ctrl->setParameterByClass("ilsurveyeditorgui", "pgov", $this->request->getTargetPosition());
687  $this->ctrl->redirectByClass(array("ilobjsurveygui", "ilsurveyeditorgui"), "questions");
688  }
689  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCurrentRunId()

ilSurveyExecutionGUI::getCurrentRunId ( )
protected

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

Referenced by confirmedFinish(), mailUserResults(), outSurveyPage(), saveActiveQuestionData(), start(), and viewUserResults().

507  : int
508  {
509  return $this->run_manager->getCurrentRunId();
510  }
+ Here is the caller graph for this function:

◆ gotoPage()

ilSurveyExecutionGUI::gotoPage ( )

Go to a specific page without saving.

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

References ILIAS\Repository\ctrl().

339  : void
340  {
341  $this->ctrl->setParameter($this, "activecommand", "gotoPage");
342  $this->ctrl->setParameter($this, "qid", $this->request->getQuestionId());
343  $this->ctrl->setParameter($this, "direction", "0");
344  $this->ctrl->redirect($this, "redirectQuestion");
345  }
+ Here is the call graph for this function:

◆ mailUserResults()

ilSurveyExecutionGUI::mailUserResults ( )

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

References $user, backToRepository(), checkAuth(), ILIAS\Repository\ctrl(), getCurrentRunId(), ilUtil\is_email(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

739  : void
740  {
741  $ilUser = $this->user;
742 
743  if (!$this->object->hasMailConfirmation()) {
744  $this->backToRepository();
745  }
746 
747  $this->checkAuth(false, true);
748 
749  $recipient = $this->request->getMail();
750  if (!$recipient) {
751  $recipient = $ilUser->getEmail();
752  }
753  if (!ilUtil::is_email($recipient)) {
754  $this->ctrl->redirect($this, "runShowFinishedPage");
755  }
756 
757  $survey_gui = new ilObjSurveyGUI();
758  $survey_gui->sendUserResultsMail(
759  $this->getCurrentRunId(),
760  $recipient
761  );
762 
763  $this->tpl->setOnScreenMessage('success', $this->lng->txt("mail_sent"), true);
764  $this->ctrl->redirect($this, "runShowFinishedPage");
765  }
static is_email(string $a_email, ?ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
ilObjSurveyGUI: ilSurveyEvaluationGUI, ilSurveyExecutionGUI ilObjSurveyGUI: ilObjectMetaDataGUI, ilPermissionGUI ilObjSurveyGUI: ilInfoScreenGUI, ilObjectCopyGUI ilObjSurveyGUI: ilSurveySkillDeterminationGUI ilObjSurveyGUI: ilCommonActionDispatcherGUI, ilSurveySkillGUI ilObjSurveyGUI: ilSurveyEditorGUI, ilSurveyConstraintsGUI ilObjSurveyGUI: ilSurveyParticipantsGUI, ilLearningProgressGUI ilObjSurveyGUI: ilExportGUI, ilLTIProviderObjectSettingGUI ilObjSurveyGUI: ILIAS
checkAuth(bool $a_may_start=false, bool $a_ignore_status=false)
+ Here is the call graph for this function:

◆ next()

ilSurveyExecutionGUI::next ( )

Navigates to the next page.

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

References ILIAS\Repository\ctrl(), and saveUserInput().

323  : void
324  {
325  $result = $this->saveUserInput("next");
326  $this->ctrl->setParameter($this, "activecommand", "next");
327  $this->ctrl->setParameter($this, "qid", $this->request->getQuestionId());
328  if ($result > 0) {
329  $this->ctrl->setParameter($this, "direction", "0");
330  } else {
331  $this->ctrl->setParameter($this, "direction", "1");
332  }
333  $this->ctrl->redirect($this, "redirectQuestion");
334  }
saveUserInput(string $navigationDirection="next")
Save the user's input.
+ Here is the call graph for this function:

◆ outNavigationButtons()

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

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

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

Referenced by outSurveyPage().

695  : void {
696  $prevpage = $this->object->getNextPage($page[0]["question_id"], -1);
697  $stpl->setCurrentBlock($navigationblock . "_prev");
698  if (is_null($prevpage)) {
699  $stpl->setVariable("BTN_PREV", $this->lng->txt("survey_start"));
700  } else {
701  $stpl->setVariable("BTN_PREV", $this->lng->txt("survey_previous"));
702  }
703  $stpl->parseCurrentBlock();
704  $nextpage = $this->object->getNextPage($page[0]["question_id"], 1);
705  $stpl->setCurrentBlock($navigationblock . "_next");
706  if (is_null($nextpage)) {
707  $stpl->setVariable("BTN_NEXT", $this->lng->txt("survey_finish"));
708  } else {
709  $stpl->setVariable("BTN_NEXT", $this->lng->txt("survey_next"));
710  }
711  $stpl->parseCurrentBlock();
712  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:
+ Here is the caller 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 352 of file class.ilSurveyExecutionGUI.php.

References $data, $help, $requested_appr_id, $user, ilLearningProgress\_tracProgress(), ANONYMOUS_USER_ID, checkAuth(), ILIAS\Repository\ctrl(), getCurrentRunId(), ilProgressBar\getInstance(), ilUserUtil\getNamePresentation(), ILIAS\Repository\int(), ILIAS\Repository\lng(), ILIAS\Repository\object(), outNavigationButtons(), preview(), runShowFinishedPage(), ilHelpGUI\setScreenIdComponent(), and showFinishConfirmation().

Referenced by preview(), and redirectQuestion().

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

◆ preview()

ilSurveyExecutionGUI::preview ( )

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

References outSurveyPage().

Referenced by __construct(), checkAuth(), confirmedFinish(), exitSurvey(), outSurveyPage(), runShowFinishedPage(), saveActiveQuestionData(), saveUserInput(), and start().

714  : void
715  {
716  $this->outSurveyPage();
717  }
outSurveyPage(int $activepage=0, int $direction=0)
Output of the active survey question to the screen.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ previous()

ilSurveyExecutionGUI::previous ( bool  $a_save_input = true)

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

References ILIAS\Repository\ctrl(), and saveUserInput().

Referenced by previousNoSave().

304  : void {
305  $has_error = "";
306  if ($a_save_input) {
307  // #16209
308  $has_error = $this->saveUserInput("previous");
309  }
310  $this->ctrl->setParameter($this, "activecommand", "previous");
311  $this->ctrl->setParameter($this, "qid", $this->request->getQuestionId());
312  if ($has_error > 0) {
313  $this->ctrl->setParameter($this, "direction", "0");
314  } else {
315  $this->ctrl->setParameter($this, "direction", "-1");
316  }
317  $this->ctrl->redirect($this, "redirectQuestion");
318  }
saveUserInput(string $navigationDirection="next")
Save the user's input.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ previousNoSave()

ilSurveyExecutionGUI::previousNoSave ( )

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

References previous().

297  : void
298  {
299  $this->previous(false);
300  }
previous(bool $a_save_input=true)
+ Here is the call graph for this function:

◆ 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 276 of file class.ilSurveyExecutionGUI.php.

References outSurveyPage().

276  : void
277  {
278  switch ($this->request->getActiveCommand()) {
279  case "previous":
280  case "gotoPage":
281  case "next":
282  $this->outSurveyPage(
283  $this->request->getQuestionId(),
284  $this->request->getDirection()
285  );
286  break;
287  case "default":
288  $this->outSurveyPage($this->request->getQuestionId());
289  break;
290  default:
291  // don't save input, go to the first page
292  $this->outSurveyPage();
293  break;
294  }
295  }
outSurveyPage(int $activepage=0, int $direction=0)
Output of the active survey question to the screen.
+ Here is the call graph for this function:

◆ resume()

ilSurveyExecutionGUI::resume ( )

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

References start().

244  : void
245  {
246  $this->start(true);
247  }
+ Here is the call graph for this function:

◆ runShowFinishedPage()

ilSurveyExecutionGUI::runShowFinishedPage ( )

Show finish page.

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

References Vendor\Package\$f, $r, $toolbar, $txt, $user, ilObjSurveyAccess\_hasEvaluationAccess(), ANONYMOUS_USER_ID, ILIAS\Repository\ctrl(), exitSurvey(), ILIAS\Repository\lng(), ilObjSurvey\MODE_360, ILIAS\Repository\object(), and preview().

Referenced by outSurveyPage().

580  : void
581  {
582  $ilToolbar = $this->toolbar;
583  $ilUser = $this->user;
584 
585  $has_button = false;
586 
587 
588  if (!$this->preview) {
589  if ($this->object->hasViewOwnResults()) {
590  $this->gui->link(
591  $this->lng->txt("svy_view_own_results"),
592  $this->ctrl->getLinkTarget($this, "viewUserResults")
593  )->toToolbar();
594 
595  $has_button = true;
596  }
597 
598  if ($this->object->hasMailConfirmation()) {
599  if ($has_button) {
600  $ilToolbar->addSeparator();
601  }
602 
603  if ($ilUser->getId() === ANONYMOUS_USER_ID ||
604  !$ilUser->getEmail()) {
605  $mail = new ilTextInputGUI($this->lng->txt("email"), "mail");
606  $mail->setSize(25);
607  $ilToolbar->addInputItem($mail, true);
608  }
609 
610  $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "mailUserResults"));
611 
612  $this->gui->button(
613  $this->lng->txt("svy_mail_send_confirmation"),
614  "mailUserResults"
615  )->submit()->toToolbar();
616 
617  $has_button = true;
618  }
619 
620  // #6307
621  if (ilObjSurveyAccess::_hasEvaluationAccess($this->object->getId(), $ilUser->getId())) {
622  $this->gui->link(
623  $this->lng->txt("svy_results"),
624  $this->ctrl->getLinkTargetByClass("ilObjSurveyGUI", "evaluation")
625  )->toToolbar();
626 
627  $has_button = true;
628  }
629  }
630 
631  if (!$has_button &&
632  $this->object->getOutro() === '') {
633  $this->exitSurvey();
634  } else {
635  if ($has_button) {
636  $ilToolbar->addSeparator();
637  }
638 
639  if ($this->object->getMode() === ilObjSurvey::MODE_360) {
640  $txt = $this->lng->txt("survey_execution_exit_360");
641  } else {
642  $txt = $this->lng->txt("survey_execution_exit");
643  }
644  $this->gui->button(
645  $txt,
646  $this->ctrl->getLinkTarget($this, "exitSurvey")
647  )->toToolbar();
648 
649  if ($this->object->getOutro() !== '') {
650  $f = $this->gui->ui()->factory();
651  $r = $this->gui->ui()->renderer();
652  $p = $f->panel()->standard(
653  "",
654  $f->legacy()->content($this->object->prepareTextareaOutput($this->object->getOutro()))
655  );
656 
657  $this->tpl->setContent($r->render($p));
658  }
659  }
660  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
exitSurvey()
Exits the survey after finishing it.
$txt
Definition: error.php:31
static _hasEvaluationAccess(int $a_obj_id, int $user_id)
$r
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveActiveQuestionData()

ilSurveyExecutionGUI::saveActiveQuestionData ( array  $data)

Saves the users input of the active page.

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

References SurveyQuestion\_instanciateQuestion(), getCurrentRunId(), ILIAS\Repository\object(), and preview().

Referenced by saveUserInput().

547  : int
548  {
549  $question = SurveyQuestion::_instanciateQuestion($data["question_id"]);
550  $error = $question->checkUserInput($this->raw_post_data, $this->object->getSurveyId());
551  if (strlen($error) === 0) {
552  if (!$this->preview) {
553  // delete old answers
554  $this->object->deleteWorkingData($data["question_id"], $this->getCurrentRunId());
555 
556  $question->saveUserInput($this->raw_post_data, $this->getCurrentRunId());
557  } else {
558  $this->run_manager->setPreviewData(
559  $data["question_id"],
560  $question->saveUserInput($this->raw_post_data, 0, true)
561  );
562  }
563  return 0;
564  } else {
565  $errors = $this->run_manager->getErrors();
566  $errors[$question->getId()] = $error;
567  $this->run_manager->setErrors($errors);
568  return 1;
569  }
570  }
static _instanciateQuestion(int $question_id)
Get question object.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveUserInput()

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

Save the user's input.

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

References $data, ILIAS\Repository\lng(), preview(), and saveActiveQuestionData().

Referenced by next(), and previous().

517  : int {
518  if (!$this->preview) {
519  $this->run_manager->setEndTime();
520  }
521 
522  // check users input when it is a metric question
523  $this->run_manager->clearErrors();
524  $this->run_manager->setPostData($this->raw_post_data);
525 
526  $page_error = 0;
527  $page = $this->object->getNextPage($this->request->getQuestionId(), 0);
528  foreach ($page as $data) {
529  $page_error += $this->saveActiveQuestionData($data);
530  }
531  if ($page_error && (strcmp($navigationDirection, "previous") !== 0)) {
532  if ($page_error === 1) {
533  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("svy_page_error"), true);
534  } else {
535  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("svy_page_errors"), true);
536  }
537  } else {
538  $page_error = 0;
539  $this->run_manager->clearErrors();
540  }
541  return $page_error;
542  }
saveActiveQuestionData(array $data)
Saves the users input of the active page.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showFinishConfirmation()

ilSurveyExecutionGUI::showFinishConfirmation ( )

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

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

Referenced by outSurveyPage().

767  : void
768  {
769  $tpl = $this->tpl;
770 
771  $cgui = new ilConfirmationGUI();
772  $cgui->setHeaderText($this->lng->txt("survey_execution_sure_finish"));
773 
774  $cgui->setFormAction($this->ctrl->getFormAction($this, "confirmedFinish"));
775  $cgui->setCancel($this->lng->txt("cancel"), "previousNoSave");
776  $cgui->setConfirm($this->lng->txt("confirm"), "confirmedFinish");
777 
778  $tpl->setContent($cgui->getHTML());
779  }
setContent(string $a_html)
Sets content for standard template.
ilGlobalTemplateInterface $tpl
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ start()

ilSurveyExecutionGUI::start ( bool  $resume = false)

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

References checkAuth(), ILIAS\Repository\ctrl(), getCurrentRunId(), and preview().

Referenced by resume().

249  : void
250  {
251  if ($this->preview) {
252  $this->run_manager->clearAllPreviewData();
253  }
254  $this->run_manager->clearErrors();
255 
256  $this->checkAuth(!$resume);
257 
258  $activepage = "";
259  if ($resume) {
260  $activepage = $this->object->getLastActivePage(
261  $this->getCurrentRunId()
262  );
263  }
264 
265  if ((string) $activepage !== '') {
266  $this->ctrl->setParameter($this, "qid", (string) $activepage);
267  }
268  $this->ctrl->setParameter($this, "activecommand", "default");
269  $this->ctrl->redirect($this, "redirectQuestion");
270  }
checkAuth(bool $a_may_start=false, bool $a_ignore_status=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ viewUserResults()

ilSurveyExecutionGUI::viewUserResults ( )

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

References $toolbar, backToRepository(), checkAuth(), ILIAS\Repository\ctrl(), getCurrentRunId(), ILIAS\Repository\lng(), and ILIAS\Repository\object().

719  : void
720  {
721  $ilToolbar = $this->toolbar;
722 
723  if (!$this->object->hasViewOwnResults()) {
724  $this->backToRepository();
725  }
726 
727  $this->checkAuth(false, true);
728 
729  $this->gui->link(
730  $this->lng->txt("btn_back"),
731  $this->ctrl->getLinkTarget($this, "runShowFinishedPage")
732  )->toToolbar();
733 
734  $survey_gui = new ilObjSurveyGUI();
735  $html = $survey_gui->getUserResultsTable($this->getCurrentRunId());
736  $this->tpl->setContent($html);
737  }
ilObjSurveyGUI: ilSurveyEvaluationGUI, ilSurveyExecutionGUI ilObjSurveyGUI: ilObjectMetaDataGUI, ilPermissionGUI ilObjSurveyGUI: ilInfoScreenGUI, ilObjectCopyGUI ilObjSurveyGUI: ilSurveySkillDeterminationGUI ilObjSurveyGUI: ilCommonActionDispatcherGUI, ilSurveySkillGUI ilObjSurveyGUI: ilSurveyEditorGUI, ilSurveyConstraintsGUI ilObjSurveyGUI: ilSurveyParticipantsGUI, ilLearningProgressGUI ilObjSurveyGUI: ilExportGUI, ilLTIProviderObjectSettingGUI ilObjSurveyGUI: ILIAS
checkAuth(bool $a_may_start=false, bool $a_ignore_status=false)
+ 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 32 of file class.ilSurveyExecutionGUI.php.

◆ $help

ilHelpGUI ilSurveyExecutionGUI::$help
protected

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

Referenced by outSurveyPage().

◆ $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.

Referenced by checkAuth().

◆ $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

◆ $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.

Referenced by runShowFinishedPage(), and viewUserResults().

◆ $tpl

ilGlobalTemplateInterface ilSurveyExecutionGUI::$tpl
protected

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

Referenced by __construct(), and showFinishConfirmation().

◆ $tree

ilTree ilSurveyExecutionGUI::$tree
protected

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

Referenced by __construct(), and backToRepository().

◆ $user

ilObjUser ilSurveyExecutionGUI::$user
protected

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