ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilLTIConsumeProviderFormGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5
15{
19 protected $provider;
20
24 protected $adminContext = false;
25
31 {
33
34 $this->provider = $provider;
35 }
36
40 public function isAdminContext() : bool
41 {
43 }
44
48 public function setAdminContext(bool $adminContext)
49 {
50 $this->adminContext = $adminContext;
51 }
52
58 public function initForm($formaction, $saveCmd, $cancelCmd)
59 {
60 global $DIC; /* @var \ILIAS\DI\Container $DIC */
61 $lng = $DIC->language();
62
64 $this->addCommandButton($saveCmd, $lng->txt('save'));
65 $this->addCommandButton($cancelCmd, $lng->txt('cancel'));
66
67 if ($this->provider->getId()) {
68 $this->setTitle($lng->txt('lti_form_provider_edit'));
69 } else {
70 $this->setTitle($lng->txt('lti_form_provider_create'));
71 }
72
73 $titleInp = new ilTextInputGUI($lng->txt('lti_con_prov_title'), 'title');
74 $titleInp->setValue($this->provider->getTitle());
75 $titleInp->setRequired(true);
76 $this->addItem($titleInp);
77
78 $descInp = new ilTextInputGUI($lng->txt('lti_con_prov_description'), 'description');
79 $descInp->setValue($this->provider->getDescription());
80 $this->addItem($descInp);
81
82 $iconInp = new ilImageFileInputGUI($lng->txt('lti_con_prov_icon'), 'icon');
83 $iconInp->setInfo($lng->txt('obj_tile_image_info'));
85 $iconInp->setUseCache(false);
86 if ($this->provider->hasProviderIcon() && $this->provider->getProviderIcon()->exists()) {
87 $iconInp->setImage($this->provider->getProviderIcon()->getAbsoluteFilePath());
88 } else {
89 $iconInp->setImage('');//todo default image?
90 }
91 $this->addItem($iconInp);
92
93 if ($this->isAdminContext()) {
94 $availabilityInp = new ilRadioGroupInputGUI($lng->txt('lti_con_prov_availability'), 'availability');
95 $availabilityInp->setValue($this->provider->getAvailability());
96 $availabilityInp->setRequired(true);
97 $optionCreate = new ilRadioOption(
98 $lng->txt('lti_con_prov_availability_create'),
100 );
101 $availabilityInp->addOption($optionCreate);
102 $optionCreate = new ilRadioOption(
103 $lng->txt('lti_con_prov_availability_existing'),
105 );
106 $availabilityInp->addOption($optionCreate);
107 $optionCreate = new ilRadioOption(
108 $lng->txt('lti_con_prov_availability_non'),
110 );
111 $availabilityInp->addOption($optionCreate);
112 $this->addItem($availabilityInp);
113 }
114
115
116 $sectionHeader = new ilFormSectionHeaderGUI();
117 $sectionHeader->setTitle($lng->txt('lti_con_prov_authentication'));
118 $this->addItem($sectionHeader);
119
120
121 $providerUrlInp = new ilTextInputGUI($lng->txt('lti_con_prov_url'), 'provider_url');
122 $providerUrlInp->setValue($this->provider->getProviderUrl());
123 $providerUrlInp->setRequired(true);
124 $this->addItem($providerUrlInp);
125 //Abfrage ob Key und secret von Objekterstellern eingegeben werden soll
126 $item = new ilCheckboxInputGUI($lng->txt('lti_con_prov_provider_key_global'), 'provider_key_global');
127 $item->setValue("1");
128 if (!$this->provider->isProviderKeyCustomizable()) {
129 $item->setChecked(true);
130 }
131 $item->setInfo($lng->txt('lti_con_prov_provider_key_global_info'));
132
133 $providerKeyInp = new ilTextInputGUI($lng->txt('lti_con_prov_key'), 'provider_key');
134 $providerKeyInp->setValue($this->provider->getProviderKey());
135 $providerKeyInp->setRequired(true);
136 $item->addSubItem($providerKeyInp);
137
138 $providerSecretInp = new ilTextInputGUI($lng->txt('lti_con_prov_secret'), 'provider_secret');
139 $providerSecretInp->setValue($this->provider->getProviderSecret());
140 $providerSecretInp->setRequired(true);
141 $item->addSubItem($providerSecretInp);
142
143 $this->addItem($item);
144
145 //privacy-settings
146
147 $sectionHeader = new ilFormSectionHeaderGUI();
148 $sectionHeader->setTitle($lng->txt('lti_con_prov_privacy_settings'));
149 $this->addItem($sectionHeader);
150
151 $item = new ilRadioGroupInputGUI($DIC->language()->txt('conf_privacy_ident'), 'privacy_ident');
152 $op = new ilRadioOption(
153 $DIC->language()->txt('conf_privacy_ident_il_uuid_user_id'),
155 );
156 $op->setInfo($DIC->language()->txt('conf_privacy_ident_il_uuid_user_id_info'));
157 $item->addOption($op);
158 $op = new ilRadioOption(
159 $DIC->language()->txt('conf_privacy_ident_il_uuid_login'),
161 );
162 $op->setInfo($DIC->language()->txt('conf_privacy_ident_il_uuid_login_info'));
163 $item->addOption($op);
164 $op = new ilRadioOption(
165 $DIC->language()->txt('conf_privacy_ident_il_uuid_ext_account'),
167 );
168 $op->setInfo($DIC->language()->txt('conf_privacy_ident_il_uuid_ext_account_info'));
169 $item->addOption($op);
170 $op = new ilRadioOption(
171 $DIC->language()->txt('conf_privacy_ident_il_uuid_sha256'),
173 );
174 $op->setInfo($DIC->language()->txt('conf_privacy_ident_il_uuid_sha256_info'));
175 $item->addOption($op);
176 $op = new ilRadioOption(
177 $DIC->language()->txt('conf_privacy_ident_il_uuid_sha256url'),
179 );
180 $op->setInfo($DIC->language()->txt('conf_privacy_ident_il_uuid_sha256url_info'));
181 $item->addOption($op);
182 $op = new ilRadioOption(
183 $DIC->language()->txt('conf_privacy_ident_real_email'),
185 );
186 $op->setInfo($DIC->language()->txt('conf_privacy_ident_real_email_info'));
187 $item->addOption($op);
188 $item->setValue($this->provider->getPrivacyIdent());
189 $item->setInfo(
190 $DIC->language()->txt('conf_privacy_ident_info') . ' ' . ilCmiXapiUser::getIliasUuid() . '.ilias'
191 );
192 $item->setRequired(false);
193 $this->addItem($item);
194
195 $item = new ilRadioGroupInputGUI($DIC->language()->txt('conf_privacy_name'), 'privacy_name');
196 $op = new ilRadioOption($DIC->language()->txt('conf_privacy_name_none'), ilLTIConsumeProvider::PRIVACY_NAME_NONE);
197 $op->setInfo($DIC->language()->txt('conf_privacy_name_none_info'));
198 $item->addOption($op);
199 $op = new ilRadioOption($DIC->language()->txt('conf_privacy_name_firstname'), ilLTIConsumeProvider::PRIVACY_NAME_FIRSTNAME);
200 $op->setInfo($DIC->language()->txt('conf_privacy_name_firstname_info'));
201 $item->addOption($op);
202 $op = new ilRadioOption($DIC->language()->txt('conf_privacy_name_lastname'), ilLTIConsumeProvider::PRIVACY_NAME_LASTNAME);
203 $op->setInfo($DIC->language()->txt('conf_privacy_name_lastname_info'));
204 $item->addOption($op);
205 $op = new ilRadioOption($DIC->language()->txt('conf_privacy_name_fullname'), ilLTIConsumeProvider::PRIVACY_NAME_FULLNAME);
206 $op->setInfo($DIC->language()->txt('conf_privacy_name_fullname_info'));
207 $item->addOption($op);
208 $item->setValue($this->provider->getPrivacyName());
209 $item->setInfo($DIC->language()->txt('conf_privacy_name_info'));
210 $item->setRequired(false);
211 $this->addItem($item);
212
213 $includeUserImage = new ilCheckboxInputGUI($lng->txt('lti_con_prov_inc_usr_pic'), 'inc_usr_pic');
214 $includeUserImage->setInfo($lng->txt('lti_con_prov_inc_usr_pic_info'));
215 $includeUserImage->setChecked($this->provider->getIncludeUserPicture());
216 $this->addItem($includeUserImage);
217
218 $item = new ilCheckboxInputGUI($lng->txt('lti_con_prov_external_provider'), 'is_external_provider');
219 $item->setValue("1");
220 if ($this->provider->IsExternalProvider()) {
221 $item->setChecked(true);
222 }
223 $item->setInfo($lng->txt('lti_con_prov_external_provider_info'));
224 $this->addItem($item);
225
226
227 $sectionHeader = new ilFormSectionHeaderGUI();
228 $sectionHeader->setTitle($lng->txt('lti_con_prov_learning_progress_options'));
229 $this->addItem($sectionHeader);
230 $item = new ilCheckboxInputGUI($lng->txt('lti_con_prov_has_outcome_service'), 'has_outcome_service');
231 $item->setValue("1");
232 if ($this->provider->getHasOutcome()) {
233 $item->setChecked(true);
234 }
235 $item->setInfo($lng->txt('lti_con_prov_has_outcome_service_info'));
236 $masteryScore = new ilNumberInputGUI($lng->txt('lti_con_prov_mastery_score_default'), 'mastery_score');
237 $masteryScore->setInfo($lng->txt('lti_con_prov_mastery_score_default_info'));
238 $masteryScore->setSuffix('%');
239 $masteryScore->allowDecimals(true);
240 $masteryScore->setDecimals(2);
241 $masteryScore->setMinvalueShouldBeGreater(false);
242 $masteryScore->setMinValue(0);
243 $masteryScore->setMaxvalueShouldBeLess(false);
244 $masteryScore->setMaxValue(100);
245 $masteryScore->setSize(4);
246 $masteryScore->setValue($this->provider->getMasteryScorePercent());
247 $item->addSubItem($masteryScore);
248 $this->addItem($item);
249
250
251 $sectionHeader = new ilFormSectionHeaderGUI();
252 $sectionHeader->setTitle($lng->txt('lti_con_prov_launch_options'));
253 $this->addItem($sectionHeader);
254
255 $item = new ilCheckboxInputGUI($lng->txt('lti_con_prov_use_provider_id'), 'use_provider_id');
256 $item->setValue("1");
257 if ($this->provider->getUseProviderId()) {
258 $item->setChecked(true);
259 }
260 $item->setInfo($lng->txt('lti_con_prov_use_provider_id_info'));
261
262 $this->addItem($item);
263
264 $item = new ilCheckboxInputGUI($lng->txt('lti_con_prov_always_learner'), 'always_learner');
265 $item->setValue("1");
266 if ($this->provider->getAlwaysLearner()) {
267 $item->setChecked(true);
268 }
269 $item->setInfo($lng->txt('lti_con_prov_always_learner_info'));
270 $this->addItem($item);
271
272 $item = new ilCheckboxInputGUI($lng->txt('lti_con_prov_use_xapi'), 'use_xapi');
273 $item->setValue("1");
274 if ($this->provider->getUseXapi()) {
275 $item->setChecked(true);
276 }
277 $item->setInfo($lng->txt('lti_con_prov_use_xapi_info'));
278
279 $subitem = new ilTextInputGUI($lng->txt('lti_con_prov_xapi_launch_url'), 'xapi_launch_url');
280 $subitem->setValue($this->provider->getXapiLaunchUrl());
281 $subitem->setInfo($lng->txt('lti_con_prov_xapi_launch_url_info'));
282 $subitem->setRequired(true);
283 $subitem->setMaxLength(255);
284 $item->addSubItem($subitem);
285
286 $subitem = new ilTextInputGUI($lng->txt('lti_con_prov_xapi_launch_key'), 'xapi_launch_key');
287 $subitem->setValue($this->provider->getXapiLaunchKey());
288 $subitem->setInfo($lng->txt('lti_con_prov_xapi_launch_key_info'));
289 $subitem->setRequired(true);
290 $subitem->setMaxLength(64);
291 $item->addSubItem($subitem);
292
293 $subitem = new ilTextInputGUI($lng->txt('lti_con_prov_xapi_launch_secret'), 'xapi_launch_secret');
294 $subitem->setValue($this->provider->getXapiLaunchSecret());
295 $subitem->setInfo($lng->txt('lti_con_prov_xapi_launch_secret_info'));
296 $subitem->setRequired(true);
297 $subitem->setMaxLength(64);
298 $item->addSubItem($subitem);
299
300 $subitem = new ilTextInputGUI($lng->txt('lti_con_prov_xapi_activity_id'), 'xapi_activity_id');
301 $subitem->setValue($this->provider->getXapiActivityId());
302 $subitem->setInfo($lng->txt('lti_con_prov_xapi_activity_id_info'));
303 $subitem->setMaxLength(128);
304 $item->addSubItem($subitem);
305
306 $this->addItem($item);
307
308 $item = new ilTextAreaInputGUI($lng->txt('lti_con_prov_custom_params'), 'custom_params');
309 $item->setValue($this->provider->getCustomParams());
310 $item->setRows(6);
311 $item->setInfo($lng->txt('lti_con_prov_custom_params_info'));
312 $this->addItem($item);
313
314 $sectionHeader = new ilFormSectionHeaderGUI();
315 $sectionHeader->setTitle($lng->txt('lti_con_prov_group_options'));
316 $this->addItem($sectionHeader);
317
318 $item = new ilTextInputGUI($lng->txt('lti_con_prov_keywords'), 'keywords');
319 $item->setValue($this->provider->getKeywords());
320 $item->setInfo($lng->txt('lti_con_prov_keywords_info'));
321 $item->setMaxLength(1000);
322 $this->addItem($item);
323
324 $category = new ilRadioGroupInputGUI($DIC->language()->txt('lti_con_prov_category'), 'category');
325 $category->setInfo($DIC->language()->txt('lti_con_prov_category_info'));
326 $category->setValue($this->provider->getCategory());
327 $category->setRequired(true);
328 foreach (ilLTIConsumeProvider::getCategoriesSelectOptions() as $value => $label) {
329 $category->addOption(new ilRadioOption($label, $value));
330 }
331 $this->addItem($category);
332
333 $sectionHeader = new ilFormSectionHeaderGUI();
334 $sectionHeader->setTitle($lng->txt('lti_con_prov_hints'));
335 $this->addItem($sectionHeader);
336
337 $remarksInp = new ilTextAreaInputGUI($lng->txt('lti_con_prov_remarks'), 'remarks');
338 $remarksInp->setValue($this->provider->getRemarks());
339 $remarksInp->setRows(6);
340 $this->addItem($remarksInp);
341 }
342
344 {
345 $provider->setTitle($this->getInput('title'));
346 $provider->setDescription($this->getInput('description'));
347
348 $provider->setProviderIconUploadInput($this->getItemByPostVar('icon'));
349
350
351 $provider->setHasOutcome((bool) $this->getInput('has_outcome_service'));
352 $provider->setMasteryScorePercent($this->getInput('mastery_score'));
353
354 if ($this->isAdminContext()) {
355 $provider->setAvailability($this->getInput('availability'));
356 }
357
358 if ($this->getInput('provider_key_global') == 1) {
359 $provider->setProviderKeyCustomizable(false);
360 $provider->setProviderKey($this->getInput('provider_key'));
361 $provider->setProviderSecret($this->getInput('provider_secret'));
362 } else {
363 $provider->setProviderKeyCustomizable(true);
364 }
365 $provider->setPrivacyIdent($this->getInput('privacy_ident'));
366 $provider->setPrivacyName($this->getInput('privacy_name'));
367 $provider->setIncludeUserPicture((bool) $this->getInput('inc_usr_pic'));
368 $provider->setIsExternalProvider((bool) $this->getInput('is_external_provider'));
369
370 $provider->setAlwaysLearner((bool) $this->getInput('always_learner'));
371
372 $provider->setUseProviderId((bool) $this->getInput('use_provider_id'));
373 $provider->setXapiActivityId($this->getInput('xapi_activity_id'));
374
375 $provider->setUseXapi((bool) $this->getInput('use_xapi'));
376 $provider->setXapiLaunchUrl($this->getInput('xapi_launch_url'));
377 $provider->setXapiLaunchKey($this->getInput('xapi_launch_key'));
378 $provider->setXapiLaunchSecret($this->getInput('xapi_launch_secret'));
379 $provider->setCustomParams($this->getInput('custom_params'));
380 $provider->setKeywords($this->getInput('keywords'));
381
382 if ($provider->isValidCategory($this->getInput('category'))) {
383 $provider->setCategory($this->getInput('category'));
384 }
385
386 if (null !== $this->getInput('provider_url')) {
387 $provider->setProviderUrl($this->getInput('provider_url'));
388 }
389 if ($provider->isProviderKeyCustomizable()) {
390 $provider->setProviderKey($this->getInput('provider_key'));
391 $provider->setProviderSecret($this->getInput('provider_secret'));
392 }
393 $provider->setRemarks($this->getInput('remarks'));
394 }
395}
An exception for terminatinating execution or to throw for unit testing.
This class represents a checkbox property in a property form.
setFormAction($a_formaction)
Set FormAction.
This class represents a section header in a property form.
This class represents an image file property in a property form.
initForm($formaction, $saveCmd, $cancelCmd)
__construct(ilLTIConsumeProvider $provider)
ilLTIConsumeProviderFormGUI constructor.
initProvider(ilLTIConsumeProvider $provider)
setProviderUrl(string $provider_url)
setUseProviderId(bool $use_provider_id)
setCustomParams(string $custom_params)
setProviderIconUploadInput(ilImageFileInputGUI $providerIconUploadInput)
setDescription(string $description)
setXapiLaunchSecret(string $xapi_launch_secret)
setMasteryScorePercent(float $mastery_score_percent)
setIncludeUserPicture(bool $include_user_picture)
setIsExternalProvider(bool $is_external_provider)
setXapiLaunchUrl(string $xapi_launch_url)
setAlwaysLearner(bool $always_learner)
setProviderKeyCustomizable(bool $provider_key_customizable)
setXapiActivityId(string $xapi_activity_id)
setXapiLaunchKey(string $xapi_launch_key)
setProviderSecret(string $provider_secret)
setPrivacyName(string $privacy_name)
This class represents a number property in a property form.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
addCommandButton($a_cmd, $a_text, $a_id="")
Add Command button.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
getItemByPostVar($a_post_var)
Get Item by POST variable.
setTitle($a_title)
Set Title.
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.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc