ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjSurveyGUI.php
Go to the documentation of this file.
1<?php
2
22
35{
37 protected \ILIAS\Survey\Execution\ExecutionGUIRequest $execution_request;
40 protected ilTabsGUI $tabs;
41 protected ilHelpGUI $help;
42 protected ilLogger $log;
44 protected \ILIAS\Survey\InternalService $survey_service;
47 protected \ILIAS\Survey\Execution\RunManager $run_manager;
48 protected \ILIAS\Survey\Participants\StatusManager $status_manager;
49 protected ?ilObjSurvey $survey = null;
52
53 public function __construct()
54 {
55 global $DIC;
56
57 $this->user = $DIC->user();
58 $this->survey_service = $DIC->survey()->internal();
59 $this->gui = $this->survey_service->gui();
60
61 $this->lng = $DIC->language();
62 $this->nav_history = $DIC["ilNavigationHistory"];
63 $this->tabs = $DIC->tabs();
64 $this->help = $DIC["ilHelp"];
65 $this->rbacsystem = $DIC->rbac()->system();
66 $this->tree = $DIC->repositoryTree();
67 $this->tpl = $DIC["tpl"];
68 $this->toolbar = $DIC->toolbar();
69 $this->access = $DIC->access();
70 $this->senderFactory = $DIC->mail()->mime()->senderFactory();
71 $lng = $DIC->language();
72 $ilCtrl = $DIC->ctrl();
73
74 $this->type = "svy";
75 $lng->loadLanguageModule("survey");
77 $this->ctrl = $ilCtrl;
78 $this->ctrl->saveParameter($this, "ref_id");
79
80 $this->log = ilLoggerFactory::getLogger("svy");
81
82 $this->invitation_manager = $this->survey_service->domain()->participants()->invitations();
83
84 $this->execution_request = $this->survey_service
85 ->gui()
86 ->execution()
87 ->request();
88
89 parent::__construct("", $this->execution_request->getRefId(), true, false);
90
91 if ($this->object->getType() !== "svy") {
92 $this->setCreationMode(true);
93 }
94 if ($this->object && $this->object->getType() === "svy") {
96 $survey = $this->object;
97 $this->survey = $survey;
98
99 $this->status_manager = $this->survey_service
100 ->domain()
101 ->participants()
102 ->status($survey, $this->user->getId());
103 $this->feature_config = $this->survey_service->domain()
104 ->modeFeatureConfig($this->object->getMode());
105 $this->run_manager = $this->survey_service->domain()
106 ->execution()->run($survey, $this->user->getId());
107 $this->access_manager = $this->survey_service
108 ->domain()
109 ->access($this->requested_ref_id, $this->user->getId());
110 }
111 $this->edit_request = $this->survey_service
112 ->gui()
113 ->editing()
114 ->request();
115
116 // this class will be treated as a baseclass in most cases, therefore
117 // we need to claim the repository context manually. see #37010
118 if (!$DIC->globalScreen()->tool()->context()->stack()->hasMatch(
119 $DIC->globalScreen()->tool()->context()->collection()->repository()
120 )) {
121 $DIC->globalScreen()->tool()->context()->claim()->repository();
122 }
123 }
124
125 public function executeCommand(): void
126 {
127 $ilTabs = $this->tabs;
130 if ($survey) {
131 if (!$access_manager->canAccessInfoScreen()) {
132 $this->noPermission();
133 }
134 $this->addToNavigationHistory();
135 }
136
137 $cmd = $this->ctrl->getCmd("properties");
138
139
140 // deep link from repository - "redirect" to page view
141 if (!$this->ctrl->getCmdClass() && $cmd === "questionsrepo") {
142 $this->ctrl->setParameterByClass("ilsurveyeditorgui", "pgov", "1");
143 $this->ctrl->redirectByClass("ilsurveyeditorgui", "questions");
144 }
145
146 $next_class = $this->ctrl->getNextClass($this);
147 if ($next_class !== "") {
148 $this->ctrl->setReturn($this, "properties");
149 }
150 // deprecated, moved for less file
151 //$this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "survey.css", "components/ILIAS/Survey"), "screen");
152 $this->prepareOutput();
153
154 $this->log->debug("next_class= $next_class");
155 switch ($next_class) {
156 case 'illtiproviderobjectsettinggui':
157 $this->addSubTabs('settings');
158 $ilTabs->activateTab("settings");
159 $ilTabs->activateSubTab('lti_provider');
160 $lti_gui = new ilLTIProviderObjectSettingGUI($this->object->getRefId());
161 $lti_gui->setCustomRolesForSelection($GLOBALS['DIC']->rbac()->review()->getLocalRoles($this->object->getRefId()));
162 $lti_gui->offerLTIRolesForSelection(false);
163 $this->ctrl->forwardCommand($lti_gui);
164 break;
165
166
167 case "ilinfoscreengui":
168 if (!in_array(
169 $this->ctrl->getCmdClass(),
170 array(strtolower(PublicProfileGUI::class), 'ilobjportfoliogui')
171 )) {
172 $this->addHeaderAction();
173 $this->infoScreen(); // forwards command
174 } else {
175 // #16891
176 $ilTabs->clearTargets();
177 $info = new ilInfoScreenGUI($this);
178 $this->ctrl->forwardCommand($info);
179 }
180 break;
181
182 case 'ilobjectmetadatagui':
183 $this->checkPermission("write");
184 $ilTabs->activateTab("meta_data");
185 $this->addHeaderAction();
186 $md_gui = new ilObjectMetaDataGUI($this->object);
187 $this->ctrl->forwardCommand($md_gui);
188 break;
189
190 case "ilsurveyevaluationgui":
191
192 if ($this->checkRbacOrPositionPermission('read_results', 'access_results') ||
193 ilObjSurveyAccess::_hasEvaluationAccess($this->object->getId(), $this->user->getId())) {
194 $ilTabs->activateTab("svy_results");
195 $this->addHeaderAction();
196 $eval_gui = new ilSurveyEvaluationGUI($survey);
197 $this->ctrl->forwardCommand($eval_gui);
198 }
199 break;
200
201 case "ilsurveyexecutiongui":
202 $ilTabs->clearTargets();
203 $exec_gui = new ilSurveyExecutionGUI($survey);
204 $this->ctrl->forwardCommand($exec_gui);
205 break;
206
207 case 'ilpermissiongui':
208 $ilTabs->activateTab("perm_settings");
209 $this->addHeaderAction();
210 $perm_gui = new ilPermissionGUI($this);
211 $this->ctrl->forwardCommand($perm_gui);
212 break;
213
214 case 'ilobjectcopygui':
215 $cp = new ilObjectCopyGUI($this);
216 $cp->setType('svy');
217 $this->ctrl->forwardCommand($cp);
218 break;
219
220 case "ilcommonactiondispatchergui":
222 $this->ctrl->forwardCommand($gui);
223 break;
224
225 // 360, skill service
226 case 'ilsurveyskillgui':
227 $ilTabs->activateTab("survey_competences");
229 $this->ctrl->forwardCommand($gui);
230 break;
231
232 case 'ilsurveyskilldeterminationgui':
233 $ilTabs->activateTab("maintenance");
235 $this->ctrl->forwardCommand($gui);
236 break;
237
238 case 'ilsurveyeditorgui':
239 $this->checkPermission("write");
240 $ilTabs->activateTab("survey_questions");
241 $gui = new ilSurveyEditorGUI($this);
242 $this->ctrl->forwardCommand($gui);
243 break;
244
245 case 'ilsurveyconstraintsgui':
246 $this->checkPermission("write");
247 $ilTabs->activateTab("constraints");
248 $gui = new ilSurveyConstraintsGUI($this);
249 $this->ctrl->forwardCommand($gui);
250 break;
251
252 case 'ilsurveyparticipantsgui':
253 if (!$this->feature_config->usesAppraisees()) {
254 $ilTabs->activateTab("maintenance");
255 } else {
256 $ilTabs->activateTab("survey_360_appraisees");
257 }
258 $gui = new ilSurveyParticipantsGUI($this, $this->checkRbacOrPositionPermission('read_results', 'access_results'));
259 $this->ctrl->forwardCommand($gui);
260 break;
261
262 case "illearningprogressgui":
263 $ilTabs->activateTab("learning_progress");
264 $new_gui = new ilLearningProgressGUI(
266 $this->object->getRefId()
267 );
268 $this->ctrl->forwardCommand($new_gui);
269 break;
270
271 case 'ilexportgui':
272 $ilTabs->activateTab("export");
273 $exp_gui = new ilExportGUI($this);
274 $exp_gui->addFormat("xml");
275 $this->ctrl->forwardCommand($exp_gui);
276 break;
277
278 case strtolower(\ILIAS\Survey\Execution\LaunchGUI::class):
279 $ilTabs->activateTab("run");
280 $this->ctrl->forwardCommand(
281 $this->gui->execution()->launchGUI(
282 $this->survey
283 )
284 );
285 break;
286
287 default:
288 $this->addHeaderAction();
289 $cmd .= "Object";
290
291 $this->log->debug("Default cmd= $cmd");
292
293 $this->$cmd();
294 break;
295 }
296
297 if (strtolower($this->edit_request->getBaseClass()) !== "iladministrationgui" &&
298 $this->getCreationMode() !== true) {
299 $this->tpl->printToStdout();
300
301 //cherry pick conflict with d97cf1c77b
302 //$this->tpl->show();
303 //$this->log->debug("after tpl show");
304 }
305 }
306
307 protected function noPermission(): void
308 {
309 throw new ilObjectException($this->lng->txt("permission_denied"));
310 }
311
312 protected function addToNavigationHistory(): void
313 {
314 $external_rater = $this->status_manager->isExternalRater();
315 // add entry to navigation history
316 if (!$external_rater && !$this->getCreationMode() &&
317 $this->checkPermissionBool("read")) {
318 $this->ctrl->setParameterByClass("ilobjsurveygui", "ref_id", $this->ref_id);
319 $link = $this->ctrl->getLinkTargetByClass("ilobjsurveygui", "infoScreen");
320 $this->nav_history->addItem($this->ref_id, $link, "svy");
321 }
322 }
323
328 public function evaluationObject(): void
329 {
330 $eval_gui = new ilSurveyEvaluationGUI($this->survey);
331 $this->ctrl->redirect($eval_gui, "openEvaluation");
332 }
333
335 {
336 $a_options = [];
337 // JF, 2013-06-10
338 $a_options["svy360_1"] = array($this->lng->txt("survey_360_mode"),
339 $this->lng->txt("survey_360_mode_info"));
340
341 //Self evaluation only
342 $a_options["svyselfeval_1"] = array($this->lng->txt("svy_self_ev_mode"),
343 $this->lng->txt("svy_self_ev_info"));
344
345 // individual feedback
346 $a_options["individfeedb_1"] = array($this->lng->txt("svy_ind_feedb_mode"),
347 $this->lng->txt("svy_ind_feedb_info"));
348
349 return $a_options;
350 }
351
352 protected function afterSave(ilObject $new_object): void
353 {
354 $form = $this
355 ->initCreateForm($this->requested_new_type)
356 ->withRequest($this->request);
357 $data = $form->getData();
358 $dtemplate = $data["didactic_templates"];
359
360 // #16446
361 $new_object->loadFromDb();
362
363 // set the mode depending on didactic template
364 if (str_starts_with($dtemplate, "svy360_")) {
365 $new_object->setMode(ilObjSurvey::MODE_360);
366 } elseif (str_starts_with($dtemplate, "svyselfeval_")) {
367 $new_object->setMode(ilObjSurvey::MODE_SELF_EVAL);
368 } elseif (str_starts_with($dtemplate, "individfeedb_")) {
369 $new_object->setMode(ilObjSurvey::MODE_IND_FEEDB);
370 }
371
372 $svy_mode = $new_object->getMode();
373 if ($svy_mode === ilObjSurvey::MODE_360) {
374 // this should rather be ilObjSurvey::ANONYMIZE_ON - see ilObjSurvey::getUserDataFromActiveId()
375 $new_object->setAnonymize(ilObjSurvey::ANONYMIZE_CODE_ALL);
376 $new_object->setEvaluationAccess(ilObjSurvey::EVALUATION_ACCESS_PARTICIPANTS);
377 } elseif ($svy_mode === ilObjSurvey::MODE_SELF_EVAL) {
378 $new_object->setEvaluationAccess(ilObjSurvey::EVALUATION_ACCESS_PARTICIPANTS);
379 }
380 $new_object->saveToDB();
381
382 // always send a message
383 $this->tpl->setOnScreenMessage('success', $this->lng->txt("object_added"), true);
384 ilUtil::redirect("ilias.php?baseClass=ilObjSurveyGUI&ref_id=" .
385 $new_object->getRefId() . "&cmd=properties");
386 }
387
388 protected function getTabs(): void
389 {
390 $ilUser = $this->user;
391 $ilHelp = $this->help;
393
394 if (is_null($this->object)) {
395 return;
396 }
397
398 // @todo investigate, if this can still be the case
399 if ($this->object instanceof ilObjSurveyQuestionPool) {
400 return;
401 }
402
403 $ilHelp->setScreenIdComponent("svy");
404
405 if ($this->checkPermissionBool("read")) {
406 $this->tabs_gui->addTab(
407 "run",
408 $this->lng->txt("obj_svy"),
409 $this->ctrl->getLinkTarget($this, 'run')
410 );
411 }
412
413 if ($this->checkPermissionBool("write")) {
414 $this->tabs_gui->addTab(
415 "survey_questions",
416 $this->lng->txt("survey_questions"),
417 $this->ctrl->getLinkTargetByClass(array("ilsurveyeditorgui"), "questions")
418 );
419 }
420
421 if ($this->checkPermissionBool("read")) {
422 $this->tabs_gui->addTab(
423 "info_short",
424 $this->lng->txt("info_short"),
425 $this->ctrl->getLinkTarget($this, 'infoScreen')
426 );
427 }
428
429 // properties
430 if ($this->checkPermissionBool("write")) {
431 $this->tabs_gui->addTab(
432 "settings",
433 $this->lng->txt("settings"),
434 $this->ctrl->getLinkTarget($this, 'properties')
435 );
436 } elseif ($this->checkPermissionBool("read")) {
437 if ($this->feature_config->usesAppraisees() &&
438 $this->object->get360SelfRaters() &&
439 $this->object->isAppraisee($ilUser->getId()) &&
440 !$this->object->isAppraiseeClosed($ilUser->getId())) {
441 $this->tabs_gui->addTab(
442 "survey_360_edit_raters",
443 $this->lng->txt("survey_360_edit_raters"),
444 $this->ctrl->getLinkTargetByClass('ilsurveyparticipantsgui', 'editRaters')
445 );
446
447 // :TODO: mail to raters
448 }
449 }
450
451 // questions
452 if ($this->checkPermissionBool("write") &&
453 $this->object->getMode() === ilObjSurvey::MODE_STANDARD) {
454 // constraints (tab called routing)
455 $this->tabs_gui->addTab(
456 "constraints",
457 $this->lng->txt("constraints"),
458 $this->ctrl->getLinkTargetByClass("ilsurveyconstraintsgui", "constraints")
459 );
460 }
461
462 if ($this->checkPermissionBool("write")) {
463 if ($feature_config && $feature_config->supportsCompetences()) {
464 $skmg_set = new ilSkillManagementSettings();
465 if ($this->object->getSkillService() && $skmg_set->isActivated()) {
466 $this->tabs_gui->addTab(
467 "survey_competences",
468 $this->lng->txt("survey_competences"),
469 $this->ctrl->getLinkTargetByClass("ilsurveyskillgui", "listQuestionAssignment")
470 );
471 }
472 }
473
474 if ($feature_config && $feature_config->usesAppraisees()) {
475 $this->tabs_gui->addTab(
476 "survey_360_appraisees",
477 $this->lng->txt("survey_360_appraisees"),
478 $this->ctrl->getLinkTargetByClass('ilsurveyparticipantsgui', 'listAppraisees')
479 );
480 } else {
481 $this->tabs_gui->addTab(
482 "maintenance",
483 $this->lng->txt("svy_participants"),
484 $this->ctrl->getLinkTargetByClass('ilsurveyparticipantsgui', 'maintenance')
485 );
486 }
487 }
488
489 if ($this->access_manager->canAccessEvaluation()) {
490 // evaluation
491 $this->tabs_gui->addTab(
492 "svy_results",
493 $this->lng->txt("svy_results"),
494 $this->ctrl->getLinkTargetByClass("ilsurveyevaluationgui", "openEvaluation")
495 );
496 }
497
498 // learning progress
499 if (ilLearningProgressAccess::checkAccess($this->object->getRefId())) {
500 $this->tabs_gui->addTarget(
501 "learning_progress",
502 $this->ctrl->getLinkTargetByClass(array("ilobjsurveygui", "illearningprogressgui"), ""),
503 "",
504 array("illplistofobjectsgui", "illplistofsettingsgui", "illearningprogressgui", "illplistofprogressgui")
505 );
506 }
507
508 if ($this->checkPermissionBool("write")) {
509 // meta data
510 $mdgui = new ilObjectMetaDataGUI($this->object);
511 $mdtab = $mdgui->getTab();
512 if ($mdtab) {
513 $this->tabs_gui->addTab(
514 "meta_data",
515 $this->lng->txt("meta_data"),
516 $mdtab
517 );
518 }
519
520 // export
521 $this->tabs_gui->addTab(
522 "export",
523 $this->lng->txt("export"),
524 $this->ctrl->getLinkTargetByClass("ilexportgui", "")
525 );
526 }
527
528 if ($this->checkPermissionBool("edit_permission")) {
529 // permissions
530 $this->tabs_gui->addTab(
531 "perm_settings",
532 $this->lng->txt("perm_settings"),
533 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm")
534 );
535 }
536 }
537
538
539 //
540 // SETTINGS
541 //
542
543 public function savePropertiesObject(): void
544 {
545 $settings_ui = $this->survey_service->gui()->surveySettings($this->survey);
546
547 $form = $settings_ui->form("ilObjSurveyGUI");
548 if ($settings_ui->checkForm($form)) {
549 $settings_ui->saveForm($form);
550
551 // settings change clear the code
552 // this is adopted from ILIAS 7, unsure if or when this is necessary
553 $this->run_manager->clearCode();
554
555 $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
556 $this->ctrl->redirect($this, "properties");
557 }
558
559 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("form_input_not_valid"));
560 $form->setValuesByPost();
561 $this->propertiesObject($form);
562 }
563
565 {
566 $form = $this->survey_service
567 ->gui()->surveySettings($this->survey)->form("ilObjSurveyGUI");
568 return $form;
569 }
570
571 public function addSubTabs(
572 string $a_section
573 ): void {
574 if ($a_section === 'settings') {
575 $this->tabs_gui->addSubTabTarget(
576 "settings",
577 $this->ctrl->getLinkTarget($this, 'properties')
578 );
579
580 $lti_settings = new ilLTIProviderObjectSettingGUI($this->object->getRefId());
581 if ($lti_settings->hasSettingsAccess()) {
582 $this->tabs_gui->addSubTabTarget(
583 'lti_provider',
584 $this->ctrl->getLinkTargetByClass(ilLTIProviderObjectSettingGUI::class)
585 );
586 }
587 }
588 }
589
590
594 public function propertiesObject(
595 ?ilPropertyFormGUI $a_form = null
596 ): void {
597 $ilTabs = $this->tabs;
598 $ilHelp = $this->help;
599
600 $this->checkPermission("write");
601
602 $this->addSubTabs('settings');
603 $ilTabs->activateTab("settings");
604 $ilTabs->activateSubTab('settings');
605
606 if ($this->object->get360Mode()) {
607 $ilHelp->setScreenId("settings_360");
608 }
609
610 if (!$a_form) {
611 $a_form = $this->initPropertiesForm();
612 }
613
614 $this->tpl->setContent($a_form->getHTML());
615 }
616
617 public function doAutoCompleteObject(): void
618 {
619 $fields = array('login','firstname','lastname','email');
620
621 $auto = new ilUserAutoComplete();
622 $auto->setSearchFields($fields);
623 $auto->setResultField('login');
624 $auto->enableFieldSearchableCheck(true);
625 $auto->setMoreLinkAvailable(true);
626
627 if ($this->edit_request->getFetchAll()) {
628 $auto->setLimit(ilUserAutoComplete::MAX_ENTRIES);
629 }
630
631 echo $auto->getList(ilUtil::stripSlashes($this->edit_request->getTerm()));
632 exit();
633 }
634
635 public function importSurveyObject(): void
636 {
637 $tpl = $this->tpl;
638
639 $new_type = $this->edit_request->getNewType();
640
641 // create permission is already checked in createObject. This check here is done to prevent hacking attempts
642 $this->checkPermission("create", "", $new_type);
643
644 $this->lng->loadLanguageModule($new_type);
645 $this->ctrl->setParameter($this, "new_type", $new_type);
646
647 $form = $this->initImportForm($new_type);
648 if ($form->checkInput()) {
649 $newObj = new ilObjSurvey();
650 $newObj->setType($new_type);
651 $newObj->setTitle("dummy");
652 $newObj->create();
653 $this->putObjectInTree($newObj);
654
655 // copy uploaded file to import directory
656
657 $this->log->debug("form->getInput(spl) = " . $form->getInput("spl"));
658
659 $error = $newObj->importObject($_FILES["importfile"], (int) $form->getInput("spl"));
660 if ($error !== '') {
661 $newObj->delete();
662 $this->tpl->setOnScreenMessage('failure', $error);
663 return;
664 }
665
666 $this->tpl->setOnScreenMessage('success', $this->lng->txt("object_imported"), true);
667 ilUtil::redirect("ilias.php?ref_id=" . $newObj->getRefId() .
668 "&baseClass=ilObjSurveyGUI");
669 }
670
671 // display form to correct errors
672 $form->setValuesByPost();
673 $tpl->setContent($form->getHTML());
674 }
675
676
677 //
678 // INFOSCREEN
679 //
680
686 public function infoScreenObject(): void
687 {
688 $this->ctrl->redirectByClass(ilInfoScreenGUI::class, "showSummary");
689 }
690
694 public function infoScreen(): void
695 {
696 $ilTabs = $this->tabs;
697 if (!$this->access_manager->canAccessInfoScreen()) {
698 $this->noPermission();
699 }
700 $ilTabs->activateTab("info_short");
701
702 $info = $this->survey_service->gui()->infoScreen($this, $this->toolbar);
703
704 $this->ctrl->forwardCommand($info);
705 }
706
707 protected function addLocatorItems(): void
708 {
709 $ilLocator = $this->gui->locator();
710 switch ($this->ctrl->getCmd()) {
711 case "next":
712 case "previous":
713 case "start":
714 case "resume":
715 case "infoScreen":
716 case "redirectQuestion":
717 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $this->requested_ref_id);
718 break;
719 case "evaluation":
720 case "checkEvaluationAccess":
721 case "evaluationdetails":
722 case "evaluationuser":
723 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTargetByClass("ilsurveyevaluationgui", "evaluation"), "", $this->requested_ref_id);
724 break;
725 case "create":
726 case "save":
727 case "cancel":
728 case "importSurvey":
729 case "cloneAll":
730 break;
731 default:
732 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $this->requested_ref_id);
733
734 // this has to be done here because ilSurveyEditorGUI is called after finalizing the locator
735 if ($this->edit_request->getQuestionId() > 0 &&
736 !$this->edit_request->getNewForSurvey()) {
737 // not on create
738 // see ilObjSurveyQuestionPool::addLocatorItems
739 $q_id = $this->edit_request->getQuestionId();
740 $q_type = SurveyQuestion::_getQuestionType($q_id) . "GUI";
741 $this->ctrl->setParameterByClass($q_type, "q_id", $q_id);
742 $ilLocator->addItem(
744 $this->ctrl->getLinkTargetByClass(array("ilSurveyEditorGUI", $q_type), "editQuestion")
745 );
746 }
747 break;
748 }
749 }
750
755 public static function _goto(
756 string $a_target
757 ): void {
758 global $DIC;
759 $main_tpl = $DIC->ui()->mainTemplate();
760 $request = $DIC->survey()->internal()->gui()->execution()->request();
761 $a_access_code = $request->getAccessCode();
762
763 $ilAccess = $DIC->access();
764 $lng = $DIC->language();
765 $ctrl = $DIC->ctrl();
766
767 $t_arr = explode("_", $a_target);
768 $ref_id = (int) $t_arr[0];
769 if ($a_access_code === "" && isset($t_arr[1])) {
770 $a_access_code = $t_arr[1];
771 }
772 // see ilObjSurveyAccess::_checkGoto()
773 if ($a_access_code !== '') {
774 $sess = $DIC->survey()->internal()->repo()
775 ->execution()->runSession();
776 $sess->setCode(ilObject::_lookupObjId($ref_id), $a_access_code);
777 $ctrl->setParameterByClass("ilObjSurveyGUI", "ref_id", $ref_id);
778 $ctrl->redirectByClass("ilObjSurveyGUI", "run");
779 }
780
781 // write permission -> info screen
782 if ($ilAccess->checkAccess("write", "", $ref_id)) {
783 $ctrl->setParameterByClass("ilObjSurveyGUI", "ref_id", $ref_id);
784 $ctrl->redirectByClass("ilObjSurveyGUI", "run");
785 }
786
787 // read permission, evaluation access and finished run -> evaluation
788 if ($ilAccess->checkAccess("visible", "", $ref_id) ||
789 $ilAccess->checkAccess("read", "", $ref_id)) {
790 if ($ilAccess->checkAccess("read", "", $ref_id)) {
791 $domain_service = $DIC->survey()->internal()->domain();
792 $am = $domain_service->access($ref_id, $DIC->user()->getId());
793 $survey = new ilObjSurvey($ref_id);
794 $run_manager = $domain_service->execution()->run($survey, $DIC->user()->getId());
795 if ($am->canAccessEvaluation()) {
796 $ctrl->setParameterByClass("ilObjSurveyGUI", "ref_id", $ref_id);
797 $ctrl->redirectByClass(["ilObjSurveyGUI", "ilSurveyEvaluationGUI"], "openEvaluation");
798 }
799 $ctrl->setParameterByClass("ilObjSurveyGUI", "ref_id", $ref_id);
800 $ctrl->redirectByClass("ilObjSurveyGUI", "run");
801 } else {
802 $ctrl->setParameterByClass("ilObjSurveyGUI", "ref_id", $ref_id);
803 $ctrl->redirectByClass(["ilObjSurveyGUI", "ilInfoScreenGUI"]);
804 }
805 } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
806 $main_tpl->setOnScreenMessage('failure', sprintf(
807 $lng->txt("msg_no_perm_read_item"),
809 ), true);
811 }
812 }
813
817 public function getUserResultsTable(
818 int $a_active_id
819 ): string {
820 $rtpl = new ilTemplate("tpl.svy_view_user_results.html", true, true, "components/ILIAS/Survey");
821
822 $show_titles = $this->object->getShowQuestionTitles();
823
824 foreach ($this->object->getSurveyPages() as $page) {
825 if (count($page) > 0) {
826 // question block
827 if (count($page) > 1) {
828 if ($page[0]["questionblock_show_blocktitle"]) {
829 $rtpl->setVariable("BLOCK_TITLE", trim($page[0]["questionblock_title"] ?? ""));
830 }
831 }
832
833 // questions
834 foreach ($page as $question) {
835 $question_gui = $this->object->getQuestionGUI($question["type_tag"], $question["question_id"]);
836 $rtpl->setCurrentBlock("question_bl");
837
838 // heading
839 if (strlen($question["heading"] ?? "")) {
840 $rtpl->setVariable("HEADING", trim($question["heading"] ?? ""));
841 }
842
843 $rtpl->setVariable(
844 "QUESTION_DATA",
845 $question_gui->getPrintView(
846 $show_titles,
847 (bool) $question["questionblock_show_questiontext"],
848 $this->object->getId(),
849 $this->object->loadWorkingData($question["question_id"], $a_active_id)
850 )
851 );
852
853 $rtpl->parseCurrentBlock();
854 }
855
856 $rtpl->setCurrentBlock("block_bl");
857 $rtpl->parseCurrentBlock();
858 }
859 }
860
861 return $rtpl->get();
862 }
863
867 protected function viewUserResultsObject(): void
868 {
869 $ilUser = $this->user;
870 $tpl = $this->tpl;
871 $ilTabs = $this->tabs;
872
873 $anonymous_code = $this->run_manager->getCode();
874 $active_id = $this->object->getActiveID($ilUser->getId(), $anonymous_code, 0);
875
876 if (!$this->run_manager->hasFinished() ||
877 !$active_id) {
878 $this->ctrl->redirect($this, "infoScreen");
879 }
880
881 $ilTabs->clearTargets();
882 $ilTabs->setBackTarget(
883 $this->lng->txt("btn_back"),
884 $this->ctrl->getLinkTarget($this, "infoScreen")
885 );
886
887 $html = $this->getUserResultsTable($active_id);
888 $tpl->setContent($html);
889 }
890
894 protected function getUserResultsPlain(
895 int $a_active_id
896 ): string {
897 $res = array();
898
899 $show_titles = (bool) $this->object->getShowQuestionTitles();
900
901 foreach ($this->object->getSurveyPages() as $page) {
902 if (count($page) > 0) {
903 $res[] = "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
904
905 // question block
906 if (count($page) > 1) {
907 if ($page[0]["questionblock_show_blocktitle"]) {
908 $res[$this->lng->txt("questionblock")] = trim($page[0]["questionblock_title"] ?? "") . "\n";
909 }
910 }
911
912 // questions
913
914 $page_res = array();
915
916 foreach ($page as $question) {
917 $question_gui = $this->object->getQuestionGUI($question["type_tag"], $question["question_id"]);
918 $question_parts = array();
919
920 // heading
921 if (strlen($question["heading"] ?? "")) {
922 $question_parts[$this->lng->txt("heading")] = trim($question["heading"] ?? "");
923 }
924
925 if ($show_titles) {
926 $question_parts[$this->lng->txt("title")] = trim($question["title"] ?? "");
927 }
928
929 if ($question["questionblock_show_questiontext"]) {
930 $question_parts[$this->lng->txt("question")] = trim(strip_tags($question_gui->object->getQuestionText()));
931 }
932
933 $answers = $question_gui->getParsedAnswers(
934 $this->object->loadWorkingData($question["question_id"], $a_active_id),
935 true
936 );
937
938 if (count($answers)) {
939 $multiline = false;
940 if (count($answers) > 1 ||
941 get_class($question_gui) === "SurveyTextQuestionGUI") {
942 $multiline = true;
943 }
944
945 $parts = array();
946 foreach ($answers as $answer) {
947 $text = null;
948 if ($answer["textanswer"] ?? false) {
949 $text = ' ("' . $answer["textanswer"] . '")';
950 }
951 if (!isset($answer["cols"])) {
952 if (isset($answer["title"])) {
953 $parts[] = $answer["title"] . $text;
954 } elseif (isset($answer["value"])) {
955 $parts[] = $answer["value"];
956 } elseif ($text) {
957 $parts[] = substr($text, 2, -1);
958 }
959 }
960 // matrix
961 else {
962 $tmp = array();
963 foreach ($answer["cols"] as $col) {
964 $tmp[] = $col["title"];
965 }
966 $parts[] = $answer["title"] . ": " . implode(", ", $tmp) . $text;
967 }
968 }
969 $question_parts[$this->lng->txt("answer")] =
970 ($multiline ? "\n" : "") . implode("\n", $parts);
971 }
972
973 $tmp = array();
974 foreach ($question_parts as $type => $value) {
975 $tmp[] = $type . ": " . $value;
976 }
977 $page_res[] = implode("\n", $tmp);
978 }
979
980 $res[] = implode("\n\n-------------------------------\n\n", $page_res);
981 }
982 }
983
984 $res[] = "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
985
986 return implode("\n", $res);
987 }
988
989 public function sendUserResultsMail(
990 int $a_active_id,
991 string $a_recipient
992 ): void {
993 $ilUser = $this->user;
994
995 $finished = $this->object->getSurveyParticipants(array($a_active_id));
996 $finished = array_pop($finished);
997 $finished = ilDatePresentation::formatDate(new ilDateTime($finished["finished_tstamp"], IL_CAL_UNIX));
998
999 $body = ilMail::getSalutation($ilUser->getId()) . "\n\n";
1000 $body .= $this->lng->txt("svy_mail_own_results_body") . "\n";
1001 $body .= "\n" . $this->lng->txt("obj_svy") . ": " . $this->object->getTitle() . "\n";
1002 $body .= ilLink::_getLink($this->object->getRefId(), "svy") . "\n";
1003 $body .= "\n" . $this->lng->txt("survey_results_finished") . ": " . $finished . "\n\n";
1004
1005 if ($this->object->hasMailOwnResults()) {
1006 $subject = "svy_mail_own_results_subject";
1007 $body .= $this->getUserResultsPlain($a_active_id);
1008 } else {
1009 $subject = "svy_mail_confirmation_subject";
1010 }
1011
1012 // $body .= ilMail::_getAutoGeneratedMessageString($this->lng);
1014
1015
1016 $mmail = new ilMimeMail();
1017 $mmail->From($this->senderFactory->system());
1018 $mmail->To($a_recipient);
1019 $mmail->Subject(sprintf($this->lng->txt($subject), $this->object->getTitle()), true);
1020 $mmail->Body($body);
1021 $mmail->Send();
1022 }
1023
1024 public function mailUserResultsObject(): void
1025 {
1026 $ilUser = $this->user;
1027
1028 $anonymous_code = $this->run_manager->getCode();
1029 $active_id = $this->object->getActiveID($ilUser->getId(), $anonymous_code, 0);
1030 if (!$this->run_manager->hasFinished() ||
1031 !$active_id) {
1032 $this->ctrl->redirect($this, "infoScreen");
1033 }
1034
1035 $recipient = $this->edit_request->getMail();
1036 if (!$recipient) {
1037 $recipient = $ilUser->getEmail();
1038 }
1039 if (!ilUtil::is_email($recipient)) {
1040 $this->ctrl->redirect($this, "infoScreen");
1041 }
1042
1043 $this->sendUserResultsMail($active_id, $recipient);
1044
1045 $this->tpl->setOnScreenMessage('success', $this->lng->txt("mail_sent"), true);
1046 $this->ctrl->redirect($this, "infoScreen");
1047 }
1048
1053 string $a_rbac_permission,
1054 string $a_position_permission
1055 ): bool {
1056 $access = $GLOBALS['DIC']->access();
1057 return $access->checkRbacOrPositionPermissionAccess(
1058 $a_rbac_permission,
1059 $a_position_permission,
1060 $this->object->getRefId()
1061 );
1062 }
1063
1064 protected function runObject(): void
1065 {
1066 $this->ctrl->redirectByClass(
1067 \ILIAS\Survey\Execution\LaunchGUI::class
1068 );
1069 }
1070}
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
GUI class for public user profile presentation.
static _getTitle(int $question_id)
Returns the question title of a question with a given id.
static _getQuestionType(int $question_id)
Returns the question type of a question with a given id.
const IL_CAL_UNIX
return true
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
Export User Interface Class.
Help GUI class.
Class ilInfoScreenGUI.
GUI class for LTI provider object settings.
loadLanguageModule(string $a_module)
Load language module.
static checkAccess(int $a_ref_id, bool $a_allow_only_read=true)
check access to learning progress
Class ilObjUserTrackingGUI.
static getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
static _getInstallationSignature()
Last visited history for repository items.
static _hasEvaluationAccess(int $a_obj_id, int $user_id)
@ilCtrl_Calls ilObjSurveyGUI: ilSurveyEvaluationGUI, ilSurveyExecutionGUI @ilCtrl_Calls ilObjSurveyGU...
ILIAS Survey Execution ExecutionGUIRequest $execution_request
ILIAS Survey Access AccessManager $access_manager
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually,...
ILIAS Survey InternalService $survey_service
ILIAS Survey Mode FeatureConfig $feature_config
getUserResultsTable(int $a_active_id)
ilNavigationHistory $nav_history
ILIAS Survey Participants StatusManager $status_manager
Participants InvitationsManager $invitation_manager
afterSave(ilObject $new_object)
Post (successful) object creation hook.
sendUserResultsMail(int $a_active_id, string $a_recipient)
ILIAS Survey Editing EditingGUIRequest $edit_request
static _goto(string $a_target)
redirect script
infoScreen()
show information screen
evaluationObject()
Redirects the evaluation object call to the ilSurveyEvaluationGUI class Coming from ListGUI....
InternalGUIService $gui
addLocatorItems()
should be overwritten to add object specific items (repository items are preloaded)
ILIAS Survey Execution RunManager $run_manager
propertiesObject(?ilPropertyFormGUI $a_form=null)
Display the properties form.
ilMailMimeSenderFactory $senderFactory
addSubTabs(string $a_section)
getTabs()
@abstract overwrite in derived GUI class of your object type
getUserResultsPlain(int $a_active_id)
ilRbacSystem $rbacsystem
checkRbacOrPositionPermission(string $a_rbac_permission, string $a_position_permission)
Class ilObjSurveyQuestionPool.
const EVALUATION_ACCESS_PARTICIPANTS
const ANONYMIZE_CODE_ALL
GUI class for the workflow of copying objects.
Base exception class for object service.
Class ilObjectGUI Basic methods of all Output classes.
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
setCreationMode(bool $mode=true)
If true, a creation screen is displayed the current [ref_id] does belong to the parent class The mode...
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
addHeaderAction()
Add header action menu.
prepareOutput(bool $show_sub_objects=true)
ilLanguage $lng
Class ilObjectMetaDataGUI.
Class ilObject Basic functions for all objects.
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
This class represents a property form user interface.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilSurveyEditorGUI.
Survey evaluation graphical output.
Survey execution graphical output.
Class ilSurveyParticipantsGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
special template class to simplify handling of ITX/PEAR
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static is_email(string $a_email, ?ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static redirect(string $a_script)
const ROOT_FOLDER_ID
Definition: constants.php:32
exit
$info
Definition: entry_point.php:21
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:66
$res
Definition: ltiservices.php:69
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $lng
Definition: privfeed.php:31
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54