ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 551 of file class.ilAssQuestionHintsGUI.php.

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

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

552  {
553  $questionHintList = ilAssQuestionHintList::getListByQuestionId( $this->questionOBJ->getId() );
554 
555  if( !$questionHintList->hintExists($hintId) )
556  {
557  ilUtil::sendFailure($lng->txt('tst_question_hints_invalid_hint_id'), true);
558  $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
559  }
560  }
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 596 of file class.ilAssQuestionHintsGUI.php.

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

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

597  {
598  global $ilCtrl, $lng;
599 
600  if( !count($hintIds) )
601  {
602  ilUtil::sendFailure($lng->txt('tst_question_hints_cut_hints_missing_selection_msg'), true);
603  $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
604  }
605  elseif( count($hintIds) > 1 )
606  {
607  ilUtil::sendFailure($lng->txt('tst_question_hints_cut_hints_single_selection_msg'), true);
608  $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
609  }
610  }
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 202 of file class.ilAssQuestionHintsGUI.php.

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

203  {
204  global $ilCtrl, $tpl, $lng;
205 
206  $hintIds = self::fetchHintIdsParameter();
207 
208  if( !count($hintIds) )
209  {
210  ilUtil::sendFailure($lng->txt('tst_question_hints_delete_hints_missing_selection_msg'), true);
211  $ilCtrl->redirect($this);
212  }
213 
214  require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
215  $confirmation = new ilConfirmationGUI();
216 
217  $confirmation->setHeaderText($lng->txt('tst_question_hints_delete_hints_confirm_header'));
218  $confirmation->setFormAction($ilCtrl->getFormAction($this));
219  $confirmation->setConfirm($lng->txt('tst_question_hints_delete_hints_confirm_cmd'), self::CMD_PERFORM_DELETE);
220  $confirmation->setCancel($lng->txt('cancel'), self::CMD_SHOW_LIST);
221 
222  $questionHintList = ilAssQuestionHintList::getListByQuestionId($this->questionOBJ->getId());
223 
224  foreach($questionHintList as $questionHint)
225  {
226  /* @var $questionHint ilAssQuestionHint */
227 
228  if( in_array($questionHint->getId(), $hintIds) )
229  {
230  $confirmation->addItem('hint_ids[]', $questionHint->getId(), sprintf(
231  $lng->txt('tst_question_hints_delete_hints_confirm_item'), $questionHint->getIndex(), $questionHint->getText()
232  ));
233  }
234  }
235 
236  $tpl->setContent( $ilCtrl->getHtml($confirmation) );
237  }
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
global $tpl
Definition: ilias.php:8
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 676 of file class.ilAssQuestionHintsGUI.php.

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

◆ cutToOrderingClipboardCmd()

ilAssQuestionHintsGUI::cutToOrderingClipboardCmd ( )
private

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

private ilCtrl $ilCtrl

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

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

362  {
363  if( !$this->isEditingEnabled() )
364  {
365  return;
366  }
367 
368  global $ilCtrl;
369 
370  $moveHintIds = self::fetchHintIdsParameter();
371  $this->checkForSingleHintIdAndRedirectOnFailure($moveHintIds);
372 
373  $moveHintId = current($moveHintIds);
374 
376 
377  $this->hintOrderingClipboard->setStored($moveHintId);
378 
379  $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
380  }
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 $cmd, $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  {
104  case 'ilassquestionhintgui':
105 
106  if( !$this->isEditingEnabled() )
107  {
108  return;
109  }
110 
111  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintGUI.php';
112  $gui = new ilAssQuestionHintGUI($this->questionGUI);
113  $ilCtrl->forwardCommand($gui);
114  break;
115 
116  case 'ilasshintpagegui':
117 
118  if( $this->isEditingEnabled() )
119  {
121  }
122  else
123  {
125  }
126 
127  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintPageObjectCommandForwarder.php';
128  $forwarder = new ilAssQuestionHintPageObjectCommandForwarder($this->questionOBJ, $ilCtrl, $ilTabs, $lng);
129  $forwarder->setPresentationMode($presentationMode);
130  $forwarder->forward();
131  break;
132 
133  default:
134 
135  $cmd .= 'Cmd';
136  $this->$cmd();
137  break;
138  }
139  }
$cmd
Definition: sahs_server.php:35
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
static getContentStylePath($a_style_id)
get content style path
global $lng
Definition: privfeed.php:17
global $DIC
+ 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 620 of file class.ilAssQuestionHintsGUI.php.

References $_GET, $_POST, and array.

621  {
622  $hintIds = array();
623 
624  if( isset($_POST['hint_ids']) && is_array($_POST['hint_ids']) )
625  {
626  foreach($_POST['hint_ids'] as $hintId)
627  {
628  if( (int)$hintId ) $hintIds[] = (int)$hintId;
629  }
630  }
631  elseif( isset($_GET['hint_id']) && (int)$_GET['hint_id'] )
632  {
633  $hintIds[] = (int)$_GET['hint_id'];
634  }
635 
636  return $hintIds;
637  }
$_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 646 of file class.ilAssQuestionHintsGUI.php.

References $_POST, and array.

647  {
648  $hintIndexes = array();
649 
650  if( isset($_POST['hint_indexes']) && is_array($_POST['hint_indexes']) )
651  {
652  foreach($_POST['hint_indexes'] as $hintId => $hintIndex)
653  {
654  if( (int)$hintId ) $hintIndexes[(int)$hintId] = $hintIndex;
655  }
656  }
657 
658  return $hintIndexes;
659  }
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 688 of file class.ilAssQuestionHintsGUI.php.

References $DIC, and $ilCtrl.

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

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

Referenced by showListCmd().

571  {
572  $filteredQuestionHintList = new ilAssQuestionHintList();
573 
574  foreach($questionHintList as $questionHint)
575  {
576  /* @var $questionHint ilAssQuestionHint */
577 
578  if( $questionHint->getId() != $this->hintOrderingClipboard->getStored() )
579  {
580  $filteredQuestionHintList->addHint($questionHint);
581  }
582  }
583 
584  return $filteredQuestionHintList;
585  }
+ 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 528 of file class.ilAssQuestionHintsGUI.php.

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

Referenced by showListCmd().

529  {
530  global $lng;
531 
532  if( !$this->hintOrderingClipboard->hasStored() )
533  {
534  return;
535  }
536 
537  $questionHint = ilAssQuestionHint::getInstanceById( $this->hintOrderingClipboard->getStored() );
538 
539  ilUtil::sendInfo(sprintf(
540  $lng->txt('tst_question_hints_item_stored_in_ordering_clipboard'), $questionHint->getIndex()
541  ));
542  }
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 669 of file class.ilAssQuestionHintsGUI.php.

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

◆ pasteFromOrderingClipboardAfterCmd()

ilAssQuestionHintsGUI::pasteFromOrderingClipboardAfterCmd ( )
private

pastes a hint from ordering clipboard after the selected one

private ilCtrl $ilCtrl ilLanguage $lng

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

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

451  {
452  if( !$this->isEditingEnabled() )
453  {
454  return;
455  }
456 
457  global $ilCtrl, $lng;
458 
459  $targetHintIds = self::fetchHintIdsParameter();
460  $this->checkForSingleHintIdAndRedirectOnFailure($targetHintIds);
461 
462  $targetHintId = current($targetHintIds);
463 
465 
466  $curQuestionHintList = ilAssQuestionHintList::getListByQuestionId( $this->questionOBJ->getId() );
467  $newQuestionHintList = new ilAssQuestionHintList( $this->questionOBJ->getId() );
468 
469  foreach($curQuestionHintList as $questionHint)
470  {
471  /* @var $questionHint ilAssQuestionHint */
472 
473  if( $questionHint->getId() == $this->hintOrderingClipboard->getStored() )
474  {
475  continue;
476  }
477 
478  $newQuestionHintList->addHint($questionHint);
479 
480  if( $questionHint->getId() == $targetHintId )
481  {
482  $targetQuestionHint = $questionHint;
483 
484  $pasteQuestionHint = ilAssQuestionHint::getInstanceById( $this->hintOrderingClipboard->getStored() );
485 
486  $newQuestionHintList->addHint($pasteQuestionHint);
487  }
488  }
489 
490  $successMsg = sprintf(
491  $lng->txt('tst_question_hints_paste_after_success_msg'),
492  $pasteQuestionHint->getIndex(), $targetQuestionHint->getIndex()
493  );
494 
495  $newQuestionHintList->reIndex();
496 
497  $this->hintOrderingClipboard->resetStored();
498 
499  ilUtil::sendSuccess($successMsg, true);
500 
501  $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
502  }
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 389 of file class.ilAssQuestionHintsGUI.php.

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

390  {
391  if( !$this->isEditingEnabled() )
392  {
393  return;
394  }
395 
396  global $ilCtrl, $lng;
397 
398  $targetHintIds = self::fetchHintIdsParameter();
399  $this->checkForSingleHintIdAndRedirectOnFailure($targetHintIds);
400 
401  $targetHintId = current($targetHintIds);
402 
404 
405  $curQuestionHintList = ilAssQuestionHintList::getListByQuestionId( $this->questionOBJ->getId() );
406  $newQuestionHintList = new ilAssQuestionHintList( $this->questionOBJ->getId() );
407 
408  foreach($curQuestionHintList as $questionHint)
409  {
410  /* @var $questionHint ilAssQuestionHint */
411 
412  if( $questionHint->getId() == $this->hintOrderingClipboard->getStored() )
413  {
414  continue;
415  }
416 
417  if( $questionHint->getId() == $targetHintId )
418  {
419  $targetQuestionHint = $questionHint;
420 
421  $pasteQuestionHint = ilAssQuestionHint::getInstanceById( $this->hintOrderingClipboard->getStored() );
422 
423  $newQuestionHintList->addHint($pasteQuestionHint);
424  }
425 
426  $newQuestionHintList->addHint($questionHint);
427  }
428 
429  $successMsg = sprintf(
430  $lng->txt('tst_question_hints_paste_before_success_msg'),
431  $pasteQuestionHint->getIndex(), $targetQuestionHint->getIndex()
432  );
433 
434  $newQuestionHintList->reIndex();
435 
436  $this->hintOrderingClipboard->resetStored();
437 
438  ilUtil::sendSuccess($successMsg, true);
439 
440  $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
441  }
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 246 of file class.ilAssQuestionHintsGUI.php.

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

247  {
248  if( !$this->isEditingEnabled() )
249  {
250  return;
251  }
252 
253  global $ilCtrl, $tpl, $lng;
254 
255  $hintIds = self::fetchHintIdsParameter();
256 
257  if( !count($hintIds) )
258  {
259  ilUtil::sendFailure($lng->txt('tst_question_hints_delete_hints_missing_selection_msg'), true);
260  $ilCtrl->redirect($this);
261  }
262 
263  $questionCompleteHintList = ilAssQuestionHintList::getListByQuestionId($this->questionOBJ->getId());
264 
265  $questionRemainingHintList = new ilAssQuestionHintList();
266 
267  foreach($questionCompleteHintList as $listKey => $questionHint)
268  {
269  /* @var $questionHint ilAssQuestionHint */
270 
271  if( in_array($questionHint->getId(), $hintIds) )
272  {
273  $questionHint->delete();
274  }
275  else
276  {
277  $questionRemainingHintList->addHint($questionHint);
278  }
279  }
280 
281  $questionRemainingHintList->reIndex();
282 
283  ilUtil::sendSuccess($lng->txt('tst_question_hints_delete_success_msg'), true);
284 
285  $originalexists = $this->questionOBJ->_questionExistsInPool($this->questionOBJ->original_id);
286  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
287  global $ilUser;
288  if ($_GET["calling_test"] && $originalexists && assQuestion::_isWriteable($this->questionOBJ->original_id, $ilUser->getId()))
289  {
290  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_CONFIRM_SYNC);
291  }
292 
293  $ilCtrl->redirect($this);
294  }
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 $tpl
Definition: ilias.php:8
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 511 of file class.ilAssQuestionHintsGUI.php.

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

512  {
513  global $ilCtrl, $lng;
514 
515  $this->hintOrderingClipboard->resetStored();
516 
517  ilUtil::sendInfo($lng->txt('tst_question_hints_ordering_clipboard_resetted'), true);
518  $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
519  }
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 304 of file class.ilAssQuestionHintsGUI.php.

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

305  {
306  if( !$this->isEditingEnabled() )
307  {
308  return;
309  }
310 
311  global $ilCtrl, $lng;
312 
313  $hintIndexes = self::orderHintIndexes(
314  self::fetchHintIndexesParameter()
315  );
316 
317  if( !count($hintIndexes) )
318  {
319  ilUtil::sendFailure($lng->txt('tst_question_hints_save_order_unkown_failure_msg'), true);
320  $ilCtrl->redirect($this);
321  }
322 
323  $curQuestionHintList = ilAssQuestionHintList::getListByQuestionId( $this->questionOBJ->getId() );
324 
325  $newQuestionHintList = new ilAssQuestionHintList();
326 
327  foreach($hintIndexes as $hintId => $hintIndex)
328  {
329  if( !$curQuestionHintList->hintExists($hintId) )
330  {
331  ilUtil::sendFailure($lng->txt('tst_question_hints_save_order_unkown_failure_msg'), true);
332  $ilCtrl->redirect($this);
333  }
334 
335  $questionHint = $curQuestionHintList->getHint($hintId);
336 
337  $newQuestionHintList->addHint($questionHint);
338  }
339 
340  $newQuestionHintList->reIndex();
341 
342  ilUtil::sendSuccess($lng->txt('tst_question_hints_save_order_success_msg'), true);
343 
344  $originalexists = $this->questionOBJ->_questionExistsInPool($this->questionOBJ->original_id);
345  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
346  global $ilUser;
347  if ($_GET["calling_test"] && $originalexists && assQuestion::_isWriteable($this->questionOBJ->original_id, $ilUser->getId()))
348  {
349  $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_CONFIRM_SYNC);
350  }
351 
352  $ilCtrl->redirect($this);
353  }
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 715 of file class.ilAssQuestionHintsGUI.php.

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

