ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
4include_once 'Modules/TestQuestionPool/interfaces/interface.iQuestionCondition.php';
5include_once 'Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php';
6
14{
15 protected $lng;
16
17 protected $tpl;
18
20
24 private $questionOBJ;
25
26 private $examplesByQuestionType = array(
27 'assQuestion' => array('PercentageResultExpression', 'EmptyAnswerExpression'),
28 'assSingleChoice' => array('NumberOfResultExpression'),
29 'assMultipleChoice' => array('NumberOfResultExpression', 'ExclusiveResultExpression'),
30 'assErrorText' => array('NumberOfResultExpression', 'ExclusiveResultExpression'),
31 'assImagemapQuestion' => array('NumberOfResultExpression', 'ExclusiveResultExpression'),
32 'assNumeric' => array('NumericResultExpression'),
33 'assOrderingQuestion' => array('OrderingResultExpression'),
34 'assOrderingHorizontal' => array('OrderingResultExpression'),
35 'assMatchingQuestion' => array('MatchingResultExpression'),
36 'assTextSubset' => array('StringResultExpression'),
37 'assFormulaQuestion' => array('NumericResultExpression'),
38
39 'assClozeTest' => array(
40 'StringResultExpression_1', 'StringResultExpression_2',
41 'NumberOfResultExpression', 'NumericResultExpression'
42 ),
43 );
44
46 {
47 $this->lng = $lng;
48 $this->tpl = $tpl;
49
50 $this->initialVisibilityEnabled = false;
51
52 $this->questionOBJ = null;
53
54 parent::__construct('qpl_lac_legend');
55 }
56
57 public function getQuestionOBJ()
58 {
59 return $this->questionOBJ;
60 }
61
63 {
64 $this->questionOBJ = $questionOBJ;
65 }
66
68 {
70 }
71
73 {
74 $this->initialVisibilityEnabled = $initialVisibilityEnabled;
75 }
76
77 public function getHTML()
78 {
79 $this->initOverlay();
80
81 $tpl = $this->getTemplate();
82
83 $this->renderCloseIcon($tpl);
87
90
91 return $tpl->get();
92 }
93
94 protected function renderCloseIcon($tpl)
95 {
96 $tpl->setVariable('CLOSE_ICON', ilGlyphGUI::get(ilGlyphGUI::CLOSE));
97 }
98
99 protected function initOverlay()
100 {
101 include_once 'Services/YUI/classes/class.ilYuiUtil.php';
103
104 $this->tpl->addCss('Modules/TestQuestionPool/templates/default/lac_legend.css');
105
106 //$this->setAnchor('fixed_content', 'tr', 'tr');
107 // we use css instead, does not hoppel over screen for initially visible overlays
108
109 //$this->setTrigger('lac_legend_toggle_btn', 'click');
110 // is done by own listener that also changes the toggle label
111
112 $this->setVisible($this->isInitialVisibilityEnabled());
113 $this->setAutoHide(false);
114
115 $this->add();
116 }
117
118 protected function getTemplate()
119 {
120 return new ilTemplate(
121 'tpl.qpl_logical_answer_compare_legend.html',
122 true,
123 true,
124 'Modules/TestQuestionPool'
125 );
126 }
127
129 {
130 $tpl->setVariable(
131 'COMMON_ELEMENTS_HEADER',
132 $this->lng->txt('qpl_lac_legend_header_common')
133 );
134
135 foreach ($this->getCommonElements() as $element => $description) {
136 $tpl->setCurrentBlock('common_elements');
137 $tpl->setVariable('CE_ELEMENT', $element);
138 $tpl->setVariable('CE_DESCRIPTION', $description);
139 $tpl->parseCurrentBlock();
140 }
141 }
142
144 {
145 $tpl->setVariable(
146 'QUEST_SPECIFIC_ELEMENTS_HEADER',
147 $this->lng->txt('qpl_lac_legend_header_quest_specific')
148 );
149
150 foreach ($this->getQuestionTypeSpecificExpressions() as $expression => $description) {
151 $tpl->setCurrentBlock('quest_specific_elements');
152 $tpl->setVariable('QSE_ELEMENT', $expression);
153 $tpl->setVariable('QSE_DESCRIPTION', $this->lng->txt($description));
154 $tpl->setVariable('QSE_OPERATORS_TXT', $this->lng->txt('qpl_lac_legend_label_operators'));
155 $tpl->setVariable('QSE_OPERATORS', implode(', ', $this->getQuestionOBJ()->getOperators($expression)));
156 $tpl->parseCurrentBlock();
157 }
158 }
159
161 {
162 $tpl->setVariable(
163 'QUEST_SPECIFIC_EXAMPLES_HEADER',
164 $this->lng->txt('lacex_example_header')
165 );
166
167 $questionTypes = array(
168 'assQuestion', $this->getQuestionOBJ()->getQuestionType()
169 );
170
171 foreach ($questionTypes as $questionType) {
172 $examples = $this->getExpressionTypeExamplesByQuestionType($questionType);
173 $this->renderExamples($tpl, $examples, $questionType);
174 }
175 }
176
177 protected function buildLangVarsByExampleCode($questionType, $exampleCode)
178 {
179 $langVar = 'lacex_' . $questionType . '_' . $exampleCode;
180 return array($langVar . '_e', $langVar . '_d');
181 }
182
183 protected function renderExample(ilTemplate $tpl, $langVarE, $langVarD)
184 {
185 $tpl->setCurrentBlock('quest_specific_examples');
186 $tpl->setVariable('QSEX_ELEMENT', $this->lng->txt($langVarE));
187 $tpl->setVariable('QSEX_DESCRIPTION', $this->lng->txt($langVarD));
188 $tpl->parseCurrentBlock();
189 }
190
192 {
193 if (!$this->isInitialVisibilityEnabled()) {
194 $tpl->setVariable('CSS_DISPLAY_NONE', 'display:none;');
195 }
196 }
197
199 {
200 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignment.php';
201
202 $tpl->setVariable(
203 'TOGGLE_BTN_SHOW_LABEL',
204 $this->lng->txt('ass_lac_show_legend_btn')
205 );
206
207 $tpl->setVariable(
208 'TOGGLE_BTN_HIDE_LABEL',
209 $this->lng->txt('ass_lac_hide_legend_btn')
210 );
211
212 $tpl->setVariable(
213 'SKILL_POINT_EVAL_MODE_BY_RESULT',
215 );
216
217 $tpl->setVariable(
218 'SKILL_POINT_EVAL_MODE_BY_SOLUTION',
220 );
221 }
222
223 public function getTriggerElement()
224 {
225 return "<div id=\"qpl_lac_legend_trigger\"><a href=\"#\">" . $this->lng->txt("qpl_lac_legend_link") . "</a></div>";
226 }
227
229 {
230 $availableExpressionTypes = $this->getAvailableExpressionTypes();
231
232 $expressionTypes = array();
233
234 foreach ($this->getQuestionOBJ()->getExpressionTypes() as $expressionType) {
235 $expressionTypes[$expressionType] = $availableExpressionTypes[$expressionType];
236 }
237
238 return $expressionTypes;
239 }
240
241 protected function getCommonElements()
242 {
243 return array(
244 '&' => $this->lng->txt('qpl_lac_desc_logical_and'),
245 '|' => $this->lng->txt('qpl_lac_desc_logical_or'),
246 '!' => $this->lng->txt('qpl_lac_desc_negation'),
247 '()' => $this->lng->txt('qpl_lac_desc_brackets'),
248 //'Qn' => $this->lng->txt('qpl_lac_desc_res_of_quest_n'),
249 //'Qn[m]' => $this->lng->txt('qpl_lac_desc_res_of_answ_m_of_quest_n'),
250 'R' => $this->lng->txt('qpl_lac_desc_res_of_cur_quest'),
251 'R[m]' => $this->lng->txt('qpl_lac_desc_res_of_answ_m_of_cur_quest')
252 );
253 }
254
255 protected function getAvailableExpressionTypes()
256 {
257 return array(
258 iQuestionCondition::PercentageResultExpression => 'qpl_lac_desc_compare_with_quest_res',
259 iQuestionCondition::NumericResultExpression => 'qpl_lac_desc_compare_with_number',
260 iQuestionCondition::StringResultExpression => 'qpl_lac_desc_compare_with_text',
261 iQuestionCondition::MatchingResultExpression => 'qpl_lac_desc_compare_with_assignment',
262 iQuestionCondition::OrderingResultExpression => 'qpl_lac_desc_compare_with_sequence',
263 iQuestionCondition::NumberOfResultExpression => 'qpl_lac_desc_compare_with_answer_n',
264 iQuestionCondition::ExclusiveResultExpression => 'qpl_lac_desc_compare_with_exact_sequence',
265 iQuestionCondition::EmptyAnswerExpression => 'qpl_lac_desc_compare_answer_exist'
266 );
267 }
268
269 public function getExpressionTypeExamplesByQuestionType($questionType)
270 {
271 if (!isset($this->examplesByQuestionType[$questionType])) {
272 return array();
273 }
274
275 return $this->examplesByQuestionType[$questionType];
276 }
277
283 protected function renderExamples(ilTemplate $tpl, $examples, $questionType)
284 {
285 foreach ($examples as $exampleCode) {
286 list($langVarE, $langVarD) = $this->buildLangVarsByExampleCode($questionType, $exampleCode);
287 $this->renderExample($tpl, $langVarE, $langVarD);
288 }
289 }
290}
An exception for terminatinating execution or to throw for unit testing.
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:613
populateVisibilityCss(ilTemplate $tpl)
setQuestionOBJ(iQuestionCondition $questionOBJ)
renderQuestSpecificExamples(ilTemplate $tpl)
renderCommonLegendPart(ilTemplate $tpl)
populateTriggerDepencies(ilTemplate $tpl)
buildLangVarsByExampleCode($questionType, $exampleCode)
renderQuestSpecificLegendPart(ilTemplate $tpl)
getExpressionTypeExamplesByQuestionType($questionType)
renderExample(ilTemplate $tpl, $langVarE, $langVarD)
__construct(ilLanguage $lng, ilTemplate $tpl)
setInitialVisibilityEnabled($initialVisibilityEnabled)
renderExamples(ilTemplate $tpl, $examples, $questionType)
static get($a_glyph, $a_text="")
Get glyph html.
language handling
This is a utility class for the yui overlays.
setVisible($a_visible=true)
Set visible.
setAutoHide($a_val)
Set auto hiding.
add()
Makes an existing HTML element an overlay.
special template class to simplify handling of ITX/PEAR
static initOverlay(ilTemplate $a_main_tpl=null)
Init YUI Overlay module.
Class iQuestionCondition.