61 $this->main_tpl = $DIC->ui()->mainTemplate();
62 $this->
ctrl = $DIC->ctrl();
64 $local_dic = QuestionPoolDIC::dic();
65 $this->questionrepository = $local_dic[
'question.general_properties.repository'];
85 $ilHelp = $DIC[
'ilHelp'];
86 $ilHelp->setScreenIdComponent(
'qpl');
88 $DIC->ui()->mainTemplate()->setCurrentBlock(
"ContentStyle");
90 $DIC->ui()->mainTemplate()->parseCurrentBlock();
92 $cmd = $this->
ctrl->getCmd(self::CMD_SHOW_LIST);
93 $nextClass = $this->
ctrl->getNextClass($this);
96 case 'ilassquestionhintgui':
102 $this->
ctrl->forwardCommand($gui);
105 case 'ilasshintpagegui':
118 $forwarder->setPresentationMode($presentationMode);
119 $forwarder->forward();
123 $this->
tabs->setTabActive(
'tst_question_hints_tab');
130 private function showListCmd(
string $additional_content =
''): void
139 if ($this->hintOrderingClipboard->hasStored()) {
143 $this->
lng->txt(
'tst_questions_hints_toolbar_cmd_reset_ordering_clipboard'),
144 $this->
ctrl->getLinkTarget($this, self::CMD_RESET_ORDERING_CLIPBOARD)
148 $this->
lng->txt(
'tst_questions_hints_toolbar_cmd_add_hint'),
164 $this->hintOrderingClipboard
167 $this->main_tpl->setContent($toolbar->getHTML() . $table->getHTML() . $additional_content);
174 if (!count($hint_ids)) {
175 $this->main_tpl->setOnScreenMessage(
177 $this->
lng->txt(
'tst_question_hints_delete_hints_missing_selection_msg'),
180 $this->
ctrl->redirectByClass(self::class);
185 $confirmation->setHeaderText($this->
lng->txt(
'tst_question_hints_delete_hints_confirm_header'));
186 $confirmation->setFormAction($this->
ctrl->getFormAction($this));
187 $confirmation->setConfirm($this->
lng->txt(
'tst_question_hints_delete_hints_confirm_cmd'), self::CMD_PERFORM_DELETE);
188 $confirmation->setCancel($this->
lng->txt(
'cancel'), self::CMD_SHOW_LIST);
192 foreach ($questionHintList as $questionHint) {
195 if (in_array($questionHint->getId(), $hint_ids)) {
196 $confirmation->addItem(
'hint_ids[]', $questionHint->getId(), sprintf(
197 $this->
lng->txt(
'tst_question_hints_delete_hints_confirm_item'),
198 $questionHint->getIndex(),
199 $questionHint->getText()
204 $this->main_tpl->setContent($this->
ctrl->getHtml($confirmation));
215 if (!count($hintIds)) {
216 $this->main_tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'tst_question_hints_delete_hints_missing_selection_msg'),
true);
217 $this->
ctrl->redirectByClass(self::class);
224 foreach ($questionCompleteHintList as $questionHint) {
227 if (in_array($questionHint->getId(), $hintIds)) {
228 $questionHint->delete();
230 $questionRemainingHintList->addHint($questionHint);
234 $questionRemainingHintList->reIndex();
236 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'tst_question_hints_delete_success_msg'),
true);
238 if ($this->question_gui->needsSyncQuery()) {
239 $this->
ctrl->redirectByClass(
240 ilAssQuestionHintsGUI::class,
245 $this->
ctrl->redirectByClass(self::class);
256 if (!count($hintIndexes)) {
257 $this->main_tpl->setOnScreenMessage(
259 $this->
lng->txt(
'tst_question_hints_save_order_unkown_failure_msg'),
262 $this->
ctrl->redirectByClass(self::class);
269 foreach (array_keys($hintIndexes) as $hintId) {
270 if (!$curQuestionHintList->hintExists($hintId)) {
271 $this->main_tpl->setOnScreenMessage(
273 $this->
lng->txt(
'tst_question_hints_save_order_unkown_failure_msg'),
276 $this->
ctrl->redirectByClass(self::class);
279 $questionHint = $curQuestionHintList->getHint($hintId);
281 $newQuestionHintList->addHint($questionHint);
284 $newQuestionHintList->reIndex();
286 $this->main_tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'tst_question_hints_save_order_success_msg'),
true);
288 if ($this->question_gui->needsSyncQuery()) {
289 $this->
ctrl->redirectByClass(
290 ilAssQuestionHintsGUI::class,
295 $this->
ctrl->redirectByClass(self::class);
307 $moveHintId = current($moveHintIds);
311 $this->hintOrderingClipboard->setStored($moveHintId);
313 $this->
ctrl->redirect($this, self::CMD_SHOW_LIST);
325 $targetHintId = current($targetHintIds);
332 foreach ($curQuestionHintList as $questionHint) {
335 if ($questionHint->getId() == $this->hintOrderingClipboard->getStored()) {
339 if ($questionHint->getId() == $targetHintId) {
340 $targetQuestionHint = $questionHint;
344 $newQuestionHintList->addHint($pasteQuestionHint);
347 $newQuestionHintList->addHint($questionHint);
350 $successMsg = sprintf(
351 $this->
lng->txt(
'tst_question_hints_paste_before_success_msg'),
352 $pasteQuestionHint->getIndex(),
353 $targetQuestionHint->getIndex()
356 $newQuestionHintList->reIndex();
358 $this->hintOrderingClipboard->resetStored();
360 $this->main_tpl->setOnScreenMessage(
'success', $successMsg,
true);
362 $this->
ctrl->redirect($this, self::CMD_SHOW_LIST);
379 $ilCtrl = $DIC[
'ilCtrl'];
385 $targetHintId = current($targetHintIds);
392 foreach ($curQuestionHintList as $questionHint) {
395 if ($questionHint->getId() == $this->hintOrderingClipboard->getStored()) {
399 $newQuestionHintList->
addHint($questionHint);
401 if ($questionHint->getId() == $targetHintId) {
402 $targetQuestionHint = $questionHint;
406 $newQuestionHintList->addHint($pasteQuestionHint);
410 $successMsg = sprintf(
411 $lng->
txt(
'tst_question_hints_paste_after_success_msg'),
412 $pasteQuestionHint->getIndex(),
413 $targetQuestionHint->getIndex()
416 $newQuestionHintList->reIndex();
418 $this->hintOrderingClipboard->resetStored();
420 $this->main_tpl->setOnScreenMessage(
'success', $successMsg,
true);
422 $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
435 $ilCtrl = $DIC[
'ilCtrl'];
438 $this->hintOrderingClipboard->resetStored();
440 $this->main_tpl->setOnScreenMessage(
'info',
$lng->
txt(
'tst_question_hints_ordering_clipboard_resetted'),
true);
441 $ilCtrl->redirect($this, self::CMD_SHOW_LIST);
456 if (!$this->hintOrderingClipboard->hasStored()) {
462 $this->main_tpl->setOnScreenMessage(
'info', sprintf(
463 $lng->
txt(
'tst_question_hints_item_stored_in_ordering_clipboard'),
464 $questionHint->getIndex()
479 if (!$questionHintList->hintExists($hintId)) {
480 $this->main_tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'tst_question_hints_invalid_hint_id'),
true);
481 $this->
ctrl->redirect($this, self::CMD_SHOW_LIST);
490 foreach ($questionHintList as $questionHint) {
491 if ($questionHint->getId() !== $this->hintOrderingClipboard->getStored()) {
492 $filteredQuestionHintList->addHint($questionHint);
496 return $filteredQuestionHintList;
501 if ($hint_ids === []) {
502 $this->main_tpl->setOnScreenMessage(
504 $this->
lng->txt(
'tst_question_hints_cut_hints_missing_selection_msg'),
507 $this->
ctrl->redirect($this, self::CMD_SHOW_LIST);
510 if (count($hint_ids) > 1) {
511 $this->main_tpl->setOnScreenMessage(
513 $this->
lng->txt(
'tst_question_hints_cut_hints_single_selection_msg'),
516 $this->
ctrl->redirect($this, self::CMD_SHOW_LIST);
522 $hint_ids = [$this->request_data_collector->int(
'hint_id')];
523 if ($hint_ids[0] !== 0) {
527 return $this->request_data_collector->intArray(
'hint_ids');
532 $hint_indexes = $this->request_data_collector->intArray(
'hint_indexes');
533 asort($hint_indexes);
534 return $hint_indexes;
539 $modal = $this->question_gui->getQuestionSyncModal(self::CMD_SYNC, self::class);
545 $this->question_obj->syncWithOriginal();
551 bool $xml_style =
true 553 if ($this->question_obj->isAdditionalContentEditingModePageObject()) {
554 $this->
ctrl->setParameterByClass(
'ilasshintpagegui',
'hint_id', $hint_id);
555 return $this->
ctrl->getLinkTargetByClass(
'ilAssHintPageGUI',
'',
'',
false, $xml_style);
558 $this->
ctrl->setParameter($this,
'hintId', $hint_id);
559 return $this->
ctrl->getLinkTarget($this, self::CMD_SHOW_HINT,
'',
false, $xml_style);
564 if (!$this->request_data_collector->isset(
'hintId') || !(
int) $this->request_data_collector->raw(
'hintId')) {
568 $this->
tabs->clearTargets();
569 $this->
tabs->clearSubTabs();
571 $this->
tabs->setBackTarget(
572 $this->
lng->txt(
'tst_question_hints_back_to_hint_list'),
573 $this->
ctrl->getLinkTargetByClass(self::class, self::CMD_SHOW_LIST)
582 $form->setFormAction($this->
ctrl->getFormAction($this));
584 $form->setTableWidth(
'100%');
586 $form->setTitle(sprintf(
587 $this->
lng->txt(
'tst_question_hints_form_header_edit'),
588 $questionHint->getIndex(),
589 $this->question_obj->getTitleForHTMLOutput()
595 $this->
lng->txt(
'tst_question_hints_form_label_hint_text'),
599 $nonEditableHintText->setValue(
602 $form->addItem($nonEditableHintText);
607 $this->
lng->txt(
'tst_question_hints_form_label_hint_points'),
610 $nonEditableHintPoints->setValue($questionHint->getPoints());
611 $form->addItem($nonEditableHintPoints);
613 $this->main_tpl->setContent($form->getHTML());
checkForSingleHintIdAndRedirectOnFailure(array $hint_ids)
static getListByQuestionId($questionId)
instantiates a question hint list for the passed question id
const CMD_CUT_TO_ORDERING_CLIPBOARD
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...
showListCmd(string $additional_content='')
const CMD_RESET_ORDERING_CLIPBOARD
ilAssQuestionHintsOrderingClipboard $hintOrderingClipboard
const PRESENTATION_MODE_PREVIEW
presentation mode for authoring
const CMD_SHOW_LIST
command constants
getQuestionHintListWithoutHintStoredInOrderingClipboard(ilAssQuestionHintList $questionHintList)
Base Exception for all Exceptions relating to Modules/Test.
getHintPresentationLinkTarget(int $hint_id, bool $xml_style=true)
__construct(assQuestionGUI $questionGUI)
const CMD_SAVE_LIST_ORDER
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
resetOrderingClipboardCmd()
resets the ordering clipboard
const TBL_MODE_ADMINISTRATION
const TBL_MODE_TESTOUTPUT
the available table modes controlling the tables behaviour
cutToOrderingClipboardCmd()
pasteFromOrderingClipboardAfterCmd()
pastes a hint from ordering clipboard after the selected one
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)
ilGlobalTemplateInterface $main_tpl
pasteFromOrderingClipboardBeforeCmd()
GeneralQuestionPropertiesRepository $questionrepository
addHint(ilAssQuestionHint $questionHint)
__construct(Container $dic, ilPlugin $plugin)
fetchHintIndexesParameter()
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...