ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLTIConsumerSettingsFormGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
30{
35
39 public function __construct(ilObjLTIConsumer $object, string $formaction, string $saveCommand, string $cancelCommand)
40 {
41 $this->object = $object;
42
44
45 $this->initForm($formaction, $saveCommand, $cancelCommand);
46 }
47
48 protected function initForm(string $formaction, string $saveCommand, string $cancelCommand): void
49 {
50 global $DIC; /* @var \ILIAS\DI\Container $DIC */
51 $DIC->language()->loadLanguageModule('lti');
52 $this->setFormAction($formaction);
53 $this->addCommandButton($saveCommand, $DIC->language()->txt('save'));
54 $this->addCommandButton($cancelCommand, $DIC->language()->txt('cancel'));
55
56 $this->setTitle($DIC->language()->txt('lti_settings_form'));
57
58 $item = new ilNonEditableValueGUI($DIC->language()->txt('provider_info'));
59 $item->setValue($this->object->getProvider()->getTitle());
60 $item->setInfo(htmlspecialchars($this->object->getProvider()->getDescription()));
61 $this->addItem($item);
62
63 $item = new ilTextInputGUI($DIC->language()->txt('title'), 'title');
64 $item->setSize(40);
65 $item->setMaxLength(128);
66 $item->setRequired(true);
67 $item->setInfo($DIC->language()->txt('title_info'));
68 $item->setValue($this->object->getTitle());
69 $this->addItem($item);
70
71 $item = new ilTextAreaInputGUI($DIC->language()->txt('description'), 'description');
72 $item->setInfo($DIC->language()->txt('description_info'));
73 $item->setRows(2);
74 $item->setValue($this->object->getDescription());
75 $this->addItem($item);
76
77 $item = new ilCheckboxInputGUI($DIC->language()->txt('online'), 'online');
78 $item->setInfo($DIC->language()->txt("online_info"));
79 $item->setValue("1");
80 if (!$this->object->getOfflineStatus()) {
81 $item->setChecked(true);
82 }
83 $this->addItem($item);
84
85 if ($this->object->getProvider()->getLtiVersion() == 'LTI-1p0' && $this->object->getProvider()->isProviderKeyCustomizable()) {
86 $sectionHeader = new ilFormSectionHeaderGUI();
87 $sectionHeader->setTitle($DIC->language()->txt('lti_con_prov_authentication'));
88 $this->addItem($sectionHeader);
89
90 $providerKeyInp = new ilTextInputGUI($DIC->language()->txt('lti_con_prov_key'), 'provider_key');
91 $providerKeyInp->setValue($this->object->getCustomLaunchKey());
92 $providerKeyInp->setRequired(true);
93 $this->addItem($providerKeyInp);
94
95 $providerSecretInp = new ilTextInputGUI($DIC->language()->txt('lti_con_prov_secret'), 'provider_secret');
96 $providerSecretInp->setValue($this->object->getCustomLaunchSecret());
97 $providerSecretInp->setRequired(true);
98 $this->addItem($providerSecretInp);
99 }
100
101 if ($this->object->getProvider()->getHasOutcome()) {
102 $sectionHeader = new ilFormSectionHeaderGUI();
103 $sectionHeader->setTitle($DIC->language()->txt('learning_progress_options'));
104 $this->addItem($sectionHeader);
105 $masteryScore = new ilNumberInputGUI($DIC->language()->txt('mastery_score'), 'mastery_score');
106 $masteryScore->setInfo($DIC->language()->txt('mastery_score_info'));
107 $masteryScore->setSuffix('%');
108 $masteryScore->allowDecimals(true);
109 $masteryScore->setDecimals(2);
110 $masteryScore->setMinvalueShouldBeGreater(false);
111 $masteryScore->setMinValue(0);
112 $masteryScore->setMaxvalueShouldBeLess(false);
113 $masteryScore->setMaxValue(100);
114 $masteryScore->setSize(4);
115 $masteryScore->setValue((string) $this->object->getMasteryScorePercent());
116 $this->addItem($masteryScore);
117 }
118
119 $item = new ilFormSectionHeaderGUI();
120 $item->setTitle($DIC->language()->txt('lti_form_section_appearance'));
121 $this->addItem($item);
122
123 $item = new ilRadioGroupInputGUI($DIC->language()->txt('launch_method'), 'launch_method');
124 $item->setRequired(true);
125 $item->setValue($this->object->getLaunchMethod());
126 $optOwnWindow = new ilRadioOption(
127 $DIC->language()->txt('launch_method_own_win'),
129 );
130 $optOwnWindow->setInfo($DIC->language()->txt('launch_method_own_win_info'));
131 $item->addOption($optOwnWindow);
132 $optAnyWindow = new ilRadioOption(
133 $DIC->language()->txt('launch_method_new_win'),
135 );
136 $optAnyWindow->setInfo($DIC->language()->txt('launch_method_new_win_info'));
137 $item->addOption($optAnyWindow);
138 $optEmbedded = new ilRadioOption(
139 $DIC->language()->txt('launch_method_embedded'),
141 );
142 $optEmbedded->setInfo($DIC->language()->txt('launch_method_embedded_info'));
143 $item->addOption($optEmbedded);
144 $this->addItem($item);
145
146 $customParams = new ilTextAreaInputGUI($DIC->language()->txt('launch_custom_params'), 'custom_params');
147 $customParams->setRows(6);
148 $customParams->setValue($this->object->getCustomParams());
149 $customParams->setInfo($DIC->language()->txt('lti_con_prov_custom_params_info'));
150 $this->addItem($customParams);
151
152 if ($this->object->getProvider()->getUseXapi()) {
153 $item = new ilCheckboxInputGUI($DIC->language()->txt('use_xapi'), 'use_xapi');
154 $item->setInfo($DIC->language()->txt("use_xapi_info"));
155 $item->setValue("1");
156 if ($this->object->getUseXapi()) {
157 $item->setChecked(true);
158 }
159
160 if (!strlen($this->object->getProvider()->getXapiActivityId())) {
161 $subitem = new ilTextInputGUI($DIC->language()->txt('activity_id'), 'activity_id');
162 $subitem->setSize(40);
163 $subitem->setMaxLength(128);
164 $subitem->setRequired(true);
165 $subitem->setInfo($DIC->language()->txt('activity_id_info'));
166 $subitem->setValue($this->object->getCustomActivityId());
167 $item->addSubItem($subitem);
168 }
169
170 $subitem = new ilCheckboxInputGUI($DIC->language()->txt('show_statements'), 'show_statements');
171 $subitem->setInfo($DIC->language()->txt("show_statements_info"));
172 $subitem->setValue("1");
173 if ($this->object->isStatementsReportEnabled()) {
174 $subitem->setChecked(true);
175 }
176 $item->addSubItem($subitem);
177
178 $highscore = new ilCheckboxInputGUI($DIC->language()->txt("highscore_enabled"), "highscore_enabled");
179 $highscore->setValue("1");
180 $highscore->setChecked($this->object->getHighscoreEnabled());
181 $highscore->setInfo($DIC->language()->txt("highscore_description"));
182 $highscore_tables = new ilRadioGroupInputGUI($DIC->language()->txt('highscore_mode'), 'highscore_mode');
183 $highscore_tables->setRequired(true);
184 $highscore_tables->setValue((string) $this->object->getHighscoreMode());
185 $highscore_table_own = new ilRadioOption($DIC->language()->txt('highscore_own_table'), (string) ilObjLTIConsumer::HIGHSCORE_SHOW_OWN_TABLE);
186 $highscore_table_own->setInfo($DIC->language()->txt('highscore_own_table_description'));
187 $highscore_tables->addOption($highscore_table_own);
188 $highscore_table_other = new ilRadioOption($DIC->language()->txt('highscore_top_table'), (string) ilObjLTIConsumer::HIGHSCORE_SHOW_TOP_TABLE);
189 $highscore_table_other->setInfo($DIC->language()->txt('highscore_top_table_description'));
190 $highscore_tables->addOption($highscore_table_other);
191 $highscore_table_other = new ilRadioOption($DIC->language()->txt('highscore_all_tables'), (string) ilObjLTIConsumer::HIGHSCORE_SHOW_ALL_TABLES);
192 $highscore_table_other->setInfo($DIC->language()->txt('highscore_all_tables_description'));
193 $highscore_tables->addOption($highscore_table_other);
194 $highscore->addSubItem($highscore_tables);
195 $highscore_top_num = new ilNumberInputGUI($DIC->language()->txt("highscore_top_num"), "highscore_top_num");
196 $highscore_top_num->setSize(4);
197 $highscore_top_num->setRequired(true);
198 $highscore_top_num->setMinValue(1);
199 $highscore_top_num->setSuffix($DIC->language()->txt("highscore_top_num_unit"));
200 $highscore_top_num->setValue((string) $this->object->getHighscoreTopNum(0));
201 $highscore_top_num->setInfo($DIC->language()->txt("highscore_top_num_description"));
202 $highscore->addSubItem($highscore_top_num);
203 $highscore_achieved_ts = new ilCheckboxInputGUI($DIC->language()->txt("highscore_achieved_ts"), "highscore_achieved_ts");
204 $highscore_achieved_ts->setValue("1");
205 $highscore_achieved_ts->setChecked($this->object->getHighscoreAchievedTS());
206 $highscore_achieved_ts->setInfo($DIC->language()->txt("highscore_achieved_ts_description"));
207 $highscore->addSubItem($highscore_achieved_ts);
208 $highscore_percentage = new ilCheckboxInputGUI($DIC->language()->txt("highscore_percentage"), "highscore_percentage");
209 $highscore_percentage->setValue("1");
210 $highscore_percentage->setChecked($this->object->getHighscorePercentage());
211 $highscore_percentage->setInfo($DIC->language()->txt("highscore_percentage_description"));
212 $highscore->addSubItem($highscore_percentage);
213 $highscore_wtime = new ilCheckboxInputGUI($DIC->language()->txt("highscore_wtime"), "highscore_wtime");
214 $highscore_wtime->setValue("1");
215 $highscore_wtime->setChecked($this->object->getHighscoreWTime());
216 $highscore_wtime->setInfo($DIC->language()->txt("highscore_wtime_description"));
217 $highscore->addSubItem($highscore_wtime);
218
219 $item->addSubItem($highscore);
220 $this->addItem($item);
221 }
222 }
223
224 public function initObject(ilObjLTIConsumer $object): void
225 {
226 $object->setTitle($this->getInput('title'));
227 $object->setDescription($this->getInput('description'));
228 $object->setOfflineStatus(!(bool) $this->getInput('online'));
229
230 if ($object->getProvider()->getLtiVersion() == 'LTI-1p0' && $object->getProvider()->isProviderKeyCustomizable()) {
231 $object->setCustomLaunchKey($this->getInput('provider_key'));
232 $object->setCustomLaunchSecret($this->getInput('provider_secret'));
233 }
234
235 if ($object->getProvider()->getHasOutcome()) {
236 $object->setMasteryScorePercent($this->getInput('mastery_score'));
237 }
238
239 $object->setLaunchMethod($this->getInput('launch_method'));
240 $object->setCustomParams($this->getInput('custom_params'));
241 $object->setUseXapi((bool) $this->getInput('use_xapi'));
242 if ($object->getUseXapi()) {
243 if (!strlen($this->object->getProvider()->getXapiActivityId())) {
244 $object->setCustomActivityId($this->getInput('activity_id'));
245 }
246 $object->setStatementsReportEnabled((bool) $this->getInput('show_statements'));
247 $object->setHighscoreEnabled((bool) $this->getInput('highscore_enabled'));
248 if ($object->getHighscoreEnabled()) {
249 // highscore settings
250 $object->setHighscoreEnabled((bool) $this->getInput('highscore_enabled'));
251 $object->setHighscoreAchievedTS((bool) $this->getInput('highscore_achieved_ts'));
252 $object->setHighscorePercentage((bool) $this->getInput('highscore_percentage'));
253 $object->setHighscoreWTime((bool) $this->getInput('highscore_wtime'));
254 $object->setHighscoreMode((int) $this->getInput('highscore_mode'));
255 $object->setHighscoreTopNum((int) $this->getInput('highscore_top_num'));
256 }
257 }
258 }
259}
This class represents a checkbox property in a property form.
setFormAction(string $a_formaction)
string $formaction
This class represents a section header in a property form.
__construct(ilObjLTIConsumer $object, string $formaction, string $saveCommand, string $cancelCommand)
ilLTIConsumerSettingsFormGUI constructor.
initForm(string $formaction, string $saveCommand, string $cancelCommand)
This class represents a non editable value in a property form.
This class represents a number property in a property form.
setCustomLaunchSecret(string $customLaunchSecret)
getHighscoreEnabled()
Gets the setting which determines if the highscore feature is enabled.
setHighscorePercentage(bool $a_percentage)
Sets if the percentages of the scores pass should be shown.
setCustomParams(string $customParams)
setHighscoreEnabled(bool $a_enabled)
HIGHSCORE.
setHighscoreAchievedTS(bool $a_achieved_ts)
Sets if the date and time of the scores achievement should be displayed.
setLaunchMethod(string $launchMethod)
setStatementsReportEnabled(bool $statementsReportEnabled)
setMasteryScorePercent(float $mastery_score_percent)
setHighscoreTopNum(int $a_top_num)
Sets the number of entries which are to be shown in the top-rankings table.
setHighscoreWTime(bool $a_wtime)
Sets if the workingtime of the scores should be shown.
setCustomLaunchKey(string $customLaunchKey)
setCustomActivityId(string $custom_activity_id)
setUseXapi(bool $use_xapi)
setTitle(string $title)
setOfflineStatus(bool $status)
setDescription(string $description)
This class represents a property form user interface.
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a text area property in a property form.
This class represents a text property in a property form.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26