3 declare(strict_types=1);
    36     protected Presentation\PresentationGUIRequest 
$request;
    48         $this->
ctrl = $DIC->ctrl();
    49         $this->
lng = $DIC->language();
    50         $this->tpl = $DIC->ui()->mainTemplate();
    51         $this->ui_fac = $DIC->ui()->factory();
    52         $this->ui_ren = $DIC->ui()->renderer();
    53         $this->request = $DIC->glossary()
    58         $gs = $DIC->glossary()->internal();
    59         $this->manager = $gs->domain()->flashcard($this->request->getRefId());
    61         $this->
ctrl->saveParameter($this, [
"box_id"]);
    62         $this->box_nr = $this->request->getBoxId();
    63         $this->initial_terms_in_box = $this->manager->getSessionInitialTerms($this->box_nr);
    64         $this->terms_in_box = $this->manager->getSessionTerms($this->box_nr);
    65         $this->current_term = $this->terms_in_box[0] ?? null;
    66         $this->glossary = 
new ilObjGlossary($this->request->getRefId());
    71         $next_class = $this->
ctrl->getNextClass($this);
    72         $cmd = $this->
ctrl->getCmd();
    74         switch ($next_class) {
    76                 $cmd = $this->
ctrl->getCmd(
"show");
    82     public function show(): void
    84         if ($this->box_nr === Flashcard\FlashcardBox::FIRST_BOX) {
    85             $cnt_all = count($this->manager->getUserTermsForBox($this->box_nr))
    86                 + count($this->manager->getAllTermsWithoutEntry());
    87             $cnt_remaining = count($this->manager->getNonTodayUserTermsForBox($this->box_nr))
    88                 + count($this->manager->getAllTermsWithoutEntry());
    90             $cnt_all = count($this->manager->getUserTermsForBox($this->box_nr));
    91             $cnt_remaining = count($this->manager->getNonTodayUserTermsForBox($this->box_nr));
    93         $cnt_today = count($this->manager->getTodayUserTermsForBox($this->box_nr));
    95         if (($this->box_nr === Flashcard\FlashcardBox::FIRST_BOX
    96                 && !$this->manager->getAllTermsWithoutEntry()
    97                 && !$this->manager->getNonTodayUserTermsForBox($this->box_nr)
    98                 && $this->manager->getTodayUserTermsForBox($this->box_nr))
    99             || ($this->box_nr !== Flashcard\FlashcardBox::FIRST_BOX
   100                 && !$this->manager->getNonTodayUserTermsForBox($this->box_nr)
   101                 && $this->manager->getTodayUserTermsForBox($this->box_nr))) {
   102             $all_button = $this->ui_fac->button()->standard(
   103                 sprintf($this->
lng->txt(
"glo_use_all_flashcards"), $cnt_all),
   104                 $this->
ctrl->getLinkTarget($this, 
"showAllItems")
   106             $cbox = $this->ui_fac->messageBox()->info(
   107                 sprintf($this->
lng->txt(
"glo_flashcards_from_today_only_info"), $cnt_all)
   108             )->withButtons([$all_button]);
   109             $this->tpl->setContent($this->ui_ren->render($cbox));
   110         } elseif ($this->manager->getTodayUserTermsForBox($this->box_nr)) {
   111             $remaining_button = $this->ui_fac->button()->standard(
   112                 sprintf($this->
lng->txt(
"glo_use_remaining_flashcards"), $cnt_remaining),
   113                 $this->
ctrl->getLinkTarget($this, 
"showRemainingItems")
   115             $all_button = $this->ui_fac->button()->standard(
   116                 sprintf($this->
lng->txt(
"glo_use_all_flashcards"), $cnt_all),
   117                 $this->
ctrl->getLinkTarget($this, 
"showAllItems")
   119             $cbox = $this->ui_fac->messageBox()->info(
   120                 sprintf($this->
lng->txt(
"glo_flashcards_from_today_confirmation"), $cnt_today, $cnt_remaining, $cnt_all)
   121             )->withButtons([$remaining_button, $all_button]);
   122             $this->tpl->setContent($this->ui_ren->render($cbox));
   141             $terms = $this->manager->getUserTermsForBox($this->box_nr);
   143             $terms = $this->manager->getNonTodayUserTermsForBox($this->box_nr);
   145         if ($this->box_nr === Flashcard\FlashcardBox::FIRST_BOX) {
   146             $terms_without_entry = $this->manager->getAllTermsWithoutEntry();
   147             $terms = array_merge($terms_without_entry, $terms);
   149         $this->manager->setSessionInitialTerms($this->box_nr, $terms);
   150         $this->manager->setSessionTerms($this->box_nr, $terms);
   151         $this->manager->createOrUpdateBoxAccessEntry($this->box_nr);
   152         $this->
ctrl->redirect($this, 
"showHidden");
   159         if ($this->glossary->getFlashcardsMode() === 
"term") {
   160             $flashcard = $this->ui_fac->panel()->standard(
   161                 sprintf($this->
lng->txt(
"glo_what_means_term"), $this->
getTermText()),
   162                 $this->ui_fac->legacy(
"???")
   165             $flashcard = $this->ui_fac->panel()->standard(
   166                 $this->
lng->txt(
"glo_what_means_definition"),
   171         $btn_show = $this->ui_fac->button()->standard(
   172             $this->
lng->txt(
"glo_check"),
   173             $this->
ctrl->getLinkTarget($this, 
"showRevealed")
   176         $btn_quit = $this->ui_fac->button()->standard(
   177             $this->
lng->txt(
"glo_quit_box"),
   178             $this->
ctrl->getLinkTargetByClass(
"ilglossarypresentationgui", 
"showFlashcards")
   181         $html = $this->ui_ren->render($flashcard)
   182             . $this->ui_ren->render($btn_show)
   183             . $this->ui_ren->render($btn_quit);
   184         $this->tpl->setContent($html);
   191         $flashcard = $this->ui_fac->panel()->standard(
   193             $this->ui_fac->legacy($this->getDefinitionPage())
   196         $btn_correct = $this->ui_fac->button()->standard(
   197             $this->
lng->txt(
"glo_answered_correctly"),
   198             $this->
ctrl->getLinkTarget($this, 
"answerCorrectly")
   201         $btn_not_correct = $this->ui_fac->button()->standard(
   202             $this->
lng->txt(
"glo_answered_not_correctly"),
   203             $this->
ctrl->getLinkTarget($this, 
"answerIncorrectly")
   206         $html = $this->ui_ren->render($flashcard)
   207             . $this->ui_ren->render($btn_correct)
   208             . $this->ui_ren->render($btn_not_correct);
   209         $this->tpl->setContent($html);
   214         $this->tpl->setTitle($this->glossary->getTitle() . 
": " . $this->
lng->txt(
"glo_box") . 
" " . 
$this->box_nr);
   216         $current_cnt = (count($this->initial_terms_in_box) - count($this->terms_in_box)) + 1;
   217         $all_cnt = count($this->initial_terms_in_box);
   218         $progress_txt = sprintf($this->
lng->txt(
"glo_flashcards_progress"), $current_cnt, $all_cnt);
   219         $this->tpl->setDescription($progress_txt);
   232     public function answer(
bool $correct): void
   234         $this->manager->createOrUpdateUserTermEntry($this->current_term?->getTermId(), $correct);
   235         array_shift($this->terms_in_box);
   236         $this->manager->setSessionTerms($this->box_nr, $this->terms_in_box);
   237         if ($this->terms_in_box) {
   238             $this->
ctrl->redirect($this, 
"showHidden");
   240         $this->tpl->setOnScreenMessage(
"success", $this->
lng->txt(
"glo_box_completed"), 
true);
   241         $this->
ctrl->redirectByClass(
"ilglossarypresentationgui", 
"showFlashcards");
   253         return $page_gui->showPage();
 
Presentation PresentationGUIRequest $request
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
Flashcard Term $current_term
 
GUI class for glossary flashcard boxes. 
 
Flashcard FlashcardManager $manager
 
setFlashcardTitleAndDescription()
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
array $initial_terms_in_box
 
static _lookGlossaryTerm(int $term_id)
get glossary term 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
ilGlobalTemplateInterface $tpl
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...