ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilTestGradingMessageBuilder Class Reference
+ Collaboration diagram for ilTestGradingMessageBuilder:

Public Member Functions

 __construct (private ilLanguage $lng, private ilGlobalTemplateInterface $main_tpl, private 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 ()
 
 populateListEntry ($label, $value)
 
 parseListTemplate ()
 

Private Attributes

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

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

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

58  {
59  }

Member Function Documentation

◆ addMessagePart()

ilTestGradingMessageBuilder::addMessagePart (   $msgPart)
private

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

Referenced by buildMessage().

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

◆ areObligationsAnswered()

ilTestGradingMessageBuilder::areObligationsAnswered ( )
private

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

Referenced by buildList().

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

◆ buildGradingMarkMsg()

ilTestGradingMessageBuilder::buildGradingMarkMsg ( )
private

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

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

Referenced by buildMessage().

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

◆ buildGradingStatusMsg()

ilTestGradingMessageBuilder::buildGradingStatusMsg ( )
private

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

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

Referenced by buildMessage().

115  : string
116  {
117  if ($this->isPassed()) {
118  return $this->lng->txt('grading_status_passed_msg');
119  }
120 
121  return $this->lng->txt('grading_status_failed_msg');
122  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildList()

ilTestGradingMessageBuilder::buildList ( )

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

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

174  {
175  $this->loadResultData();
176 
177  $this->initListTemplate();
178 
179  if ($this->testOBJ->isShowGradingStatusEnabled()) {
180  $passedStatusLangVar = $this->isPassed() ? 'passed_official' : 'failed_official';
181 
182  $this->populateListEntry(
183  $this->lng->txt('passed_status'),
184  $this->lng->txt($passedStatusLangVar)
185  );
186  }
187 
188  if ($this->testOBJ->areObligationsEnabled()) {
189  if ($this->areObligationsAnswered()) {
190  $obligAnsweredStatusLangVar = 'grading_obligations_answered_listentry';
191  } else {
192  $obligAnsweredStatusLangVar = 'grading_obligations_missing_listentry';
193  }
194 
195  $this->populateListEntry(
196  $this->lng->txt('grading_obligations_listlabel'),
197  $this->lng->txt($obligAnsweredStatusLangVar)
198  );
199  }
200 
201  if ($this->testOBJ->isShowGradingMarkEnabled()) {
202  $this->populateListEntry($this->lng->txt('tst_mark'), $this->getMarkOfficial());
203  }
204 
205  $this->parseListTemplate();
206  }
+ Here is the call graph for this function:

◆ buildMessage()

ilTestGradingMessageBuilder::buildMessage ( )

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

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

72  {
73  $this->loadResultData();
74 
75  if ($this->testOBJ->isShowGradingStatusEnabled()) {
76  $this->addMessagePart($this->buildGradingStatusMsg());
77  }
78 
79  if ($this->testOBJ->isShowGradingMarkEnabled()) {
80  $this->addMessagePart($this->buildGradingMarkMsg());
81  }
82  }
+ Here is the call graph for this function:

◆ getActiveId()

ilTestGradingMessageBuilder::getActiveId ( )

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

References $activeId.

Referenced by loadResultData().

+ Here is the caller graph for this function:

◆ getFullMessage()

ilTestGradingMessageBuilder::getFullMessage ( )
private

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

Referenced by sendMessage().

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

◆ getList()

ilTestGradingMessageBuilder::getList ( )

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

227  : string
228  {
229  return $this->tpl->get();
230  }

◆ getMarkOfficial()

ilTestGradingMessageBuilder::getMarkOfficial ( )
private

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

Referenced by buildGradingMarkMsg(), and buildList().

138  {
139  return $this->resultData['mark_official'];
140  }
+ Here is the caller graph for this function:

◆ getMarkShort()

ilTestGradingMessageBuilder::getMarkShort ( )
private

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

Referenced by buildGradingMarkMsg().

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

◆ getMaxPoints()

ilTestGradingMessageBuilder::getMaxPoints ( )
private

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

Referenced by buildGradingMarkMsg(), and getPercentage().

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

◆ getPercentage()

ilTestGradingMessageBuilder::getPercentage ( )
private

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

References getMaxPoints(), and getReachedPoints().

Referenced by buildGradingMarkMsg().

147  : string
148  {
149  $percentage = 0;
150 
151  if ($this->getMaxPoints() > 0) {
152  $percentage = $this->getReachedPoints() / $this->getMaxPoints();
153  }
154 
155  return sprintf("%.2f", $percentage);
156  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getReachedPoints()

ilTestGradingMessageBuilder::getReachedPoints ( )
private

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

Referenced by buildGradingMarkMsg(), and getPercentage().

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

◆ initListTemplate()

ilTestGradingMessageBuilder::initListTemplate ( )

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

Referenced by buildList().

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

◆ isPassed()

ilTestGradingMessageBuilder::isPassed ( )
private

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

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

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

◆ loadResultData()

ilTestGradingMessageBuilder::loadResultData ( )
private

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

References getActiveId().

Referenced by buildList(), and buildMessage().

111  {
112  $this->resultData = $this->testOBJ->getResultsForActiveId($this->getActiveId());
113  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parseListTemplate()

ilTestGradingMessageBuilder::parseListTemplate ( )
private

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

Referenced by buildList().

222  {
223  $this->tpl->setCurrentBlock('grading_msg_list');
224  $this->tpl->parseCurrentBlock();
225  }
+ Here is the caller graph for this function:

◆ populateListEntry()

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

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

Referenced by buildList().

214  {
215  $this->tpl->setCurrentBlock('grading_msg_entry');
216  $this->tpl->setVariable('LABEL', $label);
217  $this->tpl->setVariable('VALUE', $value);
218  $this->tpl->parseCurrentBlock();
219  }
+ Here is the caller graph for this function:

◆ sendMessage()

ilTestGradingMessageBuilder::sendMessage ( )

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

References getFullMessage(), and isPassed().

100  {
101  if (!$this->testOBJ->isShowGradingStatusEnabled()) {
102  $this->main_tpl->setOnScreenMessage('info', $this->getFullMessage());
103  } elseif ($this->isPassed()) {
104  $this->main_tpl->setOnScreenMessage('success', $this->getFullMessage());
105  } else {
106  $this->main_tpl->setOnScreenMessage('info', $this->getFullMessage());
107  }
108  }
+ Here is the call graph for this function:

◆ setActiveId()

ilTestGradingMessageBuilder::setActiveId (   $activeId)

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

References $activeId.

62  {
63  $this->activeId = $activeId;
64  }

Field Documentation

◆ $activeId

ilTestGradingMessageBuilder::$activeId
private

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

Referenced by getActiveId(), and setActiveId().

◆ $container

ilTestGradingMessageBuilder::$container
private

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

◆ $messageText

array ilTestGradingMessageBuilder::$messageText = []
private

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

◆ $resultData

ilTestGradingMessageBuilder::$resultData
private

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

◆ $tpl

ilTestGradingMessageBuilder::$tpl
private

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


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