ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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...
 
 __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.

@access public

Parameters
assQuestionGUI$questionGUI

Reimplemented from ilAssQuestionHintAbstractGUI.

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

References ilAssQuestionHintAbstractGUI\$questionGUI, and ILIAS\GlobalScreen\Provider\__construct().

+ 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

@access private

Parameters
integer$hintId

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

549 {
550 $questionHintList = ilAssQuestionHintList::getListByQuestionId($this->questionOBJ->getId());
551
552 if (!$questionHintList->hintExists($hintId)) {
553 ilUtil::sendFailure($lng->txt('tst_question_hints_invalid_hint_id'), true);
554 $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
555 }
556 }
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilCtrl
Definition: ilias.php:18
$lng

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

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

+ 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

@access private @global ilCtrl $ilCtrl @global ilLanguage $lng

Parameters
array$hintIds

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

591 {
592 global $DIC;
593 $ilCtrl = $DIC['ilCtrl'];
594 $lng = $DIC['lng'];
595
596 if (!count($hintIds)) {
597 ilUtil::sendFailure($lng->txt('tst_question_hints_cut_hints_missing_selection_msg'), true);
598 $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
599 } elseif (count($hintIds) > 1) {
600 ilUtil::sendFailure($lng->txt('tst_question_hints_cut_hints_single_selection_msg'), true);
601 $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
602 }
603 }
$DIC
Definition: xapitoken.php:46

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

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

+ 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

@access private @global ilCtrl $ilCtrl @global ilTemplate $tpl @global ilLanguage $lng

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

202 {
203 global $DIC;
204 $ilCtrl = $DIC['ilCtrl'];
205 $tpl = $DIC['tpl'];
206 $lng = $DIC['lng'];
207
208 $hintIds = self::fetchHintIdsParameter();
209
210 if (!count($hintIds)) {
211 ilUtil::sendFailure($lng->txt('tst_question_hints_delete_hints_missing_selection_msg'), true);
212 $ilCtrl->redirect($this);
213 }
214
215 require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
216 $confirmation = new ilConfirmationGUI();
217
218 $confirmation->setHeaderText($lng->txt('tst_question_hints_delete_hints_confirm_header'));
219 $confirmation->setFormAction($ilCtrl->getFormAction($this));
220 $confirmation->setConfirm($lng->txt('tst_question_hints_delete_hints_confirm_cmd'), self::CMD_PERFORM_DELETE);
221 $confirmation->setCancel($lng->txt('cancel'), self::CMD_SHOW_LIST);
222
223 $questionHintList = ilAssQuestionHintList::getListByQuestionId($this->questionOBJ->getId());
224
225 foreach ($questionHintList as $questionHint) {
226 /* @var $questionHint ilAssQuestionHint */
227
228 if (in_array($questionHint->getId(), $hintIds)) {
229 $confirmation->addItem('hint_ids[]', $questionHint->getId(), sprintf(
230 $lng->txt('tst_question_hints_delete_hints_confirm_item'),
231 $questionHint->getIndex(),
232 $questionHint->getText()
233 ));
234 }
235 }
236
237 $tpl->setContent($ilCtrl->getHtml($confirmation));
238 }
static fetchHintIdsParameter()
fetches either an array of hint ids from POST or a single hint id from GET and returns an array of (a...
Confirmation screen class.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl

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

+ Here is the call graph for this function:

◆ confirmSyncCmd()

ilAssQuestionHintsGUI::confirmSyncCmd ( )

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

668 {
669 $this->questionGUI->originalSyncForm('showHints');
670 }

◆ cutToOrderingClipboardCmd()

ilAssQuestionHintsGUI::cutToOrderingClipboardCmd ( )
private

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

@access private @global ilCtrl $ilCtrl

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

358 {
359 if (!$this->isEditingEnabled()) {
360 return;
361 }
362
363 global $DIC;
364 $ilCtrl = $DIC['ilCtrl'];
365
366 $moveHintIds = self::fetchHintIdsParameter();
367 $this->checkForSingleHintIdAndRedirectOnFailure($moveHintIds);
368
369 $moveHintId = current($moveHintIds);
370
372
373 $this->hintOrderingClipboard->setStored($moveHintId);
374
375 $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
376 }
checkForExistingHintRelatingToCurrentQuestionAndRedirectOnFailure($hintId)
checks for an existing hint relating to current question and redirects with corresponding failure mes...
checkForSingleHintIdAndRedirectOnFailure($hintIds)
checks for a hint id in the passed array and redirects with corresponding failure message if not exac...

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

+ Here is the call graph for this function:

◆ executeCommand()

ilAssQuestionHintsGUI::executeCommand ( )

Execute Command.

@access public @global ilCtrl $ilCtrl

Returns
mixed

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

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

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

+ 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

@access private

Returns
array $hintIds

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

614 {
615 $hintIds = array();
616
617 if (isset($_POST['hint_ids']) && is_array($_POST['hint_ids'])) {
618 foreach ($_POST['hint_ids'] as $hintId) {
619 if ((int) $hintId) {
620 $hintIds[] = (int) $hintId;
621 }
622 }
623 } elseif (isset($_GET['hint_id']) && (int) $_GET['hint_id']) {
624 $hintIds[] = (int) $_GET['hint_id'];
625 }
626
627 return $hintIds;
628 }
$_GET["client_id"]
$_POST["username"]

References $_GET, and $_POST.

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

+ Here is the caller graph for this function:

◆ fetchHintIndexesParameter()

static ilAssQuestionHintsGUI::fetchHintIndexesParameter ( )
staticprivate

fetches an array of hint index values from POST

@access private

Returns
array $hintIndexes

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

638 {
639 $hintIndexes = array();
640
641 if (isset($_POST['hint_indexes']) && is_array($_POST['hint_indexes'])) {
642 foreach ($_POST['hint_indexes'] as $hintId => $hintIndex) {
643 if ((int) $hintId) {
644 $hintIndexes[(int) $hintId] = $hintIndex;
645 }
646 }
647 }
648
649 return $hintIndexes;
650 }

References $_POST.

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

680 {
681 global $DIC;
682 $ilCtrl = $DIC['ilCtrl'];
683
684 if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
685 $ilCtrl->setParameterByClass('ilasshintpagegui', 'hint_id', $hintId);
686 $linkTarget = $ilCtrl->getLinkTargetByClass('ilAssHintPageGUI', '', '', false, $xmlStyle);
687 } else {
688 $ilCtrl->setParameter($this, 'hintId', $hintId);
689 $linkTarget = $ilCtrl->getLinkTarget($this, self::CMD_SHOW_HINT, '', false, $xmlStyle);
690 }
691
692 return $linkTarget;
693 }

References $DIC, and $ilCtrl.

◆ 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

@access private

Parameters
ilAssQuestionHintList$questionHintList
Returns
ilAssQuestionHintList $filteredQuestionHintList

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

567 {
568 $filteredQuestionHintList = new ilAssQuestionHintList();
569
570 foreach ($questionHintList as $questionHint) {
571 /* @var $questionHint ilAssQuestionHint */
572
573 if ($questionHint->getId() != $this->hintOrderingClipboard->getStored()) {
574 $filteredQuestionHintList->addHint($questionHint);
575 }
576 }
577
578 return $filteredQuestionHintList;
579 }

Referenced by showListCmd().

+ 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

@access private @global ilLanguage $lng

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

525 {
526 global $DIC;
527 $lng = $DIC['lng'];
528
529 if (!$this->hintOrderingClipboard->hasStored()) {
530 return;
531 }
532
533 $questionHint = ilAssQuestionHint::getInstanceById($this->hintOrderingClipboard->getStored());
534
535 ilUtil::sendInfo(sprintf(
536 $lng->txt('tst_question_hints_item_stored_in_ordering_clipboard'),
537 $questionHint->getIndex()
538 ));
539 }
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.

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

Referenced by showListCmd().

+ 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

@access private

Returns
array $hintIndexes

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

661 {
662 asort($hintIndexes);
663
664 return $hintIndexes;
665 }

Referenced by saveListOrderCmd().

+ Here is the caller graph for this function:

◆ pasteFromOrderingClipboardAfterCmd()

ilAssQuestionHintsGUI::pasteFromOrderingClipboardAfterCmd ( )
private

pastes a hint from ordering clipboard after the selected one

@access private @global ilCtrl $ilCtrl @global ilLanguage $lng

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

446 {
447 if (!$this->isEditingEnabled()) {
448 return;
449 }
450
451 global $DIC;
452 $ilCtrl = $DIC['ilCtrl'];
453 $lng = $DIC['lng'];
454
455 $targetHintIds = self::fetchHintIdsParameter();
456 $this->checkForSingleHintIdAndRedirectOnFailure($targetHintIds);
457
458 $targetHintId = current($targetHintIds);
459
461
462 $curQuestionHintList = ilAssQuestionHintList::getListByQuestionId($this->questionOBJ->getId());
463 $newQuestionHintList = new ilAssQuestionHintList($this->questionOBJ->getId());
464
465 foreach ($curQuestionHintList as $questionHint) {
466 /* @var $questionHint ilAssQuestionHint */
467
468 if ($questionHint->getId() == $this->hintOrderingClipboard->getStored()) {
469 continue;
470 }
471
472 $newQuestionHintList->addHint($questionHint);
473
474 if ($questionHint->getId() == $targetHintId) {
475 $targetQuestionHint = $questionHint;
476
477 $pasteQuestionHint = ilAssQuestionHint::getInstanceById($this->hintOrderingClipboard->getStored());
478
479 $newQuestionHintList->addHint($pasteQuestionHint);
480 }
481 }
482
483 $successMsg = sprintf(
484 $lng->txt('tst_question_hints_paste_after_success_msg'),
485 $pasteQuestionHint->getIndex(),
486 $targetQuestionHint->getIndex()
487 );
488
489 $newQuestionHintList->reIndex();
490
491 $this->hintOrderingClipboard->resetStored();
492
493 ilUtil::sendSuccess($successMsg, true);
494
495 $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
496 }

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

+ Here is the call graph for this function:

◆ pasteFromOrderingClipboardBeforeCmd()

ilAssQuestionHintsGUI::pasteFromOrderingClipboardBeforeCmd ( )
private

pastes a hint from ordering clipboard before the selected one

@access private @global ilCtrl $ilCtrl @global ilLanguage $lng

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

386 {
387 if (!$this->isEditingEnabled()) {
388 return;
389 }
390
391 global $DIC;
392 $ilCtrl = $DIC['ilCtrl'];
393 $lng = $DIC['lng'];
394
395 $targetHintIds = self::fetchHintIdsParameter();
396 $this->checkForSingleHintIdAndRedirectOnFailure($targetHintIds);
397
398 $targetHintId = current($targetHintIds);
399
401
402 $curQuestionHintList = ilAssQuestionHintList::getListByQuestionId($this->questionOBJ->getId());
403 $newQuestionHintList = new ilAssQuestionHintList($this->questionOBJ->getId());
404
405 foreach ($curQuestionHintList as $questionHint) {
406 /* @var $questionHint ilAssQuestionHint */
407
408 if ($questionHint->getId() == $this->hintOrderingClipboard->getStored()) {
409 continue;
410 }
411
412 if ($questionHint->getId() == $targetHintId) {
413 $targetQuestionHint = $questionHint;
414
415 $pasteQuestionHint = ilAssQuestionHint::getInstanceById($this->hintOrderingClipboard->getStored());
416
417 $newQuestionHintList->addHint($pasteQuestionHint);
418 }
419
420 $newQuestionHintList->addHint($questionHint);
421 }
422
423 $successMsg = sprintf(
424 $lng->txt('tst_question_hints_paste_before_success_msg'),
425 $pasteQuestionHint->getIndex(),
426 $targetQuestionHint->getIndex()
427 );
428
429 $newQuestionHintList->reIndex();
430
431 $this->hintOrderingClipboard->resetStored();
432
433 ilUtil::sendSuccess($successMsg, true);
434
435 $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
436 }

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

+ Here is the call graph for this function:

◆ performDeleteCmd()

ilAssQuestionHintsGUI::performDeleteCmd ( )
private

performs confirmed deletion for selected hints

@access private @global ilCtrl $ilCtrl @global ilLanguage $lng

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

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

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

+ Here is the call graph for this function:

◆ resetOrderingClipboardCmd()

ilAssQuestionHintsGUI::resetOrderingClipboardCmd ( )
private

resets the ordering clipboard

@access private @global ilCtrl $ilCtrl @global ilLanguage $lng

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

506 {
507 global $DIC;
508 $ilCtrl = $DIC['ilCtrl'];
509 $lng = $DIC['lng'];
510
511 $this->hintOrderingClipboard->resetStored();
512
513 ilUtil::sendInfo($lng->txt('tst_question_hints_ordering_clipboard_resetted'), true);
514 $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
515 }

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

+ 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)

@access private @global ilCtrl $ilCtrl @global ilLanguage $lng

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

303 {
304 if (!$this->isEditingEnabled()) {
305 return;
306 }
307
308 global $DIC;
309 $ilCtrl = $DIC['ilCtrl'];
310 $lng = $DIC['lng'];
311
312 $hintIndexes = self::orderHintIndexes(
313 self::fetchHintIndexesParameter()
314 );
315
316 if (!count($hintIndexes)) {
317 ilUtil::sendFailure($lng->txt('tst_question_hints_save_order_unkown_failure_msg'), true);
318 $ilCtrl->redirect($this);
319 }
320
321 $curQuestionHintList = ilAssQuestionHintList::getListByQuestionId($this->questionOBJ->getId());
322
323 $newQuestionHintList = new ilAssQuestionHintList();
324
325 foreach ($hintIndexes as $hintId => $hintIndex) {
326 if (!$curQuestionHintList->hintExists($hintId)) {
327 ilUtil::sendFailure($lng->txt('tst_question_hints_save_order_unkown_failure_msg'), true);
328 $ilCtrl->redirect($this);
329 }
330
331 $questionHint = $curQuestionHintList->getHint($hintId);
332
333 $newQuestionHintList->addHint($questionHint);
334 }
335
336 $newQuestionHintList->reIndex();
337
338 ilUtil::sendSuccess($lng->txt('tst_question_hints_save_order_success_msg'), true);
339
340 $originalexists = $this->questionOBJ->_questionExistsInPool($this->questionOBJ->original_id);
341 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
342 global $DIC;
343 $ilUser = $DIC['ilUser'];
344 if ($_GET["calling_test"] && $originalexists && assQuestion::_isWriteable($this->questionOBJ->original_id, $ilUser->getId())) {
345 $ilCtrl->redirectByClass('ilAssQuestionHintsGUI', ilAssQuestionHintsGUI::CMD_CONFIRM_SYNC);
346 }
347
348 $ilCtrl->redirect($this);
349 }
static orderHintIndexes($hintIndexes)
sorts the array of indexes by index value so keys (hint ids) get into new order submitted by user

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

+ 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.

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

References $editingEnabled.

◆ showHintCmd()

ilAssQuestionHintsGUI::showHintCmd ( )
private

shows an allready requested hint

@access private @global ilCtrl $ilCtrl @global ilTemplate $tpl @global ilLanguage $lng

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

704 {
705 global $DIC;
706 $ilCtrl = $DIC['ilCtrl'];
707 $tpl = $DIC['tpl'];
708 $lng = $DIC['lng'];
709
710 if (!isset($_GET['hintId']) || !(int) $_GET['hintId']) {
711 throw new ilTestException('no hint id given');
712 }
713
714 $DIC->tabs()->clearTargets();
715 $DIC->tabs()->clearSubTabs();
716
717 $DIC->tabs()->setBackTarget(
718 $DIC->language()->txt('tst_question_hints_back_to_hint_list'),
719 $DIC->ctrl()->getLinkTarget($this, self::CMD_SHOW_LIST)
720 );
721
722 $questionHint = ilAssQuestionHint::getInstanceById((int) $_GET['hintId']);
723
724 // build form
725
726 $form = new ilPropertyFormGUI();
727
728 $form->setFormAction($ilCtrl->getFormAction($this));
729
730 $form->setTableWidth('100%');
731
732 $form->setTitle(sprintf(
733 $lng->txt('tst_question_hints_form_header_edit'),
734 $questionHint->getIndex(),
735 $this->questionOBJ->getTitle()
736 ));
737
738 // form input: hint text
739
740 $nonEditableHintText = new ilNonEditableValueGUI($lng->txt('tst_question_hints_form_label_hint_text'), 'hint_text', true);
741 $nonEditableHintText->setValue(ilUtil::prepareTextareaOutput($questionHint->getText(), true));
742 $form->addItem($nonEditableHintText);
743
744 // form input: hint points
745
746 $nonEditableHintPoints = new ilNonEditableValueGUI($lng->txt('tst_question_hints_form_label_hint_points'), 'hint_points');
747 $nonEditableHintPoints->setValue($questionHint->getPoints());
748 $form->addItem($nonEditableHintPoints);
749
750 $tpl->setContent($form->getHTML());
751 }
This class represents a non editable value in a property form.
This class represents a property form user interface.
Base Exception for all Exceptions relating to Modules/Test.
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,...

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

+ Here is the call graph for this function:

◆ showListCmd()

ilAssQuestionHintsGUI::showListCmd ( )
private

shows a table with existing hints

@access private @global ilTemplate $tpl

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

146 {
147 global $DIC;
148 $ilCtrl = $DIC['ilCtrl'];
149 $tpl = $DIC['tpl'];
150 $lng = $DIC['lng'];
151
153
154 require_once 'Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
155 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintsTableGUI.php';
156
157 $toolbar = new ilToolbarGUI();
158
159 $questionHintList = ilAssQuestionHintList::getListByQuestionId($this->questionOBJ->getId());
160
161 if ($this->isEditingEnabled()) {
162 if ($this->hintOrderingClipboard->hasStored()) {
163 $questionHintList = $this->getQuestionHintListWithoutHintStoredInOrderingClipboard($questionHintList);
164
165 $toolbar->addButton(
166 $lng->txt('tst_questions_hints_toolbar_cmd_reset_ordering_clipboard'),
167 $ilCtrl->getLinkTarget($this, self::CMD_RESET_ORDERING_CLIPBOARD)
168 );
169 } else {
170 $toolbar->addButton(
171 $lng->txt('tst_questions_hints_toolbar_cmd_add_hint'),
172 $ilCtrl->getLinkTargetByClass('ilAssQuestionHintGUI', ilAssQuestionHintGUI::CMD_SHOW_FORM)
173 );
174 }
175
177 } else {
179 }
180
181 $table = new ilAssQuestionHintsTableGUI(
182 $this->questionOBJ,
183 $questionHintList,
184 $this,
185 self::CMD_SHOW_LIST,
186 $tableMode,
187 $this->hintOrderingClipboard
188 );
189
190 $tpl->setContent($ilCtrl->getHtml($toolbar) . $ilCtrl->getHtml($table));
191 }
const CMD_SHOW_FORM
command constants
getQuestionHintListWithoutHintStoredInOrderingClipboard(ilAssQuestionHintList $questionHintList)
returns a new quastion hint list that contains all question hints from the passed list except for the...
initHintOrderingClipboardNotification()
inits the notification telling the user, that a hint is stored to hint ordering clipboard
const TBL_MODE_TESTOUTPUT
the available table modes controlling the tables behaviour

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

+ 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: