ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilGlossaryFlashcardBoxGUI Class Reference

GUI class for glossary flashcard boxes. More...

+ Collaboration diagram for ilGlossaryFlashcardBoxGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 show ()
 
 showAllItems ()
 
 showRemainingItems ()
 
 showItems (bool $all)
 
 showHidden ()
 
 showRevealed ()
 
 answerCorrectly ()
 
 answerInCorrectly ()
 
 answer (bool $correct)
 

Protected Member Functions

 getTermText ()
 
 getDefinitionPage ()
 

Protected Attributes

ilCtrl $ctrl
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
UI Factory $ui_fac
 
UI Renderer $ui_ren
 
Presentation PresentationGUIRequest $request
 
Flashcard FlashcardManager $manager
 
int $box_nr = 0
 
array $initial_terms_in_box = []
 
array $terms_in_box = []
 
int $current_term_id = 0
 
ilObjGlossary $glossary
 

Detailed Description

GUI class for glossary flashcard boxes.

Author
Thomas Famula famul.nosp@m.a@le.nosp@m.ifos..nosp@m.de

Definition at line 29 of file class.ilGlossaryFlashcardBoxGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilGlossaryFlashcardBoxGUI::__construct ( )

Definition at line 44 of file class.ilGlossaryFlashcardBoxGUI.php.

References $DIC, ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

45  {
46  global $DIC;
47 
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()
54  ->internal()
55  ->gui()
56  ->presentation()
57  ->request();
58  $gs = $DIC->glossary()->internal();
59  $this->manager = $gs->domain()->flashcard($this->request->getRefId());
60 
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_id = $this->terms_in_box[0] ?? 0;
66  $this->glossary = new ilObjGlossary($this->request->getRefId());
67  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ answer()

ilGlossaryFlashcardBoxGUI::answer ( bool  $correct)

Definition at line 240 of file class.ilGlossaryFlashcardBoxGUI.php.

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by answerCorrectly(), and answerInCorrectly().

240  : void
241  {
242  $this->manager->createOrUpdateUserTermEntry($this->current_term_id, $correct);
243  array_shift($this->terms_in_box);
244  $this->manager->setSessionTerms($this->box_nr, $this->terms_in_box);
245  if ($this->terms_in_box) {
246  $this->ctrl->redirect($this, "showHidden");
247  }
248  $this->tpl->setOnScreenMessage("success", $this->lng->txt("glo_box_completed"), true);
249  $this->ctrl->redirectByClass("ilglossarypresentationgui", "showFlashcards");
250  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ answerCorrectly()

ilGlossaryFlashcardBoxGUI::answerCorrectly ( )

Definition at line 230 of file class.ilGlossaryFlashcardBoxGUI.php.

References answer().

230  : void
231  {
232  $this->answer(true);
233  }
+ Here is the call graph for this function:

◆ answerInCorrectly()

ilGlossaryFlashcardBoxGUI::answerInCorrectly ( )

Definition at line 235 of file class.ilGlossaryFlashcardBoxGUI.php.

References answer().

235  : void
236  {
237  $this->answer(false);
238  }
+ Here is the call graph for this function:

◆ executeCommand()

ilGlossaryFlashcardBoxGUI::executeCommand ( )

Definition at line 69 of file class.ilGlossaryFlashcardBoxGUI.php.

References ILIAS\Repository\ctrl().

69  : void
70  {
71  $next_class = $this->ctrl->getNextClass($this);
72  $cmd = $this->ctrl->getCmd();
73 
74  switch ($next_class) {
75  default:
76  $cmd = $this->ctrl->getCmd("show");
77  $ret = $this->$cmd();
78  break;
79  }
80  }
+ Here is the call graph for this function:

◆ getDefinitionPage()

ilGlossaryFlashcardBoxGUI::getDefinitionPage ( )
protected

Definition at line 258 of file class.ilGlossaryFlashcardBoxGUI.php.

Referenced by showHidden(), and showRevealed().

258  : string
259  {
260  $page_gui = new ilGlossaryDefPageGUI($this->current_term_id);
261  return $page_gui->showPage();
262  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ getTermText()

ilGlossaryFlashcardBoxGUI::getTermText ( )
protected

Definition at line 252 of file class.ilGlossaryFlashcardBoxGUI.php.

References ilGlossaryTerm\_lookGlossaryTerm().

Referenced by showHidden(), and showRevealed().

252  : string
253  {
254  $text = ilGlossaryTerm::_lookGlossaryTerm($this->current_term_id);
255  return $text;
256  }
static _lookGlossaryTerm(int $term_id)
get glossary term
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ show()

ilGlossaryFlashcardBoxGUI::show ( )

Definition at line 82 of file class.ilGlossaryFlashcardBoxGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and showAllItems().

82  : void
83  {
84  if ($this->box_nr === Flashcard\FlashcardBox::FIRST_BOX) {
85  $cnt_all = count($this->manager->getUserTermIdsForBox($this->box_nr))
86  + count($this->manager->getAllTermsWithoutEntry());
87  $cnt_remaining = count($this->manager->getNonTodayUserTermIdsForBox($this->box_nr))
88  + count($this->manager->getAllTermsWithoutEntry());
89  } else {
90  $cnt_all = count($this->manager->getUserTermIdsForBox($this->box_nr));
91  $cnt_remaining = count($this->manager->getNonTodayUserTermIdsForBox($this->box_nr));
92  }
93  $cnt_today = count($this->manager->getTodayUserTermIdsForBox($this->box_nr));
94 
95  if (($this->box_nr === Flashcard\FlashcardBox::FIRST_BOX
96  && !$this->manager->getAllTermsWithoutEntry()
97  && !$this->manager->getNonTodayUserTermIdsForBox($this->box_nr)
98  && $this->manager->getTodayUserTermIdsForBox($this->box_nr))
99  || ($this->box_nr !== Flashcard\FlashcardBox::FIRST_BOX
100  && !$this->manager->getNonTodayUserTermIdsForBox($this->box_nr)
101  && $this->manager->getTodayUserTermIdsForBox($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")
105  );
106  $cbox = $this->ui_fac->messageBox()->confirmation(
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->getTodayUserTermIdsForBox($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")
114  );
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")
118  );
119  $cbox = $this->ui_fac->messageBox()->confirmation(
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));
123  } else {
124  $this->showAllItems();
125  }
126  }
+ Here is the call graph for this function:

◆ showAllItems()

ilGlossaryFlashcardBoxGUI::showAllItems ( )

Definition at line 128 of file class.ilGlossaryFlashcardBoxGUI.php.

References showItems().

Referenced by show().

128  : void
129  {
130  $this->showItems(true);
131  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showHidden()

ilGlossaryFlashcardBoxGUI::showHidden ( )

Definition at line 155 of file class.ilGlossaryFlashcardBoxGUI.php.

References $box_nr, ILIAS\Repository\ctrl(), getDefinitionPage(), ilProgressBar\getInstance(), getTermText(), and ILIAS\Repository\lng().

155  : void
156  {
157  $this->tpl->setDescription($this->lng->txt("glo_box") . " " . $this->box_nr);
158 
159  $progress = $this->manager->getBoxProgress($this->terms_in_box, $this->initial_terms_in_box);
160  $progress_bar = ilProgressBar::getInstance();
161  $progress_bar->setCurrent($progress);
162 
163  if ($this->glossary->getFlashcardsMode() === "term") {
164  $flashcard = $this->ui_fac->panel()->standard(
165  $this->lng->txt("term") . ": " . $this->getTermText(),
166  $this->ui_fac->legacy("???")
167  );
168  } else {
169  $flashcard = $this->ui_fac->panel()->standard(
170  $this->lng->txt("term") . ": ???",
171  $this->ui_fac->legacy($this->getDefinitionPage())
172  );
173  }
174 
175  if ($this->glossary->getFlashcardsMode() === "term") {
176  $btn_show = $this->ui_fac->button()->standard(
177  $this->lng->txt("glo_show_definition"),
178  $this->ctrl->getLinkTarget($this, "showRevealed")
179  );
180  } else {
181  $btn_show = $this->ui_fac->button()->standard(
182  $this->lng->txt("glo_show_term"),
183  $this->ctrl->getLinkTarget($this, "showRevealed")
184  );
185  }
186 
187  $btn_quit = $this->ui_fac->button()->standard(
188  $this->lng->txt("glo_quit_box"),
189  $this->ctrl->getLinkTargetByClass("ilglossarypresentationgui", "showFlashcards")
190  );
191 
192  $html = $progress_bar->render()
193  . $this->ui_ren->render($flashcard)
194  . $this->ui_ren->render($btn_show)
195  . $this->ui_ren->render($btn_quit);
196  $this->tpl->setContent($html);
197  }
+ Here is the call graph for this function:

◆ showItems()

ilGlossaryFlashcardBoxGUI::showItems ( bool  $all)

Definition at line 138 of file class.ilGlossaryFlashcardBoxGUI.php.

References ILIAS\Repository\ctrl().

Referenced by showAllItems(), and showRemainingItems().

138  : void
139  {
140  if ($all) {
141  $terms = $this->manager->getUserTermIdsForBox($this->box_nr);
142  } else {
143  $terms = $this->manager->getNonTodayUserTermIdsForBox($this->box_nr);
144  }
145  if ($this->box_nr === Flashcard\FlashcardBox::FIRST_BOX) {
146  $terms_without_entry = $this->manager->getAllTermsWithoutEntry();
147  $terms = array_merge($terms_without_entry, $terms);
148  }
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");
153  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showRemainingItems()

ilGlossaryFlashcardBoxGUI::showRemainingItems ( )

Definition at line 133 of file class.ilGlossaryFlashcardBoxGUI.php.

References showItems().

133  : void
134  {
135  $this->showItems(false);
136  }
+ Here is the call graph for this function:

◆ showRevealed()

ilGlossaryFlashcardBoxGUI::showRevealed ( )

Definition at line 199 of file class.ilGlossaryFlashcardBoxGUI.php.

References $box_nr, ILIAS\Repository\ctrl(), getDefinitionPage(), ilProgressBar\getInstance(), getTermText(), and ILIAS\Repository\lng().

199  : void
200  {
201  $this->tpl->setDescription($this->lng->txt("glo_box") . " " . $this->box_nr);
202 
203 
204  $progress = $this->manager->getBoxProgress($this->terms_in_box, $this->initial_terms_in_box);
205  $progress_bar = ilProgressBar::getInstance();
206  $progress_bar->setCurrent($progress);
207 
208  $flashcard = $this->ui_fac->panel()->standard(
209  $this->lng->txt("term") . ": " . $this->getTermText(),
210  $this->ui_fac->legacy($this->getDefinitionPage())
211  );
212 
213  $btn_correct = $this->ui_fac->button()->standard(
214  $this->lng->txt("glo_answered_correctly"),
215  $this->ctrl->getLinkTarget($this, "answerCorrectly")
216  );
217 
218  $btn_not_correct = $this->ui_fac->button()->standard(
219  $this->lng->txt("glo_answered_not_correctly"),
220  $this->ctrl->getLinkTarget($this, "answerInCorrectly")
221  );
222 
223  $html = $progress_bar->render()
224  . $this->ui_ren->render($flashcard)
225  . $this->ui_ren->render($btn_correct)
226  . $this->ui_ren->render($btn_not_correct);
227  $this->tpl->setContent($html);
228  }
+ Here is the call graph for this function:

Field Documentation

◆ $box_nr

int ilGlossaryFlashcardBoxGUI::$box_nr = 0
protected

Definition at line 38 of file class.ilGlossaryFlashcardBoxGUI.php.

Referenced by showHidden(), and showRevealed().

◆ $ctrl

ilCtrl ilGlossaryFlashcardBoxGUI::$ctrl
protected

Definition at line 31 of file class.ilGlossaryFlashcardBoxGUI.php.

◆ $current_term_id

int ilGlossaryFlashcardBoxGUI::$current_term_id = 0
protected

Definition at line 41 of file class.ilGlossaryFlashcardBoxGUI.php.

◆ $glossary

ilObjGlossary ilGlossaryFlashcardBoxGUI::$glossary
protected

Definition at line 42 of file class.ilGlossaryFlashcardBoxGUI.php.

◆ $initial_terms_in_box

array ilGlossaryFlashcardBoxGUI::$initial_terms_in_box = []
protected

Definition at line 39 of file class.ilGlossaryFlashcardBoxGUI.php.

◆ $lng

ilLanguage ilGlossaryFlashcardBoxGUI::$lng
protected

Definition at line 32 of file class.ilGlossaryFlashcardBoxGUI.php.

◆ $manager

Flashcard FlashcardManager ilGlossaryFlashcardBoxGUI::$manager
protected

Definition at line 37 of file class.ilGlossaryFlashcardBoxGUI.php.

◆ $request

Presentation PresentationGUIRequest ilGlossaryFlashcardBoxGUI::$request
protected

Definition at line 36 of file class.ilGlossaryFlashcardBoxGUI.php.

◆ $terms_in_box

array ilGlossaryFlashcardBoxGUI::$terms_in_box = []
protected

Definition at line 40 of file class.ilGlossaryFlashcardBoxGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilGlossaryFlashcardBoxGUI::$tpl
protected

Definition at line 33 of file class.ilGlossaryFlashcardBoxGUI.php.

◆ $ui_fac

UI Factory ilGlossaryFlashcardBoxGUI::$ui_fac
protected

Definition at line 34 of file class.ilGlossaryFlashcardBoxGUI.php.

◆ $ui_ren

UI Renderer ilGlossaryFlashcardBoxGUI::$ui_ren
protected

Definition at line 35 of file class.ilGlossaryFlashcardBoxGUI.php.


The documentation for this class was generated from the following file: