ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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

 setFlashcardTitleAndDescription ()
 
 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 = []
 
Flashcard Term $current_term
 
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(), ILIAS\Repository\lng(), and null.

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 = $this->terms_in_box[0] ?? null;
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...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ answer()

ilGlossaryFlashcardBoxGUI::answer ( bool  $correct)

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

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

Referenced by answerCorrectly(), and answerIncorrectly().

232  : void
233  {
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");
239  }
240  $this->tpl->setOnScreenMessage("success", $this->lng->txt("glo_box_completed"), true);
241  $this->ctrl->redirectByClass("ilglossarypresentationgui", "showFlashcards");
242  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ answerCorrectly()

ilGlossaryFlashcardBoxGUI::answerCorrectly ( )

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

References answer().

222  : void
223  {
224  $this->answer(true);
225  }
+ Here is the call graph for this function:

◆ answerIncorrectly()

ilGlossaryFlashcardBoxGUI::answerIncorrectly ( )

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

References answer().

227  : void
228  {
229  $this->answer(false);
230  }
+ 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 250 of file class.ilGlossaryFlashcardBoxGUI.php.

Referenced by showHidden(), and showRevealed().

250  : string
251  {
252  $page_gui = new ilGlossaryDefPageGUI($this->current_term?->getTermId());
253  return $page_gui->showPage();
254  }
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 244 of file class.ilGlossaryFlashcardBoxGUI.php.

References ilGlossaryTerm\_lookGlossaryTerm().

Referenced by showHidden(), and showRevealed().

244  : string
245  {
246  $text = ilGlossaryTerm::_lookGlossaryTerm($this->current_term?->getTermId());
247  return $text;
248  }
static _lookGlossaryTerm(int $term_id)
get glossary term
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setFlashcardTitleAndDescription()

ilGlossaryFlashcardBoxGUI::setFlashcardTitleAndDescription ( )
protected

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

References $box_nr, and ILIAS\Repository\lng().

Referenced by showHidden(), and showRevealed().

212  : void
213  {
214  $this->tpl->setTitle($this->glossary->getTitle() . ": " . $this->lng->txt("glo_box") . " " . $this->box_nr);
215 
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);
220  }
+ 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->getUserTermsForBox($this->box_nr))
86  + count($this->manager->getAllTermsWithoutEntry());
87  $cnt_remaining = count($this->manager->getNonTodayUserTermsForBox($this->box_nr))
88  + count($this->manager->getAllTermsWithoutEntry());
89  } else {
90  $cnt_all = count($this->manager->getUserTermsForBox($this->box_nr));
91  $cnt_remaining = count($this->manager->getNonTodayUserTermsForBox($this->box_nr));
92  }
93  $cnt_today = count($this->manager->getTodayUserTermsForBox($this->box_nr));
94 
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")
105  );
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")
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()->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));
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 ILIAS\Repository\ctrl(), getDefinitionPage(), getTermText(), ILIAS\Repository\lng(), and setFlashcardTitleAndDescription().

155  : void
156  {
158 
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()->content("???")
163  );
164  } else {
165  $flashcard = $this->ui_fac->panel()->standard(
166  $this->lng->txt("glo_what_means_definition"),
167  $this->ui_fac->legacy()->content($this->getDefinitionPage())
168  );
169  }
170 
171  $btn_show = $this->ui_fac->button()->standard(
172  $this->lng->txt("glo_check"),
173  $this->ctrl->getLinkTarget($this, "showRevealed")
174  );
175 
176  $btn_quit = $this->ui_fac->button()->standard(
177  $this->lng->txt("glo_quit_box"),
178  $this->ctrl->getLinkTargetByClass("ilglossarypresentationgui", "showFlashcards")
179  );
180 
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);
185  }
+ 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->getUserTermsForBox($this->box_nr);
142  } else {
143  $terms = $this->manager->getNonTodayUserTermsForBox($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 187 of file class.ilGlossaryFlashcardBoxGUI.php.

References ILIAS\Repository\ctrl(), getDefinitionPage(), getTermText(), ILIAS\Repository\lng(), and setFlashcardTitleAndDescription().

187  : void
188  {
190 
191  $flashcard = $this->ui_fac->panel()->standard(
192  $this->getTermText(),
193  $this->ui_fac->legacy()->content($this->getDefinitionPage())
194  );
195 
196  $btn_correct = $this->ui_fac->button()->standard(
197  $this->lng->txt("glo_answered_correctly"),
198  $this->ctrl->getLinkTarget($this, "answerCorrectly")
199  );
200 
201  $btn_not_correct = $this->ui_fac->button()->standard(
202  $this->lng->txt("glo_answered_not_correctly"),
203  $this->ctrl->getLinkTarget($this, "answerIncorrectly")
204  );
205 
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);
210  }
+ 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 setFlashcardTitleAndDescription().

◆ $ctrl

ilCtrl ilGlossaryFlashcardBoxGUI::$ctrl
protected

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

◆ $current_term

Flashcard Term ilGlossaryFlashcardBoxGUI::$current_term
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: