ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 ()
 
 populateListEntry ($label, $value)
 
 parseListTemplate ()
 

Private Attributes

ilTemplate $tpl
 
array $resultData
 
int $activeId
 
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 
)

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

42  {
43  }

Member Function Documentation

◆ addMessagePart()

ilTestGradingMessageBuilder::addMessagePart (   $msgPart)
private

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

Referenced by buildMessage().

69  {
70  $this->messageText[] = $msgPart;
71  }
+ Here is the caller graph for this function:

◆ buildGradingMarkMsg()

ilTestGradingMessageBuilder::buildGradingMarkMsg ( )
private

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

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

Referenced by buildMessage().

109  {
110  $markMsg = $this->lng->txt('grading_mark_msg');
111 
112  $markMsg = str_replace("[mark]", $this->getMarkOfficial(), $markMsg);
113  $markMsg = str_replace("[markshort]", $this->getMarkShort(), $markMsg);
114  $markMsg = str_replace("[percentage]", $this->getPercentage(), $markMsg);
115  $markMsg = str_replace("[reached]", (string) $this->getReachedPoints(), $markMsg);
116  $markMsg = str_replace("[max]", (string) $this->getMaxPoints(), $markMsg);
117 
118  return $markMsg;
119  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildGradingStatusMsg()

ilTestGradingMessageBuilder::buildGradingStatusMsg ( )
private

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

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

Referenced by buildMessage().

99  : string
100  {
101  if ($this->isPassed()) {
102  return $this->lng->txt('grading_status_passed_msg');
103  }
104 
105  return $this->lng->txt('grading_status_failed_msg');
106  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildList()

ilTestGradingMessageBuilder::buildList ( )

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

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

153  {
154  $this->loadResultData();
155 
156  $this->initListTemplate();
157 
158  if ($this->testOBJ->isShowGradingStatusEnabled()) {
159  $passedStatusLangVar = $this->isPassed() ? 'passed_official' : 'failed_official';
160 
161  $this->populateListEntry(
162  $this->lng->txt('passed_status'),
163  $this->lng->txt($passedStatusLangVar)
164  );
165  }
166 
167  if ($this->testOBJ->isShowGradingMarkEnabled()) {
168  $this->populateListEntry($this->lng->txt('tst_mark'), $this->getMarkOfficial());
169  }
170 
171  $this->parseListTemplate();
172  }
+ Here is the call graph for this function:

◆ buildMessage()

ilTestGradingMessageBuilder::buildMessage ( )

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

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

56  {
57  $this->loadResultData();
58 
59  if ($this->testOBJ->isShowGradingStatusEnabled()) {
60  $this->addMessagePart($this->buildGradingStatusMsg());
61  }
62 
63  if ($this->testOBJ->isShowGradingMarkEnabled()) {
64  $this->addMessagePart($this->buildGradingMarkMsg());
65  }
66  }
+ Here is the call graph for this function:

◆ getActiveId()

ilTestGradingMessageBuilder::getActiveId ( )

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

References $activeId.

Referenced by loadResultData().

50  : int
51  {
52  return $this->activeId;
53  }
+ Here is the caller graph for this function:

◆ getFullMessage()

ilTestGradingMessageBuilder::getFullMessage ( )
private

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

Referenced by sendMessage().

73  : string
74  {
75  return implode(' ', $this->messageText);
76  }
+ Here is the caller graph for this function:

◆ getList()

ilTestGradingMessageBuilder::getList ( )

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

193  : string
194  {
195  return $this->tpl->get();
196  }

◆ getMarkOfficial()

ilTestGradingMessageBuilder::getMarkOfficial ( )
private

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

Referenced by buildGradingMarkMsg(), and buildList().

122  {
123  return $this->resultData['mark_official'];
124  }
+ Here is the caller graph for this function:

◆ getMarkShort()

ilTestGradingMessageBuilder::getMarkShort ( )
private

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

Referenced by buildGradingMarkMsg().

127  {
128  return $this->resultData['mark_short'];
129  }
+ Here is the caller graph for this function:

◆ getMaxPoints()

ilTestGradingMessageBuilder::getMaxPoints ( )
private

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

Referenced by buildGradingMarkMsg(), and getPercentage().

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

◆ getPercentage()

ilTestGradingMessageBuilder::getPercentage ( )
private

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

References getMaxPoints(), and getReachedPoints().

Referenced by buildGradingMarkMsg().

131  : string
132  {
133  $percentage = 0;
134 
135  if ($this->getMaxPoints() > 0) {
136  $percentage = $this->getReachedPoints() / $this->getMaxPoints();
137  }
138 
139  return sprintf("%.2f", $percentage);
140  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getReachedPoints()

ilTestGradingMessageBuilder::getReachedPoints ( )
private

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

Referenced by buildGradingMarkMsg(), and getPercentage().

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

◆ initListTemplate()

ilTestGradingMessageBuilder::initListTemplate ( )

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

Referenced by buildList().

175  {
176  $this->tpl = new ilTemplate('tpl.tst_grading_msg_list.html', true, true, 'components/ILIAS/Test');
177  }
+ Here is the caller graph for this function:

◆ isPassed()

ilTestGradingMessageBuilder::isPassed ( )
private

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

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

78  : bool
79  {
80  return (bool) $this->resultData['passed'];
81  }
+ Here is the caller graph for this function:

◆ loadResultData()

ilTestGradingMessageBuilder::loadResultData ( )
private

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

References getActiveId().

Referenced by buildList(), and buildMessage().

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

◆ parseListTemplate()

ilTestGradingMessageBuilder::parseListTemplate ( )
private

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

Referenced by buildList().

188  {
189  $this->tpl->setCurrentBlock('grading_msg_list');
190  $this->tpl->parseCurrentBlock();
191  }
+ Here is the caller graph for this function:

◆ populateListEntry()

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

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

Referenced by buildList().

180  {
181  $this->tpl->setCurrentBlock('grading_msg_entry');
182  $this->tpl->setVariable('LABEL', $label);
183  $this->tpl->setVariable('VALUE', $value);
184  $this->tpl->parseCurrentBlock();
185  }
+ Here is the caller graph for this function:

◆ sendMessage()

ilTestGradingMessageBuilder::sendMessage ( )

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

References getFullMessage(), and isPassed().

84  {
85  if (!$this->testOBJ->isShowGradingStatusEnabled()) {
86  $this->main_tpl->setOnScreenMessage('info', $this->getFullMessage());
87  } elseif ($this->isPassed()) {
88  $this->main_tpl->setOnScreenMessage('success', $this->getFullMessage());
89  } else {
90  $this->main_tpl->setOnScreenMessage('info', $this->getFullMessage());
91  }
92  }
+ Here is the call graph for this function:

◆ setActiveId()

ilTestGradingMessageBuilder::setActiveId (   $activeId)

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

References $activeId.

46  {
47  $this->activeId = $activeId;
48  }

Field Documentation

◆ $activeId

int ilTestGradingMessageBuilder::$activeId
private

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

Referenced by getActiveId(), and setActiveId().

◆ $messageText

array< string > ilTestGradingMessageBuilder::$messageText = []
private

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

◆ $resultData

array ilTestGradingMessageBuilder::$resultData
private

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

◆ $tpl

ilTemplate ilTestGradingMessageBuilder::$tpl
private

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


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