ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTestQuestionHeaderBlockBuilder.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 require_once 'Modules/TestQuestionPool/interfaces/interface.ilQuestionHeaderBlockBuilder.php';
5 
13 {
17  protected $lng;
18 
22  protected $headerMode;
23 
27  protected $questionTitle;
28 
32  protected $questionPoints;
33 
37  protected $questionPosition;
38 
42  protected $questionCount;
43 
47  protected $questionPostponed;
48 
53 
58 
60  {
61  $this->lng = $lng;
62 
63  $this->headerMode = null;
64  $this->questionTitle = '';
65  $this->questionPoints = 0.0;
66  $this->questionPosition = 0;
67  $this->questionCount = 0;
68  $this->questionPostponed = false;
69  $this->questionObligatory = false;
70  $this->questionRelatedObjectives = '';
71  }
72 
76  public function getHeaderMode()
77  {
78  return $this->headerMode;
79  }
80 
84  public function setHeaderMode($headerMode)
85  {
86  $this->headerMode = $headerMode;
87  }
88 
92  public function getQuestionTitle()
93  {
94  return $this->questionTitle;
95  }
96 
101  {
102  $this->questionTitle = $questionTitle;
103  }
104 
108  public function getQuestionPoints()
109  {
110  return $this->questionPoints;
111  }
112 
117  {
118  $this->questionPoints = $questionPoints;
119  }
120 
124  public function getQuestionPosition()
125  {
127  }
128 
133  {
134  $this->questionPosition = $questionPosition;
135  }
136 
140  public function getQuestionCount()
141  {
142  return $this->questionCount;
143  }
144 
149  {
150  $this->questionCount = $questionCount;
151  }
152 
156  public function isQuestionPostponed()
157  {
159  }
160 
165  {
166  $this->questionPostponed = $questionPostponed;
167  }
168 
172  public function isQuestionObligatory()
173  {
175  }
176 
181  {
182  $this->questionObligatory = $questionObligatory;
183  }
184 
189  {
191  }
192 
197  {
198  $this->questionRelatedObjectives = $questionRelatedObjectives;
199  }
200 
201  protected function buildQuestionPositionString()
202  {
203  if( $this->getQuestionCount() )
204  {
205  return sprintf($this->lng->txt("tst_position"), $this->getQuestionPosition(), $this->getQuestionCount());
206  }
207 
208  return sprintf($this->lng->txt("tst_position_without_total"), $this->getQuestionPosition());
209  }
210 
211  protected function buildQuestionPointsString()
212  {
213  if( $this->getQuestionPoints() == 1 )
214  {
215  return " ({$this->getQuestionPoints()} {$this->lng->txt('point')})";
216  }
217 
218  return " ({$this->getQuestionPoints()} {$this->lng->txt('points')})";
219  }
220 
221  protected function buildQuestionPostponedString()
222  {
223  if( $this->isQuestionPostponed() )
224  {
225  return " <em>(" . $this->lng->txt("postponed") . ")</em>";
226  }
227 
228  return '';
229  }
230 
231  protected function buildQuestionObligatoryString()
232  {
233  if( $this->isQuestionObligatory() )
234  {
235  $obligatoryText = $this->lng->txt("tst_you_have_to_answer_this_question");
236  return '<br /><span class="obligatory" style="font-size:small">'.$obligatoryText.'</span>';
237  }
238 
239  return '';
240  }
241 
243  {
244  if( strlen($this->getQuestionRelatedObjectives()) )
245  {
246  $label = $this->lng->txt('tst_res_lo_objectives_header');
247  return '<div class="ilTestQuestionRelatedObjectivesInfo">'.$label.': '.$this->getQuestionRelatedObjectives();
248  }
249 
250  return '';
251  }
252 
253  public function getHTML()
254  {
255  $headerBlock = $this->buildQuestionPositionString();
256 
257  switch( $this->getHeaderMode() )
258  {
259  case 1:
260 
261  $headerBlock .= " - ".$this->getQuestionTitle();
262  $headerBlock .= $this->buildQuestionPostponedString();
263  $headerBlock .= $this->buildQuestionObligatoryString();
264  break;
265 
266  case 2:
267 
268  $headerBlock .= $this->buildQuestionPostponedString();
269  $headerBlock .= $this->buildQuestionObligatoryString();
270  break;
271 
272  case 0:
273  default:
274 
275  $headerBlock .= " - ".$this->getQuestionTitle();
276  $headerBlock .= $this->buildQuestionPostponedString();
277  $headerBlock .= $this->buildQuestionPointsString();
278  $headerBlock .= $this->buildQuestionObligatoryString();
279  }
280 
281  $headerBlock .= $this->buildQuestionRelatedObjectivesString();
282 
283  return $headerBlock;
284  }
285 }