ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\Test\Questions\Presentation\Printer Class Reference
+ Collaboration diagram for ILIAS\Test\Questions\Presentation\Printer:

Public Member Functions

 __construct (private readonly UIFactory $ui_factory, private \ilGlobalTemplateInterface $tpl, private TabsManager $tabs_manager, private \ilToolbarGUI $toolbar, private readonly Refinery $refinery, private readonly Language $lng, private readonly \ilCtrl $ctrl, private readonly \ilObjUser $user, private readonly \ilTestQuestionHeaderBlockBuilder $question_header_builder, private readonly \ilObjTest $test_obj,)
 
 printSelectedQuestions (array $print_view_types, ?Types $selected_print_view_type, array $question_ids)
 
 printAnswers (int $question_id)
 

Private Member Functions

 addQuestionResultForTestUsersToTemplate (\ilTemplate $template, \assQuestionGUI $question_gui, int $test_id)
 
 addResultUserInfoToTemplate (\ilTemplate $template, int $active_id, int $pass)
 
 addPrintButtonToToolbar ()
 

Detailed Description

Definition at line 29 of file Printer.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Test\Questions\Presentation\Printer::__construct ( private readonly UIFactory  $ui_factory,
private \ilGlobalTemplateInterface  $tpl,
private TabsManager  $tabs_manager,
private \ilToolbarGUI  $toolbar,
private readonly Refinery  $refinery,
private readonly Language  $lng,
private readonly \ilCtrl  $ctrl,
private readonly \ilObjUser  $user,
private readonly \ilTestQuestionHeaderBlockBuilder  $question_header_builder,
private readonly \ilObjTest  $test_obj 
)
Parameters
array$data<string, mixed>

Definition at line 34 of file Printer.php.

45  {
46  }

Member Function Documentation

◆ addPrintButtonToToolbar()

ILIAS\Test\Questions\Presentation\Printer::addPrintButtonToToolbar ( )
private

Definition at line 230 of file Printer.php.

References $id, ILIAS\Repository\lng(), ILIAS\Repository\toolbar(), and ILIAS\UI\Implementation\Component\withOnLoadCode().

Referenced by ILIAS\Test\Questions\Presentation\Printer\printAnswers(), and ILIAS\Test\Questions\Presentation\Printer\printSelectedQuestions().

230  : void
231  {
232  $this->toolbar->addComponent(
233  $this->ui_factory->button()->standard($this->lng->txt('print'), '')
234  ->withOnLoadCode(fn($id) => "$('#$id').on('click', ()=>{window.print();})")
235  );
236  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addQuestionResultForTestUsersToTemplate()

ILIAS\Test\Questions\Presentation\Printer::addQuestionResultForTestUsersToTemplate ( \ilTemplate  $template,
\assQuestionGUI  $question_gui,
int  $test_id 
)
private

Definition at line 155 of file Printer.php.

References ilObjTest\_getResultPass(), ILIAS\Test\Questions\Presentation\Printer\addResultUserInfoToTemplate(), assQuestionGUI\getObject(), assQuestionGUI\getSolutionOutput(), null, ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

Referenced by ILIAS\Test\Questions\Presentation\Printer\printAnswers().

159  : \ilTemplate {
160  $this->test_obj->setAccessFilteredParticipantList(
161  $this->test_obj->buildStatisticsAccessFilteredParticipantList()
162  );
163 
164  $foundusers = $this->test_obj->getParticipantsForTestAndQuestion(
165  $test_id,
166  $question_gui->getObject()->getId()
167  );
168 
169  foreach ($foundusers as $active_id => $passes) {
170  if (($resultpass = \ilObjTest::_getResultPass($active_id)) === null) {
171  continue;
172  }
173 
174  for ($i = 0; $i < count($passes); $i++) {
175  if ($passes[$i]['pass'] !== $resultpass) {
176  continue;
177  }
178 
179  $template->setCurrentBlock('question');
180  $template = $this->addResultUserInfoToTemplate(
181  $template,
182  $active_id,
183  $resultpass + 1
184  );
185  $template->setVariable(
186  'SOLUTION_OUTPUT',
187  $question_gui->getSolutionOutput(
188  $active_id,
189  $resultpass,
190  false,
191  false,
192  false,
193  false
194  )
195  );
196  $template->parseCurrentBlock('question');
197  }
198  }
199  return $template;
200  }
addResultUserInfoToTemplate(\ilTemplate $template, int $active_id, int $pass)
Definition: Printer.php:202
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _getResultPass($active_id)
Retrieves the pass number that should be counted for a given user.
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addResultUserInfoToTemplate()

ILIAS\Test\Questions\Presentation\Printer::addResultUserInfoToTemplate ( \ilTemplate  $template,
int  $active_id,
int  $pass 
)
private

Definition at line 202 of file Printer.php.

References $user_id, ilObjUser\_lookupLogin(), ILIAS\Repository\lng(), ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

Referenced by ILIAS\Test\Questions\Presentation\Printer\addQuestionResultForTestUsersToTemplate().

206  : \ilTemplate {
207  $user_id = $this->test_obj->_getUserIdFromActiveId($active_id);
208  if (\ilObjUser::_lookupLogin($user_id) !== '') {
209  $user = new \ilObjUser($user_id);
210  } else {
211  $user = new \ilObjUser();
212  $user->setLastname($this->lng->txt('deleted_user'));
213  }
214  if ($user->getMatriculation() !== ''
215  && $this->test_obj->getAnonymity() === false) {
216  $template->setCurrentBlock('matriculation');
217  $template->setVariable('TXT_USR_MATRIC', $this->lng->txt('matriculation'));
218  $template->setVariable('VALUE_USR_MATRIC', $user->getMatriculation());
219  $template->parseCurrentBlock();
220  }
221 
222  $template->setVariable('TXT_USR_NAME', $this->lng->txt('name'));
223  $uname = $this->test_obj->userLookupFullName($user_id, false);
224  $template->setVariable('VALUE_USR_NAME', $uname);
225  $template->setVariable('TXT_PASS', $this->lng->txt('scored_pass'));
226  $template->setVariable('VALUE_PASS', $pass);
227  return $template;
228  }
special template class to simplify handling of ITX/PEAR
static _lookupLogin(int $a_user_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ printAnswers()

ILIAS\Test\Questions\Presentation\Printer::printAnswers ( int  $question_id)

Definition at line 123 of file Printer.php.

References ILIAS\Test\Questions\Presentation\Printer\addPrintButtonToToolbar(), ILIAS\Test\Questions\Presentation\Printer\addQuestionResultForTestUsersToTemplate(), ILIAS\Repository\ctrl(), ilUtil\getStyleSheetLocation(), ILIAS\Repository\lng(), assQuestionGUI\RENDER_PURPOSE_PREVIEW, ilObjTestGUI\SHOW_QUESTIONS_CMD, and ILIAS\Repository\user().

123  : void
124  {
125  $this->tabs_manager->resetTabsAndAddBacklink(
126  $this->ctrl->getLinkTargetByClass(\ilObjTestGUI::class, \ilObjTestGUI::SHOW_QUESTIONS_CMD)
127  );
128 
129  $this->addPrintButtonToToolbar();
130 
131  $template = new \ilTemplate('tpl.il_as_tst_print_questions_answers.html', true, true, 'components/ILIAS/Test');
132  $this->tpl->addCss(\ilUtil::getStyleSheetLocation('output', 'test_print.css'), 'print');
133 
134  $question_gui = $this->test_obj->createQuestionGUI('', $question_id);
135  $question_gui->setRenderPurpose(\assQuestionGUI::RENDER_PURPOSE_PREVIEW);
136  $template->setVariable('TITLE', $question_gui->getObject()->getTitleForHTMLOutput());
137  $template->setVariable('TXT_PRINT_DATE', $this->lng->txt('date'));
138  $template->setVariable(
139  'VALUE_PRINT_DATE',
140  (new \DateTimeImmutable())
141  ->setTimezone(new \DateTimeZone($this->user->getTimeZone()))
142  ->format($this->user->getDateTimeFormat()->toString())
143  );
144 
145  $this->tpl->setVariable(
146  'PRINT_CONTENT',
148  $template,
149  $question_gui,
150  $this->test_obj->getTestId()
151  )->get()
152  );
153  }
addQuestionResultForTestUsersToTemplate(\ilTemplate $template, \assQuestionGUI $question_gui, int $test_id)
Definition: Printer.php:155
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
+ Here is the call graph for this function:

◆ printSelectedQuestions()

ILIAS\Test\Questions\Presentation\Printer::printSelectedQuestions ( array  $print_view_types,
?Types  $selected_print_view_type,
array  $question_ids 
)
Parameters
array<int>$question_ids

Definition at line 51 of file Printer.php.

References ILIAS\Test\Questions\Presentation\Printer\addPrintButtonToToolbar(), ILIAS\Repository\ctrl(), ilUtil\getStyleSheetLocation(), ILIAS\Repository\lng(), null, ILIAS\Repository\refinery(), assQuestionGUI\RENDER_PURPOSE_PREVIEW, ilObjTestGUI\SHOW_QUESTIONS_CMD, ILIAS\Repository\toolbar(), and ILIAS\Repository\user().

55  : void {
56  $this->tabs_manager->resetTabsAndAddBacklink(
57  $this->ctrl->getLinkTargetByClass(\ilObjTestGUI::class, \ilObjTestGUI::SHOW_QUESTIONS_CMD)
58  );
59 
60  $this->toolbar->addComponent(
61  $this->ui_factory->viewControl()->mode(
62  $print_view_types,
63  $this->lng->txt('show_hide_best_solution')
64  )->withActive($selected_print_view_type->getLabel($this->lng))
65  );
66 
67  $this->toolbar->addSeparator();
68  $this->addPrintButtonToToolbar();
69 
70  $template = new \ilTemplate('tpl.il_as_tst_print_questions_preview.html', true, true, 'components/ILIAS/Test');
71 
72  $this->tpl->addCss(\ilUtil::getStyleSheetLocation('output', 'test_print.css'), 'print');
73 
74  $max_points = 0;
75  $counter = 1;
76  $this->question_header_builder->setHeaderMode($this->test_obj->getTitleOutput());
77 
78  foreach ($question_ids as $question_id) {
79  $template->setCurrentBlock('question');
80  $question_gui = $this->test_obj->createQuestionGUI('', $question_id);
81  $question_gui->setRenderPurpose(\assQuestionGUI::RENDER_PURPOSE_PREVIEW);
82 
83  $this->question_header_builder->setQuestionTitle($question_gui->getObject()->getTitleForHTMLOutput());
84  $this->question_header_builder->setQuestionPoints($question_gui->getObject()->getMaximumPoints());
85  $this->question_header_builder->setQuestionPosition($counter);
86  $template->setVariable('QUESTION_HEADER', $this->question_header_builder->getHTML());
87 
88  if ($selected_print_view_type === Types::RESULTS_VIEW_TYPE_HIDE) {
89  $template->setVariable('SOLUTION_OUTPUT', $question_gui->getPreview(false));
90  } else {
91  $template->setVariable('TXT_QUESTION_ID', $this->lng->txt('question_id_short'));
92  $template->setVariable('QUESTION_ID', $question_gui->getObject()->getId());
93  $template->setVariable('SOLUTION_OUTPUT', $question_gui->getSolutionOutput(0, null, false, true, false, false));
94  }
95 
96  $template->parseCurrentBlock('question');
97  $counter++;
98  $max_points += $question_gui->getObject()->getMaximumPoints();
99  }
100 
101  $template->setVariable(
102  'TITLE',
103  $this->refinery->encode()->htmlSpecialCharsAsEntities()->transform(
104  $this->test_obj->getTitle()
105  )
106  );
107  $template->setVariable('PRINT_TEST', $this->lng->txt('tst_print'));
108  $template->setVariable('TXT_PRINT_DATE', $this->lng->txt('date'));
109  $template->setVariable(
110  'VALUE_PRINT_DATE',
111  (new \DateTimeImmutable())
112  ->setTimezone(new \DateTimeZone($this->user->getTimeZone()))
113  ->format($this->user->getDateTimeFormat()->toString())
114  );
115  $template->setVariable(
116  'TXT_MAXIMUM_POINTS',
117  $this->lng->txt('tst_maximum_points')
118  );
119  $template->setVariable('VALUE_MAXIMUM_POINTS', $max_points);
120  $this->tpl->setVariable('PRINT_CONTENT', $template->get());
121  }
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

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