ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilIndividualAssessmentCommonSettingsGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 public const CMD_EDIT = 'editSettings';
24 public const CMD_SAVE = 'saveSettings';
25
27 protected ilCtrl $ctrl;
29 protected ilLanguage $lng;
31
32 public function __construct(
38 ) {
39 $this->object = $object;
40 $this->ctrl = $ctrl;
41 $this->tpl = $tpl;
42 $this->lng = $lng;
43 $this->object_service = $object_service;
44 }
45
46 public function executeCommand(): void
47 {
48 $cmd = $this->ctrl->getCmd();
49 switch ($cmd) {
50 case self::CMD_EDIT:
51 $this->editSettings();
52 break;
53 case self::CMD_SAVE:
54 $this->saveSettings();
55 break;
56 default:
57 throw new Exception('Unknown command ' . $cmd);
58 }
59 }
60
61 protected function editSettings(?ilPropertyFormGUI $form = null): void
62 {
63 if (is_null($form)) {
64 $form = $this->buildForm();
65 }
66 $this->tpl->setContent($form->getHTML());
67 }
68
69 protected function buildForm(): ilPropertyFormGUI
70 {
71 $form = new ilPropertyFormGUI();
72 $form->setFormAction($this->ctrl->getFormAction($this));
73 $form->setTitle($this->txt('obj_features'));
74 $form->addCommandButton(self::CMD_SAVE, $this->txt('save'));
75 $form->addCommandButton(self::CMD_EDIT, $this->txt('cancel'));
76
77 $this->addServiceSettingsToForm($form);
78 $this->addCommonFieldsToForm($form);
79
80 return $form;
81 }
82
83 protected function addServiceSettingsToForm(ilPropertyFormGUI $form): void
84 {
86 $this->object->getId(),
87 $form,
88 [
91 ]
92 );
93 }
94
95 protected function addCommonFieldsToForm(ilPropertyFormGUI $form): void
96 {
97 $section_appearance = new ilFormSectionHeaderGUI();
98 $section_appearance->setTitle($this->txt('cont_presentation'));
99 $form->addItem($section_appearance);
100 $form_service = $this->object_service->commonSettings()->legacyForm($form, $this->object);
101 $form_service->addTileImage();
102 }
103
104 protected function saveSettings(): void
105 {
106 $form = $this->buildForm();
107
108 if (!$form->checkInput()) {
109 $form->setValuesByPost();
110 $this->editSettings($form);
111 return;
112 }
113
115 $this->object->getId(),
116 $form,
117 [
120 ]
121 );
122
123 $form_service = $this->object_service->commonSettings()->legacyForm($form, $this->object);
124 $form_service->saveTileImage();
125
126 $this->tpl->setOnScreenMessage("success", $this->lng->txt('iass_settings_saved'), true);
127 $this->ctrl->redirect($this, self::CMD_EDIT);
128 }
129
130 protected function txt(string $code): string
131 {
132 return $this->lng->txt($code);
133 }
134}
Class ilCtrl provides processing control methods.
This class represents a section header in a property form.
__construct(ilObjIndividualAssessment $object, ilCtrl $ctrl, ilGlobalTemplateInterface $tpl, ilLanguage $lng, ilObjectService $object_service)
language handling
For the purpose of streamlining the grading and learning-process status definition outside of tests,...
static updateServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
static initServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
This class represents a property form user interface.