36 protected \ILIAS\Survey\Execution\ExecutionGUIRequest
$request;
58 $this->rbacsystem = $DIC->rbac()->system();
59 $this->
user = $DIC->user();
60 $this->
help = $DIC[
"ilHelp"];
61 $this->
toolbar = $DIC->toolbar();
62 $lng = $DIC->language();
64 $ilCtrl = $DIC->ctrl();
65 $tree = $DIC->repositoryTree();
69 $this->
ctrl = $ilCtrl;
70 $this->
object = $a_object;
72 $this->
user = $DIC->user();
74 $this->request = $DIC->survey()
81 $this->
preview = (bool) $this->request->getPreview();
82 $this->requested_appr_id = $this->request->getAppraiseeId();
83 $this->
ctrl->saveParameter($this,
"prvw");
84 $this->
ctrl->saveParameter($this,
"appr_id");
85 $this->
ctrl->saveParameter($this,
"pgov");
89 $domain_service = $DIC->survey()->internal();
91 ? $this->
user->getId()
93 $this->run_manager = $domain_service->domain()->execution()->run(
98 $this->participant_manager = $domain_service->domain()->participants()->status(
102 $this->access_manager = $domain_service->domain()->access(
107 $this->feature_config = $domain_service->domain()->modeFeatureConfig($a_object->
getMode());
112 $this->raw_post_data = $DIC->http()->request()->getParsedBody() ?? [];
120 $this->
object->getRefId(),
121 $this->
object->getId(),
125 $cmd = $this->
ctrl->getCmd();
126 $next_class = $this->
ctrl->getNextClass($this);
128 $this->log->debug(
"- cmd= " . $cmd);
130 if ($cmd === null || $cmd ===
'') {
131 $this->
ctrl->setParameter(
134 $this->request->getQuestionId()
136 $this->
ctrl->redirect($this,
"gotoPage");
138 switch ($next_class) {
140 $ret = $this->$cmd();
143 return (
string) $ret;
147 bool $a_may_start =
false,
148 bool $a_ignore_status =
false 154 if (!$rbacsystem->
checkAccess(
"write", $this->object->getRefId())) {
162 if (!$this->access_manager->canStartSurvey()) {
171 $anonymous_id = null;
172 $anonymous_code =
"";
173 if ($this->access_manager->isCodeInputAllowed()) {
174 $anonymous_code = $this->run_manager->getCode();
175 $anonymous_id = $this->
object->getAnonymousIdByCode($anonymous_code);
176 if (!$anonymous_id) {
177 $this->tpl->setOnScreenMessage(
'failure', sprintf($this->
lng->txt(
"error_retrieving_anonymous_survey"), $anonymous_code,
true));
178 $this->
ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
185 if ($this->feature_config->usesAppraisees()) {
192 $appraisees = $this->
object->getAppraiseesToRate(0, $anonymous_id);
195 $appraisees = $this->
object->getAppraiseesToRate($user_id);
197 if (!in_array($appr_id, $appraisees)) {
198 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"survey_360_execution_invalid_appraisee"),
true);
199 $this->
ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
203 #23575 in self eval the appraisee is the current user. 210 if (!$a_ignore_status) {
212 if ($this->run_manager->hasFinished()) {
213 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"already_completed_survey"),
true);
214 $this->
ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
217 elseif (!$this->run_manager->hasStarted()) {
221 $this->run_manager->start($appr_id);
223 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"survey_use_start_button"),
true);
224 $this->
ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
234 if ($this->
object->getActiveID($user_id, $anonymous_code, $appr_id) !==
235 $this->run_manager->getCurrentRunId()) {
245 public function start(
bool $resume =
false): void
248 $this->run_manager->clearAllPreviewData();
250 $this->run_manager->clearErrors();
256 $activepage = $this->
object->getLastActivePage(
261 if ((
string) $activepage !==
'') {
262 $this->
ctrl->setParameter($this,
"qid", (
string) $activepage);
264 $this->
ctrl->setParameter($this,
"activecommand",
"default");
265 $this->
ctrl->redirect($this,
"redirectQuestion");
274 switch ($this->request->getActiveCommand()) {
279 $this->request->getQuestionId(),
280 $this->request->getDirection()
299 bool $a_save_input =
true 306 $this->
ctrl->setParameter($this,
"activecommand",
"previous");
307 $this->
ctrl->setParameter($this,
"qid", $this->request->getQuestionId());
308 if ($has_error > 0) {
309 $this->
ctrl->setParameter($this,
"direction",
"0");
311 $this->
ctrl->setParameter($this,
"direction",
"-1");
313 $this->
ctrl->redirect($this,
"redirectQuestion");
322 $this->
ctrl->setParameter($this,
"activecommand",
"next");
323 $this->
ctrl->setParameter($this,
"qid", $this->request->getQuestionId());
325 $this->
ctrl->setParameter($this,
"direction",
"0");
327 $this->
ctrl->setParameter($this,
"direction",
"1");
329 $this->
ctrl->redirect($this,
"redirectQuestion");
337 $this->
ctrl->setParameter($this,
"activecommand",
"gotoPage");
338 $this->
ctrl->setParameter($this,
"qid", $this->request->getQuestionId());
339 $this->
ctrl->setParameter($this,
"direction",
"0");
340 $this->
ctrl->redirect($this,
"redirectQuestion");
355 $page = $this->
object->getNextPage($activepage, $direction);
356 $constraint_true = 0;
359 if (!is_null($page) && is_array($page[0][
"constraints"]) && count($page[0][
"constraints"])) {
360 $this->log->debug(
"Page constraints= ", $page[0][
"constraints"]);
362 while (!is_null($page) and ($constraint_true == 0) and (count($page[0][
"constraints"]))) {
363 $constraint_true = $page[0][
'constraints'][0][
'conjunction'] == 0;
364 foreach ($page[0][
"constraints"] as $constraint) {
366 $working_data = $this->
object->loadWorkingData($constraint[
"question"], $this->
getCurrentRunId());
368 $working_data = $this->run_manager->getPreviewData($constraint[
"question"]);
370 if ($constraint[
'conjunction'] == 0) {
372 $constraint_true &= $this->
object->checkConstraint($constraint, $working_data);
375 $constraint_true |= $this->
object->checkConstraint($constraint, $working_data);
378 if ($constraint_true == 0) {
380 foreach ($page as $page_question) {
381 $qid = $page_question[
"question_id"];
387 $this->run_manager->clearPreviewData($qid);
391 $page = $this->
object->getNextPage($page[0][
"question_id"], $direction);
395 $first_question = -1;
396 if (is_null($page) && $direction === -1) {
397 $this->
ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
398 } elseif (is_null($page) && $direction === 1) {
399 $state = $this->
object->getUserSurveyExecutionStatus();
410 $ilHelp->setScreenId(
"quest_presentation");
418 $stpl =
new ilTemplate(
"tpl.il_svy_svy_content.html",
true,
true,
"Modules/Survey");
421 if ($this->feature_config->usesAppraisees()) {
424 $this->tpl->setTitle($this->
object->getTitle() .
" (" .
425 $this->
lng->txt(
"survey_360_appraisee") .
": " .
431 $stpl->setCurrentBlock(
"suspend_survey");
434 $stpl->setVariable(
"TEXT_SUSPEND", $this->
lng->txt(
"cancel_survey"));
435 $stpl->setVariable(
"HREF_SUSPEND", $this->
ctrl->getLinkTargetByClass(
"ilObjSurveyGUI",
"infoScreen"));
437 $this->
ctrl->setParameterByClass(
"ilObjSurveyGUI",
"pgov", $this->request->getTargetPosition());
438 $stpl->setVariable(
"TEXT_SUSPEND", $this->
lng->txt(
"survey_cancel_preview"));
439 $stpl->setVariable(
"HREF_SUSPEND", $this->
ctrl->getLinkTargetByClass(array(
"ilObjSurveyGUI",
"ilSurveyEditorGUI"),
"questions"));
442 $stpl->setVariable(
"ALT_IMG_SUSPEND", $this->
lng->txt(
"cancel_survey"));
443 $stpl->setVariable(
"TITLE_IMG_SUSPEND", $this->
lng->txt(
"cancel_survey"));
444 $stpl->parseCurrentBlock();
450 $stpl->setCurrentBlock(
"percentage");
451 $percentage = (
int) (($page[0][
"position"]) * 100);
453 $pbar->setCurrent($percentage);
454 $stpl->setVariable(
"NEW_PBAR", $pbar->render());
455 $stpl->parseCurrentBlock();
459 $errors = $this->run_manager->getErrors();
460 foreach ($page as
$data) {
461 if ($first_question === -1) {
462 $first_question = $data[
"question_id"];
464 $question_gui = $this->
object->getQuestionGUI($data[
"type_tag"], $data[
"question_id"]);
467 $working_data[$data[
"question_id"]] = $question_gui->object->getWorkingDataFromUserInput(
468 $this->run_manager->getPostData()
472 $working_data[$data[
"question_id"]] = $this->
object->loadWorkingData(
473 $data[
"question_id"],
474 $this->run_manager->getCurrentRunId()
477 $working_data[$data[
"question_id"]] =
478 $this->run_manager->getPreviewData($data[
"question_id"]);
483 $page_renderer = new \ILIAS\Survey\Page\PageRenderer(
490 $stpl->setVariable(
"PAGE", $page_renderer->render());
492 $this->
ctrl->setParameter($this,
"qid", $first_question);
493 $stpl->setVariable(
"FORM_ACTION", $this->
ctrl->getFormAction($this,
"redirectQuestion"));
494 $this->tpl->setContent($stpl->get());
498 $this->
object->setPage($this->
getCurrentRunId(), $page[0][
'question_id']);
499 $this->run_manager->setStartTime($first_question);
505 return $this->run_manager->getCurrentRunId();
512 string $navigationDirection =
"next" 515 $this->run_manager->setEndTime();
519 $this->run_manager->clearErrors();
520 $this->run_manager->setPostData($this->raw_post_data);
523 $page = $this->
object->getNextPage($this->request->getQuestionId(), 0);
524 foreach ($page as
$data) {
527 if ($page_error && (strcmp($navigationDirection,
"previous") !== 0)) {
528 if ($page_error === 1) {
529 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"svy_page_error"),
true);
531 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"svy_page_errors"),
true);
535 $this->run_manager->clearErrors();
546 $error = $question->checkUserInput($this->raw_post_data, $this->
object->getSurveyId());
547 if (strlen($error) === 0) {
550 $this->
object->deleteWorkingData($data[
"question_id"], $this->
getCurrentRunId());
552 $question->saveUserInput($this->raw_post_data, $this->
getCurrentRunId());
554 $this->run_manager->setPreviewData(
555 $data[
"question_id"],
556 $question->saveUserInput($this->raw_post_data, 0,
true)
561 $errors = $this->run_manager->getErrors();
562 $errors[$question->getId()] = $error;
563 $this->run_manager->setErrors(
$errors);
570 $this->
ctrl->redirectByClass(
"ilobjsurveygui",
"infoScreen");
585 if ($this->
object->hasViewOwnResults()) {
587 $button->setCaption(
"svy_view_own_results");
588 $button->setUrl($this->
ctrl->getLinkTarget($this,
"viewUserResults"));
589 $ilToolbar->addButtonInstance($button);
594 if ($this->
object->hasMailConfirmation()) {
596 $ilToolbar->addSeparator();
603 $ilToolbar->addInputItem($mail,
true);
606 $ilToolbar->setFormAction($this->
ctrl->getFormAction($this,
"mailUserResults"));
609 $button->setCaption(
"svy_mail_send_confirmation");
610 $button->setCommand(
"mailUserResults");
611 $ilToolbar->addButtonInstance($button);
619 $button->setCaption(
"svy_results");
620 $button->setUrl($this->
ctrl->getLinkTargetByClass(
"ilObjSurveyGUI",
"evaluation"));
621 $ilToolbar->addButtonInstance($button);
628 $this->
object->getOutro() ===
'') {
632 $ilToolbar->addSeparator();
637 $button->setCaption(
"survey_execution_exit_360");
639 $button->setCaption(
"survey_execution_exit");
641 $button->setUrl($this->
ctrl->getLinkTarget($this,
"exitSurvey"));
642 $ilToolbar->addButtonInstance($button);
644 if ($this->
object->getOutro() !==
'') {
646 $panel->setBody($this->
object->prepareTextareaOutput($this->object->getOutro()));
647 $this->tpl->setContent(
$panel->getHTML());
658 $target_ref_id = $this->
object->getRefId();
676 $this->
ctrl->setParameterByClass(
"ilsurveyeditorgui",
"pgov", $this->request->getTargetPosition());
677 $this->
ctrl->redirectByClass(array(
"ilobjsurveygui",
"ilsurveyeditorgui"),
"questions");
682 string $navigationblock,
686 $prevpage = $this->
object->getNextPage($page[0][
"question_id"], -1);
688 if (is_null($prevpage)) {
691 $stpl->
setVariable(
"BTN_PREV", $this->
lng->txt(
"survey_previous"));
694 $nextpage = $this->
object->getNextPage($page[0][
"question_id"], 1);
696 if (is_null($nextpage)) {
713 if (!$this->
object->hasViewOwnResults()) {
720 $button->setCaption(
"btn_back");
721 $button->setUrl($this->
ctrl->getLinkTarget($this,
"runShowFinishedPage"));
722 $ilToolbar->addButtonInstance($button);
726 $this->tpl->setContent($html);
733 if (!$this->
object->hasMailConfirmation()) {
739 $recipient = $this->request->getMail();
741 $recipient =
$ilUser->getEmail();
744 $this->
ctrl->redirect($this,
"runShowFinishedPage");
748 $survey_gui->sendUserResultsMail(
753 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"mail_sent"),
true);
754 $this->
ctrl->redirect($this,
"runShowFinishedPage");
762 $cgui->setHeaderText($this->
lng->txt(
"survey_execution_sure_finish"));
764 $cgui->setFormAction($this->
ctrl->getFormAction($this,
"confirmedFinish"));
765 $cgui->setCancel($this->
lng->txt(
"cancel"),
"previousNoSave");
766 $cgui->setConfirm($this->
lng->txt(
"confirm"),
"confirmedFinish");
776 $this->
object->finishSurvey($this->
getCurrentRunId(), $this->requested_appr_id);
783 if ($this->
object->getMailNotification()) {
784 $this->
object->sendNotificationMail(
786 $this->run_manager->getCode(),
792 $this->
ctrl->redirect($this,
"runShowFinishedPage");
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
Mode FeatureConfig $feature_config
ILIAS Survey Participants StatusManager $participant_manager
static getLogger(string $a_component_id)
Get component logger.
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:
outSurveyPage(int $activepage=0, int $direction=0)
Output of the active survey question to the screen.
static is_email(string $a_email, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
exitSurvey()
Exits the survey after finishing it.
outNavigationButtons(string $navigationblock, array $page, ilTemplate $stpl)
redirectQuestion()
Called when a user answered a page to perform a redirect after POST.
saveActiveQuestionData(array $data)
Saves the users input of the active page.
ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _tracProgress(int $a_user_id, int $a_obj_id, int $a_ref_id, string $a_obj_type='')
__construct(ilObjSurvey $a_object)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 ...
next()
Navigates to the next page.
setVariable($variable, $value='')
Sets a variable value.
ILIAS Survey Execution RunManager $run_manager
setContent(string $a_html)
Sets content for standard template.
checkAuth(bool $a_may_start=false, bool $a_ignore_status=false)
gotoPage()
Go to a specific page without saving.
setScreenIdComponent(string $a_comp)
ILIAS Survey Access AccessManager $access_manager
Survey execution graphical output.
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)
runShowFinishedPage()
Show finish page.
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
ILIAS Survey Execution ExecutionGUIRequest $request
getParentId(int $a_node_id)
get parent id of given node
static _getLink(?int $a_ref_id, string $a_type='', array $a_params=array(), string $append="")
static _hasEvaluationAccess(int $a_obj_id, int $user_id)
static redirect(string $a_script)
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
previous(bool $a_save_input=true)
saveUserInput(string $navigationDirection="next")
Save the user's input.
static _instanciateQuestion(int $question_id)
Get question object.
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
start(bool $resume=false)