ILIAS  release_8 Revision v8.23
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 25 of file class.ilTestQuestionHeaderBlockBuilder.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestQuestionHeaderBlockBuilder::__construct ( ilLanguage  $lng)

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

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

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

Member Function Documentation

◆ buildQuestionObligatoryString()

ilTestQuestionHeaderBlockBuilder::buildQuestionObligatoryString ( )
protected

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

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

Referenced by getHTML(), and getQuestionInfoHTML().

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

◆ buildQuestionPointsString()

ilTestQuestionHeaderBlockBuilder::buildQuestionPointsString ( )
protected

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

References getQuestionPoints().

Referenced by getHTML(), and getQuestionInfoHTML().

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

◆ buildQuestionPositionString()

ilTestQuestionHeaderBlockBuilder::buildQuestionPositionString ( )
protected

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

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

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

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

◆ buildQuestionPostponedString()

ilTestQuestionHeaderBlockBuilder::buildQuestionPostponedString ( )
protected

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

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

Referenced by getHTML(), and getQuestionInfoHTML().

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

◆ buildQuestionRelatedObjectivesString()

ilTestQuestionHeaderBlockBuilder::buildQuestionRelatedObjectivesString ( )
protected

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

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

Referenced by getHTML(), and getQuestionInfoHTML().

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

◆ getHeaderMode()

ilTestQuestionHeaderBlockBuilder::getHeaderMode ( )
Returns
int

Definition at line 96 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 371 of file class.ilTestQuestionHeaderBlockBuilder.php.

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

371  : string
372  {
373  $headerBlock = $this->buildQuestionPositionString();
374 
375  switch ($this->getHeaderMode()) {
376  case 1:
377 
378  $headerBlock .= " - " . $this->getQuestionTitle();
379  $headerBlock .= $this->buildQuestionPostponedString();
380  $headerBlock .= $this->buildQuestionObligatoryString();
381  break;
382 
383  case 2:
384 
385  $headerBlock .= $this->buildQuestionPostponedString();
386  $headerBlock .= $this->buildQuestionObligatoryString();
387  break;
388 
389  case 0:
390  default:
391 
392  $headerBlock .= " - " . $this->getQuestionTitle();
393  $headerBlock .= $this->buildQuestionPostponedString();
394 // fau: testNav - put the points in parentheses here, not in building the string
395  $headerBlock .= ' (' . $this->buildQuestionPointsString() . ')';
396 // fau.
397  $headerBlock .= $this->buildQuestionObligatoryString();
398  }
399 
400  $headerBlock .= $this->buildQuestionRelatedObjectivesString();
401 
402  return $headerBlock;
403  }
+ 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 300 of file class.ilTestQuestionHeaderBlockBuilder.php.

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

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

◆ getQuestionCount()

ilTestQuestionHeaderBlockBuilder::getQuestionCount ( )
Returns
int

Definition at line 169 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 320 of file class.ilTestQuestionHeaderBlockBuilder.php.

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

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

◆ getQuestionPoints()

ilTestQuestionHeaderBlockBuilder::getQuestionPoints ( )
Returns
float

Definition at line 128 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 153 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 227 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 112 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 194 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 211 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 185 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 104 of file class.ilTestQuestionHeaderBlockBuilder.php.

References $headerMode.

105  {
106  $this->headerMode = $headerMode;
107  }

◆ setQuestionAnswered()

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

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

References $questionAnswered.

146  {
147  $this->questionAnswered = $questionAnswered;
148  }

◆ setQuestionCount()

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

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

References $questionCount.

178  {
179  $this->questionCount = $questionCount;
180  }

◆ setQuestionObligatory()

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

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

References $questionObligatory.

220  {
221  $this->questionObligatory = $questionObligatory;
222  }

◆ setQuestionPoints()

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

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

References $questionPoints.

137  {
138  $this->questionPoints = $questionPoints;
139  }

◆ setQuestionPosition()

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

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

References $questionPosition.

162  {
163  $this->questionPosition = $questionPosition;
164  }

◆ setQuestionPostponed()

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

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

References $questionPostponed.

204  {
205  $this->questionPostponed = $questionPostponed;
206  }

◆ setQuestionRelatedObjectives()

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

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

References $questionRelatedObjectives.

236  {
237  $this->questionRelatedObjectives = $questionRelatedObjectives;
238  }

◆ setQuestionTitle()

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

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

References $questionTitle.

121  {
122  $this->questionTitle = $questionTitle;
123  }

Field Documentation

◆ $headerMode

ilTestQuestionHeaderBlockBuilder::$headerMode
protected

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

Referenced by getHeaderMode(), and setHeaderMode().

◆ $lng

ilTestQuestionHeaderBlockBuilder::$lng
protected

Definition at line 30 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: