ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilTestQuestionHeaderBlockBuilder Class Reference
+ Inheritance diagram for ilTestQuestionHeaderBlockBuilder:
+ Collaboration diagram for ilTestQuestionHeaderBlockBuilder:

Public Member Functions

 __construct (private readonly ilLanguage $lng)
 
 getHeaderMode ()
 
 setHeaderMode (int $header_mode)
 
 getQuestionTitle ()
 
 setQuestionTitle (string $question_title)
 
 getQuestionPoints ()
 
 setQuestionPoints (float $question_points)
 
 setQuestionAnswered (bool $question_answered)
 
 getQuestionPosition ()
 
 setQuestionPosition (int $question_position)
 
 getQuestionCount ()
 
 setQuestionCount (int $question_count)
 
 isQuestionPostponed ()
 
 isQuestionAnswered ()
 
 setQuestionPostponed (bool $question_postponed)
 
 getQuestionRelatedObjectives ()
 
 setQuestionRelatedObjectives (string $question_related_objectives)
 
 getPresentationTitle ()
 
 getQuestionInfoHTML ()
 
 getHTML ()
 Get the HTML representation of the header block. More...
 
 getHTML ()
 Get the HTML representation of the header block. More...
 

Protected Member Functions

 getQuestionTitleForHTMLOutput ()
 
 buildQuestionPositionString ()
 
 buildQuestionPointsString ()
 
 buildQuestionPostponedString ()
 
 buildQuestionRelatedObjectivesString ()
 

Protected Attributes

int $header_mode = null
 
string $question_title = ''
 
float $question_points = 0.0
 
int $question_position = 0
 
int $question_count = 0
 
bool $question_postponed = false
 
string $question_related_objectives = ''
 
bool $question_answered = null
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilTestQuestionHeaderBlockBuilder::__construct ( private readonly ilLanguage  $lng)

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

37 {
38 }

Member Function Documentation

◆ buildQuestionPointsString()

ilTestQuestionHeaderBlockBuilder::buildQuestionPointsString ( )
protected

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

138 : string
139 {
140 if ($this->getQuestionPoints() == 1) {
141 return "{$this->getQuestionPoints()} {$this->lng->txt('point')}";
142 }
143
144 return "{$this->getQuestionPoints()} {$this->lng->txt('points')}";
145 }

References getQuestionPoints().

Referenced by getHTML(), getPresentationTitle(), 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 125 of file class.ilTestQuestionHeaderBlockBuilder.php.

125 : string
126 {
127 if (!$this->getQuestionPosition()) {
128 return '';
129 }
130
131 if ($this->getQuestionCount()) {
132 return sprintf($this->lng->txt('tst_position'), $this->getQuestionPosition(), $this->getQuestionCount());
133 }
134
135 return sprintf($this->lng->txt('tst_position_without_total'), $this->getQuestionPosition());
136 }

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 147 of file class.ilTestQuestionHeaderBlockBuilder.php.

147 : string
148 {
149 if ($this->isQuestionPostponed()) {
150 return $this->lng->txt('postponed');
151 }
152
153 return '';
154 }

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 156 of file class.ilTestQuestionHeaderBlockBuilder.php.

156 : string
157 {
158 if (strlen($this->getQuestionRelatedObjectives())) {
159 $label = $this->lng->txt('tst_res_lo_objectives_header');
160 return $label . ': ' . $this->getQuestionRelatedObjectives();
161 }
162
163 return '';
164 }

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 ( )

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

References $header_mode.

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 229 of file class.ilTestQuestionHeaderBlockBuilder.php.

229 : string
230 {
231 $header_block = $this->buildQuestionPositionString();
232
233 switch ($this->getHeaderMode()) {
234 case 1:
235 $header_block .= " - " . $this->getQuestionTitleForHTMLOutput();
236 $header_block .= $this->buildQuestionPostponedString();
237 break;
238
239 case 2:
240 $header_block .= $this->buildQuestionPostponedString();
241 break;
242
243 case 0:
244 default:
245
246 $header_block .= " - " . $this->getQuestionTitleForHTMLOutput();
247 $header_block .= $this->buildQuestionPostponedString();
248 $header_block .= ' (' . $this->buildQuestionPointsString() . ')';
249 }
250
251 $header_block .= $this->buildQuestionRelatedObjectivesString();
252
253 return $header_block;
254 }

References buildQuestionPointsString(), buildQuestionPositionString(), buildQuestionPostponedString(), buildQuestionRelatedObjectivesString(), getHeaderMode(), and getQuestionTitleForHTMLOutput().

+ Here is the call graph for this function:

◆ getPresentationTitle()

ilTestQuestionHeaderBlockBuilder::getPresentationTitle ( )

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

166 : string
167 {
168 switch ($this->getHeaderMode()) {
169 case 3: // only points => show no title here
170 return $this->buildQuestionPointsString();
171 break;
172 case 2: // neither titles nor points => show position as title
173 return $this->buildQuestionPositionString();
174 break;
175
176 case 0: // titles and points => show title here
177 case 1: // only titles => show title here
178 default:
179 return $this->getQuestionTitle();
180 }
181 }

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

+ Here is the call graph for this function:

◆ getQuestionCount()

ilTestQuestionHeaderBlockBuilder::getQuestionCount ( )

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

References $question_count.

Referenced by buildQuestionPositionString().

+ Here is the caller graph for this function:

◆ getQuestionInfoHTML()

ilTestQuestionHeaderBlockBuilder::getQuestionInfoHTML ( )

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

183 : string
184 {
185 $tpl = new ilTemplate('tpl.tst_question_info.html', true, true, 'components/ILIAS/Test');
186
187 // position and/or points
188 switch ($this->getHeaderMode()) {
189 case 1: // only titles => show position here
191 break;
192
193 case 3: // only points => show nothing here
195 break;
196 case 2: // neither titles nor points => position is separate title, show nothing here
197 $text = '';
198 break;
199
200 case 0: // titles and points => show position and points here
201 default:
202 $text = $this->buildQuestionPositionString() . ' (' . $this->buildQuestionPointsString() . ')';
203 }
204 if ($this->isQuestionPostponed()) {
205 $text .= ($text ? ', ' : '') . $this->buildQuestionPostponedString();
206 }
207
208 $tpl->setVariable('TXT_POSITION_POINTS', $text);
209
210 if (strlen($this->getQuestionRelatedObjectives())) {
211 $tpl->setVariable('TXT_OBJECTIVES', $this->buildQuestionRelatedObjectivesString());
212 }
213
214 if ($this->isQuestionAnswered()) {
215 $tpl->setVariable('HIDDEN_NOT_ANSWERED', 'hidden');
216 } else {
217 $tpl->setVariable('HIDDEN_ANSWERED', 'hidden');
218 }
219
220 $tpl->setVariable('SRC_ANSWERED', ilUtil::getImagePath('object/answered.svg'));
221 $tpl->setVariable('SRC_NOT_ANSWERED', ilUtil::getImagePath('object/answered_not.svg'));
222 $tpl->setVariable('TXT_ANSWERED', $this->lng->txt('tst_answer_status_answered'));
223 $tpl->setVariable('TXT_NOT_ANSWERED', $this->lng->txt('tst_answer_status_not_answered'));
224 $tpl->setVariable('TXT_EDITING', $this->lng->txt('tst_answer_status_editing'));
225
226 return $tpl->get();
227 }
special template class to simplify handling of ITX/PEAR
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
readonly ilGlobalTemplateInterface $tpl
$text
Definition: xapiexit.php:21

References $text, ILIAS\News\Common\Table\$tpl, buildQuestionPointsString(), buildQuestionPositionString(), buildQuestionPostponedString(), buildQuestionRelatedObjectivesString(), ILIAS\UICore\GlobalTemplate\get(), getHeaderMode(), ilUtil\getImagePath(), getQuestionRelatedObjectives(), isQuestionAnswered(), isQuestionPostponed(), ILIAS\Repository\lng(), and ILIAS\UICore\GlobalTemplate\setVariable().

+ Here is the call graph for this function:

◆ getQuestionPoints()

ilTestQuestionHeaderBlockBuilder::getQuestionPoints ( )

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

References $question_points.

Referenced by buildQuestionPointsString().

+ Here is the caller graph for this function:

◆ getQuestionPosition()

ilTestQuestionHeaderBlockBuilder::getQuestionPosition ( )

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

References $question_position.

Referenced by buildQuestionPositionString().

+ Here is the caller graph for this function:

◆ getQuestionRelatedObjectives()

ilTestQuestionHeaderBlockBuilder::getQuestionRelatedObjectives ( )

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

References $question_related_objectives.

Referenced by buildQuestionRelatedObjectivesString(), and getQuestionInfoHTML().

+ Here is the caller graph for this function:

◆ getQuestionTitle()

ilTestQuestionHeaderBlockBuilder::getQuestionTitle ( )

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

References $question_title.

Referenced by getPresentationTitle(), and getQuestionTitleForHTMLOutput().

+ Here is the caller graph for this function:

◆ getQuestionTitleForHTMLOutput()

ilTestQuestionHeaderBlockBuilder::getQuestionTitleForHTMLOutput ( )
protected

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

60 : string
61 {
62 return htmlspecialchars($this->getQuestionTitle(), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
63 }

References getQuestionTitle().

Referenced by getHTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isQuestionAnswered()

ilTestQuestionHeaderBlockBuilder::isQuestionAnswered ( )

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

References $question_answered.

Referenced by getQuestionInfoHTML().

+ Here is the caller graph for this function:

◆ isQuestionPostponed()

ilTestQuestionHeaderBlockBuilder::isQuestionPostponed ( )

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

References $question_postponed.

Referenced by buildQuestionPostponedString(), and getQuestionInfoHTML().

+ Here is the caller graph for this function:

◆ setHeaderMode()

ilTestQuestionHeaderBlockBuilder::setHeaderMode ( int  $header_mode)

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

45 : void
46 {
47 $this->header_mode = $header_mode;
48 }

References $header_mode.

◆ setQuestionAnswered()

ilTestQuestionHeaderBlockBuilder::setQuestionAnswered ( bool  $question_answered)

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

75 : void
76 {
77 $this->question_answered = $question_answered;
78 }

References $question_answered.

◆ setQuestionCount()

ilTestQuestionHeaderBlockBuilder::setQuestionCount ( int  $question_count)

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

95 : void
96 {
97 $this->question_count = $question_count;
98 }

References $question_count.

◆ setQuestionPoints()

ilTestQuestionHeaderBlockBuilder::setQuestionPoints ( float  $question_points)

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

70 : void
71 {
72 $this->question_points = $question_points;
73 }

References $question_points.

◆ setQuestionPosition()

ilTestQuestionHeaderBlockBuilder::setQuestionPosition ( int  $question_position)

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

85 : void
86 {
87 $this->question_position = $question_position;
88 }

References $question_position.

◆ setQuestionPostponed()

ilTestQuestionHeaderBlockBuilder::setQuestionPostponed ( bool  $question_postponed)

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

110 : void
111 {
112 $this->question_postponed = $question_postponed;
113 }

References $question_postponed.

◆ setQuestionRelatedObjectives()

ilTestQuestionHeaderBlockBuilder::setQuestionRelatedObjectives ( string  $question_related_objectives)

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

120 : void
121 {
122 $this->question_related_objectives = $question_related_objectives;
123 }

References $question_related_objectives.

◆ setQuestionTitle()

ilTestQuestionHeaderBlockBuilder::setQuestionTitle ( string  $question_title)

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

55 : void
56 {
57 $this->question_title = $question_title;
58 }

References $question_title.

Field Documentation

◆ $header_mode

int ilTestQuestionHeaderBlockBuilder::$header_mode = null
protected

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

Referenced by getHeaderMode(), and setHeaderMode().

◆ $question_answered

bool ilTestQuestionHeaderBlockBuilder::$question_answered = null
protected

◆ $question_count

int ilTestQuestionHeaderBlockBuilder::$question_count = 0
protected

◆ $question_points

float ilTestQuestionHeaderBlockBuilder::$question_points = 0.0
protected

◆ $question_position

int ilTestQuestionHeaderBlockBuilder::$question_position = 0
protected

◆ $question_postponed

bool ilTestQuestionHeaderBlockBuilder::$question_postponed = false
protected

◆ $question_related_objectives

string ilTestQuestionHeaderBlockBuilder::$question_related_objectives = ''
protected

◆ $question_title

string ilTestQuestionHeaderBlockBuilder::$question_title = ''
protected

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