ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
ilTestQuestionNavigationGUI Class Reference
+ Collaboration diagram for ilTestQuestionNavigationGUI:

Public Member Functions

 __construct (protected ilLanguage $lng, protected UIFactory $ui_factory, protected UIRenderer $ui_renderer)
 
 setEditSolutionCommand (string $edit_solution_command)
 
 setQuestionWorkedThrough (bool $question_worked_through)
 
 setRevertChangesLinkTarget (string $revert_changes_link_target)
 
 setDiscardSolutionButtonEnabled (bool $discard_solution_button_enabled)
 
 setSkipQuestionLinkTarget (string $skip_question_link_target)
 
 setInstantFeedbackCommand (string $instant_feedback_command)
 
 setForceInstantResponseEnabled (bool $force_instant_response_enabled)
 
 setAnswerFreezingEnabled (bool $answer_freezing_enabled)
 
 setQuestionMarkLinkTarget (string $question_mark_link_target)
 
 setQuestionMarked (bool $question_marked)
 
 setAnythingRendered ()
 
 setShowDiscardModalSignal (Signal $signal)
 
 setFeedbackButtonEnabled (bool $feedback_button_enabled)
 
 isFeedbackButtonEnabled ()
 
 getActionsHTML ()
 
 getHTML ()
 

Data Fields

const SHOW_DISABLED_COMMANDS = false
 
const CSS_CLASS_SUBMIT_BUTTONS = 'ilc_qsubmit_Submit'
 

Private Member Functions

 getShowDiscardModalSignal ()
 
 getEditSolutionButtonLabel ()
 
 getCheckButtonLabel ()
 
 getQuestionMarkActionLabel ()
 
 getQuestionMarkIconLabel ()
 
 getQuestionMarkIconSource ()
 
 getTemplate ($a_purpose='toolbar')
 
 parseNavigation (ilTemplate $tpl)
 
 parseButtonsBlock (ilTemplate $tpl)
 
 renderButtonInstance (ilTemplate $tpl, Button $button)
 
 renderSubmitButton (ilTemplate $tpl, string $command, string $label)
 
 renderInstantFeedbackButton (ilTemplate $tpl, string $command, string $label, bool $is_primary)
 
 getOnLoadCode (string $command)
 
 renderActionsIcon (ilTemplate $tpl, string $icon_src, string $label, string $css_class)
 

Private Attributes

ILIAS DI UIServices $ui
 
string $edit_solution_command = ''
 
bool $question_worked_through = false
 
string $revert_changes_link_target = ''
 
bool $discard_solution_button_enabled = false
 
string $skip_question_link_target = ''
 
string $instant_feedback_command = ''
 
bool $answer_freezing_enabled = false
 
bool $force_instant_response_enabled = false
 
string $question_mark_link_target = ''
 
bool $question_marked = false
 
bool $anything_rendered = false
 
Signal $show_discard_modal_signal = null
 
bool $feedback_button_enabled = false
 

Detailed Description

Definition at line 33 of file class.ilTestQuestionNavigationGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestQuestionNavigationGUI::__construct ( protected ilLanguage  $lng,
protected UIFactory  $ui_factory,
protected UIRenderer  $ui_renderer 
)

Definition at line 54 of file class.ilTestQuestionNavigationGUI.php.

58 {
59 }

Member Function Documentation

◆ getActionsHTML()

ilTestQuestionNavigationGUI::getActionsHTML ( )

Definition at line 136 of file class.ilTestQuestionNavigationGUI.php.

136 : string
137 {
138 $tpl = $this->getTemplate('actions');
139 $actions = [];
140
141 if ($this->question_mark_link_target) {
142 $this->renderActionsIcon(
143 $tpl,
146 'ilTestMarkQuestionIcon'
147 );
149 $actions[] = $this->ui_factory->button()->shy(
151 ''
152 )->withAdditionalOnLoadCode(
153 static function (string $id) use ($target): string {
154 return "document.getElementById('$id').addEventListener('click', "
155 . '(e) => {'
156 . " il.TestPlayerQuestionEditControl.checkNavigation('{$target}', 'show', e);"
157 . '});';
158 }
159 );
160 }
161
162 if ($this->skip_question_link_target) {
163 $actions[] = $this->ui_factory->button()->shy(
164 $this->lng->txt('postpone_question'),
165 $this->skip_question_link_target
166 );
167 }
168
169 if ($actions !== []) {
170 $actions[] = $this->ui_factory->divider()->horizontal();
171 }
172
173 $actions[] = $this->ui_factory->button()->shy(
174 $this->lng->txt('tst_revert_changes'),
175 $this->revert_changes_link_target
176 )
177 ->withUnavailableAction(!$this->revert_changes_link_target)
178 ->withAdditionalOnLoadCode(
179 static fn(string $id): string => "document.getElementById('{$id}').classList.add('ilTestRevertChangesAction')"
180 );
181
182 $actions[] = $this->ui_factory->button()->shy($this->lng->txt('discard_answer'), '#')
183 ->withUnavailableAction(!$this->discard_solution_button_enabled)
184 ->withOnClick($this->getShowDiscardModalSignal());
185
186 $list = $this->ui_factory->dropdown()->standard($actions)->withLabel($this->lng->txt('actions'));
187 $tpl->setVariable('ACTION_MENU', $this->ui_renderer->render($list));
188
189 return $tpl->get();
190 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
renderActionsIcon(ilTemplate $tpl, string $icon_src, string $label, string $css_class)

References $id, $question_mark_link_target, getQuestionMarkActionLabel(), getQuestionMarkIconLabel(), getQuestionMarkIconSource(), getShowDiscardModalSignal(), getTemplate(), ILIAS\Repository\lng(), and renderActionsIcon().

+ Here is the call graph for this function:

◆ getCheckButtonLabel()

ilTestQuestionNavigationGUI::getCheckButtonLabel ( )
private

Definition at line 228 of file class.ilTestQuestionNavigationGUI.php.

228 : string
229 {
230 if ($this->answer_freezing_enabled) {
231 return $this->lng->txt('submit_and_check');
232 }
233
234 return $this->lng->txt('check');
235 }

References ILIAS\Repository\lng().

Referenced by getHTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEditSolutionButtonLabel()

ilTestQuestionNavigationGUI::getEditSolutionButtonLabel ( )
private

Definition at line 219 of file class.ilTestQuestionNavigationGUI.php.

219 : string
220 {
221 if ($this->question_worked_through) {
222 return $this->lng->txt('edit_answer');
223 }
224
225 return $this->lng->txt('answer_question');
226 }

References ILIAS\Repository\lng().

Referenced by getHTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHTML()

ilTestQuestionNavigationGUI::getHTML ( )

Definition at line 192 of file class.ilTestQuestionNavigationGUI.php.

192 : string
193 {
194 $tpl = $this->getTemplate('toolbar');
195 if ($this->edit_solution_command) {
196 $this->renderSubmitButton(
197 $tpl,
198 $this->edit_solution_command,
200 );
201 }
202
203 if ($this->isFeedbackButtonEnabled()) {
205 $tpl,
206 $this->instant_feedback_command,
207 $this->getCheckButtonLabel(),
208 $this->force_instant_response_enabled
209 );
210 }
211
212 if ($this->anything_rendered) {
213 $this->parseNavigation($tpl);
214 }
215
216 return $tpl->get();
217 }
renderSubmitButton(ilTemplate $tpl, string $command, string $label)
renderInstantFeedbackButton(ilTemplate $tpl, string $command, string $label, bool $is_primary)

References getCheckButtonLabel(), getEditSolutionButtonLabel(), getTemplate(), isFeedbackButtonEnabled(), parseNavigation(), renderInstantFeedbackButton(), and renderSubmitButton().

+ Here is the call graph for this function:

◆ getOnLoadCode()

ilTestQuestionNavigationGUI::getOnLoadCode ( string  $command)
private

Definition at line 341 of file class.ilTestQuestionNavigationGUI.php.

341 : Closure
342 {
343 return static function ($id) use ($command): string {
344 return "document.getElementById('$id').addEventListener('click', "
345 . '(e) => {'
346 . " e.target.setAttribute('name', 'cmd[$command]');"
347 . ' e.target.form.requestSubmit(e.target);'
348 . '});';
349 };
350 }

References $id.

◆ getQuestionMarkActionLabel()

ilTestQuestionNavigationGUI::getQuestionMarkActionLabel ( )
private

Definition at line 237 of file class.ilTestQuestionNavigationGUI.php.

237 : string
238 {
239 if ($this->question_marked) {
240 return $this->lng->txt('tst_remove_mark');
241 }
242
243 return $this->lng->txt('tst_question_mark');
244 }

References ILIAS\Repository\lng().

Referenced by getActionsHTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getQuestionMarkIconLabel()

ilTestQuestionNavigationGUI::getQuestionMarkIconLabel ( )
private

Definition at line 247 of file class.ilTestQuestionNavigationGUI.php.

247 : string
248 {
249 if ($this->question_marked) {
250 return $this->lng->txt('tst_question_marked');
251 }
252
253 return$this->lng->txt('tst_question_not_marked');
254 }

References ILIAS\Repository\lng().

Referenced by getActionsHTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getQuestionMarkIconSource()

ilTestQuestionNavigationGUI::getQuestionMarkIconSource ( )
private

Definition at line 256 of file class.ilTestQuestionNavigationGUI.php.

256 : string
257 {
258 if ($this->question_marked) {
259 return ilUtil::getImagePath('object/marked.svg');
260 }
261
262 return ilUtil::getImagePath('object/marked_.svg');
263 }
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)

References ilUtil\getImagePath().

Referenced by getActionsHTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getShowDiscardModalSignal()

ilTestQuestionNavigationGUI::getShowDiscardModalSignal ( )
private

Definition at line 121 of file class.ilTestQuestionNavigationGUI.php.

121 : Signal
122 {
123 return $this->show_discard_modal_signal ?? new SignalImplementation('');
124 }

Referenced by getActionsHTML().

+ Here is the caller graph for this function:

◆ getTemplate()

ilTestQuestionNavigationGUI::getTemplate (   $a_purpose = 'toolbar')
private

Definition at line 265 of file class.ilTestQuestionNavigationGUI.php.

265 : ilTemplate
266 {
267 switch ($a_purpose) {
268 case 'toolbar':
269 return new ilTemplate(
270 'tpl.tst_question_navigation.html',
271 true,
272 true,
273 'components/ILIAS/Test'
274 );
275 default:
276 case 'actions':
277 return new ilTemplate(
278 'tpl.tst_question_actions.html',
279 true,
280 true,
281 'components/ILIAS/Test'
282 );
283 }
284 }
special template class to simplify handling of ITX/PEAR

Referenced by getActionsHTML(), and getHTML().

+ Here is the caller graph for this function:

◆ isFeedbackButtonEnabled()

ilTestQuestionNavigationGUI::isFeedbackButtonEnabled ( )

Definition at line 131 of file class.ilTestQuestionNavigationGUI.php.

References $feedback_button_enabled.

Referenced by getHTML().

+ Here is the caller graph for this function:

◆ parseButtonsBlock()

ilTestQuestionNavigationGUI::parseButtonsBlock ( ilTemplate  $tpl)
private

Definition at line 292 of file class.ilTestQuestionNavigationGUI.php.

292 : void
293 {
294 $tpl->setCurrentBlock('buttons');
295 $tpl->parseCurrentBlock();
296 }
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)

References ilTemplate\parseCurrentBlock(), and ilTemplate\setCurrentBlock().

Referenced by renderButtonInstance().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseNavigation()

ilTestQuestionNavigationGUI::parseNavigation ( ilTemplate  $tpl)
private

Definition at line 286 of file class.ilTestQuestionNavigationGUI.php.

286 : void
287 {
288 $tpl->setCurrentBlock('question_related_navigation');
289 $tpl->parseCurrentBlock();
290 }

References ilTemplate\parseCurrentBlock(), and ilTemplate\setCurrentBlock().

Referenced by getHTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderActionsIcon()

ilTestQuestionNavigationGUI::renderActionsIcon ( ilTemplate  $tpl,
string  $icon_src,
string  $label,
string  $css_class 
)
private

Definition at line 352 of file class.ilTestQuestionNavigationGUI.php.

357 : void {
358 $tpl->setCurrentBlock('actions_icon');
359 $tpl->setVariable('ICON_SRC', $icon_src);
360 $tpl->setVariable('ICON_TEXT', $label);
361 $tpl->setVariable('ICON_CLASS', $css_class);
362 $tpl->parseCurrentBlock();
363 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544

Referenced by getActionsHTML().

+ Here is the caller graph for this function:

◆ renderButtonInstance()

ilTestQuestionNavigationGUI::renderButtonInstance ( ilTemplate  $tpl,
Button  $button 
)
private

Definition at line 298 of file class.ilTestQuestionNavigationGUI.php.

298 : void
299 {
300 $tpl->setCurrentBlock('button_instance');
301 $tpl->setVariable('BUTTON_INSTANCE', $this->ui_renderer->render($button));
302 $tpl->parseCurrentBlock();
303
304 $this->parseButtonsBlock($tpl);
305 $this->setAnythingRendered();
306 }

References parseButtonsBlock(), ilTemplate\parseCurrentBlock(), setAnythingRendered(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

+ Here is the call graph for this function:

◆ renderInstantFeedbackButton()

ilTestQuestionNavigationGUI::renderInstantFeedbackButton ( ilTemplate  $tpl,
string  $command,
string  $label,
bool  $is_primary 
)
private

Definition at line 320 of file class.ilTestQuestionNavigationGUI.php.

325 : void {
326 $on_load_code = $this->getOnLoadCode($command);
327 if ($is_primary) {
329 $tpl,
330 $this->ui_factory->button()->primary($label, '')->withAdditionalOnLoadCode($on_load_code)
331 );
332 return;
333 }
334
336 $tpl,
337 $this->ui_factory->button()->standard($label, '')->withAdditionalOnLoadCode($on_load_code)
338 );
339 }
renderButtonInstance(ilTemplate $tpl, Button $button)

Referenced by getHTML().

+ Here is the caller graph for this function:

◆ renderSubmitButton()

ilTestQuestionNavigationGUI::renderSubmitButton ( ilTemplate  $tpl,
string  $command,
string  $label 
)
private

Definition at line 308 of file class.ilTestQuestionNavigationGUI.php.

312 : void {
313 $on_load_code = $this->getOnLoadCode($command);
315 $tpl,
316 $this->ui_factory->button()->standard($label, '')->withAdditionalOnLoadCode($on_load_code)
317 );
318 }

Referenced by getHTML().

+ Here is the caller graph for this function:

◆ setAnswerFreezingEnabled()

ilTestQuestionNavigationGUI::setAnswerFreezingEnabled ( bool  $answer_freezing_enabled)

Definition at line 96 of file class.ilTestQuestionNavigationGUI.php.

96 : void
97 {
98 $this->answer_freezing_enabled = $answer_freezing_enabled;
99 }

References $answer_freezing_enabled.

◆ setAnythingRendered()

ilTestQuestionNavigationGUI::setAnythingRendered ( )

Definition at line 111 of file class.ilTestQuestionNavigationGUI.php.

111 : void
112 {
113 $this->anything_rendered = true;
114 }

Referenced by renderButtonInstance().

+ Here is the caller graph for this function:

◆ setDiscardSolutionButtonEnabled()

ilTestQuestionNavigationGUI::setDiscardSolutionButtonEnabled ( bool  $discard_solution_button_enabled)

Definition at line 76 of file class.ilTestQuestionNavigationGUI.php.

76 : void
77 {
78 $this->discard_solution_button_enabled = $discard_solution_button_enabled;
79 }

References $discard_solution_button_enabled.

◆ setEditSolutionCommand()

ilTestQuestionNavigationGUI::setEditSolutionCommand ( string  $edit_solution_command)

Definition at line 61 of file class.ilTestQuestionNavigationGUI.php.

61 : void
62 {
63 $this->edit_solution_command = $edit_solution_command;
64 }

References $edit_solution_command.

◆ setFeedbackButtonEnabled()

ilTestQuestionNavigationGUI::setFeedbackButtonEnabled ( bool  $feedback_button_enabled)

Definition at line 126 of file class.ilTestQuestionNavigationGUI.php.

126 : void
127 {
128 $this->feedback_button_enabled = $feedback_button_enabled;
129 }

References $feedback_button_enabled.

◆ setForceInstantResponseEnabled()

ilTestQuestionNavigationGUI::setForceInstantResponseEnabled ( bool  $force_instant_response_enabled)

Definition at line 91 of file class.ilTestQuestionNavigationGUI.php.

91 : void
92 {
93 $this->force_instant_response_enabled = $force_instant_response_enabled;
94 }

References $force_instant_response_enabled.

◆ setInstantFeedbackCommand()

ilTestQuestionNavigationGUI::setInstantFeedbackCommand ( string  $instant_feedback_command)

Definition at line 86 of file class.ilTestQuestionNavigationGUI.php.

86 : void
87 {
88 $this->instant_feedback_command = $instant_feedback_command;
89 }

References $instant_feedback_command.

◆ setQuestionMarked()

ilTestQuestionNavigationGUI::setQuestionMarked ( bool  $question_marked)

Definition at line 106 of file class.ilTestQuestionNavigationGUI.php.

106 : void
107 {
108 $this->question_marked = $question_marked;
109 }

References $question_marked.

◆ setQuestionMarkLinkTarget()

ilTestQuestionNavigationGUI::setQuestionMarkLinkTarget ( string  $question_mark_link_target)

Definition at line 101 of file class.ilTestQuestionNavigationGUI.php.

101 : void
102 {
103 $this->question_mark_link_target = $question_mark_link_target;
104 }

References $question_mark_link_target.

◆ setQuestionWorkedThrough()

ilTestQuestionNavigationGUI::setQuestionWorkedThrough ( bool  $question_worked_through)

Definition at line 66 of file class.ilTestQuestionNavigationGUI.php.

66 : void
67 {
68 $this->question_worked_through = $question_worked_through;
69 }

References $question_worked_through.

◆ setRevertChangesLinkTarget()

ilTestQuestionNavigationGUI::setRevertChangesLinkTarget ( string  $revert_changes_link_target)

Definition at line 71 of file class.ilTestQuestionNavigationGUI.php.

71 : void
72 {
73 $this->revert_changes_link_target = $revert_changes_link_target;
74 }

References $revert_changes_link_target.

◆ setShowDiscardModalSignal()

ilTestQuestionNavigationGUI::setShowDiscardModalSignal ( Signal  $signal)

Definition at line 116 of file class.ilTestQuestionNavigationGUI.php.

116 : void
117 {
118 $this->show_discard_modal_signal = $signal;
119 }

◆ setSkipQuestionLinkTarget()

ilTestQuestionNavigationGUI::setSkipQuestionLinkTarget ( string  $skip_question_link_target)

Definition at line 81 of file class.ilTestQuestionNavigationGUI.php.

81 : void
82 {
83 $this->skip_question_link_target = $skip_question_link_target;
84 }

References $skip_question_link_target.

Field Documentation

◆ $answer_freezing_enabled

bool ilTestQuestionNavigationGUI::$answer_freezing_enabled = false
private

Definition at line 46 of file class.ilTestQuestionNavigationGUI.php.

Referenced by setAnswerFreezingEnabled().

◆ $anything_rendered

bool ilTestQuestionNavigationGUI::$anything_rendered = false
private

Definition at line 50 of file class.ilTestQuestionNavigationGUI.php.

◆ $discard_solution_button_enabled

bool ilTestQuestionNavigationGUI::$discard_solution_button_enabled = false
private

◆ $edit_solution_command

string ilTestQuestionNavigationGUI::$edit_solution_command = ''
private

Definition at line 40 of file class.ilTestQuestionNavigationGUI.php.

Referenced by setEditSolutionCommand().

◆ $feedback_button_enabled

bool ilTestQuestionNavigationGUI::$feedback_button_enabled = false
private

◆ $force_instant_response_enabled

bool ilTestQuestionNavigationGUI::$force_instant_response_enabled = false
private

◆ $instant_feedback_command

string ilTestQuestionNavigationGUI::$instant_feedback_command = ''
private

Definition at line 45 of file class.ilTestQuestionNavigationGUI.php.

Referenced by setInstantFeedbackCommand().

◆ $question_mark_link_target

string ilTestQuestionNavigationGUI::$question_mark_link_target = ''
private

◆ $question_marked

bool ilTestQuestionNavigationGUI::$question_marked = false
private

Definition at line 49 of file class.ilTestQuestionNavigationGUI.php.

Referenced by setQuestionMarked().

◆ $question_worked_through

bool ilTestQuestionNavigationGUI::$question_worked_through = false
private

Definition at line 41 of file class.ilTestQuestionNavigationGUI.php.

Referenced by setQuestionWorkedThrough().

◆ $revert_changes_link_target

string ilTestQuestionNavigationGUI::$revert_changes_link_target = ''
private

Definition at line 42 of file class.ilTestQuestionNavigationGUI.php.

Referenced by setRevertChangesLinkTarget().

◆ $show_discard_modal_signal

Signal ilTestQuestionNavigationGUI::$show_discard_modal_signal = null
private

Definition at line 51 of file class.ilTestQuestionNavigationGUI.php.

◆ $skip_question_link_target

string ilTestQuestionNavigationGUI::$skip_question_link_target = ''
private

Definition at line 44 of file class.ilTestQuestionNavigationGUI.php.

Referenced by setSkipQuestionLinkTarget().

◆ $ui

ILIAS DI UIServices ilTestQuestionNavigationGUI::$ui
private

Definition at line 38 of file class.ilTestQuestionNavigationGUI.php.

◆ CSS_CLASS_SUBMIT_BUTTONS

const ilTestQuestionNavigationGUI::CSS_CLASS_SUBMIT_BUTTONS = 'ilc_qsubmit_Submit'

Definition at line 37 of file class.ilTestQuestionNavigationGUI.php.

◆ SHOW_DISABLED_COMMANDS

const ilTestQuestionNavigationGUI::SHOW_DISABLED_COMMANDS = false

Definition at line 35 of file class.ilTestQuestionNavigationGUI.php.


The documentation for this class was generated from the following file: