ILIAS  release_8 Revision v8.24
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...
 
 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.

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 }

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

+ Here is the call graph for this function:

Member Function Documentation

◆ buildQuestionObligatoryString()

ilTestQuestionHeaderBlockBuilder::buildQuestionObligatoryString ( )
protected

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

272 : string
273 {
274 if ($this->isQuestionObligatory()) {
275 return $this->lng->txt("tst_you_have_to_answer_this_question");
276 }
277
278 return '';
279 }

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

Referenced by getHTML(), and getQuestionInfoHTML().

+ 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.

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 }

References getQuestionPoints().

Referenced by getHTML(), and getQuestionInfoHTML().

+ 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.

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 }

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

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

+ 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.

263 : string
264 {
265 if ($this->isQuestionPostponed()) {
266 return $this->lng->txt("postponed");
267 }
268
269 return '';
270 }

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

Referenced by getHTML(), and getQuestionInfoHTML().

+ 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.

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 }

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

Referenced by getHTML(), and getQuestionInfoHTML().

+ 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.

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 }

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

+ 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.

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 }

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

+ 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.

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 }
special template class to simplify handling of ITX/PEAR
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

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

+ 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.

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

References $headerMode.

◆ setQuestionAnswered()

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

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

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

References $questionAnswered.

◆ setQuestionCount()

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

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

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

References $questionCount.

◆ setQuestionObligatory()

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

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

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

References $questionObligatory.

◆ setQuestionPoints()

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

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

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

References $questionPoints.

◆ setQuestionPosition()

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

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

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

References $questionPosition.

◆ setQuestionPostponed()

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

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

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

References $questionPostponed.

◆ setQuestionRelatedObjectives()

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

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

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

References $questionRelatedObjectives.

◆ setQuestionTitle()

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

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

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

References $questionTitle.

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: