ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 ()
 
 buildObligationsMsg ()
 
 areObligationsAnswered ()
 
 buildEctsGradeMsg ()
 
 getEctsGrade ()
 
 populateListEntry ($label, $value)
 
 parseListTemplate ()
 

Private Attributes

 $lng
 
 $testOBJ
 
 $tpl
 
 $resultData
 
 $activeId
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References $lng, and $testOBJ.

Member Function Documentation

◆ addMessagePart()

ilTestGradingMessageBuilder::addMessagePart (   $msgPart)
private

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

Referenced by buildMessage().

84  {
85  $this->messageText[] = $msgPart;
86  }
+ Here is the caller graph for this function:

◆ areObligationsAnswered()

ilTestGradingMessageBuilder::areObligationsAnswered ( )
private

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

Referenced by buildList(), and buildObligationsMsg().

196  {
197  return (bool)$this->resultData['obligations_answered'];
198  }
+ Here is the caller graph for this function:

◆ buildEctsGradeMsg()

ilTestGradingMessageBuilder::buildEctsGradeMsg ( )
private

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

References getEctsGrade().

Referenced by buildMessage().

201  {
202  return str_replace('[markects]', $this->getEctsGrade(), $this->lng->txt('mark_tst_ects'));
203  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildGradingMarkMsg()

ilTestGradingMessageBuilder::buildGradingMarkMsg ( )
private

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

References getMarkOfficial(), getMarkShort(), getMaxPoints(), getPercentage(), and getReachedPoints().

Referenced by buildMessage().

141  {
142  $markMsg = $this->lng->txt('grading_mark_msg');
143 
144  $markMsg = str_replace("[mark]", $this->getMarkOfficial(), $markMsg);
145  $markMsg = str_replace("[markshort]", $this->getMarkShort(), $markMsg);
146  $markMsg = str_replace("[percentage]", $this->getPercentage(), $markMsg);
147  $markMsg = str_replace("[reached]", $this->getReachedPoints(), $markMsg);
148  $markMsg = str_replace("[max]", $this->getMaxPoints(), $markMsg);
149 
150  return $markMsg;
151  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildGradingStatusMsg()

ilTestGradingMessageBuilder::buildGradingStatusMsg ( )
private

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

References isPassed().

Referenced by buildMessage().

131  {
132  if( $this->isPassed() )
133  {
134  return $this->lng->txt('grading_status_passed_msg');
135  }
136 
137  return $this->lng->txt('grading_status_failed_msg');
138  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildList()

ilTestGradingMessageBuilder::buildList ( )

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

References areObligationsAnswered(), getEctsGrade(), getMarkOfficial(), initListTemplate(), isPassed(), loadResultData(), parseListTemplate(), and populateListEntry().

211  {
212  $this->loadResultData();
213 
214  $this->initListTemplate();
215 
216  if( $this->testOBJ->isShowGradingStatusEnabled() )
217  {
218  $passedStatusLangVar = $this->isPassed() ? 'passed_official' : 'failed_official';
219 
220  $this->populateListEntry(
221  $this->lng->txt('passed_status'), $this->lng->txt($passedStatusLangVar)
222  );
223  }
224 
225  if( $this->testOBJ->areObligationsEnabled() )
226  {
227  if( $this->areObligationsAnswered() )
228  {
229  $obligAnsweredStatusLangVar = 'grading_obligations_answered_listentry';
230  }
231  else
232  {
233  $obligAnsweredStatusLangVar = 'grading_obligations_missing_listentry';
234  }
235 
236  $this->populateListEntry(
237  $this->lng->txt('grading_obligations_listlabel'), $this->lng->txt($obligAnsweredStatusLangVar)
238  );
239  }
240 
241  if( $this->testOBJ->isShowGradingMarkEnabled() )
242  {
243  $this->populateListEntry($this->lng->txt('tst_mark'), $this->getMarkOfficial());
244  }
245 
246  if( $this->testOBJ->getECTSOutput() )
247  {
248  $this->populateListEntry($this->lng->txt('ects_grade'), $this->getEctsGrade());
249  }
250 
251  $this->parseListTemplate();
252  }
+ Here is the call graph for this function:

◆ buildMessage()

ilTestGradingMessageBuilder::buildMessage ( )

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

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

59  {
60  $this->loadResultData();
61 
62  if( $this->testOBJ->isShowGradingStatusEnabled() )
63  {
64  $this->addMessagePart($this->buildGradingStatusMsg());
65  }
66 
67  if( $this->testOBJ->areObligationsEnabled() )
68  {
69  $this->addMessagePart($this->buildObligationsMsg());
70  }
71 
72  if( $this->testOBJ->isShowGradingMarkEnabled() )
73  {
74  $this->addMessagePart($this->buildGradingMarkMsg());
75  }
76 
77  if( $this->testOBJ->getECTSOutput() )
78  {
79  $this->addMessagePart($this->buildEctsGradeMsg());
80  }
81  }
+ Here is the call graph for this function:

◆ buildObligationsMsg()

ilTestGradingMessageBuilder::buildObligationsMsg ( )
private

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

References areObligationsAnswered().

Referenced by buildMessage().

186  {
187  if( $this->areObligationsAnswered() )
188  {
189  return $this->lng->txt('grading_obligations_answered_msg');
190  }
191 
192  return $this->lng->txt('grading_obligations_missing_msg');
193  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActiveId()

ilTestGradingMessageBuilder::getActiveId ( )

Definition at line 53 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 205 of file class.ilTestGradingMessageBuilder.php.

Referenced by buildEctsGradeMsg(), and buildList().

206  {
207  return $this->resultData['ects_grade'];
208  }
+ Here is the caller graph for this function:

◆ getFullMessage()

ilTestGradingMessageBuilder::getFullMessage ( )
private

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

Referenced by sendMessage().

89  {
90  return implode(' ', $this->messageText);
91  }
+ Here is the caller graph for this function:

◆ getList()

ilTestGradingMessageBuilder::getList ( )

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

274  {
275  return $this->tpl->get();
276  }

◆ getMarkOfficial()

ilTestGradingMessageBuilder::getMarkOfficial ( )
private

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

Referenced by buildGradingMarkMsg(), and buildList().

154  {
155  return $this->resultData['mark_official'];
156  }
+ Here is the caller graph for this function:

◆ getMarkShort()

ilTestGradingMessageBuilder::getMarkShort ( )
private

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

Referenced by buildGradingMarkMsg().

159  {
160  return $this->resultData['mark_short'];
161  }
+ Here is the caller graph for this function:

◆ getMaxPoints()

ilTestGradingMessageBuilder::getMaxPoints ( )
private

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

Referenced by buildGradingMarkMsg(), and getPercentage().

181  {
182  return $this->resultData['max_points'];
183  }
+ Here is the caller graph for this function:

◆ getPercentage()

ilTestGradingMessageBuilder::getPercentage ( )
private

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

References getMaxPoints(), and getReachedPoints().

Referenced by buildGradingMarkMsg().

164  {
165  $percentage = 0;
166 
167  if( $this->getMaxPoints() > 0 )
168  {
169  $percentage = $this->getReachedPoints() / $this->getMaxPoints();
170  }
171 
172  return sprintf("%.2f", $percentage);
173  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getReachedPoints()

ilTestGradingMessageBuilder::getReachedPoints ( )
private

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

Referenced by buildGradingMarkMsg(), and getPercentage().

176  {
177  return $this->resultData['reached_points'];
178  }
+ Here is the caller graph for this function:

◆ initListTemplate()

ilTestGradingMessageBuilder::initListTemplate ( )

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

Referenced by buildList().

255  {
256  $this->tpl = new ilTemplate('tpl.tst_grading_msg_list.html', true, true, 'Modules/Test');
257  }
special template class to simplify handling of ITX/PEAR
+ Here is the caller graph for this function:

◆ isPassed()

ilTestGradingMessageBuilder::isPassed ( )
private

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

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

94  {
95  return (bool)$this->resultData['passed'];
96  }
+ Here is the caller graph for this function:

◆ loadResultData()

ilTestGradingMessageBuilder::loadResultData ( )
private

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

References getActiveId().

Referenced by buildList(), and buildMessage().

115  {
116  $this->resultData = $this->testOBJ->getResultsForActiveId($this->getActiveId());
117 
118  if( $this->testOBJ->getECTSOutput() )
119  {
120  $ectsMark = $this->testOBJ->getECTSGrade(
121  $this->testOBJ->getTotalPointsPassedArray(),
122  $this->resultData['reached_points'],
123  $this->resultData['max_points']
124  );
125 
126  $this->resultData['ects_grade'] = strtoupper($ectsMark);
127  }
128  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseListTemplate()

ilTestGradingMessageBuilder::parseListTemplate ( )
private

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

Referenced by buildList().

268  {
269  $this->tpl->setCurrentBlock('grading_msg_list');
270  $this->tpl->parseCurrentBlock();
271  }
+ Here is the caller graph for this function:

◆ populateListEntry()

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

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

Referenced by buildList().

260  {
261  $this->tpl->setCurrentBlock('grading_msg_entry');
262  $this->tpl->setVariable('LABEL', $label);
263  $this->tpl->setVariable('VALUE', $value);
264  $this->tpl->parseCurrentBlock();
265  }
+ Here is the caller graph for this function:

◆ sendMessage()

ilTestGradingMessageBuilder::sendMessage ( )

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

References getFullMessage(), isPassed(), ilUtil\sendFailure(), ilUtil\sendInfo(), and ilUtil\sendSuccess().

99  {
100  if( !$this->testOBJ->isShowGradingStatusEnabled() )
101  {
103  }
104  elseif( $this->isPassed() )
105  {
107  }
108  else
109  {
111  }
112  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ setActiveId()

ilTestGradingMessageBuilder::setActiveId (   $activeId)

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

References $activeId.

49  {
50  $this->activeId = $activeId;
51  }

Field Documentation

◆ $activeId

ilTestGradingMessageBuilder::$activeId
private

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

Referenced by getActiveId(), and setActiveId().

◆ $lng

ilTestGradingMessageBuilder::$lng
private

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

Referenced by __construct().

◆ $resultData

ilTestGradingMessageBuilder::$resultData
private

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

◆ $testOBJ

ilTestGradingMessageBuilder::$testOBJ
private

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

Referenced by __construct().

◆ $tpl

ilTestGradingMessageBuilder::$tpl
private

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


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