ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilAssQuestionHintsGUI Class Reference
+ Inheritance diagram for ilAssQuestionHintsGUI:
+ Collaboration diagram for ilAssQuestionHintsGUI:

Public Member Functions

 __construct (assQuestionGUI $questionGUI)
 Constructor. More...
 
 isEditingEnabled ()
 
 setEditingEnabled (bool $editingEnabled)
 
 executeCommand ()
 
 confirmSyncCmd ()
 
 getHintPresentationLinkTarget ($hintId, $xmlStyle=true)
 returns the link target for hint request presentation More...
 
- Public Member Functions inherited from ilAssQuestionHintAbstractGUI
 __construct (assQuestionGUI $questionGUI)
 Constructor. More...
 

Data Fields

const CMD_SHOW_LIST = 'showList'
 command constants More...
 
const CMD_SHOW_HINT = 'showHint'
 
const CMD_CONFIRM_DELETE = 'confirmDelete'
 
const CMD_PERFORM_DELETE = 'performDelete'
 
const CMD_SAVE_LIST_ORDER = 'saveListOrder'
 
const CMD_CUT_TO_ORDERING_CLIPBOARD = 'cutToOrderingClipboard'
 
const CMD_PASTE_FROM_ORDERING_CLIPBOARD_BEFORE = 'pasteFromOrderingClipboardBefore'
 
const CMD_PASTE_FROM_ORDERING_CLIPBOARD_AFTER = 'pasteFromOrderingClipboardAfter'
 
const CMD_RESET_ORDERING_CLIPBOARD = 'resetOrderingClipboard'
 
const CMD_CONFIRM_SYNC = 'confirmSync'
 

Protected Attributes

 $editingEnabled = false
 
- Protected Attributes inherited from ilAssQuestionHintAbstractGUI
ILIAS TestQuestionPool InternalRequestService $request
 
assQuestionGUI $questionGUI = null
 
assQuestion $questionOBJ = null
 
ilTabsGUI $tabs
 

Private Member Functions

 showListCmd ()
 shows a table with existing hints More...
 
 confirmDeleteCmd ()
 shows a confirmation screen with selected hints for deletion More...
 
 performDeleteCmd ()
 performs confirmed deletion for selected hints More...
 
 saveListOrderCmd ()
 saves the order based on index values passed from table's form (the table must not be paginated, because ALL hints index values are required) More...
 
 cutToOrderingClipboardCmd ()
 cuts a hint from question hint list and stores it to ordering clipboard More...
 
 pasteFromOrderingClipboardBeforeCmd ()
 pastes a hint from ordering clipboard before the selected one More...
 
 pasteFromOrderingClipboardAfterCmd ()
 pastes a hint from ordering clipboard after the selected one More...
 
 resetOrderingClipboardCmd ()
 resets the ordering clipboard More...
 
 initHintOrderingClipboardNotification ()
 inits the notification telling the user, that a hint is stored to hint ordering clipboard More...
 
 checkForExistingHintRelatingToCurrentQuestionAndRedirectOnFailure ($hintId)
 checks for an existing hint relating to current question and redirects with corresponding failure message on failure More...
 
 getQuestionHintListWithoutHintStoredInOrderingClipboard (ilAssQuestionHintList $questionHintList)
 returns a new quastion hint list that contains all question hints from the passed list except for the hint that is stored to ordering clipboard More...
 
 checkForSingleHintIdAndRedirectOnFailure ($hintIds)
 checks for a hint id in the passed array and redirects with corresponding failure message if not exactly one id is given More...
 
 showHintCmd ()
 shows an allready requested hint More...
 

Static Private Member Functions

static fetchHintIdsParameter ()
 fetches either an array of hint ids from POST or a single hint id from GET and returns an array of (a single) hint id(s) casted to integer in both cases More...
 
static fetchHintIndexesParameter ()
 fetches an array of hint index values from POST More...
 
static orderHintIndexes ($hintIndexes)
 sorts the array of indexes by index value so keys (hint ids) get into new order submitted by user More...
 

Private Attributes

 $hintOrderingClipboard = null
 
ilLanguage $lng
 
ilCtrl $ctrl
 
ilGlobalTemplateInterface $main_tpl
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionHintsGUI::__construct ( assQuestionGUI  $questionGUI)

Constructor.

public

Parameters
assQuestionGUI$questionGUI

Definition at line 69 of file class.ilAssQuestionHintsGUI.php.

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

70  {
71  global $DIC;
72  $this->main_tpl = $DIC->ui()->mainTemplate();
73  $this->ctrl = $DIC->ctrl();
74  $this->lng = $DIC->language();
75  parent::__construct($questionGUI);
76 
77  $this->hintOrderingClipboard = new ilAssQuestionHintsOrderingClipboard($questionGUI->object);
78  }
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ checkForExistingHintRelatingToCurrentQuestionAndRedirectOnFailure()