716  {
717  global $DIC;
718  $ilCtrl = $DIC['ilCtrl'];
719  $tpl = $DIC['tpl'];
720  $lng = $DIC['lng'];
721 
722  if( !isset($_GET['hintId']) || !(int)$_GET['hintId'] )
723  {
724  throw new ilTestException('no hint id given');
725  }
726 
727  $DIC->tabs()->clearTargets();
728  $DIC->tabs()->clearSubTabs();
729 
730  $DIC->tabs()->setBackTarget(
731  $DIC->language()->txt('tst_question_hints_back_to_hint_list'), $DIC->ctrl()->getLinkTarget($this, self::CMD_SHOW_LIST)
732  );
733 
734  $questionHint = ilAssQuestionHint::getInstanceById((int)$_GET['hintId']);
735 
736  // build form
737 
738  $form = new ilPropertyFormGUI();
739 
740  $form->setFormAction($ilCtrl->getFormAction($this));
741 
742  $form->setTableWidth('100%');
743 
744  $form->setTitle(sprintf(
745  $lng->txt('tst_question_hints_form_header_edit'),
746  $questionHint->getIndex(),
747  $this->questionOBJ->getTitle()
748  ));
749 
750  // form input: hint text
751 
752  $nonEditableHintText = new ilNonEditableValueGUI($lng->txt('tst_question_hints_form_label_hint_text'), 'hint_text', true);
753  $nonEditableHintText->setValue( ilUtil::prepareTextareaOutput($questionHint->getText(), true) );
754  $form->addItem($nonEditableHintText);
755 
756  // form input: hint points
757 
758  $nonEditableHintPoints = new ilNonEditableValueGUI($lng->txt('tst_question_hints_form_label_hint_points'), 'hint_points');
759  $nonEditableHintPoints->setValue($questionHint->getPoints());
760  $form->addItem($nonEditableHintPoints);
761 
762  $tpl->setContent( $form->getHTML() );
763  }
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...
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.
$_GET["client_id"]
Base Exception for all Exceptions relating to Modules/Test.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
This class represents a non editable value in a property form.
global $lng
Definition: privfeed.php:17
global $DIC
+ Here is the call graph for this function:

◆ showListCmd()

ilAssQuestionHintsGUI::showListCmd ( )
private

shows a table with existing hints

private ilTemplate $tpl

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

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

148  {
149  global $ilCtrl, $tpl, $lng;
150 
152 
153  require_once 'Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
154  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintsTableGUI.php';
155 
156  $toolbar = new ilToolbarGUI();
157 
158  $questionHintList = ilAssQuestionHintList::getListByQuestionId( $this->questionOBJ->getId() );
159 
160  if( $this->isEditingEnabled() )
161  {
162  if( $this->hintOrderingClipboard->hasStored() )
163  {
164  $questionHintList = $this->getQuestionHintListWithoutHintStoredInOrderingClipboard($questionHintList);
165 
166  $toolbar->addButton(
167  $lng->txt('tst_questions_hints_toolbar_cmd_reset_ordering_clipboard'),
168  $ilCtrl->getLinkTarget($this, self::CMD_RESET_ORDERING_CLIPBOARD)
169  );
170  }
171  else
172  {
173  $toolbar->addButton(
174  $lng->txt('tst_questions_hints_toolbar_cmd_add_hint'),
175  $ilCtrl->getLinkTargetByClass('ilAssQuestionHintGUI', ilAssQuestionHintGUI::CMD_SHOW_FORM)
176  );
177  }
178 
180  }
181  else
182  {
184  }
185 
186  $table = new ilAssQuestionHintsTableGUI(
187  $this->questionOBJ, $questionHintList, $this, self::CMD_SHOW_LIST,
188  $tableMode, $this->hintOrderingClipboard
189  );
190 
191  $tpl->setContent( $ilCtrl->getHtml($toolbar) . $ilCtrl->getHtml($table) );
192  }
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
getQuestionHintListWithoutHintStoredInOrderingClipboard(ilAssQuestionHintList $questionHintList)
returns a new quastion hint list that contains all question hints from the passed list except for the...
global $tpl
Definition: ilias.php:8
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
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: