ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 79 of file class.ilTestGradingMessageBuilder.php.

Referenced by buildMessage().

80  {
81  $this->messageText[] = $msgPart;
82  }
+ Here is the caller graph for this function:

◆ areObligationsAnswered()

ilTestGradingMessageBuilder::areObligationsAnswered ( )
private

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

Referenced by buildList(), and buildObligationsMsg().

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

◆ buildEctsGradeMsg()

ilTestGradingMessageBuilder::buildEctsGradeMsg ( )
private

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

References getEctsGrade().

Referenced by buildMessage().

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

◆ buildGradingMarkMsg()

ilTestGradingMessageBuilder::buildGradingMarkMsg ( )
private

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

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

Referenced by buildMessage().

130  {
131  $markMsg = $this->lng->txt('grading_mark_msg');
132 
133  $markMsg = str_replace("[mark]", $this->getMarkOfficial(), $markMsg);
134  $markMsg = str_replace("[markshort]", $this->getMarkShort(), $markMsg);
135  $markMsg = str_replace("[percentage]", $this->getPercentage(), $markMsg);
136  $markMsg = str_replace("[reached]", $this->getReachedPoints(), $markMsg);
137  $markMsg = str_replace("[max]", $this->getMaxPoints(), $markMsg);
138 
139  return $markMsg;
140  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildGradingStatusMsg()

ilTestGradingMessageBuilder::buildGradingStatusMsg ( )
private

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

References isPassed().

Referenced by buildMessage().

121  {
122  if ($this->isPassed()) {
123  return $this->lng->txt('grading_status_passed_msg');
124  }
125 
126  return $this->lng->txt('grading_status_failed_msg');
127  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildList()

ilTestGradingMessageBuilder::buildList ( )

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

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

198  {
199  $this->loadResultData();
200 
201  $this->initListTemplate();
202 
203  if ($this->testOBJ->isShowGradingStatusEnabled()) {
204  $passedStatusLangVar = $this->isPassed() ? 'passed_official' : 'failed_official';
205 
206  $this->populateListEntry(
207  $this->lng->txt('passed_status'),
208  $this->lng->txt($passedStatusLangVar)
209  );
210  }
211 
212  if ($this->testOBJ->areObligationsEnabled()) {
213  if ($this->areObligationsAnswered()) {
214  $obligAnsweredStatusLangVar = 'grading_obligations_answered_listentry';
215  } else {
216  $obligAnsweredStatusLangVar = 'grading_obligations_missing_listentry';
217  }
218 
219  $this->populateListEntry(
220  $this->lng->txt('grading_obligations_listlabel'),
221  $this->lng->txt($obligAnsweredStatusLangVar)
222  );
223  }
224 
225  if ($this->testOBJ->isShowGradingMarkEnabled()) {
226  $this->populateListEntry($this->lng->txt('tst_mark'), $this->getMarkOfficial());
227  }
228 
229  if ($this->testOBJ->getECTSOutput()) {
230  $this->populateListEntry($this->lng->txt('ects_grade'), $this->getEctsGrade());
231  }
232 
233  $this->parseListTemplate();
234  }
+ 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  $this->addMessagePart($this->buildGradingStatusMsg());
64  }
65 
66  if ($this->testOBJ->areObligationsEnabled()) {
67  $this->addMessagePart($this->buildObligationsMsg());
68  }
69 
70  if ($this->testOBJ->isShowGradingMarkEnabled()) {
71  $this->addMessagePart($this->buildGradingMarkMsg());
72  }
73 
74  if ($this->testOBJ->getECTSOutput()) {
75  $this->addMessagePart($this->buildEctsGradeMsg());
76  }
77  }
+ Here is the call graph for this function:

◆ buildObligationsMsg()

ilTestGradingMessageBuilder::buildObligationsMsg ( )
private

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

References areObligationsAnswered().

Referenced by buildMessage().

174  {
175  if ($this->areObligationsAnswered()) {
176  return $this->lng->txt('grading_obligations_answered_msg');
177  }
178 
179  return $this->lng->txt('grading_obligations_missing_msg');
180  }
+ 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 192 of file class.ilTestGradingMessageBuilder.php.

Referenced by buildEctsGradeMsg(), and buildList().

193  {
194  return $this->resultData['ects_grade'];
195  }
+ Here is the caller graph for this function:

◆ getFullMessage()

ilTestGradingMessageBuilder::getFullMessage ( )
private

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

Referenced by sendMessage().

85  {
86  return implode(' ', $this->messageText);
87  }
+ Here is the caller graph for this function:

◆ getList()

ilTestGradingMessageBuilder::getList ( )

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

256  {
257  return $this->tpl->get();
258  }

◆ getMarkOfficial()

ilTestGradingMessageBuilder::getMarkOfficial ( )
private

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

Referenced by buildGradingMarkMsg(), and buildList().

143  {
144  return $this->resultData['mark_official'];
145  }
+ Here is the caller graph for this function:

◆ getMarkShort()

ilTestGradingMessageBuilder::getMarkShort ( )
private

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

Referenced by buildGradingMarkMsg().

148  {
149  return $this->resultData['mark_short'];
150  }
+ Here is the caller graph for this function:

◆ getMaxPoints()

ilTestGradingMessageBuilder::getMaxPoints ( )
private

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

Referenced by buildGradingMarkMsg(), and getPercentage().

169  {
170  return $this->resultData['max_points'];
171  }
+ Here is the caller graph for this function:

◆ getPercentage()

ilTestGradingMessageBuilder::getPercentage ( )
private

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

References getMaxPoints(), and getReachedPoints().

Referenced by buildGradingMarkMsg().

153  {
154  $percentage = 0;
155 
156  if ($this->getMaxPoints() > 0) {
157  $percentage = $this->getReachedPoints() / $this->getMaxPoints();
158  }
159 
160  return sprintf("%.2f", $percentage);
161  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getReachedPoints()

ilTestGradingMessageBuilder::getReachedPoints ( )
private

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

Referenced by buildGradingMarkMsg(), and getPercentage().

164  {
165  return $this->resultData['reached_points'];
166  }
+ Here is the caller graph for this function:

◆ initListTemplate()

ilTestGradingMessageBuilder::initListTemplate ( )

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

Referenced by buildList().

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

◆ isPassed()

ilTestGradingMessageBuilder::isPassed ( )
private

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

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

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

◆ loadResultData()

ilTestGradingMessageBuilder::loadResultData ( )
private

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

References getActiveId().

Referenced by buildList(), and buildMessage().

106  {
107  $this->resultData = $this->testOBJ->getResultsForActiveId($this->getActiveId());
108 
109  if ($this->testOBJ->getECTSOutput()) {
110  $ectsMark = $this->testOBJ->getECTSGrade(
111  $this->testOBJ->getTotalPointsPassedArray(),
112  $this->resultData['reached_points'],
113  $this->resultData['max_points']
114  );
115 
116  $this->resultData['ects_grade'] = strtoupper($ectsMark);
117  }
118  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseListTemplate()

ilTestGradingMessageBuilder::parseListTemplate ( )
private

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

Referenced by buildList().

250  {
251  $this->tpl->setCurrentBlock('grading_msg_list');
252  $this->tpl->parseCurrentBlock();
253  }
+ Here is the caller graph for this function:

◆ populateListEntry()

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

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

Referenced by buildList().

242  {
243  $this->tpl->setCurrentBlock('grading_msg_entry');
244  $this->tpl->setVariable('LABEL', $label);
245  $this->tpl->setVariable('VALUE', $value);
246  $this->tpl->parseCurrentBlock();
247  }
+ Here is the caller graph for this function:

◆ sendMessage()

ilTestGradingMessageBuilder::sendMessage ( )

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

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

95  {
96  if (!$this->testOBJ->isShowGradingStatusEnabled()) {
98  } elseif ($this->isPassed()) {
99  ilUtil::sendSuccess($this->getFullMessage());
100  } else {
102  }
103  }
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: