ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
4 include_once 'Modules/TestQuestionPool/interfaces/interface.iQuestionCondition.php';
5 include_once 'Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php';
6 
14 {
15  protected $lng;
16 
17  protected $tpl;
18 
20 
24  private $questionOBJ;
25 
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 
67  public function isInitialVisibilityEnabled()
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', true, true, 'Modules/TestQuestionPool'
122  );
123  }
124 
126  {
127  $tpl->setVariable(
128  'COMMON_ELEMENTS_HEADER', $this->lng->txt('qpl_lac_legend_header_common')
129  );
130 
131  foreach($this->getCommonElements() as $element => $description)
132  {
133  $tpl->setCurrentBlock('common_elements');
134  $tpl->setVariable('CE_ELEMENT', $element);
135  $tpl->setVariable('CE_DESCRIPTION', $description);
136  $tpl->parseCurrentBlock();
137  }
138  }
139 
141  {
142  $tpl->setVariable(
143  'QUEST_SPECIFIC_ELEMENTS_HEADER', $this->lng->txt('qpl_lac_legend_header_quest_specific')
144  );
145 
146  foreach($this->getQuestionTypeSpecificExpressions() as $expression => $description)
147  {
148  $tpl->setCurrentBlock('quest_specific_elements');
149  $tpl->setVariable('QSE_ELEMENT', $expression);
150  $tpl->setVariable('QSE_DESCRIPTION', $this->lng->txt($description));
151  $tpl->setVariable('QSE_OPERATORS_TXT', $this->lng->txt('qpl_lac_legend_label_operators'));
152  $tpl->setVariable('QSE_OPERATORS', implode(', ', $this->getQuestionOBJ()->getOperators($expression)));
153  $tpl->parseCurrentBlock();
154  }
155  }
156 
158  {
159  $tpl->setVariable(
160  'QUEST_SPECIFIC_EXAMPLES_HEADER', $this->lng->txt('lacex_example_header')
161  );
162 
163  $questionTypes = array(
164  'assQuestion', $this->getQuestionOBJ()->getQuestionType()
165  );
166 
167  foreach($questionTypes as $questionType)
168  {
169  $examples = $this->getExpressionTypeExamplesByQuestionType($questionType);
170  $this->renderExamples($tpl, $examples, $questionType);
171  }
172  }
173 
174  protected function buildLangVarsByExampleCode($questionType, $exampleCode)
175  {
176  $langVar = 'lacex_'.$questionType.'_'.$exampleCode;
177  return array($langVar.'_e', $langVar.'_d');
178  }
179 
180  protected function renderExample(ilTemplate $tpl, $langVarE, $langVarD)
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 
189  {
190  if( !$this->isInitialVisibilityEnabled() )
191  {
192  $tpl->setVariable('CSS_DISPLAY_NONE', 'display:none;');
193  }
194  }
195 
197  {
198  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignment.php';
199 
200  $tpl->setVariable(
201  'TOGGLE_BTN_SHOW_LABEL', $this->lng->txt('ass_lac_show_legend_btn')
202  );
203 
204  $tpl->setVariable(
205  'TOGGLE_BTN_HIDE_LABEL', $this->lng->txt('ass_lac_hide_legend_btn')
206  );
207 
208  $tpl->setVariable(
209  'SKILL_POINT_EVAL_MODE_BY_RESULT', ilAssQuestionSkillAssignment::EVAL_MODE_BY_QUESTION_RESULT
210  );
211 
212  $tpl->setVariable(
213  'SKILL_POINT_EVAL_MODE_BY_SOLUTION', ilAssQuestionSkillAssignment::EVAL_MODE_BY_QUESTION_SOLUTION
214  );
215  }
216 
217  public function getTriggerElement()
218  {
219  return "<div id=\"qpl_lac_legend_trigger\"><a href=\"#\">".$this->lng->txt("qpl_lac_legend_link")."</a></div>";
220  }
221 
223  {
224  $availableExpressionTypes = $this->getAvailableExpressionTypes();
225 
226  $expressionTypes = array();
227 
228  foreach($this->getQuestionOBJ()->getExpressionTypes() as $expressionType)
229  {
230  $expressionTypes[$expressionType] = $availableExpressionTypes[$expressionType];
231  }
232 
233  return $expressionTypes;
234  }
235 
236  protected function getCommonElements()
237  {
238  return array(
239  '&' => $this->lng->txt('qpl_lac_desc_logical_and'),
240  '|' => $this->lng->txt('qpl_lac_desc_logical_or'),
241  '!' => $this->lng->txt('qpl_lac_desc_negation'),
242  '()' => $this->lng->txt('qpl_lac_desc_brackets'),
243  //'Qn' => $this->lng->txt('qpl_lac_desc_res_of_quest_n'),
244  //'Qn[m]' => $this->lng->txt('qpl_lac_desc_res_of_answ_m_of_quest_n'),
245  'R' => $this->lng->txt('qpl_lac_desc_res_of_cur_quest'),
246  'R[m]' => $this->lng->txt('qpl_lac_desc_res_of_answ_m_of_cur_quest')
247  );
248  }
249 
250  protected function getAvailableExpressionTypes()
251  {
252  return array(
253  iQuestionCondition::PercentageResultExpression => 'qpl_lac_desc_compare_with_quest_res',
254  iQuestionCondition::NumericResultExpression => 'qpl_lac_desc_compare_with_number',
255  iQuestionCondition::StringResultExpression => 'qpl_lac_desc_compare_with_text',
256  iQuestionCondition::MatchingResultExpression => 'qpl_lac_desc_compare_with_assignment',
257  iQuestionCondition::OrderingResultExpression => 'qpl_lac_desc_compare_with_sequence',
258  iQuestionCondition::NumberOfResultExpression => 'qpl_lac_desc_compare_with_answer_n',
259  iQuestionCondition::ExclusiveResultExpression => 'qpl_lac_desc_compare_with_exact_sequence',
260  iQuestionCondition::EmptyAnswerExpression => 'qpl_lac_desc_compare_answer_exist'
261  );
262  }
263 
264  public function getExpressionTypeExamplesByQuestionType($questionType)
265  {
266  if( !isset($this->examplesByQuestionType[$questionType]) )
267  {
268  return array();
269  }
270 
271  return $this->examplesByQuestionType[$questionType];
272  }
273 
279  protected function renderExamples(ilTemplate $tpl, $examples, $questionType)
280  {
281  foreach($examples as $exampleCode)
282  {
283  list($langVarE, $langVarD) = $this->buildLangVarsByExampleCode($questionType, $exampleCode);
284  $this->renderExample($tpl, $langVarE, $langVarD);
285  }
286  }
287 }
getExpressionTypeExamplesByQuestionType($questionType)
Class iQuestionCondition.
setAutoHide($a_val)
Set auto hiding.
buildLangVarsByExampleCode($questionType, $exampleCode)
add()
Makes an existing HTML element an overlay.
static get($a_glyph, $a_text="")
Get glyph html.
renderCommonLegendPart(ilTemplate $tpl)
renderExamples(ilTemplate $tpl, $examples, $questionType)
renderQuestSpecificExamples(ilTemplate $tpl)
__construct(ilLanguage $lng, ilTemplate $tpl)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:613
setInitialVisibilityEnabled($initialVisibilityEnabled)
renderExample(ilTemplate $tpl, $langVarE, $langVarD)
special template class to simplify handling of ITX/PEAR
This is a utility class for the yui overlays.
populateVisibilityCss(ilTemplate $tpl)
Create styles array
The data for the language used.
setCurrentBlock($part="DEFAULT")
Überladene Funktion, die sich hier lokal noch den aktuellen Block merkt.
static initOverlay()
Init YUI Overlay module.
setQuestionOBJ(iQuestionCondition $questionOBJ)
language handling
parseCurrentBlock($part="DEFAULT")
Überladene Funktion, die auf den aktuelle Block vorher noch ein replace ausführt public...
setVisible($a_visible=true)
Set visible.
renderQuestSpecificLegendPart(ilTemplate $tpl)
populateTriggerDepencies(ilTemplate $tpl)