ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilAssQuestionHintsGUI Class Reference
+ Inheritance diagram for ilAssQuestionHintsGUI:
+ Collaboration diagram for ilAssQuestionHintsGUI:

Public Member Functions

 __construct (assQuestionGUI $questionGUI)
 Constructor. More...
 
 isEditingEnabled ()
 
 setEditingEnabled (bool $editingEnabled)
 
 executeCommand ()
 Execute Command. More...
 
 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
 $questionGUI = null
 
 $questionOBJ = null
 

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
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilAssQuestionHintsGUI::__construct ( assQuestionGUI  $questionGUI)

Constructor.

public

Parameters
assQuestionGUI$questionGUI

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

58  {
59  parent::__construct($questionGUI);
60 
61  $this->hintOrderingClipboard = new ilAssQuestionHintsOrderingClipboard($questionGUI->object);
62  }

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 524 of file class.ilAssQuestionHintsGUI.php.

References $ilCtrl, $lng, ilAssQuestionHintList\getListByQuestionId(), and ilUtil\sendFailure().

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

525  {
526  $questionHintList = ilAssQuestionHintList::getListByQuestionId($this->questionOBJ->getId());
527 
528  if (!$questionHintList->hintExists($hintId)) {
529  ilUtil::sendFailure($lng->txt('tst_question_hints_invalid_hint_id'), true);
530  $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
531  }
532  }
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
global $ilCtrl
Definition: ilias.php:18
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:17
+ 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 566 of file class.ilAssQuestionHintsGUI.php.

References $ilCtrl, $lng, and ilUtil\sendFailure().

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

567  {
568  global $ilCtrl, $lng;
569 
570  if (!count($hintIds)) {
571  ilUtil::sendFailure($lng->txt('tst_question_hints_cut_hints_missing_selection_msg'), true);
572  $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
573  } elseif (count($hintIds) > 1) {
574  ilUtil::sendFailure($lng->txt('tst_question_hints_cut_hints_single_selection_msg'), true);
575  $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
576  }
577  }
global $ilCtrl
Definition: ilias.php:18
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:17
+ 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 195 of file class.ilAssQuestionHintsGUI.php.

References $ilCtrl, $lng, $tpl, ilAssQuestionHintList\getListByQuestionId(), and ilUtil\sendFailure().

196  {
197  global $ilCtrl, $tpl, $lng;
198 
199  $hintIds = self::fetchHintIdsParameter();
200 
201  if (!count($hintIds)) {
202  ilUtil::sendFailure($lng->txt('tst_question_hints_delete_hints_missing_selection_msg'), true);
203  $ilCtrl->redirect($this);
204  }
205 
206  require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
207  $confirmation = new ilConfirmationGUI();
208 
209  $confirmation->setHeaderText($lng->txt('tst_question_hints_delete_hints_confirm_header'));
210  $confirmation->setFormAction($ilCtrl->getFormAction($this));
211  $confirmation->setConfirm($lng->txt('tst_question_hints_delete_hints_confirm_cmd'), self::CMD_PERFORM_DELETE);
212  $confirmation->setCancel($lng->txt('cancel'), self::CMD_SHOW_LIST);
213 
214  $questionHintList = ilAssQuestionHintList::getListByQuestionId($this->questionOBJ->getId());
215 
216  foreach ($questionHintList as $questionHint) {
217  /* @var $questionHint ilAssQuestionHint */
218 
219  if (in_array($questionHint->getId(), $hintIds)) {
220  $confirmation->addItem('hint_ids[]', $questionHint->getId(), sprintf(
221  $lng->txt('tst_question_hints_delete_hints_confirm_item'),
222  $questionHint->getIndex(),
223  $questionHint->getText()
224  ));
225  }
226  }
227 
228  $tpl->setContent($ilCtrl->getHtml($confirmation));
229  }
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
$tpl
Definition: ilias.php:10
global $ilCtrl
Definition: ilias.php:18
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:17
Confirmation screen class.
+ Here is the call graph for this function:

◆ confirmSyncCmd()

ilAssQuestionHintsGUI::confirmSyncCmd ( )

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

642  {
643  $this->questionGUI->originalSyncForm('showHints');
644  }

◆ cutToOrderingClipboardCmd()

ilAssQuestionHintsGUI::cutToOrderingClipboardCmd ( )
private

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

private ilCtrl $ilCtrl

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

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

342  {
343  if (!$this->isEditingEnabled()) {
344  return;
345  }
346 
347  global $ilCtrl;
348 
349  $moveHintIds = self::fetchHintIdsParameter();
350  $this->checkForSingleHintIdAndRedirectOnFailure($moveHintIds);
351 
352  $moveHintId = current($moveHintIds);
353 
355 
356  $this->hintOrderingClipboard->setStored($moveHintId);
357 
358  $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
359  }
global $ilCtrl
Definition: ilias.php:18
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 ( )

Execute Command.

public ilCtrl $ilCtrl

Returns
mixed

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

References $DIC, $ilCtrl, $lng, $tpl, ilObjStyleSheet\getContentStylePath(), isEditingEnabled(), ilAssQuestionHintPageObjectCommandForwarder\PRESENTATION_MODE_AUTHOR, and ilAssQuestionHintPageObjectCommandForwarder\PRESENTATION_MODE_PREVIEW.

88  {
89  global $ilCtrl, $ilTabs, $lng, $tpl;
90  global $DIC; /* @var \ILIAS\DI\Container $DIC */
91  $ilHelp = $DIC['ilHelp']; /* @var ilHelpGUI $ilHelp */
92  $ilHelp->setScreenIdComponent('qpl');
93 
94  require_once "./Services/Style/Content/classes/class.ilObjStyleSheet.php";
95  $tpl->setCurrentBlock("ContentStyle");
96  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
97  $tpl->parseCurrentBlock();
98 
99  $cmd = $ilCtrl->getCmd(self::CMD_SHOW_LIST);
100  $nextClass = $ilCtrl->getNextClass($this);
101 
102  switch ($nextClass) {
103  case 'ilassquestionhintgui':
104 
105  if (!$this->isEditingEnabled()) {
106  return;
107  }
108 
109  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintGUI.php';
110  $gui = new ilAssQuestionHintGUI($this->questionGUI);
111  $ilCtrl->forwardCommand($gui);
112  break;
113 
114  case 'ilasshintpagegui':
115 
116  if ($this->isEditingEnabled()) {
118  } else {
120  }
121 
122  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintPageObjectCommandForwarder.php';
123  $forwarder = new ilAssQuestionHintPageObjectCommandForwarder($this->questionOBJ, $ilCtrl, $ilTabs, $lng);
124  $forwarder->setPresentationMode($presentationMode);
125  $forwarder->forward();
126  break;
127 
128  default:
129 
130  $cmd .= 'Cmd';
131  $this->$cmd();
132  break;
133  }
134  }
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
global $ilCtrl
Definition: ilias.php:18
static getContentStylePath($a_style_id, $add_random=true)
get content style path
global $lng
Definition: privfeed.php:17
+ 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 587 of file class.ilAssQuestionHintsGUI.php.

References $_GET, $_POST, and array.

588  {
589  $hintIds = array();
590 
591  if (isset($_POST['hint_ids']) && is_array($_POST['hint_ids'])) {
592  foreach ($_POST['hint_ids'] as $hintId) {
593  if ((int) $hintId) {
594  $hintIds[] = (int) $hintId;
595  }
596  }
597  } elseif (isset($_GET['hint_id']) && (int) $_GET['hint_id']) {
598  $hintIds[] = (int) $_GET['hint_id'];
599  }
600 
601  return $hintIds;
602  }
$_GET["client_id"]
Create styles array
The data for the language used.
$_POST["username"]

◆ fetchHintIndexesParameter()

static ilAssQuestionHintsGUI::fetchHintIndexesParameter ( )
staticprivate

fetches an array of hint index values from POST

private

Returns
array $hintIndexes

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

References $_POST, and array.

612  {
613  $hintIndexes = array();
614 
615  if (isset($_POST['hint_indexes']) && is_array($_POST['hint_indexes'])) {
616  foreach ($_POST['hint_indexes'] as $hintId => $hintIndex) {
617  if ((int) $hintId) {
618  $hintIndexes[(int) $hintId] = $hintIndex;
619  }
620  }
621  }
622 
623  return $hintIndexes;
624  }
Create styles array
The data for the language used.
$_POST["username"]

◆ 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 653 of file class.ilAssQuestionHintsGUI.php.

References $DIC, and $ilCtrl.

654  {
655  global $DIC;
656  $ilCtrl = $DIC['ilCtrl'];
657 
658  if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
659  $ilCtrl->setParameterByClass('ilasshintpagegui', 'hint_id', $hintId);
660  $linkTarget = $ilCtrl->getLinkTargetByClass('ilAssHintPageGUI', '', '', false, $xmlStyle);
661  } else {
662  $ilCtrl->setParameter($this, 'hintId', $hintId);
663  $linkTarget = $ilCtrl->getLinkTarget($this, self::CMD_SHOW_HINT, '', false, $xmlStyle);
664  }
665 
666  return $linkTarget;
667  }
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18

◆ 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 542 of file class.ilAssQuestionHintsGUI.php.

Referenced by showListCmd().

543  {
544  $filteredQuestionHintList = new ilAssQuestionHintList();
545 
546  foreach ($questionHintList as $questionHint) {
547  /* @var $questionHint ilAssQuestionHint */
548 
549  if ($questionHint->getId() != $this->hintOrderingClipboard->getStored()) {
550  $filteredQuestionHintList->addHint($questionHint);
551  }
552  }
553 
554  return $filteredQuestionHintList;
555  }
+ 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 501 of file class.ilAssQuestionHintsGUI.php.

References $lng, ilAssQuestionHint\getInstanceById(), and ilUtil\sendInfo().

Referenced by showListCmd().

502  {
503  global $lng;
504 
505  if (!$this->hintOrderingClipboard->hasStored()) {
506  return;
507  }
508 
509  $questionHint = ilAssQuestionHint::getInstanceById($this->hintOrderingClipboard->getStored());
510 
511  ilUtil::sendInfo(sprintf(
512  $lng->txt('tst_question_hints_item_stored_in_ordering_clipboard'),
513  $questionHint->getIndex()
514  ));
515  }
static getInstanceById($hintId)
creates a hint object instance, loads the persisted hint dataset identified by passed hint id from da...
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $lng
Definition: privfeed.php:17
+ 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 634 of file class.ilAssQuestionHintsGUI.php.

635  {
636  asort($hintIndexes);
637 
638  return $hintIndexes;
639  }

◆ pasteFromOrderingClipboardAfterCmd()

ilAssQuestionHintsGUI::pasteFromOrderingClipboardAfterCmd ( )
private

pastes a hint from ordering clipboard after the selected one

private ilCtrl $ilCtrl ilLanguage $lng

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

References $ilCtrl, $lng, ilAssQuestionHintList\addHint(), checkForExistingHintRelatingToCurrentQuestionAndRedirectOnFailure(), checkForSingleHintIdAndRedirectOnFailure(), ilAssQuestionHint\getInstanceById(), ilAssQuestionHintList\getListByQuestionId(), isEditingEnabled(), and ilUtil\sendSuccess().

427  {
428  if (!$this->isEditingEnabled()) {
429  return;
430  }
431 
432  global $ilCtrl, $lng;
433 
434  $targetHintIds = self::fetchHintIdsParameter();
435  $this->checkForSingleHintIdAndRedirectOnFailure($targetHintIds);
436 
437  $targetHintId = current($targetHintIds);
438 
440 
441  $curQuestionHintList = ilAssQuestionHintList::getListByQuestionId($this->questionOBJ->getId());
442  $newQuestionHintList = new ilAssQuestionHintList($this->questionOBJ->getId());
443 
444  foreach ($curQuestionHintList as $questionHint) {
445  /* @var $questionHint ilAssQuestionHint */
446 
447  if ($questionHint->getId() == $this->hintOrderingClipboard->getStored()) {
448  continue;
449  }
450 
451  $newQuestionHintList->addHint($questionHint);
452 
453  if ($questionHint->getId() == $targetHintId) {
454  $targetQuestionHint = $questionHint;
455 
456  $pasteQuestionHint = ilAssQuestionHint::getInstanceById($this->hintOrderingClipboard->getStored());
457 
458  $newQuestionHintList->addHint($pasteQuestionHint);
459  }
460  }
461 
462  $successMsg = sprintf(
463  $lng->txt('tst_question_hints_paste_after_success_msg'),
464  $pasteQuestionHint->getIndex(),
465  $targetQuestionHint->getIndex()
466  );
467 
468  $newQuestionHintList->reIndex();
469 
470  $this->hintOrderingClipboard->resetStored();
471 
472  ilUtil::sendSuccess($successMsg, true);
473 
474  $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
475  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
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...
global $ilCtrl
Definition: ilias.php:18
addHint(ilAssQuestionHint $questionHint)
adds a question hint object to the current list instance
global $lng
Definition: privfeed.php:17
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 368 of file class.ilAssQuestionHintsGUI.php.

References $ilCtrl, $lng, checkForExistingHintRelatingToCurrentQuestionAndRedirectOnFailure(), checkForSingleHintIdAndRedirectOnFailure(), ilAssQuestionHint\getInstanceById(), ilAssQuestionHintList\getListByQuestionId(), isEditingEnabled(), and ilUtil\sendSuccess().

369  {
370  if (!$this->isEditingEnabled()) {
371  return;
372  }
373 
374  global $ilCtrl, $lng;
375 
376  $targetHintIds = self::fetchHintIdsParameter();
377  $this->checkForSingleHintIdAndRedirectOnFailure($targetHintIds);
378 
379  $targetHintId = current($targetHintIds);
380 
382 
383  $curQuestionHintList = ilAssQuestionHintList::getListByQuestionId($this->questionOBJ->getId());
384  $newQuestionHintList = new ilAssQuestionHintList($this->questionOBJ->getId());
385 
386  foreach ($curQuestionHintList as $questionHint) {
387  /* @var $questionHint ilAssQuestionHint */
388 
389  if ($questionHint->getId() == $this->hintOrderingClipboard->getStored()) {
390  continue;
391  }
392 
393  if ($questionHint->getId() == $targetHintId) {
394  $targetQuestionHint = $questionHint;
395 
396  $pasteQuestionHint = ilAssQuestionHint::getInstanceById($this->hintOrderingClipboard->getStored());
397 
398  $newQuestionHintList->addHint($pasteQuestionHint);
399  }
400 
401  $newQuestionHintList->addHint($questionHint);
402  }
403 
404  $successMsg = sprintf(
405  $lng->txt('tst_question_hints_paste_before_success_msg'),
406  $pasteQuestionHint->getIndex(),
407  $targetQuestionHint->getIndex()
408  );
409 
410  $newQuestionHintList->reIndex();
411 
412  $this->hintOrderingClipboard->resetStored();
413 
414  ilUtil::sendSuccess($successMsg, true);
415 
416  $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
417  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
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...
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
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 238 of file class.ilAssQuestionHintsGUI.php.

References $_GET, $ilCtrl, $ilUser, $lng, $tpl, assQuestion\_isWriteable(), CMD_CONFIRM_SYNC, ilAssQuestionHintList\getListByQuestionId(), isEditingEnabled(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

239  {
240  if (!$this->isEditingEnabled()) {
241  return;
242  }
243 
244  global $ilCtrl, $tpl, $lng;
245 
246  $hintIds = self::fetchHintIdsParameter();
247 
248  if (!count($hintIds)) {
249  ilUtil::sendFailure($lng->txt('tst_question_hints_delete_hints_missing_selection_msg'), true);
250  $ilCtrl->redirect($this);
251  }
252 
253  $questionCompleteHintList = ilAssQuestionHintList::getListByQuestionId($this->questionOBJ->getId());
254 
255  $questionRemainingHintList = new ilAssQuestionHintList();
256 
257  foreach ($questionCompleteHintList as $listKey => $questionHint) {
258  /* @var $questionHint ilAssQuestionHint */
259 
260  if (in_array($questionHint->getId(), $hintIds)) {
261  $questionHint->delete();
262  } else {
263  $questionRemainingHintList->addHint($questionHint);
264  }
265  }
266 
267  $questionRemainingHintList->reIndex();
268 
269  ilUtil::sendSuccess($lng->txt('tst_question_hints_delete_success_msg'), true);
270 
271  $originalexists = $this->questionOBJ->_questionExistsInPool($this->questionOBJ->original_id);
272  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
273  global $ilUser;
274  if ($_GET["calling_test"] && $originalexists && assQuestion::_isWriteable($this->questionOBJ->original_id, $ilUser->getId())) {
275  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_CONFIRM_SYNC);
276  }
277 
278  $ilCtrl->redirect($this);
279  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
$_GET["client_id"]
$tpl
Definition: ilias.php:10
global $ilCtrl
Definition: ilias.php:18
$ilUser
Definition: imgupload.php:18
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:17
static _isWriteable($question_id, $user_id)
Returns true if the question is writeable by a certain user.
+ Here is the call graph for this function:

◆ resetOrderingClipboardCmd()

ilAssQuestionHintsGUI::resetOrderingClipboardCmd ( )
private

resets the ordering clipboard

private ilCtrl $ilCtrl ilLanguage $lng

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

References $ilCtrl, $lng, and ilUtil\sendInfo().

485  {
486  global $ilCtrl, $lng;
487 
488  $this->hintOrderingClipboard->resetStored();
489 
490  ilUtil::sendInfo($lng->txt('tst_question_hints_ordering_clipboard_resetted'), true);
491  $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
492  }
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $lng
Definition: privfeed.php:17
+ 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 289 of file class.ilAssQuestionHintsGUI.php.

References $_GET, $ilCtrl, $ilUser, $lng, assQuestion\_isWriteable(), CMD_CONFIRM_SYNC, ilAssQuestionHintList\getListByQuestionId(), isEditingEnabled(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

290  {
291  if (!$this->isEditingEnabled()) {
292  return;
293  }
294 
295  global $ilCtrl, $lng;
296 
297  $hintIndexes = self::orderHintIndexes(
298  self::fetchHintIndexesParameter()
299  );
300 
301  if (!count($hintIndexes)) {
302  ilUtil::sendFailure($lng->txt('tst_question_hints_save_order_unkown_failure_msg'), true);
303  $ilCtrl->redirect($this);
304  }
305 
306  $curQuestionHintList = ilAssQuestionHintList::getListByQuestionId($this->questionOBJ->getId());
307 
308  $newQuestionHintList = new ilAssQuestionHintList();
309 
310  foreach ($hintIndexes as $hintId => $hintIndex) {
311  if (!$curQuestionHintList->hintExists($hintId)) {
312  ilUtil::sendFailure($lng->txt('tst_question_hints_save_order_unkown_failure_msg'), true);
313  $ilCtrl->redirect($this);
314  }
315 
316  $questionHint = $curQuestionHintList->getHint($hintId);
317 
318  $newQuestionHintList->addHint($questionHint);
319  }
320 
321  $newQuestionHintList->reIndex();
322 
323  ilUtil::sendSuccess($lng->txt('tst_question_hints_save_order_success_msg'), true);
324 
325  $originalexists = $this->questionOBJ->_questionExistsInPool($this->questionOBJ->original_id);
326  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
327  global $ilUser;
328  if ($_GET["calling_test"] && $originalexists && assQuestion::_isWriteable($this->questionOBJ->original_id, $ilUser->getId())) {
329  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_CONFIRM_SYNC);
330  }
331 
332  $ilCtrl->redirect($this);
333  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
$_GET["client_id"]
global $ilCtrl
Definition: ilias.php:18
$ilUser
Definition: imgupload.php:18
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $lng
Definition: privfeed.php:17
static _isWriteable($question_id, $user_id)
Returns true if the question is writeable by a certain user.
+ Here is the call graph for this function:

◆ setEditingEnabled()

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

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

References $editingEnabled.

76  {
77  $this->editingEnabled = $editingEnabled;
78  }

◆ showHintCmd()

ilAssQuestionHintsGUI::showHintCmd ( )
private

shows an allready requested hint

private ilCtrl $ilCtrl ilTemplate $tpl ilLanguage $lng

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

References $_GET, $DIC, $form, $ilCtrl, $lng, $tpl, ilAssQuestionHint\getInstanceById(), ilUtil\prepareTextareaOutput(), and ilNonEditableValueGUI\setValue().

678  {
679  global $DIC;
680  $ilCtrl = $DIC['ilCtrl'];
681  $tpl = $DIC['tpl'];
682  $lng = $DIC['lng'];
683 
684  if (!isset($_GET['hintId']) || !(int) $_GET['hintId']) {
685  throw new ilTestException('no hint id given');
686  }
687 
688  $DIC->tabs()->clearTargets();
689  $DIC->tabs()->clearSubTabs();
690 
691  $DIC->tabs()->setBackTarget(
692  $DIC->language()->txt('tst_question_hints_back_to_hint_list'),
693  $DIC->ctrl()->getLinkTarget($this, self::CMD_SHOW_LIST)
694  );
695 
696  $questionHint = ilAssQuestionHint::getInstanceById((int) $_GET['hintId']);
697 
698  // build form
699 
700  $form = new ilPropertyFormGUI();
701 
702  $form->setFormAction($ilCtrl->getFormAction($this));
703 
704  $form->setTableWidth('100%');
705 
706  $form->setTitle(sprintf(
707  $lng->txt('tst_question_hints_form_header_edit'),
708  $questionHint->getIndex(),
709  $this->questionOBJ->getTitle()
710  ));
711 
712  // form input: hint text
713 
714  $nonEditableHintText = new ilNonEditableValueGUI($lng->txt('tst_question_hints_form_label_hint_text'), 'hint_text', true);
715  $nonEditableHintText->setValue(ilUtil::prepareTextareaOutput($questionHint->getText(), true));
716  $form->addItem($nonEditableHintText);
717 
718  // form input: hint points
719 
720  $nonEditableHintPoints = new ilNonEditableValueGUI($lng->txt('tst_question_hints_form_label_hint_points'), 'hint_points');
721  $nonEditableHintPoints->setValue($questionHint->getPoints());
722  $form->addItem($nonEditableHintPoints);
723 
724  $tpl->setContent($form->getHTML());
725  }
static getInstanceById($hintId)
creates a hint object instance, loads the persisted hint dataset identified by passed hint id from da...
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
$tpl
Definition: ilias.php:10
static prepareTextareaOutput($txt_output, $prepare_for_latex_output=false, $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free...
Base Exception for all Exceptions relating to Modules/Test.
global $ilCtrl
Definition: ilias.php:18
if(isset($_POST['submit'])) $form
This class represents a non editable value in a property form.
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ showListCmd()

ilAssQuestionHintsGUI::showListCmd ( )
private

shows a table with existing hints

private ilTemplate $tpl

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

References $ilCtrl, $lng, $table, $tpl, ilAssQuestionHintGUI\CMD_SHOW_FORM, ilAssQuestionHintList\getListByQuestionId(), getQuestionHintListWithoutHintStoredInOrderingClipboard(), initHintOrderingClipboardNotification(), isEditingEnabled(), ilAssQuestionHintsTableGUI\TBL_MODE_ADMINISTRATION, and ilAssQuestionHintsTableGUI\TBL_MODE_TESTOUTPUT.

143  {
144  global $ilCtrl, $tpl, $lng;
145 
147 
148  require_once 'Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
149  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintsTableGUI.php';
150 
151  $toolbar = new ilToolbarGUI();
152 
153  $questionHintList = ilAssQuestionHintList::getListByQuestionId($this->questionOBJ->getId());
154 
155  if ($this->isEditingEnabled()) {
156  if ($this->hintOrderingClipboard->hasStored()) {
157  $questionHintList = $this->getQuestionHintListWithoutHintStoredInOrderingClipboard($questionHintList);
158 
159  $toolbar->addButton(
160  $lng->txt('tst_questions_hints_toolbar_cmd_reset_ordering_clipboard'),
161  $ilCtrl->getLinkTarget($this, self::CMD_RESET_ORDERING_CLIPBOARD)
162  );
163  } else {
164  $toolbar->addButton(
165  $lng->txt('tst_questions_hints_toolbar_cmd_add_hint'),
166  $ilCtrl->getLinkTargetByClass('ilAssQuestionHintGUI', ilAssQuestionHintGUI::CMD_SHOW_FORM)
167  );
168  }
169 
171  } else {
173  }
174 
176  $this->questionOBJ,
177  $questionHintList,
178  $this,
179  self::CMD_SHOW_LIST,
180  $tableMode,
181  $this->hintOrderingClipboard
182  );
183 
184  $tpl->setContent($ilCtrl->getHtml($toolbar) . $ilCtrl->getHtml($table));
185  }
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
$tpl
Definition: ilias.php:10
getQuestionHintListWithoutHintStoredInOrderingClipboard(ilAssQuestionHintList $questionHintList)
returns a new quastion hint list that contains all question hints from the passed list except for the...
global $ilCtrl
Definition: ilias.php:18
const TBL_MODE_TESTOUTPUT
the available table modes controlling the tables behaviour
const CMD_SHOW_FORM
command constants
global $lng
Definition: privfeed.php:17
if(empty($password)) $table
Definition: pwgen.php:24
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

◆ $editingEnabled

ilAssQuestionHintsGUI::$editingEnabled = false
protected

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

Referenced by isEditingEnabled(), and setEditingEnabled().

◆ $hintOrderingClipboard

ilAssQuestionHintsGUI::$hintOrderingClipboard = null
private

Definition at line 44 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 30 of file class.ilAssQuestionHintsGUI.php.

◆ CMD_RESET_ORDERING_CLIPBOARD

const ilAssQuestionHintsGUI::CMD_RESET_ORDERING_CLIPBOARD = 'resetOrderingClipboard'

Definition at line 35 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 28 of file class.ilAssQuestionHintsGUI.php.

◆ CMD_SHOW_LIST


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