ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilTestQuestionHeaderBlockBuilder Class Reference
+ Inheritance diagram for ilTestQuestionHeaderBlockBuilder:
+ Collaboration diagram for ilTestQuestionHeaderBlockBuilder:

Public Member Functions

 __construct (ilLanguage $lng)
 
 getHeaderMode ()
 
 setHeaderMode ($headerMode)
 
 getQuestionTitle ()
 
 setQuestionTitle ($questionTitle)
 
 getQuestionPoints ()
 
 setQuestionPoints ($questionPoints)
 
 setQuestionAnswered ($questionAnswered)
 
 getQuestionPosition ()
 
 setQuestionPosition ($questionPosition)
 
 getQuestionCount ()
 
 setQuestionCount ($questionCount)
 
 isQuestionPostponed ()
 
 isQuestionAnswered ()
 
 setQuestionPostponed ($questionPostponed)
 
 isQuestionObligatory ()
 
 setQuestionObligatory ($questionObligatory)
 
 getQuestionRelatedObjectives ()
 
 setQuestionRelatedObjectives ($questionRelatedObjectives)
 
 getPresentationTitle ()
 Get the presentation title of the question This is shown above the title line in a test run. More...
 
 getQuestionInfoHTML ()
 Get the additional question info and answering status This is shown below the title line in a test run. More...
 
 getHTML ()
 Get the HTML representation of the header block. More...
 

Protected Member Functions

 buildQuestionPositionString ()
 
 buildQuestionPointsString ()
 
 buildQuestionPostponedString ()
 
 buildQuestionObligatoryString ()
 
 buildQuestionRelatedObjectivesString ()
 

Protected Attributes

 $lng
 
 $headerMode
 
 $questionTitle
 
 $questionPoints
 
 $questionPosition
 
 $questionCount
 
 $questionPostponed
 
 $questionObligatory
 
 $questionRelatedObjectives
 
 $questionAnswered
 

Detailed Description

Definition at line 27 of file class.ilTestQuestionHeaderBlockBuilder.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestQuestionHeaderBlockBuilder::__construct ( ilLanguage  $lng)

Definition at line 81 of file class.ilTestQuestionHeaderBlockBuilder.php.

References $lng, and ILIAS\Repository\lng().

82  {
83  $this->lng = $lng;
84 
85  $this->headerMode = null;
86  $this->questionTitle = '';
87  $this->questionPoints = 0.0;
88  $this->questionPosition = 0;
89  $this->questionCount = 0;
90  $this->questionPostponed = false;
91  $this->questionObligatory = false;
92  $this->questionRelatedObjectives = '';
93  }
+ Here is the call graph for this function:

Member Function Documentation

◆ buildQuestionObligatoryString()

ilTestQuestionHeaderBlockBuilder::buildQuestionObligatoryString ( )
protected

Definition at line 274 of file class.ilTestQuestionHeaderBlockBuilder.php.

References isQuestionObligatory(), and ILIAS\Repository\lng().

Referenced by getHTML(), and getQuestionInfoHTML().

274  : string
275  {
276  if ($this->isQuestionObligatory()) {
277  return $this->lng->txt("tst_you_have_to_answer_this_question");
278  }
279 
280  return '';
281  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildQuestionPointsString()

ilTestQuestionHeaderBlockBuilder::buildQuestionPointsString ( )
protected

Definition at line 256 of file class.ilTestQuestionHeaderBlockBuilder.php.

References getQuestionPoints().

Referenced by getHTML(), getPresentationTitle(), and getQuestionInfoHTML().

256  : string
257  {
258  if ($this->getQuestionPoints() == 1) {
259  return "{$this->getQuestionPoints()} {$this->lng->txt('point')}";
260  }
261 
262  return "{$this->getQuestionPoints()} {$this->lng->txt('points')}";
263  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildQuestionPositionString()

ilTestQuestionHeaderBlockBuilder::buildQuestionPositionString ( )
protected

Definition at line 242 of file class.ilTestQuestionHeaderBlockBuilder.php.

References getQuestionCount(), getQuestionPosition(), and ILIAS\Repository\lng().

Referenced by getHTML(), getPresentationTitle(), and getQuestionInfoHTML().

242  : string
243  {
244  if (!$this->getQuestionPosition()) {
245  return '';
246  }
247 
248  if ($this->getQuestionCount()) {
249  return sprintf($this->lng->txt("tst_position"), $this->getQuestionPosition(), $this->getQuestionCount());
250  }
251 
252  return sprintf($this->lng->txt("tst_position_without_total"), $this->getQuestionPosition());
253  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildQuestionPostponedString()

ilTestQuestionHeaderBlockBuilder::buildQuestionPostponedString ( )
protected

Definition at line 265 of file class.ilTestQuestionHeaderBlockBuilder.php.

References isQuestionPostponed(), and ILIAS\Repository\lng().

Referenced by getHTML(), and getQuestionInfoHTML().

265  : string
266  {
267  if ($this->isQuestionPostponed()) {
268  return $this->lng->txt("postponed");
269  }
270 
271  return '';
272  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildQuestionRelatedObjectivesString()

ilTestQuestionHeaderBlockBuilder::buildQuestionRelatedObjectivesString ( )
protected

Definition at line 283 of file class.ilTestQuestionHeaderBlockBuilder.php.

References getQuestionRelatedObjectives(), and ILIAS\Repository\lng().

Referenced by getHTML(), and getQuestionInfoHTML().

283  : string
284  {
285  if (strlen($this->getQuestionRelatedObjectives())) {
286  $label = $this->lng->txt('tst_res_lo_objectives_header');
287  return $label . ': ' . $this->getQuestionRelatedObjectives();
288  }
289 
290  return '';
291  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHeaderMode()

ilTestQuestionHeaderBlockBuilder::getHeaderMode ( )
Returns
int

Definition at line 98 of file class.ilTestQuestionHeaderBlockBuilder.php.

References $headerMode.

Referenced by getHTML(), getPresentationTitle(), and getQuestionInfoHTML().

+ Here is the caller graph for this function:

◆ getHTML()

ilTestQuestionHeaderBlockBuilder::getHTML ( )

Get the HTML representation of the header block.

Returns
string

Implements ilQuestionHeaderBlockBuilder.

Definition at line 379 of file class.ilTestQuestionHeaderBlockBuilder.php.

References buildQuestionObligatoryString(), buildQuestionPointsString(), buildQuestionPositionString(), buildQuestionPostponedString(), buildQuestionRelatedObjectivesString(), getHeaderMode(), and getQuestionTitle().

379  : string
380  {
381  $headerBlock = $this->buildQuestionPositionString();
382 
383  switch ($this->getHeaderMode()) {
384  case 1:
385 
386  $headerBlock .= " - " . $this->getQuestionTitle();
387  $headerBlock .= $this->buildQuestionPostponedString();
388  $headerBlock .= $this->buildQuestionObligatoryString();
389  break;
390 
391  case 2:
392 
393  $headerBlock .= $this->buildQuestionPostponedString();
394  $headerBlock .= $this->buildQuestionObligatoryString();
395  break;
396 
397  case 0:
398  default:
399 
400  $headerBlock .= " - " . $this->getQuestionTitle();
401  $headerBlock .= $this->buildQuestionPostponedString();
402  // fau: testNav - put the points in parentheses here, not in building the string
403  $headerBlock .= ' (' . $this->buildQuestionPointsString() . ')';
404  // fau.
405  $headerBlock .= $this->buildQuestionObligatoryString();
406  }
407 
408  $headerBlock .= $this->buildQuestionRelatedObjectivesString();
409 
410  return $headerBlock;
411  }
+ Here is the call graph for this function:

◆ getPresentationTitle()

ilTestQuestionHeaderBlockBuilder::getPresentationTitle ( )

Get the presentation title of the question This is shown above the title line in a test run.

Returns
string

Definition at line 302 of file class.ilTestQuestionHeaderBlockBuilder.php.

References buildQuestionPointsString(), buildQuestionPositionString(), getHeaderMode(), and getQuestionTitle().

302  : string
303  {
304  switch ($this->getHeaderMode()) {
305  case 3: // only points => show no title here
306  return $this->buildQuestionPointsString();
307  break;
308  case 2: // neither titles nor points => show position as title
309  return $this->buildQuestionPositionString();
310  break;
311 
312  case 0: // titles and points => show title here
313  case 1: // only titles => show title here
314  default:
315  return $this->getQuestionTitle();
316  }
317  }
+ Here is the call graph for this function:

◆ getQuestionCount()

ilTestQuestionHeaderBlockBuilder::getQuestionCount ( )
Returns
int

Definition at line 171 of file class.ilTestQuestionHeaderBlockBuilder.php.

References $questionCount.

Referenced by buildQuestionPositionString().

+ Here is the caller graph for this function:

◆ getQuestionInfoHTML()

ilTestQuestionHeaderBlockBuilder::getQuestionInfoHTML ( )

Get the additional question info and answering status This is shown below the title line in a test run.

Returns
string html code of the info block

Definition at line 325 of file class.ilTestQuestionHeaderBlockBuilder.php.

References buildQuestionObligatoryString(), buildQuestionPointsString(), buildQuestionPositionString(), buildQuestionPostponedString(), buildQuestionRelatedObjectivesString(), getHeaderMode(), ilUtil\getImagePath(), getQuestionRelatedObjectives(), isQuestionAnswered(), isQuestionObligatory(), isQuestionPostponed(), and ILIAS\Repository\lng().

325  : string
326  {
327  $tpl = new ilTemplate('tpl.tst_question_info.html', true, true, 'Modules/Test');
328 
329  // position and/or points
330  switch ($this->getHeaderMode()) {
331  case 1: // only titles => show position here
332  $text = $this->buildQuestionPositionString();
333  break;
334 
335  case 3: // only points => show nothing here
336  $text = $this->buildQuestionPositionString();
337  break;
338  case 2: // neither titles nor points => position is separate title, show nothing here
339  $text = '';
340  break;
341 
342  case 0: // titles and points => show position and points here
343  default:
344  $text = $this->buildQuestionPositionString() . ' (' . $this->buildQuestionPointsString() . ')';
345  }
346  if ($this->isQuestionPostponed()) {
347  $text .= ($text ? ', ' : '') . $this->buildQuestionPostponedString();
348  }
349 
350  $tpl->setVariable('TXT_POSITION_POINTS', $text);
351 
352  // obligatory
353  if ($this->isQuestionObligatory() && !$this->isQuestionAnswered()) {
354  $tpl->setVariable('TXT_OBLIGATORY', $this->buildQuestionObligatoryString());
355  }
356 
357  // objectives
358  if (strlen($this->getQuestionRelatedObjectives())) {
359  $tpl->setVariable('TXT_OBJECTIVES', $this->buildQuestionRelatedObjectivesString());
360  }
361 
362  // answer status
363  if ($this->isQuestionAnswered()) {
364  $tpl->setVariable('HIDDEN_NOT_ANSWERED', 'hidden');
365  } else {
366  $tpl->setVariable('HIDDEN_ANSWERED', 'hidden');
367  }
368 
369  $tpl->setVariable('SRC_ANSWERED', ilUtil::getImagePath('object/answered.svg'));
370  $tpl->setVariable('SRC_NOT_ANSWERED', ilUtil::getImagePath('object/answered_not.svg'));
371  $tpl->setVariable('TXT_ANSWERED', $this->lng->txt('tst_answer_status_answered'));
372  $tpl->setVariable('TXT_NOT_ANSWERED', $this->lng->txt('tst_answer_status_not_answered'));
373  $tpl->setVariable('TXT_EDITING', $this->lng->txt('tst_answer_status_editing'));
374 
375  return $tpl->get();
376  }
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
+ Here is the call graph for this function:

◆ getQuestionPoints()

ilTestQuestionHeaderBlockBuilder::getQuestionPoints ( )
Returns
float

Definition at line 130 of file class.ilTestQuestionHeaderBlockBuilder.php.

References $questionPoints.

Referenced by buildQuestionPointsString().

+ Here is the caller graph for this function:

◆ getQuestionPosition()

ilTestQuestionHeaderBlockBuilder::getQuestionPosition ( )
Returns
int

Definition at line 155 of file class.ilTestQuestionHeaderBlockBuilder.php.

References $questionPosition.

Referenced by buildQuestionPositionString().

+ Here is the caller graph for this function:

◆ getQuestionRelatedObjectives()

ilTestQuestionHeaderBlockBuilder::getQuestionRelatedObjectives ( )
Returns
string

Definition at line 229 of file class.ilTestQuestionHeaderBlockBuilder.php.

References $questionRelatedObjectives.

Referenced by buildQuestionRelatedObjectivesString(), and getQuestionInfoHTML().

+ Here is the caller graph for this function:

◆ getQuestionTitle()

ilTestQuestionHeaderBlockBuilder::getQuestionTitle ( )
Returns
string

Definition at line 114 of file class.ilTestQuestionHeaderBlockBuilder.php.

References $questionTitle.

Referenced by getHTML(), and getPresentationTitle().

+ Here is the caller graph for this function:

◆ isQuestionAnswered()

ilTestQuestionHeaderBlockBuilder::isQuestionAnswered ( )
Returns
boolean | null

Definition at line 196 of file class.ilTestQuestionHeaderBlockBuilder.php.

References $questionAnswered.

Referenced by getQuestionInfoHTML().

+ Here is the caller graph for this function:

◆ isQuestionObligatory()

ilTestQuestionHeaderBlockBuilder::isQuestionObligatory ( )
Returns
boolean

Definition at line 213 of file class.ilTestQuestionHeaderBlockBuilder.php.

References $questionObligatory.

Referenced by buildQuestionObligatoryString(), and getQuestionInfoHTML().

+ Here is the caller graph for this function:

◆ isQuestionPostponed()

ilTestQuestionHeaderBlockBuilder::isQuestionPostponed ( )
Returns
boolean

Definition at line 187 of file class.ilTestQuestionHeaderBlockBuilder.php.

References $questionPostponed.

Referenced by buildQuestionPostponedString(), and getQuestionInfoHTML().

+ Here is the caller graph for this function:

◆ setHeaderMode()

ilTestQuestionHeaderBlockBuilder::setHeaderMode (   $headerMode)
Parameters
int$headerMode

Definition at line 106 of file class.ilTestQuestionHeaderBlockBuilder.php.

References $headerMode.

107  {
108  $this->headerMode = $headerMode;
109  }

◆ setQuestionAnswered()

ilTestQuestionHeaderBlockBuilder::setQuestionAnswered (   $questionAnswered)
Parameters
bool$questionAnswered

Definition at line 147 of file class.ilTestQuestionHeaderBlockBuilder.php.

References $questionAnswered.

148  {
149  $this->questionAnswered = $questionAnswered;
150  }

◆ setQuestionCount()

ilTestQuestionHeaderBlockBuilder::setQuestionCount (   $questionCount)
Parameters
int$questionCount

Definition at line 179 of file class.ilTestQuestionHeaderBlockBuilder.php.

References $questionCount.

180  {
181  $this->questionCount = $questionCount;
182  }

◆ setQuestionObligatory()

ilTestQuestionHeaderBlockBuilder::setQuestionObligatory (   $questionObligatory)
Parameters
boolean$questionObligatory

Definition at line 221 of file class.ilTestQuestionHeaderBlockBuilder.php.

References $questionObligatory.

222  {
223  $this->questionObligatory = $questionObligatory;
224  }

◆ setQuestionPoints()

ilTestQuestionHeaderBlockBuilder::setQuestionPoints (   $questionPoints)
Parameters
float$questionPoints

Definition at line 138 of file class.ilTestQuestionHeaderBlockBuilder.php.

References $questionPoints.

139  {
140  $this->questionPoints = $questionPoints;
141  }

◆ setQuestionPosition()

ilTestQuestionHeaderBlockBuilder::setQuestionPosition (   $questionPosition)
Parameters
int$questionPosition

Definition at line 163 of file class.ilTestQuestionHeaderBlockBuilder.php.

References $questionPosition.

164  {
165  $this->questionPosition = $questionPosition;
166  }

◆ setQuestionPostponed()

ilTestQuestionHeaderBlockBuilder::setQuestionPostponed (   $questionPostponed)
Parameters
boolean$questionPostponed

Definition at line 205 of file class.ilTestQuestionHeaderBlockBuilder.php.

References $questionPostponed.

206  {
207  $this->questionPostponed = $questionPostponed;
208  }

◆ setQuestionRelatedObjectives()

ilTestQuestionHeaderBlockBuilder::setQuestionRelatedObjectives (   $questionRelatedObjectives)
Parameters
string$questionRelatedObjectives

Definition at line 237 of file class.ilTestQuestionHeaderBlockBuilder.php.

References $questionRelatedObjectives.

238  {
239  $this->questionRelatedObjectives = $questionRelatedObjectives;
240  }

◆ setQuestionTitle()

ilTestQuestionHeaderBlockBuilder::setQuestionTitle (   $questionTitle)
Parameters
string$questionTitle

Definition at line 122 of file class.ilTestQuestionHeaderBlockBuilder.php.

References $questionTitle.

123  {
124  $this->questionTitle = $questionTitle;
125  }

Field Documentation

◆ $headerMode

ilTestQuestionHeaderBlockBuilder::$headerMode
protected

Definition at line 37 of file class.ilTestQuestionHeaderBlockBuilder.php.

Referenced by getHeaderMode(), and setHeaderMode().

◆ $lng

ilTestQuestionHeaderBlockBuilder::$lng
protected

Definition at line 32 of file class.ilTestQuestionHeaderBlockBuilder.php.

Referenced by __construct().

◆ $questionAnswered

ilTestQuestionHeaderBlockBuilder::$questionAnswered
protected

◆ $questionCount

ilTestQuestionHeaderBlockBuilder::$questionCount
protected

◆ $questionObligatory

ilTestQuestionHeaderBlockBuilder::$questionObligatory
protected

◆ $questionPoints

ilTestQuestionHeaderBlockBuilder::$questionPoints
protected

◆ $questionPosition

ilTestQuestionHeaderBlockBuilder::$questionPosition
protected

◆ $questionPostponed

ilTestQuestionHeaderBlockBuilder::$questionPostponed
protected

◆ $questionRelatedObjectives

ilTestQuestionHeaderBlockBuilder::$questionRelatedObjectives
protected

◆ $questionTitle

ilTestQuestionHeaderBlockBuilder::$questionTitle
protected

The documentation for this class was generated from the following file: