71 $this->main_tpl = $DIC->ui()->mainTemplate();
72 $this->
ctrl = $DIC->ctrl();
73 $this->
lng = $DIC->language();
74 $this->questioninfo = $DIC->testQuestionPool()->questionInfo();
99 $ilCtrl = $DIC[
'ilCtrl'];
100 $ilTabs = $DIC[
'ilTabs'];
103 $ilHelp = $DIC[
'ilHelp'];
104 $ilHelp->setScreenIdComponent(
'qpl');
106 $DIC->ui()->mainTemplate()->setCurrentBlock(
"ContentStyle");
108 $DIC->ui()->mainTemplate()->parseCurrentBlock();
110 $cmd = $ilCtrl->getCmd(self::CMD_SHOW_LIST);
111 $nextClass = $ilCtrl->getNextClass($this);
113 switch ($nextClass) {
114 case 'ilassquestionhintgui':
120 $ilCtrl->forwardCommand($gui);
123 case 'ilasshintpagegui':
131 $forwarder->setPresentationMode($presentationMode);
132 $forwarder->forward();
136 $this->
tabs->setTabActive(
'tst_question_hints_tab');
152 $ilCtrl = $DIC[
'ilCtrl'];
163 if ($this->hintOrderingClipboard->hasStored()) {
167 $lng->
txt(
'tst_questions_hints_toolbar_cmd_reset_ordering_clipboard'),
168 $ilCtrl->getLinkTarget($this, self::CMD_RESET_ORDERING_CLIPBOARD)
172 $lng->
txt(
'tst_questions_hints_toolbar_cmd_add_hint'),
188 $this->hintOrderingClipboard
191 $tpl->setContent($ilCtrl->getHtml($toolbar) . $ilCtrl->getHtml($table));
205 $ilCtrl = $DIC[
'ilCtrl'];
209 $hintIds = self::fetchHintIdsParameter();
211 if (!count($hintIds)) {
212 $this->main_tpl->setOnScreenMessage(
'failure', $lng->
txt(
'tst_question_hints_delete_hints_missing_selection_msg'),
true);
213 $ilCtrl->redirect($this);
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);
225 foreach ($questionHintList as $questionHint) {
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()
237 $tpl->setContent($ilCtrl->getHtml($confirmation));
254 $ilCtrl = $DIC[
'ilCtrl'];
258 $hintIds = self::fetchHintIdsParameter();
260 if (!count($hintIds)) {
261 $this->main_tpl->setOnScreenMessage(
'failure', $lng->
txt(
'tst_question_hints_delete_hints_missing_selection_msg'),
true);
262 $ilCtrl->redirect($this);
269 foreach ($questionCompleteHintList as $listKey => $questionHint) {
272 if (in_array($questionHint->getId(), $hintIds)) {
273 $questionHint->delete();
275 $questionRemainingHintList->addHint($questionHint);
279 $questionRemainingHintList->reIndex();
281 $this->main_tpl->setOnScreenMessage(
'success', $lng->
txt(
'tst_question_hints_delete_success_msg'),
true);
283 $originalexists = $this->questioninfo->questionExistsInPool((
int) $this->questionOBJ->getOriginalId());
286 $ilUser = $DIC[
'ilUser'];
287 if ($this->request->raw(
"calling_test") && $originalexists &&
assQuestion::_isWriteable($this->questionOBJ->getOriginalId(), $ilUser->getId())) {
291 $ilCtrl->redirect($this);
309 $ilCtrl = $DIC[
'ilCtrl'];
312 $hintIndexes = self::orderHintIndexes(
313 self::fetchHintIndexesParameter()
316 if (!count($hintIndexes)) {
317 $this->main_tpl->setOnScreenMessage(
'failure', $lng->
txt(
'tst_question_hints_save_order_unkown_failure_msg'),
true);
318 $ilCtrl->redirect($this);
325 foreach ($hintIndexes as $hintId => $hintIndex) {
326 if (!$curQuestionHintList->hintExists($hintId)) {
327 $this->main_tpl->setOnScreenMessage(
'failure', $lng->
txt(
'tst_question_hints_save_order_unkown_failure_msg'),
true);
328 $ilCtrl->redirect($this);
331 $questionHint = $curQuestionHintList->getHint($hintId);
333 $newQuestionHintList->addHint($questionHint);
336 $newQuestionHintList->reIndex();
338 $this->main_tpl->setOnScreenMessage(
'success', $lng->
txt(
'tst_question_hints_save_order_success_msg'),
true);
340 $originalexists = $this->questioninfo->questionExistsInPool((
int) $this->questionOBJ->getOriginalId());
343 $ilUser = $DIC[
'ilUser'];
344 if ($this->request->raw(
"calling_test") && $originalexists &&
assQuestion::_isWriteable($this->questionOBJ->getOriginalId(), $ilUser->getId())) {
348 $ilCtrl->redirect($this);
364 $ilCtrl = $DIC[
'ilCtrl'];
366 $moveHintIds = self::fetchHintIdsParameter();
369 $moveHintId = current($moveHintIds);
373 $this->hintOrderingClipboard->setStored($moveHintId);
375 $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
392 $ilCtrl = $DIC[
'ilCtrl'];
395 $targetHintIds = self::fetchHintIdsParameter();
398 $targetHintId = current($targetHintIds);
405 foreach ($curQuestionHintList as $questionHint) {
408 if ($questionHint->getId() == $this->hintOrderingClipboard->getStored()) {
412 if ($questionHint->getId() == $targetHintId) {
413 $targetQuestionHint = $questionHint;
417 $newQuestionHintList->addHint($pasteQuestionHint);
420 $newQuestionHintList->addHint($questionHint);
423 $successMsg = sprintf(
424 $lng->
txt(
'tst_question_hints_paste_before_success_msg'),
425 $pasteQuestionHint->getIndex(),
426 $targetQuestionHint->getIndex()
429 $newQuestionHintList->reIndex();
431 $this->hintOrderingClipboard->resetStored();
433 $this->main_tpl->setOnScreenMessage(
'success', $successMsg,
true);
435 $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
452 $ilCtrl = $DIC[
'ilCtrl'];
455 $targetHintIds = self::fetchHintIdsParameter();
458 $targetHintId = current($targetHintIds);
465 foreach ($curQuestionHintList as $questionHint) {
468 if ($questionHint->getId() == $this->hintOrderingClipboard->getStored()) {
472 $newQuestionHintList->
addHint($questionHint);
474 if ($questionHint->getId() == $targetHintId) {
475 $targetQuestionHint = $questionHint;
479 $newQuestionHintList->addHint($pasteQuestionHint);
483 $successMsg = sprintf(
484 $lng->
txt(
'tst_question_hints_paste_after_success_msg'),
485 $pasteQuestionHint->getIndex(),
486 $targetQuestionHint->getIndex()
489 $newQuestionHintList->reIndex();
491 $this->hintOrderingClipboard->resetStored();
493 $this->main_tpl->setOnScreenMessage(
'success', $successMsg,
true);
495 $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
508 $ilCtrl = $DIC[
'ilCtrl'];
511 $this->hintOrderingClipboard->resetStored();
513 $this->main_tpl->setOnScreenMessage(
'info', $lng->
txt(
'tst_question_hints_ordering_clipboard_resetted'),
true);
514 $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
529 if (!$this->hintOrderingClipboard->hasStored()) {
535 $this->main_tpl->setOnScreenMessage(
'info', sprintf(
536 $lng->
txt(
'tst_question_hints_item_stored_in_ordering_clipboard'),
537 $questionHint->getIndex()
552 if (!$questionHintList->hintExists($hintId)) {
553 $this->main_tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'tst_question_hints_invalid_hint_id'),
true);
554 $this->
ctrl->redirect($this, self::CMD_SHOW_LIST);
570 foreach ($questionHintList as $questionHint) {
573 if ($questionHint->getId() != $this->hintOrderingClipboard->getStored()) {
574 $filteredQuestionHintList->addHint($questionHint);
578 return $filteredQuestionHintList;
593 $ilCtrl = $DIC[
'ilCtrl'];
596 if (!count($hintIds)) {
597 $this->main_tpl->setOnScreenMessage(
'failure', $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 $this->main_tpl->setOnScreenMessage(
'failure', $lng->
txt(
'tst_question_hints_cut_hints_single_selection_msg'),
true);
601 $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
616 $request = $DIC->testQuestionPool()->internal()->request();
619 if (isset($_POST[
'hint_ids']) && is_array($_POST[
'hint_ids'])) {
620 foreach ($_POST[
'hint_ids'] as $hintId) {
622 $hintIds[] = (
int) $hintId;
641 $hintIndexes = array();
643 if (isset($_POST[
'hint_indexes']) && is_array($_POST[
'hint_indexes'])) {
644 foreach ($_POST[
'hint_indexes'] as $hintId => $hintIndex) {
646 $hintIndexes[(
int) $hintId] = $hintIndex;
671 $this->questionGUI->originalSyncForm(
'showHints');
684 $ilCtrl = $DIC[
'ilCtrl'];
686 if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
687 $ilCtrl->setParameterByClass(
'ilasshintpagegui',
'hint_id', $hintId);
688 $linkTarget = $ilCtrl->getLinkTargetByClass(
'ilAssHintPageGUI',
'',
'',
false, $xmlStyle);
690 $ilCtrl->setParameter($this,
'hintId', $hintId);
691 $linkTarget = $ilCtrl->getLinkTarget($this, self::CMD_SHOW_HINT,
'',
false, $xmlStyle);
708 $ilCtrl = $DIC[
'ilCtrl'];
712 if (!$this->request->isset(
'hintId') || !(
int) $this->request->raw(
'hintId')) {
716 $DIC->tabs()->clearTargets();
717 $DIC->tabs()->clearSubTabs();
719 $DIC->tabs()->setBackTarget(
720 $DIC->language()->txt(
'tst_question_hints_back_to_hint_list'),
721 $DIC->ctrl()->getLinkTarget($this, self::CMD_SHOW_LIST)
730 $form->setFormAction($ilCtrl->getFormAction($this));
732 $form->setTableWidth(
'100%');
734 $form->setTitle(sprintf(
735 $lng->
txt(
'tst_question_hints_form_header_edit'),
736 $questionHint->getIndex(),
737 $this->questionOBJ->getTitleForHTMLOutput()
742 $nonEditableHintText =
new ilNonEditableValueGUI($lng->
txt(
'tst_question_hints_form_label_hint_text'),
'hint_text',
true);
744 $form->addItem($nonEditableHintText);
748 $nonEditableHintPoints =
new ilNonEditableValueGUI($lng->
txt(
'tst_question_hints_form_label_hint_points'),
'hint_points');
749 $nonEditableHintPoints->setValue($questionHint->getPoints());
750 $form->addItem($nonEditableHintPoints);
752 $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...
Base Exception for all Exceptions relating to Modules/Test.
__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
QuestionInfoService $questioninfo
Basic GUI class for assessment questions.
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
pasteFromOrderingClipboardBeforeCmd()
pastes a hint from ordering clipboard before the selected one
addHint(ilAssQuestionHint $questionHint)
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)
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...