ilAssQuestionHintsGUI::checkForExistingHintRelatingToCurrentQuestionAndRedirectOnFailure (   $hintId)
private

checks for an existing hint relating to current question and redirects with corresponding failure message on failure

private

Parameters
integer$hintId

Definition at line 556 of file class.ilAssQuestionHintsGUI.php.

References ILIAS\Repository\ctrl(), ilAssQuestionHintList\getListByQuestionId(), and ILIAS\Repository\lng().

Referenced by cutToOrderingClipboardCmd(), pasteFromOrderingClipboardAfterCmd(), and pasteFromOrderingClipboardBeforeCmd().

556  : void
557  {
558  $questionHintList = ilAssQuestionHintList::getListByQuestionId($this->questionOBJ->getId());
559 
560  if (!$questionHintList->hintExists($hintId)) {
561  $this->main_tpl->setOnScreenMessage('failure', $this->lng->txt('tst_question_hints_invalid_hint_id'), true);
562  $this->ctrl->redirect($this, self::CMD_SHOW_LIST);
563  }
564  }
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkForSingleHintIdAndRedirectOnFailure()

ilAssQuestionHintsGUI::checkForSingleHintIdAndRedirectOnFailure (   $hintIds)
private

checks for a hint id in the passed array and redirects with corresponding failure message if not exactly one id is given

private ilCtrl $ilCtrl ilLanguage $lng

Parameters
array$hintIds

Definition at line 598 of file class.ilAssQuestionHintsGUI.php.

References $DIC, and ilLanguage\txt().

Referenced by cutToOrderingClipboardCmd(), pasteFromOrderingClipboardAfterCmd(), and pasteFromOrderingClipboardBeforeCmd().

598  : void
599  {
600  global $DIC;
601  $ilCtrl = $DIC['ilCtrl'];
602  $lng = $DIC['lng'];
603 
604  if (!count($hintIds)) {
605  $this->main_tpl->setOnScreenMessage('failure', $lng->txt('tst_question_hints_cut_hints_missing_selection_msg'), true);
606  $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
607  } elseif (count($hintIds) > 1) {
608  $this->main_tpl->setOnScreenMessage('failure', $lng->txt('tst_question_hints_cut_hints_single_selection_msg'), true);
609  $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
610  }
611  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmDeleteCmd()

ilAssQuestionHintsGUI::confirmDeleteCmd ( )
private

shows a confirmation screen with selected hints for deletion

private ilCtrl $ilCtrl ilTemplate $tpl ilLanguage $lng

Definition at line 210 of file class.ilAssQuestionHintsGUI.php.

References $DIC, $tpl, ilAssQuestionHintList\getListByQuestionId(), and ilLanguage\txt().

210  : void
211  {
212  global $DIC;
213  $ilCtrl = $DIC['ilCtrl'];
214  $tpl = $DIC['tpl'];
215  $lng = $DIC['lng'];
216 
217  $hintIds = self::fetchHintIdsParameter();
218 
219  if (!count($hintIds)) {
220  $this->main_tpl->setOnScreenMessage('failure', $lng->txt('tst_question_hints_delete_hints_missing_selection_msg'), true);
221  $ilCtrl->redirect($this);
222  }
223 
224  $confirmation = new ilConfirmationGUI();
225 
226  $confirmation->setHeaderText($lng->txt('tst_question_hints_delete_hints_confirm_header'));
227  $confirmation->setFormAction($ilCtrl->getFormAction($this));
228  $confirmation->setConfirm($lng->txt('tst_question_hints_delete_hints_confirm_cmd'), self::CMD_PERFORM_DELETE);
229  $confirmation->setCancel($lng->txt('cancel'), self::CMD_SHOW_LIST);
230 
231  $questionHintList = ilAssQuestionHintList::getListByQuestionId($this->questionOBJ->getId());
232 
233  foreach ($questionHintList as $questionHint) {
234  /* @var $questionHint ilAssQuestionHint */
235 
236  if (in_array($questionHint->getId(), $hintIds)) {
237  $confirmation->addItem('hint_ids[]', $questionHint->getId(), sprintf(
238  $lng->txt('tst_question_hints_delete_hints_confirm_item'),
239  $questionHint->getIndex(),
240  $questionHint->getText()
241  ));
242  }
243  }
244 
245  $tpl->setContent($ilCtrl->getHtml($confirmation));
246  }
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
global $DIC
Definition: feed.php:28
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ confirmSyncCmd()

ilAssQuestionHintsGUI::confirmSyncCmd ( )

Definition at line 677 of file class.ilAssQuestionHintsGUI.php.

677  : void
678  {
679  $this->questionGUI->originalSyncForm('showHints');
680  }

◆ cutToOrderingClipboardCmd()

ilAssQuestionHintsGUI::cutToOrderingClipboardCmd ( )
private

cuts a hint from question hint list and stores it to ordering clipboard

private ilCtrl $ilCtrl

Definition at line 365 of file class.ilAssQuestionHintsGUI.php.

References $DIC, checkForExistingHintRelatingToCurrentQuestionAndRedirectOnFailure(), checkForSingleHintIdAndRedirectOnFailure(), and isEditingEnabled().

365  : void
366  {
367  if (!$this->isEditingEnabled()) {
368  return;
369  }
370 
371  global $DIC;
372  $ilCtrl = $DIC['ilCtrl'];
373 
374  $moveHintIds = self::fetchHintIdsParameter();
375  $this->checkForSingleHintIdAndRedirectOnFailure($moveHintIds);
376 
377  $moveHintId = current($moveHintIds);
378 
380 
381  $this->hintOrderingClipboard->setStored($moveHintId);
382 
383  $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
384  }
global $DIC
Definition: feed.php:28
checkForSingleHintIdAndRedirectOnFailure($hintIds)
checks for a hint id in the passed array and redirects with corresponding failure message if not exac...
checkForExistingHintRelatingToCurrentQuestionAndRedirectOnFailure($hintId)
checks for an existing hint relating to current question and redirects with corresponding failure mes...
+ Here is the call graph for this function:

◆ executeCommand()

ilAssQuestionHintsGUI::executeCommand ( )

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

References $DIC, ilObjStyleSheet\getContentStylePath(), isEditingEnabled(), ilAssQuestionHintPageObjectCommandForwarder\PRESENTATION_MODE_AUTHOR, ilAssQuestionHintPageObjectCommandForwarder\PRESENTATION_MODE_PREVIEW, and ILIAS\Repository\tabs().

96  : void
97  {
98  global $DIC;
99  $ilCtrl = $DIC['ilCtrl'];
100  $ilTabs = $DIC['ilTabs'];
101  $lng = $DIC['lng'];
102  global $DIC; /* @var \ILIAS\DI\Container $DIC */
103  $ilHelp = $DIC['ilHelp']; /* @var ilHelpGUI $ilHelp */
104  $ilHelp->setScreenIdComponent('qpl');
105 
106  require_once "./Services/Style/Content/classes/class.ilObjStyleSheet.php";
107  $DIC->ui()->mainTemplate()->setCurrentBlock("ContentStyle");
108  $DIC->ui()->mainTemplate()->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
109  $DIC->ui()->mainTemplate()->parseCurrentBlock();
110 
111  $cmd = $ilCtrl->getCmd(self::CMD_SHOW_LIST);
112  $nextClass = $ilCtrl->getNextClass($this);
113 
114  switch ($nextClass) {
115  case 'ilassquestionhintgui':
116 
117  if (!$this->isEditingEnabled()) {
118  return;
119  }
120 
121  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintGUI.php';
122  $gui = new ilAssQuestionHintGUI($this->questionGUI);
123  $ilCtrl->forwardCommand($gui);
124  break;
125 
126  case 'ilasshintpagegui':
127 
128  if ($this->isEditingEnabled()) {
130  } else {
132  }
133 
134  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintPageObjectCommandForwarder.php';
135  $forwarder = new ilAssQuestionHintPageObjectCommandForwarder($this->questionOBJ, $ilCtrl, $ilTabs, $lng);
136  $forwarder->setPresentationMode($presentationMode);
137  $forwarder->forward();
138  break;
139 
140  default:
141  $this->tabs->setTabActive('tst_question_hints_tab');
142  $cmd .= 'Cmd';
143  $this->$cmd();
144  break;
145  }
146  }
global $DIC
Definition: feed.php:28
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
+ Here is the call graph for this function:

◆ fetchHintIdsParameter()

static ilAssQuestionHintsGUI::fetchHintIdsParameter ( )
staticprivate

fetches either an array of hint ids from POST or a single hint id from GET and returns an array of (a single) hint id(s) casted to integer in both cases

private

Returns
array $hintIds

Definition at line 621 of file class.ilAssQuestionHintsGUI.php.

References $DIC, ilAssQuestionHintAbstractGUI\$request, and ILIAS\Repository\int().

621  : array
622  {
623  global $DIC;
624  $request = $DIC->testQuestionPool()->internal()->request();
625  $hintIds = array();
626 
627  if (isset($_POST['hint_ids']) && is_array($_POST['hint_ids'])) {
628  foreach ($_POST['hint_ids'] as $hintId) {
629  if ((int) $hintId) {
630  $hintIds[] = (int) $hintId;
631  }
632  }
633  } elseif ($request->isset('hint_id') && (int) $request->raw('hint_id')) {
634  $hintIds[] = (int) $request->raw('hint_id');
635  }
636 
637  return $hintIds;
638  }
ILIAS TestQuestionPool InternalRequestService $request
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

◆ fetchHintIndexesParameter()

static ilAssQuestionHintsGUI::fetchHintIndexesParameter ( )
staticprivate

fetches an array of hint index values from POST

private

Returns
array $hintIndexes

Definition at line 647 of file class.ilAssQuestionHintsGUI.php.

References ILIAS\Repository\int().

647  : array
648  {
649  $hintIndexes = array();
650 
651  if (isset($_POST['hint_indexes']) && is_array($_POST['hint_indexes'])) {
652  foreach ($_POST['hint_indexes'] as $hintId => $hintIndex) {
653  if ((int) $hintId) {
654  $hintIndexes[(int) $hintId] = $hintIndex;
655  }
656  }
657  }
658 
659  return $hintIndexes;
660  }
+ Here is the call graph for this function:

◆ getHintPresentationLinkTarget()

ilAssQuestionHintsGUI::getHintPresentationLinkTarget (   $hintId,
  $xmlStyle = true 
)

returns the link target for hint request presentation

Parameters
integer$hintId
boolean$xmlStyle
Returns
string $linkTarget

Definition at line 689 of file class.ilAssQuestionHintsGUI.php.

References $DIC.

689  : string
690  {
691  global $DIC;
692  $ilCtrl = $DIC['ilCtrl'];
693 
694  if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
695  $ilCtrl->setParameterByClass('ilasshintpagegui', 'hint_id', $hintId);
696  $linkTarget = $ilCtrl->getLinkTargetByClass('ilAssHintPageGUI', '', '', false, $xmlStyle);
697  } else {
698  $ilCtrl->setParameter($this, 'hintId', $hintId);
699  $linkTarget = $ilCtrl->getLinkTarget($this, self::CMD_SHOW_HINT, '', false, $xmlStyle);
700  }
701 
702  return $linkTarget;
703  }
global $DIC
Definition: feed.php:28

◆ getQuestionHintListWithoutHintStoredInOrderingClipboard()

ilAssQuestionHintsGUI::getQuestionHintListWithoutHintStoredInOrderingClipboard ( ilAssQuestionHintList  $questionHintList)
private

returns a new quastion hint list that contains all question hints from the passed list except for the hint that is stored to ordering clipboard

private

Parameters
ilAssQuestionHintList$questionHintList
Returns
ilAssQuestionHintList $filteredQuestionHintList

Definition at line 574 of file class.ilAssQuestionHintsGUI.php.

Referenced by showListCmd().

575  {
576  $filteredQuestionHintList = new ilAssQuestionHintList();
577 
578  foreach ($questionHintList as $questionHint) {
579  /* @var $questionHint ilAssQuestionHint */
580 
581  if ($questionHint->getId() != $this->hintOrderingClipboard->getStored()) {
582  $filteredQuestionHintList->addHint($questionHint);
583  }
584  }
585 
586  return $filteredQuestionHintList;
587  }
+ Here is the caller graph for this function:

◆ initHintOrderingClipboardNotification()

ilAssQuestionHintsGUI::initHintOrderingClipboardNotification ( )
private

inits the notification telling the user, that a hint is stored to hint ordering clipboard

private ilLanguage $lng

Definition at line 532 of file class.ilAssQuestionHintsGUI.php.

References $DIC, ilAssQuestionHint\getInstanceById(), and ilLanguage\txt().

Referenced by showListCmd().

532  : void
533  {
534  global $DIC;
535  $lng = $DIC['lng'];
536 
537  if (!$this->hintOrderingClipboard->hasStored()) {
538  return;
539  }
540 
541  $questionHint = ilAssQuestionHint::getInstanceById($this->hintOrderingClipboard->getStored());
542 
543  $this->main_tpl->setOnScreenMessage('info', sprintf(
544  $lng->txt('tst_question_hints_item_stored_in_ordering_clipboard'),
545  $questionHint->getIndex()
546  ));
547  }
static getInstanceById($hintId)
creates a hint object instance, loads the persisted hint dataset identified by passed hint id from da...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isEditingEnabled()

ilAssQuestionHintsGUI::isEditingEnabled ( )

◆ orderHintIndexes()

static ilAssQuestionHintsGUI::orderHintIndexes (   $hintIndexes)
staticprivate

sorts the array of indexes by index value so keys (hint ids) get into new order submitted by user

private

Returns
array $hintIndexes

Definition at line 670 of file class.ilAssQuestionHintsGUI.php.

670  : array
671  {
672  asort($hintIndexes);
673 
674  return $hintIndexes;
675  }

◆ pasteFromOrderingClipboardAfterCmd()

ilAssQuestionHintsGUI::pasteFromOrderingClipboardAfterCmd ( )
private

pastes a hint from ordering clipboard after the selected one

private ilCtrl $ilCtrl ilLanguage $lng

Definition at line 453 of file class.ilAssQuestionHintsGUI.php.

References $DIC, ilAssQuestionHintList\addHint(), checkForExistingHintRelatingToCurrentQuestionAndRedirectOnFailure(), checkForSingleHintIdAndRedirectOnFailure(), ilAssQuestionHint\getInstanceById(), ilAssQuestionHintList\getListByQuestionId(), isEditingEnabled(), and ilLanguage\txt().

453  : void
454  {
455  if (!$this->isEditingEnabled()) {
456  return;
457  }
458 
459  global $DIC;
460  $ilCtrl = $DIC['ilCtrl'];
461  $lng = $DIC['lng'];
462 
463  $targetHintIds = self::fetchHintIdsParameter();
464  $this->checkForSingleHintIdAndRedirectOnFailure($targetHintIds);
465 
466  $targetHintId = current($targetHintIds);
467 
469 
470  $curQuestionHintList = ilAssQuestionHintList::getListByQuestionId($this->questionOBJ->getId());
471  $newQuestionHintList = new ilAssQuestionHintList($this->questionOBJ->getId());
472 
473  foreach ($curQuestionHintList as $questionHint) {
474  /* @var $questionHint ilAssQuestionHint */
475 
476  if ($questionHint->getId() == $this->hintOrderingClipboard->getStored()) {
477  continue;
478  }
479 
480  $newQuestionHintList->addHint($questionHint);
481 
482  if ($questionHint->getId() == $targetHintId) {
483  $targetQuestionHint = $questionHint;
484 
485  $pasteQuestionHint = ilAssQuestionHint::getInstanceById($this->hintOrderingClipboard->getStored());
486 
487  $newQuestionHintList->addHint($pasteQuestionHint);
488  }
489  }
490 
491  $successMsg = sprintf(
492  $lng->txt('tst_question_hints_paste_after_success_msg'),
493  $pasteQuestionHint->getIndex(),
494  $targetQuestionHint->getIndex()
495  );
496 
497  $newQuestionHintList->reIndex();
498 
499  $this->hintOrderingClipboard->resetStored();
500 
501  $this->main_tpl->setOnScreenMessage('success', $successMsg, true);
502 
503  $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
504  }
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
static getInstanceById($hintId)
creates a hint object instance, loads the persisted hint dataset identified by passed hint id from da...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
global $DIC
Definition: feed.php:28
addHint(ilAssQuestionHint $questionHint)
adds a question hint object to the current list instance
checkForSingleHintIdAndRedirectOnFailure($hintIds)
checks for a hint id in the passed array and redirects with corresponding failure message if not exac...
checkForExistingHintRelatingToCurrentQuestionAndRedirectOnFailure($hintId)
checks for an existing hint relating to current question and redirects with corresponding failure mes...
+ Here is the call graph for this function:

◆ pasteFromOrderingClipboardBeforeCmd()

ilAssQuestionHintsGUI::pasteFromOrderingClipboardBeforeCmd ( )
private

pastes a hint from ordering clipboard before the selected one

private ilCtrl $ilCtrl ilLanguage $lng

Definition at line 393 of file class.ilAssQuestionHintsGUI.php.

References $DIC, checkForExistingHintRelatingToCurrentQuestionAndRedirectOnFailure(), checkForSingleHintIdAndRedirectOnFailure(), ilAssQuestionHint\getInstanceById(), ilAssQuestionHintList\getListByQuestionId(), isEditingEnabled(), and ilLanguage\txt().

393  : void
394  {
395  if (!$this->isEditingEnabled()) {
396  return;
397  }
398 
399  global $DIC;
400  $ilCtrl = $DIC['ilCtrl'];
401  $lng = $DIC['lng'];
402 
403  $targetHintIds = self::fetchHintIdsParameter();
404  $this->checkForSingleHintIdAndRedirectOnFailure($targetHintIds);
405 
406  $targetHintId = current($targetHintIds);
407 
409 
410  $curQuestionHintList = ilAssQuestionHintList::getListByQuestionId($this->questionOBJ->getId());
411  $newQuestionHintList = new ilAssQuestionHintList($this->questionOBJ->getId());
412 
413  foreach ($curQuestionHintList as $questionHint) {
414  /* @var $questionHint ilAssQuestionHint */
415 
416  if ($questionHint->getId() == $this->hintOrderingClipboard->getStored()) {
417  continue;
418  }
419 
420  if ($questionHint->getId() == $targetHintId) {
421  $targetQuestionHint = $questionHint;
422 
423  $pasteQuestionHint = ilAssQuestionHint::getInstanceById($this->hintOrderingClipboard->getStored());
424 
425  $newQuestionHintList->addHint($pasteQuestionHint);
426  }
427 
428  $newQuestionHintList->addHint($questionHint);
429  }
430 
431  $successMsg = sprintf(
432  $lng->txt('tst_question_hints_paste_before_success_msg'),
433  $pasteQuestionHint->getIndex(),
434  $targetQuestionHint->getIndex()
435  );
436 
437  $newQuestionHintList->reIndex();
438 
439  $this->hintOrderingClipboard->resetStored();
440 
441  $this->main_tpl->setOnScreenMessage('success', $successMsg, true);
442 
443  $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
444  }
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
static getInstanceById($hintId)
creates a hint object instance, loads the persisted hint dataset identified by passed hint id from da...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
global $DIC
Definition: feed.php:28
checkForSingleHintIdAndRedirectOnFailure($hintIds)
checks for a hint id in the passed array and redirects with corresponding failure message if not exac...
checkForExistingHintRelatingToCurrentQuestionAndRedirectOnFailure($hintId)
checks for an existing hint relating to current question and redirects with corresponding failure mes...
+ Here is the call graph for this function:

◆ performDeleteCmd()

ilAssQuestionHintsGUI::performDeleteCmd ( )
private

performs confirmed deletion for selected hints

private ilCtrl $ilCtrl ilLanguage $lng

Definition at line 255 of file class.ilAssQuestionHintsGUI.php.

References $DIC, $ilUser, $tpl, assQuestion\_isWriteable(), CMD_CONFIRM_SYNC, ilAssQuestionHintList\getListByQuestionId(), isEditingEnabled(), and ilLanguage\txt().

255  : void
256  {
257  if (!$this->isEditingEnabled()) {
258  return;
259  }
260 
261  global $DIC;
262  $ilCtrl = $DIC['ilCtrl'];
263  $tpl = $DIC['tpl'];
264  $lng = $DIC['lng'];
265 
266  $hintIds = self::fetchHintIdsParameter();
267 
268  if (!count($hintIds)) {
269  $this->main_tpl->setOnScreenMessage('failure', $lng->txt('tst_question_hints_delete_hints_missing_selection_msg'), true);
270  $ilCtrl->redirect($this);
271  }
272 
273  $questionCompleteHintList = ilAssQuestionHintList::getListByQuestionId($this->questionOBJ->getId());
274 
275  $questionRemainingHintList = new ilAssQuestionHintList();
276 
277  foreach ($questionCompleteHintList as $listKey => $questionHint) {
278  /* @var $questionHint ilAssQuestionHint */
279 
280  if (in_array($questionHint->getId(), $hintIds)) {
281  $questionHint->delete();
282  } else {
283  $questionRemainingHintList->addHint($questionHint);
284  }
285  }
286 
287  $questionRemainingHintList->reIndex();
288 
289  $this->main_tpl->setOnScreenMessage('success', $lng->txt('tst_question_hints_delete_success_msg'), true);
290 
291  $originalexists = $this->questionOBJ->_questionExistsInPool((int) $this->questionOBJ->getOriginalId());
292  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
293  global $DIC;
294  $ilUser = $DIC['ilUser'];
295  if ($this->request->raw("calling_test") && $originalexists && assQuestion::_isWriteable($this->questionOBJ->getOriginalId(), $ilUser->getId())) {
296  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_CONFIRM_SYNC);
297  }
298 
299  $ilCtrl->redirect($this);
300  }
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
static _isWriteable(int $question_id, int $user_id)
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
+ Here is the call graph for this function:

◆ resetOrderingClipboardCmd()

ilAssQuestionHintsGUI::resetOrderingClipboardCmd ( )
private

resets the ordering clipboard

private ilCtrl $ilCtrl ilLanguage $lng

Definition at line 513 of file class.ilAssQuestionHintsGUI.php.

References $DIC, and ilLanguage\txt().

513  : void
514  {
515  global $DIC;
516  $ilCtrl = $DIC['ilCtrl'];
517  $lng = $DIC['lng'];
518 
519  $this->hintOrderingClipboard->resetStored();
520 
521  $this->main_tpl->setOnScreenMessage('info', $lng->txt('tst_question_hints_ordering_clipboard_resetted'), true);
522  $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
523  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

◆ saveListOrderCmd()

ilAssQuestionHintsGUI::saveListOrderCmd ( )
private

saves the order based on index values passed from table's form (the table must not be paginated, because ALL hints index values are required)

private ilCtrl $ilCtrl ilLanguage $lng

Definition at line 310 of file class.ilAssQuestionHintsGUI.php.

References $DIC, $ilUser, assQuestion\_isWriteable(), CMD_CONFIRM_SYNC, ilAssQuestionHintList\getListByQuestionId(), isEditingEnabled(), and ilLanguage\txt().

310  : void
311  {
312  if (!$this->isEditingEnabled()) {
313  return;
314  }
315 
316  global $DIC;
317  $ilCtrl = $DIC['ilCtrl'];
318  $lng = $DIC['lng'];
319 
320  $hintIndexes = self::orderHintIndexes(
321  self::fetchHintIndexesParameter()
322  );
323 
324  if (!count($hintIndexes)) {
325  $this->main_tpl->setOnScreenMessage('failure', $lng->txt('tst_question_hints_save_order_unkown_failure_msg'), true);
326  $ilCtrl->redirect($this);
327  }
328 
329  $curQuestionHintList = ilAssQuestionHintList::getListByQuestionId($this->questionOBJ->getId());
330 
331  $newQuestionHintList = new ilAssQuestionHintList();
332 
333  foreach ($hintIndexes as $hintId => $hintIndex) {
334  if (!$curQuestionHintList->hintExists($hintId)) {
335  $this->main_tpl->setOnScreenMessage('failure', $lng->txt('tst_question_hints_save_order_unkown_failure_msg'), true);
336  $ilCtrl->redirect($this);
337  }
338 
339  $questionHint = $curQuestionHintList->getHint($hintId);
340 
341  $newQuestionHintList->addHint($questionHint);
342  }
343 
344  $newQuestionHintList->reIndex();
345 
346  $this->main_tpl->setOnScreenMessage('success', $lng->txt('tst_question_hints_save_order_success_msg'), true);
347 
348  $originalexists = $this->questionOBJ->_questionExistsInPool((int) $this->questionOBJ->getOriginalId());
349  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
350  global $DIC;
351  $ilUser = $DIC['ilUser'];
352  if ($this->request->raw("calling_test") && $originalexists && assQuestion::_isWriteable($this->questionOBJ->getOriginalId(), $ilUser->getId())) {
353  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_CONFIRM_SYNC);
354  }
355 
356  $ilCtrl->redirect($this);
357  }
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
static _isWriteable(int $question_id, int $user_id)
+ Here is the call graph for this function:

◆ setEditingEnabled()

ilAssQuestionHintsGUI::setEditingEnabled ( bool  $editingEnabled)
Parameters
bool$editingEnabled

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

References $editingEnabled.

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

◆ showHintCmd()

ilAssQuestionHintsGUI::showHintCmd ( )
private

shows an allready requested hint

private ilCtrl $ilCtrl ilTemplate $tpl ilLanguage $lng

Definition at line 713 of file class.ilAssQuestionHintsGUI.php.

References $DIC, $tpl, ilAssQuestionHint\getInstanceById(), ILIAS\Repository\int(), ilLegacyFormElementsUtil\prepareTextareaOutput(), ilNonEditableValueGUI\setValue(), and ilLanguage\txt().

713  : void
714  {
715  global $DIC;
716  $ilCtrl = $DIC['ilCtrl'];
717  $tpl = $DIC['tpl'];
718  $lng = $DIC['lng'];
719 
720  if (!$this->request->isset('hintId') || !(int) $this->request->raw('hintId')) {
721  throw new ilTestException('no hint id given');
722  }
723 
724  $DIC->tabs()->clearTargets();
725  $DIC->tabs()->clearSubTabs();
726 
727  $DIC->tabs()->setBackTarget(
728  $DIC->language()->txt('tst_question_hints_back_to_hint_list'),
729  $DIC->ctrl()->getLinkTarget($this, self::CMD_SHOW_LIST)
730  );
731 
732  $questionHint = ilAssQuestionHint::getInstanceById((int) $this->request->raw('hintId'));
733 
734  // build form
735 
736  $form = new ilPropertyFormGUI();
737 
738  $form->setFormAction($ilCtrl->getFormAction($this));
739 
740  $form->setTableWidth('100%');
741 
742  $form->setTitle(sprintf(
743  $lng->txt('tst_question_hints_form_header_edit'),
744  $questionHint->getIndex(),
745  $this->questionOBJ->getTitleForHTMLOutput()
746  ));
747 
748  // form input: hint text
749 
750  $nonEditableHintText = new ilNonEditableValueGUI($lng->txt('tst_question_hints_form_label_hint_text'), 'hint_text', true);
751  $nonEditableHintText->setValue(ilLegacyFormElementsUtil::prepareTextareaOutput($questionHint->getText(), true));
752  $form->addItem($nonEditableHintText);
753 
754  // form input: hint points
755 
756  $nonEditableHintPoints = new ilNonEditableValueGUI($lng->txt('tst_question_hints_form_label_hint_points'), 'hint_points');
757  $nonEditableHintPoints->setValue($questionHint->getPoints());
758  $form->addItem($nonEditableHintPoints);
759 
760  $tpl->setContent($form->getHTML());
761  }
static getInstanceById($hintId)
creates a hint object instance, loads the persisted hint dataset identified by passed hint id from da...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
+ Here is the call graph for this function:

◆ showListCmd()

ilAssQuestionHintsGUI::showListCmd ( )
private

shows a table with existing hints

private ilTemplate $tpl

Definition at line 154 of file class.ilAssQuestionHintsGUI.php.

References $DIC, $tpl, ilAssQuestionHintGUI\CMD_SHOW_FORM, ilAssQuestionHintList\getListByQuestionId(), getQuestionHintListWithoutHintStoredInOrderingClipboard(), initHintOrderingClipboardNotification(), isEditingEnabled(), ilAssQuestionHintsTableGUI\TBL_MODE_ADMINISTRATION, ilAssQuestionHintsTableGUI\TBL_MODE_TESTOUTPUT, and ilLanguage\txt().

154  : void
155  {
156  global $DIC;
157  $ilCtrl = $DIC['ilCtrl'];
158  $tpl = $DIC['tpl'];
159  $lng = $DIC['lng'];
160 
162 
163  require_once 'Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
164  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintsTableGUI.php';
165 
166  $toolbar = new ilToolbarGUI();
167 
168  $questionHintList = ilAssQuestionHintList::getListByQuestionId($this->questionOBJ->getId());
169 
170  if ($this->isEditingEnabled()) {
171  if ($this->hintOrderingClipboard->hasStored()) {
172  $questionHintList = $this->getQuestionHintListWithoutHintStoredInOrderingClipboard($questionHintList);
173 
174  $toolbar->addButton(
175  $lng->txt('tst_questions_hints_toolbar_cmd_reset_ordering_clipboard'),
176  $ilCtrl->getLinkTarget($this, self::CMD_RESET_ORDERING_CLIPBOARD)
177  );
178  } else {
179  $toolbar->addButton(
180  $lng->txt('tst_questions_hints_toolbar_cmd_add_hint'),
181  $ilCtrl->getLinkTargetByClass('ilAssQuestionHintGUI', ilAssQuestionHintGUI::CMD_SHOW_FORM)
182  );
183  }
184 
186  } else {
188  }
189 
190  $table = new ilAssQuestionHintsTableGUI(
191  $this->questionOBJ,
192  $questionHintList,
193  $this,
194  self::CMD_SHOW_LIST,
195  $tableMode,
196  $this->hintOrderingClipboard
197  );
198 
199  $tpl->setContent($ilCtrl->getHtml($toolbar) . $ilCtrl->getHtml($table));
200  }
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
getQuestionHintListWithoutHintStoredInOrderingClipboard(ilAssQuestionHintList $questionHintList)
returns a new quastion hint list that contains all question hints from the passed list except for the...
global $DIC
Definition: feed.php:28
const TBL_MODE_TESTOUTPUT
the available table modes controlling the tables behaviour
const CMD_SHOW_FORM
command constants
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
initHintOrderingClipboardNotification()
inits the notification telling the user, that a hint is stored to hint ordering clipboard ...
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilAssQuestionHintsGUI::$ctrl
private

Definition at line 55 of file class.ilAssQuestionHintsGUI.php.

◆ $editingEnabled

ilAssQuestionHintsGUI::$editingEnabled = false
protected

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

Referenced by isEditingEnabled(), and setEditingEnabled().

◆ $hintOrderingClipboard

ilAssQuestionHintsGUI::$hintOrderingClipboard = null
private

Definition at line 53 of file class.ilAssQuestionHintsGUI.php.

◆ $lng

ilLanguage ilAssQuestionHintsGUI::$lng
private

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

◆ $main_tpl

ilGlobalTemplateInterface ilAssQuestionHintsGUI::$main_tpl
private

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

◆ CMD_CONFIRM_DELETE

const ilAssQuestionHintsGUI::CMD_CONFIRM_DELETE = 'confirmDelete'

◆ CMD_CONFIRM_SYNC

const ilAssQuestionHintsGUI::CMD_CONFIRM_SYNC = 'confirmSync'

◆ CMD_CUT_TO_ORDERING_CLIPBOARD

const ilAssQuestionHintsGUI::CMD_CUT_TO_ORDERING_CLIPBOARD = 'cutToOrderingClipboard'

◆ CMD_PASTE_FROM_ORDERING_CLIPBOARD_AFTER

const ilAssQuestionHintsGUI::CMD_PASTE_FROM_ORDERING_CLIPBOARD_AFTER = 'pasteFromOrderingClipboardAfter'

◆ CMD_PASTE_FROM_ORDERING_CLIPBOARD_BEFORE

const ilAssQuestionHintsGUI::CMD_PASTE_FROM_ORDERING_CLIPBOARD_BEFORE = 'pasteFromOrderingClipboardBefore'

◆ CMD_PERFORM_DELETE

const ilAssQuestionHintsGUI::CMD_PERFORM_DELETE = 'performDelete'

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

◆ CMD_RESET_ORDERING_CLIPBOARD

const ilAssQuestionHintsGUI::CMD_RESET_ORDERING_CLIPBOARD = 'resetOrderingClipboard'

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

◆ CMD_SAVE_LIST_ORDER

const ilAssQuestionHintsGUI::CMD_SAVE_LIST_ORDER = 'saveListOrder'

◆ CMD_SHOW_HINT

const ilAssQuestionHintsGUI::CMD_SHOW_HINT = 'showHint'

Definition at line 43 of file class.ilAssQuestionHintsGUI.php.

◆ CMD_SHOW_LIST


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