19 require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionHintAbstractGUI.php';
20 require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionHintGUI.php';
21 require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionHintsOrderingClipboard.php';
72 $this->main_tpl = $DIC->ui()->mainTemplate();
73 $this->
ctrl = $DIC->ctrl();
74 $this->
lng = $DIC->language();
99 $ilCtrl = $DIC[
'ilCtrl'];
100 $ilTabs = $DIC[
'ilTabs'];
103 $ilHelp = $DIC[
'ilHelp'];
104 $ilHelp->setScreenIdComponent(
'qpl');
106 require_once
"./Services/Style/Content/classes/class.ilObjStyleSheet.php";
107 $DIC->ui()->mainTemplate()->setCurrentBlock(
"ContentStyle");
109 $DIC->ui()->mainTemplate()->parseCurrentBlock();
111 $cmd = $ilCtrl->getCmd(self::CMD_SHOW_LIST);
112 $nextClass = $ilCtrl->getNextClass($this);
114 switch ($nextClass) {
115 case 'ilassquestionhintgui':
121 require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionHintGUI.php';
123 $ilCtrl->forwardCommand($gui);
126 case 'ilasshintpagegui':
134 require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionHintPageObjectCommandForwarder.php';
136 $forwarder->setPresentationMode($presentationMode);
137 $forwarder->forward();
141 $this->
tabs->setTabActive(
'tst_question_hints_tab');
157 $ilCtrl = $DIC[
'ilCtrl'];
163 require_once
'Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php';
164 require_once
'Modules/TestQuestionPool/classes/class.ilAssQuestionHintsTableGUI.php';
171 if ($this->hintOrderingClipboard->hasStored()) {
175 $lng->
txt(
'tst_questions_hints_toolbar_cmd_reset_ordering_clipboard'),
176 $ilCtrl->getLinkTarget($this, self::CMD_RESET_ORDERING_CLIPBOARD)
180 $lng->
txt(
'tst_questions_hints_toolbar_cmd_add_hint'),
196 $this->hintOrderingClipboard
199 $tpl->setContent($ilCtrl->getHtml($toolbar) . $ilCtrl->getHtml($table));
213 $ilCtrl = $DIC[
'ilCtrl'];
217 $hintIds = self::fetchHintIdsParameter();
219 if (!count($hintIds)) {
220 $this->main_tpl->setOnScreenMessage(
'failure', $lng->
txt(
'tst_question_hints_delete_hints_missing_selection_msg'),
true);
221 $ilCtrl->redirect($this);
226 $confirmation->setHeaderText($lng->
txt(
'tst_question_hints_delete_hints_confirm_header'));
227 $confirmation->setFormAction($ilCtrl->getFormAction($this));
228 $confirmation->setConfirm($lng->
txt(
'tst_question_hints_delete_hints_confirm_cmd'), self::CMD_PERFORM_DELETE);
229 $confirmation->setCancel($lng->
txt(
'cancel'), self::CMD_SHOW_LIST);
233 foreach ($questionHintList as $questionHint) {
236 if (in_array($questionHint->getId(), $hintIds)) {
237 $confirmation->addItem(
'hint_ids[]', $questionHint->getId(), sprintf(
238 $lng->
txt(
'tst_question_hints_delete_hints_confirm_item'),
239 $questionHint->getIndex(),
240 $questionHint->getText()
245 $tpl->setContent($ilCtrl->getHtml($confirmation));
262 $ilCtrl = $DIC[
'ilCtrl'];
266 $hintIds = self::fetchHintIdsParameter();
268 if (!count($hintIds)) {
269 $this->main_tpl->setOnScreenMessage(
'failure', $lng->
txt(
'tst_question_hints_delete_hints_missing_selection_msg'),
true);
270 $ilCtrl->redirect($this);
277 foreach ($questionCompleteHintList as $listKey => $questionHint) {
280 if (in_array($questionHint->getId(), $hintIds)) {
281 $questionHint->delete();
283 $questionRemainingHintList->addHint($questionHint);
287 $questionRemainingHintList->reIndex();
289 $this->main_tpl->setOnScreenMessage(
'success', $lng->
txt(
'tst_question_hints_delete_success_msg'),
true);
291 $originalexists = $this->questionOBJ->_questionExistsInPool((
int) $this->questionOBJ->getOriginalId());
292 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
299 $ilCtrl->redirect($this);
317 $ilCtrl = $DIC[
'ilCtrl'];
320 $hintIndexes = self::orderHintIndexes(
321 self::fetchHintIndexesParameter()
324 if (!count($hintIndexes)) {
325 $this->main_tpl->setOnScreenMessage(
'failure', $lng->
txt(
'tst_question_hints_save_order_unkown_failure_msg'),
true);
326 $ilCtrl->redirect($this);
333 foreach ($hintIndexes as $hintId => $hintIndex) {
334 if (!$curQuestionHintList->hintExists($hintId)) {
335 $this->main_tpl->setOnScreenMessage(
'failure', $lng->
txt(
'tst_question_hints_save_order_unkown_failure_msg'),
true);
336 $ilCtrl->redirect($this);
339 $questionHint = $curQuestionHintList->getHint($hintId);
341 $newQuestionHintList->addHint($questionHint);
344 $newQuestionHintList->reIndex();
346 $this->main_tpl->setOnScreenMessage(
'success', $lng->
txt(
'tst_question_hints_save_order_success_msg'),
true);
348 $originalexists = $this->questionOBJ->_questionExistsInPool((
int) $this->questionOBJ->getOriginalId());
349 include_once
"./Modules/TestQuestionPool/classes/class.assQuestion.php";
356 $ilCtrl->redirect($this);
372 $ilCtrl = $DIC[
'ilCtrl'];
374 $moveHintIds = self::fetchHintIdsParameter();
377 $moveHintId = current($moveHintIds);
381 $this->hintOrderingClipboard->setStored($moveHintId);
383 $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
400 $ilCtrl = $DIC[
'ilCtrl'];
403 $targetHintIds = self::fetchHintIdsParameter();
406 $targetHintId = current($targetHintIds);
413 foreach ($curQuestionHintList as $questionHint) {
416 if ($questionHint->getId() == $this->hintOrderingClipboard->getStored()) {
420 if ($questionHint->getId() == $targetHintId) {
421 $targetQuestionHint = $questionHint;
425 $newQuestionHintList->addHint($pasteQuestionHint);
428 $newQuestionHintList->addHint($questionHint);
431 $successMsg = sprintf(
432 $lng->
txt(
'tst_question_hints_paste_before_success_msg'),
433 $pasteQuestionHint->getIndex(),
434 $targetQuestionHint->getIndex()
437 $newQuestionHintList->reIndex();
439 $this->hintOrderingClipboard->resetStored();
441 $this->main_tpl->setOnScreenMessage(
'success', $successMsg,
true);
443 $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
460 $ilCtrl = $DIC[
'ilCtrl'];
463 $targetHintIds = self::fetchHintIdsParameter();
466 $targetHintId = current($targetHintIds);
473 foreach ($curQuestionHintList as $questionHint) {
476 if ($questionHint->getId() == $this->hintOrderingClipboard->getStored()) {
480 $newQuestionHintList->
addHint($questionHint);
482 if ($questionHint->getId() == $targetHintId) {
483 $targetQuestionHint = $questionHint;
487 $newQuestionHintList->addHint($pasteQuestionHint);
491 $successMsg = sprintf(
492 $lng->
txt(
'tst_question_hints_paste_after_success_msg'),
493 $pasteQuestionHint->getIndex(),
494 $targetQuestionHint->getIndex()
497 $newQuestionHintList->reIndex();
499 $this->hintOrderingClipboard->resetStored();
501 $this->main_tpl->setOnScreenMessage(
'success', $successMsg,
true);
503 $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
516 $ilCtrl = $DIC[
'ilCtrl'];
519 $this->hintOrderingClipboard->resetStored();
521 $this->main_tpl->setOnScreenMessage(
'info', $lng->
txt(
'tst_question_hints_ordering_clipboard_resetted'),
true);
522 $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
537 if (!$this->hintOrderingClipboard->hasStored()) {
543 $this->main_tpl->setOnScreenMessage(
'info', sprintf(
544 $lng->
txt(
'tst_question_hints_item_stored_in_ordering_clipboard'),
545 $questionHint->getIndex()
560 if (!$questionHintList->hintExists($hintId)) {
561 $this->main_tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'tst_question_hints_invalid_hint_id'),
true);
562 $this->
ctrl->redirect($this, self::CMD_SHOW_LIST);
578 foreach ($questionHintList as $questionHint) {
581 if ($questionHint->getId() != $this->hintOrderingClipboard->getStored()) {
582 $filteredQuestionHintList->addHint($questionHint);
586 return $filteredQuestionHintList;
601 $ilCtrl = $DIC[
'ilCtrl'];
604 if (!count($hintIds)) {
605 $this->main_tpl->setOnScreenMessage(
'failure', $lng->
txt(
'tst_question_hints_cut_hints_missing_selection_msg'),
true);
606 $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
607 } elseif (count($hintIds) > 1) {
608 $this->main_tpl->setOnScreenMessage(
'failure', $lng->
txt(
'tst_question_hints_cut_hints_single_selection_msg'),
true);
609 $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
624 $request = $DIC->testQuestionPool()->internal()->request();
627 if (isset($_POST[
'hint_ids']) && is_array($_POST[
'hint_ids'])) {
628 foreach ($_POST[
'hint_ids'] as $hintId) {
630 $hintIds[] = (
int) $hintId;
649 $hintIndexes = array();
651 if (isset($_POST[
'hint_indexes']) && is_array($_POST[
'hint_indexes'])) {
652 foreach ($_POST[
'hint_indexes'] as $hintId => $hintIndex) {
654 $hintIndexes[(
int) $hintId] = $hintIndex;
679 $this->questionGUI->originalSyncForm(
'showHints');
692 $ilCtrl = $DIC[
'ilCtrl'];
694 if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
695 $ilCtrl->setParameterByClass(
'ilasshintpagegui',
'hint_id', $hintId);
696 $linkTarget = $ilCtrl->getLinkTargetByClass(
'ilAssHintPageGUI',
'',
'',
false, $xmlStyle);
698 $ilCtrl->setParameter($this,
'hintId', $hintId);
699 $linkTarget = $ilCtrl->getLinkTarget($this, self::CMD_SHOW_HINT,
'',
false, $xmlStyle);
716 $ilCtrl = $DIC[
'ilCtrl'];
720 if (!$this->request->isset(
'hintId') || !(
int) $this->request->raw(
'hintId')) {
724 $DIC->tabs()->clearTargets();
725 $DIC->tabs()->clearSubTabs();
727 $DIC->tabs()->setBackTarget(
728 $DIC->language()->txt(
'tst_question_hints_back_to_hint_list'),
729 $DIC->ctrl()->getLinkTarget($this, self::CMD_SHOW_LIST)
738 $form->setFormAction($ilCtrl->getFormAction($this));
740 $form->setTableWidth(
'100%');
742 $form->setTitle(sprintf(
743 $lng->
txt(
'tst_question_hints_form_header_edit'),
744 $questionHint->getIndex(),
745 $this->questionOBJ->getTitleForHTMLOutput()
750 $nonEditableHintText =
new ilNonEditableValueGUI($lng->
txt(
'tst_question_hints_form_label_hint_text'),
'hint_text',
true);
752 $form->addItem($nonEditableHintText);
756 $nonEditableHintPoints =
new ilNonEditableValueGUI($lng->
txt(
'tst_question_hints_form_label_hint_points'),
'hint_points');
757 $nonEditableHintPoints->
setValue($questionHint->getPoints());
758 $form->addItem($nonEditableHintPoints);
760 $tpl->setContent($form->getHTML());
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
const CMD_CUT_TO_ORDERING_CLIPBOARD
static orderHintIndexes($hintIndexes)
sorts the array of indexes by index value so keys (hint ids) get into new order submitted by user ...
getHintPresentationLinkTarget($hintId, $xmlStyle=true)
returns the link target for hint request presentation
static getInstanceById($hintId)
creates a hint object instance, loads the persisted hint dataset identified by passed hint id from da...
const PRESENTATION_MODE_AUTHOR
presentation mode for authoring
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
ILIAS TestQuestionPool InternalRequestService $request
showListCmd()
shows a table with existing hints
showHintCmd()
shows an allready requested hint
static fetchHintIdsParameter()
fetches either an array of hint ids from POST or a single hint id from GET and returns an array of (a...
const CMD_RESET_ORDERING_CLIPBOARD
const PRESENTATION_MODE_PREVIEW
presentation mode for authoring
const CMD_SHOW_LIST
command constants
getQuestionHintListWithoutHintStoredInOrderingClipboard(ilAssQuestionHintList $questionHintList)
returns a new quastion hint list that contains all question hints from the passed list except for the...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(assQuestionGUI $questionGUI)
Constructor.
const CMD_SAVE_LIST_ORDER
resetOrderingClipboardCmd()
resets the ordering clipboard
const TBL_MODE_ADMINISTRATION
const TBL_MODE_TESTOUTPUT
the available table modes controlling the tables behaviour
cutToOrderingClipboardCmd()
cuts a hint from question hint list and stores it to ordering clipboard
pasteFromOrderingClipboardAfterCmd()
pastes a hint from ordering clipboard after the selected one
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const CMD_PASTE_FROM_ORDERING_CLIPBOARD_BEFORE
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
confirmDeleteCmd()
shows a confirmation screen with selected hints for deletion
performDeleteCmd()
performs confirmed deletion for selected hints
const CMD_SHOW_FORM
command constants
assQuestionGUI $questionGUI
static fetchHintIndexesParameter()
fetches an array of hint index values from POST
ilGlobalTemplateInterface $main_tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
pasteFromOrderingClipboardBeforeCmd()
pastes a hint from ordering clipboard before the selected one
addHint(ilAssQuestionHint $questionHint)
adds a question hint object to the current list instance
__construct(Container $dic, ilPlugin $plugin)
saveListOrderCmd()
saves the order based on index values passed from table's form (the table must not be paginated...
static _isWriteable(int $question_id, int $user_id)
checkForSingleHintIdAndRedirectOnFailure($hintIds)
checks for a hint id in the passed array and redirects with corresponding failure message if not exac...
setEditingEnabled(bool $editingEnabled)
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
initHintOrderingClipboardNotification()
inits the notification telling the user, that a hint is stored to hint ordering clipboard ...
const CMD_PASTE_FROM_ORDERING_CLIPBOARD_AFTER
checkForExistingHintRelatingToCurrentQuestionAndRedirectOnFailure($hintId)
checks for an existing hint relating to current question and redirects with corresponding failure mes...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...