ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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)
 
 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
 

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 53 of file class.ilTestQuestionNavigationGUI.php.

57  {
58  }

Member Function Documentation

◆ getActionsHTML()

ilTestQuestionNavigationGUI::getActionsHTML ( )

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

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

125  : string
126  {
127  $tpl = $this->getTemplate('actions');
128  $actions = [];
129 
130  if ($this->question_mark_link_target) {
131  $this->renderActionsIcon(
132  $tpl,
133  $this->getQuestionMarkIconSource(),
134  $this->getQuestionMarkIconLabel(),
135  'ilTestMarkQuestionIcon'
136  );
138  $actions[] = $this->ui_factory->button()->shy(
140  ''
141  )->withAdditionalOnLoadCode(
142  static function (string $id) use ($target): string {
143  return "document.getElementById('$id').addEventListener('click', "
144  . '(e) => {'
145  . " il.TestPlayerQuestionEditControl.checkNavigation('{$target}', 'show', e);"
146  . '});';
147  }
148  );
149  }
150 
151  if ($this->skip_question_link_target) {
152  $actions[] = $this->ui_factory->button()->shy(
153  $this->lng->txt('postpone_question'),
155  );
156  }
157 
158  if ($actions !== []) {
159  $actions[] = $this->ui_factory->divider()->horizontal();
160  }
161 
162  $actions[] = $this->ui_factory->button()->shy(
163  $this->lng->txt('tst_revert_changes'),
165  )->withUnavailableAction(!$this->revert_changes_link_target);
166 
167  if ($this->question_worked_through) {
168  $actions[] = $this->ui_factory->button()->shy(
169  $this->lng->txt('discard_answer'),
170  '#'
171  )->withUnavailableAction(!$this->discard_solution_button_enabled)
172  ->withOnClick($this->getShowDiscardModalSignal());
173  }
174 
175  $list = $this->ui_factory->dropdown()->standard($actions)->withLabel($this->lng->txt('actions'));
176  $tpl->setVariable('ACTION_MENU', $this->ui_renderer->render($list));
177 
178  return $tpl->get();
179  }
renderActionsIcon(ilTemplate $tpl, string $icon_src, string $label, string $css_class)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ getCheckButtonLabel()

ilTestQuestionNavigationGUI::getCheckButtonLabel ( )
private

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

References ILIAS\Repository\lng().

Referenced by getHTML().

217  : string
218  {
219  if ($this->answer_freezing_enabled) {
220  return $this->lng->txt('submit_and_check');
221  }
222 
223  return $this->lng->txt('check');
224  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEditSolutionButtonLabel()

ilTestQuestionNavigationGUI::getEditSolutionButtonLabel ( )
private

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

References ILIAS\Repository\lng().

Referenced by getHTML().

208  : string
209  {
210  if ($this->question_worked_through) {
211  return $this->lng->txt('edit_answer');
212  }
213 
214  return $this->lng->txt('answer_question');
215  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHTML()

ilTestQuestionNavigationGUI::getHTML ( )

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

References getCheckButtonLabel(), getEditSolutionButtonLabel(), getTemplate(), parseNavigation(), renderInstantFeedbackButton(), renderSubmitButton(), and ilTestPlayerCommands\SHOW_INSTANT_RESPONSE.

181  : string
182  {
183  $tpl = $this->getTemplate('toolbar');
184  if ($this->edit_solution_command) {
185  $this->renderSubmitButton(
186  $tpl,
187  $this->edit_solution_command,
189  );
190  }
191 
192  if ($this->instant_feedback_command === ilTestPlayerCommands::SHOW_INSTANT_RESPONSE) {
194  $tpl,
195  $this->instant_feedback_command,
196  $this->getCheckButtonLabel(),
197  $this->force_instant_response_enabled
198  );
199  }
200 
201  if ($this->anything_rendered) {
202  $this->parseNavigation($tpl);
203  }
204 
205  return $tpl->get();
206  }
renderSubmitButton(ilTemplate $tpl, string $command, string $label)
renderInstantFeedbackButton(ilTemplate $tpl, string $command, string $label, bool $is_primary)
+ Here is the call graph for this function:

◆ getOnLoadCode()

ilTestQuestionNavigationGUI::getOnLoadCode ( string  $command)
private

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

References $id.

Referenced by renderInstantFeedbackButton(), and renderSubmitButton().

330  : Closure
331  {
332  return static function ($id) use ($command): string {
333  return "document.getElementById('$id').addEventListener('click', "
334  . '(e) => {'
335  . " e.target.setAttribute('name', 'cmd[$command]');"
336  . ' e.target.form.requestSubmit(e.target);'
337  . '});';
338  };
339  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the caller graph for this function:

◆ getQuestionMarkActionLabel()

ilTestQuestionNavigationGUI::getQuestionMarkActionLabel ( )
private

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

References ILIAS\Repository\lng().

Referenced by getActionsHTML().

226  : string
227  {
228  if ($this->question_marked) {
229  return $this->lng->txt('tst_remove_mark');
230  }
231 
232  return $this->lng->txt('tst_question_mark');
233  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getQuestionMarkIconLabel()

ilTestQuestionNavigationGUI::getQuestionMarkIconLabel ( )
private

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

References ILIAS\Repository\lng().

Referenced by getActionsHTML().

236  : string
237  {
238  if ($this->question_marked) {
239  return $this->lng->txt('tst_question_marked');
240  }
241 
242  return$this->lng->txt('tst_question_not_marked');
243  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getQuestionMarkIconSource()

ilTestQuestionNavigationGUI::getQuestionMarkIconSource ( )
private

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

References ilUtil\getImagePath().

Referenced by getActionsHTML().

245  : string
246  {
247  if ($this->question_marked) {
248  return ilUtil::getImagePath('object/marked.svg');
249  }
250 
251  return ilUtil::getImagePath('object/marked_.svg');
252  }
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getShowDiscardModalSignal()

ilTestQuestionNavigationGUI::getShowDiscardModalSignal ( )
private

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

Referenced by getActionsHTML().

120  : Signal
121  {
122  return $this->show_discard_modal_signal ?? new SignalImplementation('');
123  }
+ Here is the caller graph for this function:

◆ getTemplate()

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

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

Referenced by getActionsHTML(), and getHTML().

254  : ilTemplate
255  {
256  switch ($a_purpose) {
257  case 'toolbar':
258  return new ilTemplate(
259  'tpl.tst_question_navigation.html',
260  true,
261  true,
262  'components/ILIAS/Test'
263  );
264  default:
265  case 'actions':
266  return new ilTemplate(
267  'tpl.tst_question_actions.html',
268  true,
269  true,
270  'components/ILIAS/Test'
271  );
272  }
273  }
+ Here is the caller graph for this function:

◆ parseButtonsBlock()

ilTestQuestionNavigationGUI::parseButtonsBlock ( ilTemplate  $tpl)
private

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

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

Referenced by renderButtonInstance().

281  : void
282  {
283  $tpl->setCurrentBlock('buttons');
284  $tpl->parseCurrentBlock();
285  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ 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 275 of file class.ilTestQuestionNavigationGUI.php.

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

Referenced by getHTML().

275  : void
276  {
277  $tpl->setCurrentBlock('question_related_navigation');
278  $tpl->parseCurrentBlock();
279  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ 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 341 of file class.ilTestQuestionNavigationGUI.php.

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

Referenced by getActionsHTML().

346  : void {
347  $tpl->setCurrentBlock('actions_icon');
348  $tpl->setVariable('ICON_SRC', $icon_src);
349  $tpl->setVariable('ICON_TEXT', $label);
350  $tpl->setVariable('ICON_CLASS', $css_class);
351  $tpl->parseCurrentBlock();
352  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderButtonInstance()

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

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

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

Referenced by renderInstantFeedbackButton(), and renderSubmitButton().

287  : void
288  {
289  $tpl->setCurrentBlock('button_instance');
290  $tpl->setVariable('BUTTON_INSTANCE', $this->ui_renderer->render($button));
291  $tpl->parseCurrentBlock();
292 
293  $this->parseButtonsBlock($tpl);
294  $this->setAnythingRendered();
295  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderInstantFeedbackButton()

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

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

References getOnLoadCode(), and renderButtonInstance().

Referenced by getHTML().

314  : void {
315  $on_load_code = $this->getOnLoadCode($command);
316  if ($is_primary) {
317  $this->renderButtonInstance(
318  $tpl,
319  $this->ui_factory->button()->primary($label, '')->withAdditionalOnLoadCode($on_load_code)
320  );
321  return;
322  }
323 
324  $this->renderButtonInstance(
325  $tpl,
326  $this->ui_factory->button()->standard($label, '')->withAdditionalOnLoadCode($on_load_code)
327  );
328  }
renderButtonInstance(ilTemplate $tpl, Button $button)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderSubmitButton()

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

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

References getOnLoadCode(), and renderButtonInstance().

Referenced by getHTML().

301  : void {
302  $on_load_code = $this->getOnLoadCode($command);
303  $this->renderButtonInstance(
304  $tpl,
305  $this->ui_factory->button()->standard($label, '')->withAdditionalOnLoadCode($on_load_code)
306  );
307  }
renderButtonInstance(ilTemplate $tpl, Button $button)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAnswerFreezingEnabled()

ilTestQuestionNavigationGUI::setAnswerFreezingEnabled ( bool  $answer_freezing_enabled)

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

References $answer_freezing_enabled.

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

◆ setAnythingRendered()

ilTestQuestionNavigationGUI::setAnythingRendered ( )

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

Referenced by renderButtonInstance().

110  : void
111  {
112  $this->anything_rendered = true;
113  }
+ Here is the caller graph for this function:

◆ setDiscardSolutionButtonEnabled()

ilTestQuestionNavigationGUI::setDiscardSolutionButtonEnabled ( bool  $discard_solution_button_enabled)

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

References $discard_solution_button_enabled.

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

◆ setEditSolutionCommand()

ilTestQuestionNavigationGUI::setEditSolutionCommand ( string  $edit_solution_command)

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

References $edit_solution_command.

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

◆ setForceInstantResponseEnabled()

ilTestQuestionNavigationGUI::setForceInstantResponseEnabled ( bool  $force_instant_response_enabled)

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

References $force_instant_response_enabled.

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

◆ setInstantFeedbackCommand()

ilTestQuestionNavigationGUI::setInstantFeedbackCommand ( string  $instant_feedback_command)

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

References $instant_feedback_command.

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

◆ setQuestionMarked()

ilTestQuestionNavigationGUI::setQuestionMarked ( bool  $question_marked)

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

References $question_marked.

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

◆ setQuestionMarkLinkTarget()

ilTestQuestionNavigationGUI::setQuestionMarkLinkTarget ( string  $question_mark_link_target)

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

References $question_mark_link_target.

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

◆ setQuestionWorkedThrough()

ilTestQuestionNavigationGUI::setQuestionWorkedThrough ( bool  $question_worked_through)

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

References $question_worked_through.

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

◆ setRevertChangesLinkTarget()

ilTestQuestionNavigationGUI::setRevertChangesLinkTarget ( string  $revert_changes_link_target)

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

References $revert_changes_link_target.

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

◆ setShowDiscardModalSignal()

ilTestQuestionNavigationGUI::setShowDiscardModalSignal ( Signal  $signal)

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

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

◆ setSkipQuestionLinkTarget()

ilTestQuestionNavigationGUI::setSkipQuestionLinkTarget ( string  $skip_question_link_target)

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

References $skip_question_link_target.

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

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().

◆ $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

◆ $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

◆ $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: