ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilTestQuestionNavigationGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4
12{
13 const CSS_CLASS_SUBMIT_BUTTONS = 'ilc_qsubmit_Submit';
14
18 protected $lng;
19
24
28 private $questionWorkedThrough = false;
29
34
39
44
49
53 private $answerFreezingEnabled = false;
54
59
63 private $requestHintCommand = '';
64
68 private $showHintsCommand = '';
69
73 private $hintRequestsExist = false;
74
79
83 private $questionMarked = false;
84
88 private $charSelectorEnabled = false;
89
93 private $anythingRendered = false;
94
98 public function __construct(ilLanguage $lng)
99 {
100 $this->lng = $lng;
101 }
102
106 public function getEditSolutionCommand()
107 {
109 }
110
115 {
116 $this->editSolutionCommand = $editSolutionCommand;
117 }
118
122 public function isQuestionWorkedThrough()
123 {
125 }
126
131 {
132 $this->questionWorkedThrough = $questionWorkedThrough;
133 }
134
138 public function getSubmitSolutionCommand()
139 {
141 }
142
147 {
148 $this->submitSolutionCommand = $submitSolutionCommand;
149 }
150
155 {
157 }
158
163 {
164 $this->discardSolutionButtonEnabled = $discardSolutionButtonEnabled;
165 }
166
171 {
173 }
174
179 {
180 $this->skipQuestionLinkTarget = $skipQuestionLinkTarget;
181 }
182
187 {
189 }
190
195 {
196 $this->instantFeedbackCommand = $instantFeedbackCommand;
197 }
198
202 public function isAnswerFreezingEnabled()
203 {
205 }
206
211 {
213 }
214
219 {
220 $this->forceInstantResponseEnabled = $forceInstantResponseEnabled;
221 }
222
227 {
228 $this->answerFreezingEnabled = $answerFreezingEnabled;
229 }
230
234 public function getRequestHintCommand()
235 {
237 }
238
243 {
244 $this->requestHintCommand = $requestHintCommand;
245 }
246
250 public function getShowHintsCommand()
251 {
253 }
254
259 {
260 $this->showHintsCommand = $showHintsCommand;
261 }
262
266 public function hintRequestsExist()
267 {
269 }
270
275 {
277 }
278
282 public function getQuestionMarkCommand()
283 {
285 }
286
291 {
292 $this->questionMarkCommand = $questionMarkCommand;
293 }
294
298 public function isQuestionMarked()
299 {
301 }
302
307 {
308 $this->questionMarked = $questionMarked;
309 }
310
314 public function isAnythingRendered()
315 {
317 }
318
322 public function setAnythingRendered()
323 {
324 $this->anythingRendered = true;
325 }
326
330 public function isCharSelectorEnabled()
331 {
333 }
334
339 {
340 $this->charSelectorEnabled = $charSelectorEnabled;
341 }
342
346 public function getHTML()
347 {
348 $tpl = $this->getTemplate();
349
350 if( $this->getEditSolutionCommand() )
351 {
352 $this->renderSubmitButton(
354 );
355 }
356
357 if( $this->getSubmitSolutionCommand() )
358 {
359 $this->renderSubmitButton(
361 );
362 }
363
364 if( $this->isDiscardSolutionButtonEnabled() )
365 {
366 $this->renderJsLinkedButton($tpl, 'tst_discard_answer_button', 'discard_answer', '');
367 }
368
369 if( $this->getSkipQuestionLinkTarget() )
370 {
371 $this->renderLinkButton($tpl, $this->getSkipQuestionLinkTarget(), 'skip_question');
372 }
373
375 {
376 $this->renderSubmitButton(
378 );
379 }
380
381 if( $this->getRequestHintCommand() )
382 {
383 $this->renderSubmitButton(
385 );
386 }
387
388 if( $this->getShowHintsCommand() )
389 {
390 $this->renderSubmitButton(
391 $tpl, $this->getShowHintsCommand(), 'button_show_requested_question_hints'
392 );
393 }
394
395 if( $this->getQuestionMarkCommand() )
396 {
397 $this->renderIcon(
399 $this->getQuestionMarkIconLabel(), 'ilTstMarkQuestionButton'
400 );
401 }
402
403 if( $this->isCharSelectorEnabled() )
404 {
406 'charselectorbutton', 'char_selector_btn_label', 'ilCharSelectorToggle'
407 );
408 }
409
410 if( $this->isAnythingRendered() )
411 {
412 $this->parseNavigation($tpl);
413 }
414
415 return $tpl->get();
416 }
417
418 private function getEditSolutionButtonLabel()
419 {
420 if( $this->isQuestionWorkedThrough() )
421 {
422 return 'edit_answer';
423 }
424
425 return 'answer_question';
426 }
427
429 {
430 if( $this->isForceInstantResponseEnabled() )
431 {
432 return 'submit_and_check';
433 }
434
435 return 'submit_answer';
436 }
437
438 private function getCheckButtonLabel()
439 {
440 if( $this->isAnswerFreezingEnabled() )
441 {
442 return 'submit_and_check';
443 }
444
445 return 'check';
446 }
447
448 private function getRequestHintButtonLabel()
449 {
450 if( $this->hintRequestsExist() )
451 {
452 return 'button_request_next_question_hint';
453 }
454
455 return 'button_request_question_hint';
456 }
457
458 private function getQuestionMarkIconLabel()
459 {
460 if( $this->isQuestionMarked() )
461 {
462 return $this->lng->txt('tst_remove_mark');
463 }
464
465 return $this->lng->txt('tst_question_mark');
466 }
467
468 private function getQuestionMarkIconSource()
469 {
470 if( $this->isQuestionMarked() )
471 {
472 return ilUtil::getImagePath('marked.svg');
473 }
474
475 return ilUtil::getImagePath('marked_.svg');
476 }
477
481 private function getTemplate()
482 {
483 return new ilTemplate(
484 'tpl.tst_question_navigation.html', true, true, 'Modules/Test'
485 );
486 }
487
492 {
493 $tpl->setCurrentBlock('question_related_navigation');
494 $tpl->parseCurrentBlock();
495 }
496
501 {
502 $tpl->setCurrentBlock('buttons');
503 $tpl->parseCurrentBlock();
504 }
505
510 private function renderButtonInstance(ilTemplate $tpl, $button)
511 {
512 $tpl->setCurrentBlock("button_instance");
513 $tpl->setVariable("BUTTON_INSTANCE", $button->render());
514 $tpl->parseCurrentBlock();
515
516 $this->parseButtonsBlock($tpl);
517 $this->setAnythingRendered();
518 }
519
526 private function renderSubmitButton(ilTemplate $tpl, $command, $label, $primary = false)
527 {
528 $button = ilSubmitButton::getInstance();
529 $button->setCommand($command);
530 $button->setCaption($label);
531 $button->setPrimary($primary);
532 $button->addCSSClass(self::CSS_CLASS_SUBMIT_BUTTONS);
533
534 $this->renderButtonInstance($tpl, $button);
535 }
536
543 private function renderLinkButton(ilTemplate $tpl, $href, $label)
544 {
545 $button = ilLinkButton::getInstance();
546 $button->setUrl($href);
547 $button->setCaption($label);
548
549 $this->renderButtonInstance($tpl, $button);
550 }
551
558 private function renderJsLinkedButton(ilTemplate $tpl, $htmlId, $label, $cssClass)
559 {
560 $button = ilLinkButton::getInstance();
561 $button->setId($htmlId);
562 $button->addCSSClass($cssClass);
563 $button->setCaption($label);
564
565 $this->renderButtonInstance($tpl, $button);
566 }
567
575 private function renderIcon(ilTemplate $tpl, $command, $iconSrc, $label, $cssClass)
576 {
577 $tpl->setCurrentBlock("submit_icon");
578 $tpl->setVariable("SUBMIT_ICON_CMD", $command);
579 $tpl->setVariable("SUBMIT_ICON_SRC", $iconSrc);
580 $tpl->setVariable("SUBMIT_ICON_TEXT", $label);
581 $tpl->setVariable("SUBMIT_ICON_CLASS", $cssClass);
582 $tpl->parseCurrentBlock();
583
584 $this->parseButtonsBlock($tpl);
585 $this->setAnythingRendered();
586 }
587}
global $tpl
Definition: ilias.php:8
language handling
static getInstance()
Factory.
static getInstance()
Factory.
special template class to simplify handling of ITX/PEAR
setDiscardSolutionButtonEnabled($discardSolutionButtonEnabled)
renderJsLinkedButton(ilTemplate $tpl, $htmlId, $label, $cssClass)
renderLinkButton(ilTemplate $tpl, $href, $label)
renderIcon(ilTemplate $tpl, $command, $iconSrc, $label, $cssClass)
renderSubmitButton(ilTemplate $tpl, $command, $label, $primary=false)
setForceInstantResponseEnabled($forceInstantResponseEnabled)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)