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