ILIAS  release_8 Revision v8.24
ilTestGradingMessageBuilder Class Reference
+ Collaboration diagram for ilTestGradingMessageBuilder:

Public Member Functions

 __construct (ilLanguage $lng, ilObjTest $testOBJ)
 
 setActiveId ($activeId)
 
 getActiveId ()
 
 buildMessage ()
 
 sendMessage ()
 
 buildList ()
 
 initListTemplate ()
 
 getList ()
 

Private Member Functions

 addMessagePart ($msgPart)
 
 getFullMessage ()
 
 isPassed ()
 
 loadResultData ()
 
 buildGradingStatusMsg ()
 
 buildGradingMarkMsg ()
 
 getMarkOfficial ()
 
 getMarkShort ()
 
 getPercentage ()
 
 getReachedPoints ()
 
 getMaxPoints ()
 
 areObligationsAnswered ()
 
 buildEctsGradeMsg ()
 
 getEctsGrade ()
 
 populateListEntry ($label, $value)
 
 parseListTemplate ()
 

Private Attributes

 $lng
 
 $testOBJ
 
 $tpl
 
 $resultData
 
 $activeId
 
 $container
 
array $messageText = []
 

Detailed Description

Definition at line 25 of file class.ilTestGradingMessageBuilder.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestGradingMessageBuilder::__construct ( ilLanguage  $lng,
ilObjTest  $testOBJ 
)
Parameters
ilLanguage$lng
ilObjTest$testOBJ

Definition at line 62 of file class.ilTestGradingMessageBuilder.php.

63 {
64 global $DIC;
65 $this->container = $DIC;
66 $this->lng = $lng;
67 $this->testOBJ = $testOBJ;
68 }
global $DIC
Definition: feed.php:28

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addMessagePart()

ilTestGradingMessageBuilder::addMessagePart (   $msgPart)
private

Definition at line 97 of file class.ilTestGradingMessageBuilder.php.

98 {
99 $this->messageText[] = $msgPart;
100 }

Referenced by buildMessage().

+ Here is the caller graph for this function:

◆ areObligationsAnswered()

ilTestGradingMessageBuilder::areObligationsAnswered ( )
private

Definition at line 191 of file class.ilTestGradingMessageBuilder.php.

191 : bool
192 {
193 return (bool) $this->resultData['obligations_answered'];
194 }

Referenced by buildList().

+ Here is the caller graph for this function:

◆ buildEctsGradeMsg()

ilTestGradingMessageBuilder::buildEctsGradeMsg ( )
private

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

197 {
198 return str_replace('[markects]', $this->getEctsGrade(), $this->lng->txt('mark_tst_ects'));
199 }

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

Referenced by buildMessage().

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

◆ buildGradingMarkMsg()

ilTestGradingMessageBuilder::buildGradingMarkMsg ( )
private

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

148 {
149 $markMsg = $this->lng->txt('grading_mark_msg');
150
151 $markMsg = str_replace("[mark]", $this->getMarkOfficial(), $markMsg);
152 $markMsg = str_replace("[markshort]", $this->getMarkShort(), $markMsg);
153 $markMsg = str_replace("[percentage]", $this->getPercentage(), $markMsg);
154 $markMsg = str_replace("[reached]", $this->getReachedPoints(), $markMsg);
155 $markMsg = str_replace("[max]", $this->getMaxPoints(), $markMsg);
156
157 return $markMsg;
158 }

References getMarkOfficial(), getMarkShort(), getMaxPoints(), getPercentage(), getReachedPoints(), and ILIAS\Repository\lng().

Referenced by buildMessage().

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

◆ buildGradingStatusMsg()

ilTestGradingMessageBuilder::buildGradingStatusMsg ( )
private

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

138 : string
139 {
140 if ($this->isPassed()) {
141 return $this->lng->txt('grading_status_passed_msg');
142 }
143
144 return $this->lng->txt('grading_status_failed_msg');
145 }

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

Referenced by buildMessage().

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

◆ buildList()

ilTestGradingMessageBuilder::buildList ( )

Definition at line 206 of file class.ilTestGradingMessageBuilder.php.

207 {
208 $this->loadResultData();
209
210 $this->initListTemplate();
211
212 if ($this->testOBJ->isShowGradingStatusEnabled()) {
213 $passedStatusLangVar = $this->isPassed() ? 'passed_official' : 'failed_official';
214
215 $this->populateListEntry(
216 $this->lng->txt('passed_status'),
217 $this->lng->txt($passedStatusLangVar)
218 );
219 }
220
221 if ($this->testOBJ->areObligationsEnabled()) {
222 if ($this->areObligationsAnswered()) {
223 $obligAnsweredStatusLangVar = 'grading_obligations_answered_listentry';
224 } else {
225 $obligAnsweredStatusLangVar = 'grading_obligations_missing_listentry';
226 }
227
228 $this->populateListEntry(
229 $this->lng->txt('grading_obligations_listlabel'),
230 $this->lng->txt($obligAnsweredStatusLangVar)
231 );
232 }
233
234 if ($this->testOBJ->isShowGradingMarkEnabled()) {
235 $this->populateListEntry($this->lng->txt('tst_mark'), $this->getMarkOfficial());
236 }
237
238 if ($this->testOBJ->getECTSOutput()) {
239 $this->populateListEntry($this->lng->txt('ects_grade'), $this->getEctsGrade());
240 }
241
242 $this->parseListTemplate();
243 }

References areObligationsAnswered(), initListTemplate(), isPassed(), ILIAS\Repository\lng(), loadResultData(), parseListTemplate(), and populateListEntry().

+ Here is the call graph for this function:

◆ buildMessage()

ilTestGradingMessageBuilder::buildMessage ( )

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

81 {
82 $this->loadResultData();
83
84 if ($this->testOBJ->isShowGradingStatusEnabled()) {
86 }
87
88 if ($this->testOBJ->isShowGradingMarkEnabled()) {
89 $this->addMessagePart($this->buildGradingMarkMsg());
90 }
91
92 if ($this->testOBJ->getECTSOutput()) {
93 $this->addMessagePart($this->buildEctsGradeMsg());
94 }
95 }

References addMessagePart(), buildEctsGradeMsg(), buildGradingMarkMsg(), buildGradingStatusMsg(), and loadResultData().

+ Here is the call graph for this function:

◆ getActiveId()

ilTestGradingMessageBuilder::getActiveId ( )

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

References $activeId.

Referenced by loadResultData().

+ Here is the caller graph for this function:

◆ getEctsGrade()

ilTestGradingMessageBuilder::getEctsGrade ( )
private

Definition at line 201 of file class.ilTestGradingMessageBuilder.php.

202 {
203 return $this->resultData['ects_grade'];
204 }

Referenced by buildEctsGradeMsg().

+ Here is the caller graph for this function:

◆ getFullMessage()

ilTestGradingMessageBuilder::getFullMessage ( )
private

Definition at line 102 of file class.ilTestGradingMessageBuilder.php.

102 : string
103 {
104 return implode(' ', $this->messageText);
105 }

Referenced by sendMessage().

+ Here is the caller graph for this function:

◆ getList()

ilTestGradingMessageBuilder::getList ( )

Definition at line 264 of file class.ilTestGradingMessageBuilder.php.

264 : string
265 {
266 return $this->tpl->get();
267 }

◆ getMarkOfficial()

ilTestGradingMessageBuilder::getMarkOfficial ( )
private

Definition at line 160 of file class.ilTestGradingMessageBuilder.php.

161 {
162 return $this->resultData['mark_official'];
163 }

Referenced by buildGradingMarkMsg().

+ Here is the caller graph for this function:

◆ getMarkShort()

ilTestGradingMessageBuilder::getMarkShort ( )
private

Definition at line 165 of file class.ilTestGradingMessageBuilder.php.

166 {
167 return $this->resultData['mark_short'];
168 }

Referenced by buildGradingMarkMsg().

+ Here is the caller graph for this function:

◆ getMaxPoints()

ilTestGradingMessageBuilder::getMaxPoints ( )
private

Definition at line 186 of file class.ilTestGradingMessageBuilder.php.

187 {
188 return $this->resultData['max_points'];
189 }

Referenced by buildGradingMarkMsg(), and getPercentage().

+ Here is the caller graph for this function:

◆ getPercentage()

ilTestGradingMessageBuilder::getPercentage ( )
private

Definition at line 170 of file class.ilTestGradingMessageBuilder.php.

170 : string
171 {
172 $percentage = 0;
173
174 if ($this->getMaxPoints() > 0) {
175 $percentage = $this->getReachedPoints() / $this->getMaxPoints();
176 }
177
178 return sprintf("%.2f", $percentage);
179 }

References getMaxPoints(), and getReachedPoints().

Referenced by buildGradingMarkMsg().

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

◆ getReachedPoints()

ilTestGradingMessageBuilder::getReachedPoints ( )
private

Definition at line 181 of file class.ilTestGradingMessageBuilder.php.

182 {
183 return $this->resultData['reached_points'];
184 }

Referenced by buildGradingMarkMsg(), and getPercentage().

+ Here is the caller graph for this function:

◆ initListTemplate()

ilTestGradingMessageBuilder::initListTemplate ( )

Definition at line 245 of file class.ilTestGradingMessageBuilder.php.

246 {
247 $this->tpl = new ilTemplate('tpl.tst_grading_msg_list.html', true, true, 'Modules/Test');
248 }
special template class to simplify handling of ITX/PEAR

Referenced by buildList().

+ Here is the caller graph for this function:

◆ isPassed()

ilTestGradingMessageBuilder::isPassed ( )
private

Definition at line 107 of file class.ilTestGradingMessageBuilder.php.

107 : bool
108 {
109 return (bool) $this->resultData['passed'];
110 }

Referenced by buildGradingStatusMsg(), buildList(), and sendMessage().

+ Here is the caller graph for this function:

◆ loadResultData()

ilTestGradingMessageBuilder::loadResultData ( )
private

Definition at line 123 of file class.ilTestGradingMessageBuilder.php.

124 {
125 $this->resultData = $this->testOBJ->getResultsForActiveId($this->getActiveId());
126
127 if ($this->testOBJ->getECTSOutput()) {
128 $ectsMark = $this->testOBJ->getECTSGrade(
129 $this->testOBJ->getTotalPointsPassedArray(),
130 $this->resultData['reached_points'],
131 $this->resultData['max_points']
132 );
133
134 $this->resultData['ects_grade'] = strtoupper($ectsMark);
135 }
136 }

References getActiveId().

Referenced by buildList(), and buildMessage().

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

◆ parseListTemplate()

ilTestGradingMessageBuilder::parseListTemplate ( )
private

Definition at line 258 of file class.ilTestGradingMessageBuilder.php.

259 {
260 $this->tpl->setCurrentBlock('grading_msg_list');
261 $this->tpl->parseCurrentBlock();
262 }

Referenced by buildList().

+ Here is the caller graph for this function:

◆ populateListEntry()

ilTestGradingMessageBuilder::populateListEntry (   $label,
  $value 
)
private

Definition at line 250 of file class.ilTestGradingMessageBuilder.php.

251 {
252 $this->tpl->setCurrentBlock('grading_msg_entry');
253 $this->tpl->setVariable('LABEL', $label);
254 $this->tpl->setVariable('VALUE', $value);
255 $this->tpl->parseCurrentBlock();
256 }

Referenced by buildList().

+ Here is the caller graph for this function:

◆ sendMessage()

ilTestGradingMessageBuilder::sendMessage ( )

Definition at line 112 of file class.ilTestGradingMessageBuilder.php.

113 {
114 if (!$this->testOBJ->isShowGradingStatusEnabled()) {
115 $this->container->ui()->mainTemplate()->setOnScreenMessage('info', $this->getFullMessage());
116 } elseif ($this->isPassed()) {
117 $this->container->ui()->mainTemplate()->setOnScreenMessage('success', $this->getFullMessage());
118 } else {
119 $this->container->ui()->mainTemplate()->setOnScreenMessage('info', $this->getFullMessage());
120 }
121 }

References getFullMessage(), and isPassed().

+ Here is the call graph for this function:

◆ setActiveId()

ilTestGradingMessageBuilder::setActiveId (   $activeId)

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

71 {
72 $this->activeId = $activeId;
73 }

References $activeId.

Field Documentation

◆ $activeId

ilTestGradingMessageBuilder::$activeId
private

Definition at line 47 of file class.ilTestGradingMessageBuilder.php.

Referenced by getActiveId(), and setActiveId().

◆ $container

ilTestGradingMessageBuilder::$container
private

Definition at line 51 of file class.ilTestGradingMessageBuilder.php.

◆ $lng

ilTestGradingMessageBuilder::$lng
private

Definition at line 30 of file class.ilTestGradingMessageBuilder.php.

Referenced by __construct().

◆ $messageText

string[] ilTestGradingMessageBuilder::$messageText = []
private

Definition at line 56 of file class.ilTestGradingMessageBuilder.php.

◆ $resultData

ilTestGradingMessageBuilder::$resultData
private

Definition at line 42 of file class.ilTestGradingMessageBuilder.php.

◆ $testOBJ

ilTestGradingMessageBuilder::$testOBJ
private

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

Referenced by __construct().

◆ $tpl

ilTestGradingMessageBuilder::$tpl
private

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


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