ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAssLacLegendGUI.php
Go to the documentation of this file.
1 <?php
2 
24 {
26  protected $lng;
28  protected $pageTemplate;
30  private $questionOBJ;
33  'assQuestion' => ['PercentageResultExpression', 'EmptyAnswerExpression'],
34  'assSingleChoice' => ['NumberOfResultExpression'],
35  'assMultipleChoice' => ['NumberOfResultExpression', 'ExclusiveResultExpression'],
36  'assErrorText' => ['NumberOfResultExpression', 'ExclusiveResultExpression'],
37  'assImagemapQuestion' => ['NumberOfResultExpression', 'ExclusiveResultExpression'],
38  'assNumeric' => ['NumericResultExpression'],
39  'assOrderingQuestion' => ['OrderingResultExpression'],
40  'assOrderingHorizontal' => ['OrderingResultExpression'],
41  'assMatchingQuestion' => ['MatchingResultExpression'],
42  'assTextSubset' => ['StringResultExpression'],
43  'assFormulaQuestion' => ['NumericResultExpression'],
44  'assClozeTest' => [
45  'StringResultExpression_1', 'StringResultExpression_2',
46  'NumberOfResultExpression', 'NumericResultExpression'
47  ],
48  ];
50  private $uiFactory;
51 
58  public function __construct(
62  ) {
63  $this->pageTemplate = $pageTemplate;
64  $this->lng = $lng;
65  $this->uiFactory = $uiFactory;
66  $this->questionOBJ = null;
67  }
68 
72  public function getQuestionOBJ(): ?iQuestionCondition
73  {
74  return $this->questionOBJ;
75  }
76 
77  public function setQuestionOBJ(assQuestion $questionOBJ): void
78  {
79  $this->questionOBJ = $questionOBJ;
80  }
81 
85  public function get(): \ILIAS\UI\Component\Modal\Modal
86  {
87  $this->pageTemplate->addCss('Modules/TestQuestionPool/templates/default/lac_legend.css');
88 
89  $tpl = $this->getTemplate();
90 
94 
95  return $this->uiFactory->modal()->lightbox([
96  $this->uiFactory->modal()->lightboxTextPage(
97  $tpl->get(),
98  $this->lng->txt('qpl_skill_point_eval_by_solution_compare')
99  ),
100  ]);
101  }
102 
107  protected function getTemplate(): ilTemplate
108  {
109  return new ilTemplate(
110  'tpl.qpl_logical_answer_compare_legend.html',
111  true,
112  true,
113  'Modules/TestQuestionPool'
114  );
115  }
116 
120  private function renderCommonLegendPart(ilTemplate $tpl): void
121  {
122  $tpl->setVariable(
123  'COMMON_ELEMENTS_HEADER',
124  $this->lng->txt('qpl_lac_legend_header_common')
125  );
126 
127  foreach ($this->getCommonElements() as $element => $description) {
128  $tpl->setCurrentBlock('common_elements');
129  $tpl->setVariable('CE_ELEMENT', $element);
130  $tpl->setVariable('CE_DESCRIPTION', $description);
131  $tpl->parseCurrentBlock();
132  }
133  }
134 
139  {
140  $tpl->setVariable(
141  'QUEST_SPECIFIC_ELEMENTS_HEADER',
142  $this->lng->txt('qpl_lac_legend_header_quest_specific')
143  );
144 
145  foreach ($this->getQuestionTypeSpecificExpressions() as $expression => $description) {
146  $tpl->setCurrentBlock('quest_specific_elements');
147  $tpl->setVariable('QSE_ELEMENT', $expression);
148  $tpl->setVariable('QSE_DESCRIPTION', $this->lng->txt($description));
149  $tpl->setVariable('QSE_OPERATORS_TXT', $this->lng->txt('qpl_lac_legend_label_operators'));
150  $tpl->setVariable('QSE_OPERATORS', implode(', ', $this->getQuestionOBJ()->getOperators($expression)));
151  $tpl->parseCurrentBlock();
152  }
153  }
154 
159  {
160  $tpl->setVariable(
161  'QUEST_SPECIFIC_EXAMPLES_HEADER',
162  $this->lng->txt('lacex_example_header')
163  );
164 
165  $questionTypes = [
166  'assQuestion', $this->getQuestionOBJ()->getQuestionType()
167  ];
168 
169  foreach ($questionTypes as $questionType) {
170  $examples = $this->getExpressionTypeExamplesByQuestionType($questionType);
171  $this->renderExamples($tpl, $examples, $questionType);
172  }
173  }
174 
180  private function buildLangVarsByExampleCode(string $questionType, string $exampleCode): array
181  {
182  $langVar = 'lacex_' . $questionType . '_' . $exampleCode;
183 
184  return [$langVar . '_e', $langVar . '_d'];
185  }
186 
192  private function renderExample(ilTemplate $tpl, string $langVarE, string $langVarD): void
193  {
194  $tpl->setCurrentBlock('quest_specific_examples');
195  $tpl->setVariable('QSEX_ELEMENT', $this->lng->txt($langVarE));
196  $tpl->setVariable('QSEX_DESCRIPTION', $this->lng->txt($langVarD));
197  $tpl->parseCurrentBlock();
198  }
199 
203  private function getQuestionTypeSpecificExpressions(): array
204  {
205  $availableExpressionTypes = $this->getAvailableExpressionTypes();
206 
207  $expressionTypes = [];
208 
209  foreach ($this->getQuestionOBJ()->getExpressionTypes() as $expressionType) {
210  $expressionTypes[$expressionType] = $availableExpressionTypes[$expressionType];
211  }
212 
213  return $expressionTypes;
214  }
215 
219  private function getCommonElements(): array
220  {
221  return [
222  '&' => $this->lng->txt('qpl_lac_desc_logical_and'),
223  '|' => $this->lng->txt('qpl_lac_desc_logical_or'),
224  '!' => $this->lng->txt('qpl_lac_desc_negation'),
225  '()' => $this->lng->txt('qpl_lac_desc_brackets'),
226  //'Qn' => $this->lng->txt('qpl_lac_desc_res_of_quest_n'),
227  //'Qn[m]' => $this->lng->txt('qpl_lac_desc_res_of_answ_m_of_quest_n'),
228  'R' => $this->lng->txt('qpl_lac_desc_res_of_cur_quest'),
229  'R[m]' => $this->lng->txt('qpl_lac_desc_res_of_answ_m_of_cur_quest')
230  ];
231  }
232 
236  private function getAvailableExpressionTypes(): array
237  {
238  return [
239  iQuestionCondition::PercentageResultExpression => 'qpl_lac_desc_compare_with_quest_res',
240  iQuestionCondition::NumericResultExpression => 'qpl_lac_desc_compare_with_number',
241  iQuestionCondition::StringResultExpression => 'qpl_lac_desc_compare_with_text',
242  iQuestionCondition::MatchingResultExpression => 'qpl_lac_desc_compare_with_assignment',
243  iQuestionCondition::OrderingResultExpression => 'qpl_lac_desc_compare_with_sequence',
244  iQuestionCondition::NumberOfResultExpression => 'qpl_lac_desc_compare_with_answer_n',
245  iQuestionCondition::ExclusiveResultExpression => 'qpl_lac_desc_compare_with_exact_sequence',
246  iQuestionCondition::EmptyAnswerExpression => 'qpl_lac_desc_compare_answer_exist'
247  ];
248  }
249 
254  private function getExpressionTypeExamplesByQuestionType(string $questionType): array
255  {
256  if (!isset($this->examplesByQuestionType[$questionType])) {
257  return [];
258  }
259 
260  return $this->examplesByQuestionType[$questionType];
261  }
262 
268  private function renderExamples(ilTemplate $tpl, array $examples, string $questionType): void
269  {
270  foreach ($examples as $exampleCode) {
271  list($langVarE, $langVarD) = $this->buildLangVarsByExampleCode($questionType, $exampleCode);
272  $this->renderExample($tpl, $langVarE, $langVarD);
273  }
274  }
275 }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
renderExample(ilTemplate $tpl, string $langVarE, string $langVarD)
buildLangVarsByExampleCode(string $questionType, string $exampleCode)
Class Factory.
Abstract basic class which is to be extended by the concrete assessment question type classes...
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
renderCommonLegendPart(ilTemplate $tpl)
renderQuestSpecificExamples(ilTemplate $tpl)
setQuestionOBJ(assQuestion $questionOBJ)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
__construct(ilGlobalTemplateInterface $pageTemplate, ilLanguage $lng, \ILIAS\UI\Factory $uiFactory)
ilAssLacLegendGUI constructor.
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
getExpressionTypeExamplesByQuestionType(string $questionType)
renderExamples(ilTemplate $tpl, array $examples, string $questionType)
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
renderQuestSpecificLegendPart(ilTemplate $tpl)