ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilAssLacLegendGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
9{
11 protected $lng;
13 protected $pageTemplate;
15 private $questionOBJ;
18 'assQuestion' => ['PercentageResultExpression', 'EmptyAnswerExpression'],
19 'assSingleChoice' => ['NumberOfResultExpression'],
20 'assMultipleChoice' => ['NumberOfResultExpression', 'ExclusiveResultExpression'],
21 'assErrorText' => ['NumberOfResultExpression', 'ExclusiveResultExpression'],
22 'assImagemapQuestion' => ['NumberOfResultExpression', 'ExclusiveResultExpression'],
23 'assNumeric' => ['NumericResultExpression'],
24 'assOrderingQuestion' => ['OrderingResultExpression'],
25 'assOrderingHorizontal' => ['OrderingResultExpression'],
26 'assMatchingQuestion' => ['MatchingResultExpression'],
27 'assTextSubset' => ['StringResultExpression'],
28 'assFormulaQuestion' => ['NumericResultExpression'],
29 'assClozeTest' => [
30 'StringResultExpression_1', 'StringResultExpression_2',
31 'NumberOfResultExpression', 'NumericResultExpression'
32 ],
33 ];
35 private $uiFactory;
36
43 public function __construct(
46 \ILIAS\UI\Factory $uiFactory
47 ) {
48 $this->pageTemplate = $pageTemplate;
49 $this->lng = $lng;
50 $this->uiFactory = $uiFactory;
51 $this->questionOBJ = null;
52 }
53
57 public function getQuestionOBJ() : ? iQuestionCondition
58 {
59 return $this->questionOBJ;
60 }
61
66 {
67 $this->questionOBJ = $questionOBJ;
68 }
69
73 public function get() : \ILIAS\UI\Component\Modal\Modal
74 {
75 $this->pageTemplate->addCss('Modules/TestQuestionPool/templates/default/lac_legend.css');
76
77 $tpl = $this->getTemplate();
78
82
83 return $this->uiFactory->modal()->lightbox([
84 $this->uiFactory->modal()->lightboxTextPage(
85 $tpl->get(),
86 $this->lng->txt('qpl_skill_point_eval_by_solution_compare')
87 ),
88 ]);
89 }
90
95 protected function getTemplate() : ilTemplate
96 {
97 return new ilTemplate(
98 'tpl.qpl_logical_answer_compare_legend.html',
99 true,
100 true,
101 'Modules/TestQuestionPool'
102 );
103 }
104
108 private function renderCommonLegendPart(ilTemplate $tpl) : void
109 {
110 $tpl->setVariable(
111 'COMMON_ELEMENTS_HEADER',
112 $this->lng->txt('qpl_lac_legend_header_common')
113 );
114
115 foreach ($this->getCommonElements() as $element => $description) {
116 $tpl->setCurrentBlock('common_elements');
117 $tpl->setVariable('CE_ELEMENT', $element);
118 $tpl->setVariable('CE_DESCRIPTION', $description);
119 $tpl->parseCurrentBlock();
120 }
121 }
122
127 {
128 $tpl->setVariable(
129 'QUEST_SPECIFIC_ELEMENTS_HEADER',
130 $this->lng->txt('qpl_lac_legend_header_quest_specific')
131 );
132
133 foreach ($this->getQuestionTypeSpecificExpressions() as $expression => $description) {
134 $tpl->setCurrentBlock('quest_specific_elements');
135 $tpl->setVariable('QSE_ELEMENT', $expression);
136 $tpl->setVariable('QSE_DESCRIPTION', $this->lng->txt($description));
137 $tpl->setVariable('QSE_OPERATORS_TXT', $this->lng->txt('qpl_lac_legend_label_operators'));
138 $tpl->setVariable('QSE_OPERATORS', implode(', ', $this->getQuestionOBJ()->getOperators($expression)));
139 $tpl->parseCurrentBlock();
140 }
141 }
142
147 {
148 $tpl->setVariable(
149 'QUEST_SPECIFIC_EXAMPLES_HEADER',
150 $this->lng->txt('lacex_example_header')
151 );
152
153 $questionTypes = [
154 'assQuestion', $this->getQuestionOBJ()->getQuestionType()
155 ];
156
157 foreach ($questionTypes as $questionType) {
158 $examples = $this->getExpressionTypeExamplesByQuestionType($questionType);
159 $this->renderExamples($tpl, $examples, $questionType);
160 }
161 }
162
168 private function buildLangVarsByExampleCode(string $questionType, string $exampleCode) : array
169 {
170 $langVar = 'lacex_' . $questionType . '_' . $exampleCode;
171
172 return [$langVar . '_e', $langVar . '_d'];
173 }
174
180 private function renderExample(ilTemplate $tpl, string $langVarE, string $langVarD) : void
181 {
182 $tpl->setCurrentBlock('quest_specific_examples');
183 $tpl->setVariable('QSEX_ELEMENT', $this->lng->txt($langVarE));
184 $tpl->setVariable('QSEX_DESCRIPTION', $this->lng->txt($langVarD));
185 $tpl->parseCurrentBlock();
186 }
187
191 private function getQuestionTypeSpecificExpressions() : array
192 {
193 $availableExpressionTypes = $this->getAvailableExpressionTypes();
194
195 $expressionTypes = [];
196
197 foreach ($this->getQuestionOBJ()->getExpressionTypes() as $expressionType) {
198 $expressionTypes[$expressionType] = $availableExpressionTypes[$expressionType];
199 }
200
201 return $expressionTypes;
202 }
203
207 private function getCommonElements()
208 {
209 return [
210 '&' => $this->lng->txt('qpl_lac_desc_logical_and'),
211 '|' => $this->lng->txt('qpl_lac_desc_logical_or'),
212 '!' => $this->lng->txt('qpl_lac_desc_negation'),
213 '()' => $this->lng->txt('qpl_lac_desc_brackets'),
214 //'Qn' => $this->lng->txt('qpl_lac_desc_res_of_quest_n'),
215 //'Qn[m]' => $this->lng->txt('qpl_lac_desc_res_of_answ_m_of_quest_n'),
216 'R' => $this->lng->txt('qpl_lac_desc_res_of_cur_quest'),
217 'R[m]' => $this->lng->txt('qpl_lac_desc_res_of_answ_m_of_cur_quest')
218 ];
219 }
220
224 private function getAvailableExpressionTypes() : array
225 {
226 return [
227 iQuestionCondition::PercentageResultExpression => 'qpl_lac_desc_compare_with_quest_res',
228 iQuestionCondition::NumericResultExpression => 'qpl_lac_desc_compare_with_number',
229 iQuestionCondition::StringResultExpression => 'qpl_lac_desc_compare_with_text',
230 iQuestionCondition::MatchingResultExpression => 'qpl_lac_desc_compare_with_assignment',
231 iQuestionCondition::OrderingResultExpression => 'qpl_lac_desc_compare_with_sequence',
232 iQuestionCondition::NumberOfResultExpression => 'qpl_lac_desc_compare_with_answer_n',
233 iQuestionCondition::ExclusiveResultExpression => 'qpl_lac_desc_compare_with_exact_sequence',
234 iQuestionCondition::EmptyAnswerExpression => 'qpl_lac_desc_compare_answer_exist'
235 ];
236 }
237
242 private function getExpressionTypeExamplesByQuestionType(string $questionType) : array
243 {
244 if (!isset($this->examplesByQuestionType[$questionType])) {
245 return [];
246 }
247
248 return $this->examplesByQuestionType[$questionType];
249 }
250
256 private function renderExamples(ilTemplate $tpl, array $examples, string $questionType) : void
257 {
258 foreach ($examples as $exampleCode) {
259 list($langVarE, $langVarD) = $this->buildLangVarsByExampleCode($questionType, $exampleCode);
260 $this->renderExample($tpl, $langVarE, $langVarD);
261 }
262 }
263}
An exception for terminatinating execution or to throw for unit testing.
setQuestionOBJ(iQuestionCondition $questionOBJ)
renderExample(ilTemplate $tpl, string $langVarE, string $langVarD)
getExpressionTypeExamplesByQuestionType(string $questionType)
renderQuestSpecificExamples(ilTemplate $tpl)
buildLangVarsByExampleCode(string $questionType, string $exampleCode)
renderCommonLegendPart(ilTemplate $tpl)
renderQuestSpecificLegendPart(ilTemplate $tpl)
renderExamples(ilTemplate $tpl, array $examples, string $questionType)
__construct(ilGlobalTemplateInterface $pageTemplate, ilLanguage $lng, \ILIAS\UI\Factory $uiFactory)
ilAssLacLegendGUI constructor.
language handling
special template class to simplify handling of ITX/PEAR
Class iQuestionCondition.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.