ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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
 
 $messageText = []
 

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 45 of file class.ilTestGradingMessageBuilder.php.

References $lng, and $testOBJ.

Member Function Documentation

◆ addMessagePart()

ilTestGradingMessageBuilder::addMessagePart (   $msgPart)
private

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

Referenced by buildMessage().

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

◆ areObligationsAnswered()

ilTestGradingMessageBuilder::areObligationsAnswered ( )
private

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

Referenced by buildList().

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

◆ buildEctsGradeMsg()

ilTestGradingMessageBuilder::buildEctsGradeMsg ( )
private

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

References getEctsGrade().

Referenced by buildMessage().

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

◆ buildGradingMarkMsg()

ilTestGradingMessageBuilder::buildGradingMarkMsg ( )
private

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

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

Referenced by buildMessage().

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

◆ buildGradingStatusMsg()

ilTestGradingMessageBuilder::buildGradingStatusMsg ( )
private

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

References isPassed().

Referenced by buildMessage().

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

◆ buildList()

ilTestGradingMessageBuilder::buildList ( )

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

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

188  {
189  $this->loadResultData();
190 
191  $this->initListTemplate();
192 
193  if ($this->testOBJ->isShowGradingStatusEnabled()) {
194  $passedStatusLangVar = $this->isPassed() ? 'passed_official' : 'failed_official';
195 
196  $this->populateListEntry(
197  $this->lng->txt('passed_status'),
198  $this->lng->txt($passedStatusLangVar)
199  );
200  }
201 
202  if ($this->testOBJ->areObligationsEnabled()) {
203  if ($this->areObligationsAnswered()) {
204  $obligAnsweredStatusLangVar = 'grading_obligations_answered_listentry';
205  } else {
206  $obligAnsweredStatusLangVar = 'grading_obligations_missing_listentry';
207  }
208 
209  $this->populateListEntry(
210  $this->lng->txt('grading_obligations_listlabel'),
211  $this->lng->txt($obligAnsweredStatusLangVar)
212  );
213  }
214 
215  if ($this->testOBJ->isShowGradingMarkEnabled()) {
216  $this->populateListEntry($this->lng->txt('tst_mark'), $this->getMarkOfficial());
217  }
218 
219  if ($this->testOBJ->getECTSOutput()) {
220  $this->populateListEntry($this->lng->txt('ects_grade'), $this->getEctsGrade());
221  }
222 
223  $this->parseListTemplate();
224  }
+ Here is the call graph for this function:

◆ buildMessage()

ilTestGradingMessageBuilder::buildMessage ( )

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

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

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

◆ getActiveId()

ilTestGradingMessageBuilder::getActiveId ( )

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

Referenced by buildEctsGradeMsg(), and buildList().

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

◆ getFullMessage()

ilTestGradingMessageBuilder::getFullMessage ( )
private

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

Referenced by sendMessage().

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

◆ getList()

ilTestGradingMessageBuilder::getList ( )

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

246  {
247  return $this->tpl->get();
248  }

◆ getMarkOfficial()

ilTestGradingMessageBuilder::getMarkOfficial ( )
private

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

Referenced by buildGradingMarkMsg(), and buildList().

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

◆ getMarkShort()

ilTestGradingMessageBuilder::getMarkShort ( )
private

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

Referenced by buildGradingMarkMsg().

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

◆ getMaxPoints()

ilTestGradingMessageBuilder::getMaxPoints ( )
private

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

Referenced by buildGradingMarkMsg(), and getPercentage().

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

◆ getPercentage()

ilTestGradingMessageBuilder::getPercentage ( )
private

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

References getMaxPoints(), and getReachedPoints().

Referenced by buildGradingMarkMsg().

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

◆ getReachedPoints()

ilTestGradingMessageBuilder::getReachedPoints ( )
private

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

Referenced by buildGradingMarkMsg(), and getPercentage().

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

◆ initListTemplate()

ilTestGradingMessageBuilder::initListTemplate ( )

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

Referenced by buildList().

227  {
228  $this->tpl = new ilTemplate('tpl.tst_grading_msg_list.html', true, true, 'Modules/Test');
229  }
+ Here is the caller graph for this function:

◆ isPassed()

ilTestGradingMessageBuilder::isPassed ( )
private

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

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

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

◆ loadResultData()

ilTestGradingMessageBuilder::loadResultData ( )
private

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

References getActiveId().

Referenced by buildList(), and buildMessage().

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

◆ parseListTemplate()

ilTestGradingMessageBuilder::parseListTemplate ( )
private

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

Referenced by buildList().

240  {
241  $this->tpl->setCurrentBlock('grading_msg_list');
242  $this->tpl->parseCurrentBlock();
243  }
+ Here is the caller graph for this function:

◆ populateListEntry()

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

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

Referenced by buildList().

232  {
233  $this->tpl->setCurrentBlock('grading_msg_entry');
234  $this->tpl->setVariable('LABEL', $label);
235  $this->tpl->setVariable('VALUE', $value);
236  $this->tpl->parseCurrentBlock();
237  }
+ Here is the caller graph for this function:

◆ sendMessage()

ilTestGradingMessageBuilder::sendMessage ( )

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

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

94  {
95  if (!$this->testOBJ->isShowGradingStatusEnabled()) {
97  } elseif ($this->isPassed()) {
98  ilUtil::sendSuccess($this->getFullMessage());
99  } else {
101  }
102  }
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 51 of file class.ilTestGradingMessageBuilder.php.

References $activeId.

52  {
53  $this->activeId = $activeId;
54  }

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

◆ $messageText

ilTestGradingMessageBuilder::$messageText = []
private

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

◆ $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: