ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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

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

133 : string
134 {
135 if ($this->getQuestionPoints() == 1) {
136 return "{$this->getQuestionPoints()} {$this->lng->txt('point')}";
137 }
138
139 return "{$this->getQuestionPoints()} {$this->lng->txt('points')}";
140 }

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

120 : string
121 {
122 if (!$this->getQuestionPosition()) {
123 return '';
124 }
125
126 if ($this->getQuestionCount()) {
127 return sprintf($this->lng->txt('tst_position'), $this->getQuestionPosition(), $this->getQuestionCount());
128 }
129
130 return sprintf($this->lng->txt('tst_position_without_total'), $this->getQuestionPosition());
131 }

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

142 : string
143 {
144 if ($this->isQuestionPostponed()) {
145 return $this->lng->txt('postponed');
146 }
147
148 return '';
149 }

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

151 : string
152 {
153 if (strlen($this->getQuestionRelatedObjectives())) {
154 $label = $this->lng->txt('tst_res_lo_objectives_header');
155 return $label . ': ' . $this->getQuestionRelatedObjectives();
156 }
157
158 return '';
159 }

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

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

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

+ Here is the call graph for this function:

◆ getPresentationTitle()

ilTestQuestionHeaderBlockBuilder::getPresentationTitle ( )

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

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

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

+ Here is the call graph for this function:

◆ getQuestionCount()

ilTestQuestionHeaderBlockBuilder::getQuestionCount ( )

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

178 : string
179 {
180 $tpl = new ilTemplate('tpl.tst_question_info.html', true, true, 'components/ILIAS/Test');
181
182 // position and/or points
183 switch ($this->getHeaderMode()) {
184 case 1: // only titles => show position here
185 $text = $this->buildQuestionPositionString();
186 break;
187
188 case 3: // only points => show nothing here
189 $text = $this->buildQuestionPositionString();
190 break;
191 case 2: // neither titles nor points => position is separate title, show nothing here
192 $text = '';
193 break;
194
195 case 0: // titles and points => show position and points here
196 default:
197 $text = $this->buildQuestionPositionString() . ' (' . $this->buildQuestionPointsString() . ')';
198 }
199 if ($this->isQuestionPostponed()) {
200 $text .= ($text ? ', ' : '') . $this->buildQuestionPostponedString();
201 }
202
203 $tpl->setVariable('TXT_POSITION_POINTS', $text);
204
205 if (strlen($this->getQuestionRelatedObjectives())) {
206 $tpl->setVariable('TXT_OBJECTIVES', $this->buildQuestionRelatedObjectivesString());
207 }
208
209 if ($this->isQuestionAnswered()) {
210 $tpl->setVariable('HIDDEN_NOT_ANSWERED', 'hidden');
211 } else {
212 $tpl->setVariable('HIDDEN_ANSWERED', 'hidden');
213 }
214
215 $tpl->setVariable('SRC_ANSWERED', ilUtil::getImagePath('object/answered.svg'));
216 $tpl->setVariable('SRC_NOT_ANSWERED', ilUtil::getImagePath('object/answered_not.svg'));
217 $tpl->setVariable('TXT_ANSWERED', $this->lng->txt('tst_answer_status_answered'));
218 $tpl->setVariable('TXT_NOT_ANSWERED', $this->lng->txt('tst_answer_status_not_answered'));
219 $tpl->setVariable('TXT_EDITING', $this->lng->txt('tst_answer_status_editing'));
220
221 return $tpl->get();
222 }
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)

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

+ Here is the call graph for this function:

◆ getQuestionPoints()

ilTestQuestionHeaderBlockBuilder::getQuestionPoints ( )

Definition at line 60 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 75 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 110 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 getHTML(), and getPresentationTitle().

+ Here is the caller graph for this function:

◆ isQuestionAnswered()

ilTestQuestionHeaderBlockBuilder::isQuestionAnswered ( )

Definition at line 100 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 95 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 70 of file class.ilTestQuestionHeaderBlockBuilder.php.

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

References $question_answered.

◆ setQuestionCount()

ilTestQuestionHeaderBlockBuilder::setQuestionCount ( int  $question_count)

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

90 : void
91 {
92 $this->question_count = $question_count;
93 }

References $question_count.

◆ setQuestionPoints()

ilTestQuestionHeaderBlockBuilder::setQuestionPoints ( float  $question_points)

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

65 : void
66 {
67 $this->question_points = $question_points;
68 }

References $question_points.

◆ setQuestionPosition()

ilTestQuestionHeaderBlockBuilder::setQuestionPosition ( int  $question_position)

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

80 : void
81 {
82 $this->question_position = $question_position;
83 }

References $question_position.

◆ setQuestionPostponed()

ilTestQuestionHeaderBlockBuilder::setQuestionPostponed ( bool  $question_postponed)

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

105 : void
106 {
107 $this->question_postponed = $question_postponed;
108 }

References $question_postponed.

◆ setQuestionRelatedObjectives()

ilTestQuestionHeaderBlockBuilder::setQuestionRelatedObjectives ( string  $question_related_objectives)

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

115 : void
116 {
117 $this->question_related_objectives = $question_related_objectives;
118 }

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: