ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilTestGradingMessageBuilder Class Reference
+ Collaboration diagram for ilTestGradingMessageBuilder:

Public Member Functions

 __construct (private ilLanguage $lng, private ilGlobalTemplateInterface $main_tpl, private ilObjTest $testOBJ, private readonly ParticipantResult $result)
 
 buildMessage ()
 
 sendMessage ()
 
 buildList ()
 
 initListTemplate ()
 
 getList ()
 

Private Member Functions

 addMessagePart ($msgPart)
 
 getFullMessage ()
 
 buildGradingStatusMsg ()
 
 buildGradingMarkMsg ()
 
 populateListEntry ($label, $value)
 
 parseListTemplate ()
 

Private Attributes

ilTemplate $tpl
 
array $messageText = []
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilTestGradingMessageBuilder::__construct ( private ilLanguage  $lng,
private ilGlobalTemplateInterface  $main_tpl,
private ilObjTest  $testOBJ,
private readonly ParticipantResult  $result 
)

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

43  {
44  }

Member Function Documentation

◆ addMessagePart()

ilTestGradingMessageBuilder::addMessagePart (   $msgPart)
private

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

Referenced by buildMessage().

58  {
59  $this->messageText[] = $msgPart;
60  }
+ Here is the caller graph for this function:

◆ buildGradingMarkMsg()

ilTestGradingMessageBuilder::buildGradingMarkMsg ( )
private

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

References ILIAS\Repository\lng().

Referenced by buildMessage().

88  {
89  $mark_msg = $this->lng->txt('grading_mark_msg');
90 
91  $mark_msg = str_replace('[mark]', $this->result->getMarkOfficial(), $mark_msg);
92  $mark_msg = str_replace('[markshort]', $this->result->getMarkShort(), $mark_msg);
93  $mark_msg = str_replace('[percentage]', sprintf('%.2f', $this->result->getPercentage()), $mark_msg);
94  $mark_msg = str_replace('[reached]', (string) $this->result->getReachedPoints(), $mark_msg);
95  $mark_msg = str_replace('[max]', (string) $this->result->getMaxPoints(), $mark_msg);
96 
97  return $mark_msg;
98  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildGradingStatusMsg()

ilTestGradingMessageBuilder::buildGradingStatusMsg ( )
private

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

References ILIAS\Repository\lng().

Referenced by buildMessage().

78  : string
79  {
80  if ($this->result->isPassed()) {
81  return $this->lng->txt('grading_status_passed_msg');
82  }
83 
84  return $this->lng->txt('grading_status_failed_msg');
85  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildList()

ilTestGradingMessageBuilder::buildList ( )

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

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

101  {
102  $this->initListTemplate();
103 
104  if ($this->testOBJ->isShowGradingStatusEnabled()) {
105  $passedStatusLangVar = $this->result->isPassed() ? 'passed_official' : 'failed_official';
106 
107  $this->populateListEntry(
108  $this->lng->txt('passed_status'),
109  $this->lng->txt($passedStatusLangVar)
110  );
111  }
112 
113  if ($this->testOBJ->isShowGradingMarkEnabled()) {
114  $this->populateListEntry($this->lng->txt('tst_mark'), $this->result->getMarkOfficial());
115  }
116 
117  $this->parseListTemplate();
118  }
+ Here is the call graph for this function:

◆ buildMessage()

ilTestGradingMessageBuilder::buildMessage ( )

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

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

47  {
48  if ($this->testOBJ->isShowGradingStatusEnabled()) {
49  $this->addMessagePart($this->buildGradingStatusMsg());
50  }
51 
52  if ($this->testOBJ->isShowGradingMarkEnabled()) {
53  $this->addMessagePart($this->buildGradingMarkMsg());
54  }
55  }
+ Here is the call graph for this function:

◆ getFullMessage()

ilTestGradingMessageBuilder::getFullMessage ( )
private

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

Referenced by sendMessage().

62  : string
63  {
64  return implode(' ', $this->messageText);
65  }
+ Here is the caller graph for this function:

◆ getList()

ilTestGradingMessageBuilder::getList ( )

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

139  : string
140  {
141  return $this->tpl->get();
142  }

◆ initListTemplate()

ilTestGradingMessageBuilder::initListTemplate ( )

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

Referenced by buildList().

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

◆ parseListTemplate()

ilTestGradingMessageBuilder::parseListTemplate ( )
private

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

Referenced by buildList().

134  {
135  $this->tpl->setCurrentBlock('grading_msg_list');
136  $this->tpl->parseCurrentBlock();
137  }
+ Here is the caller graph for this function:

◆ populateListEntry()

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

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

Referenced by buildList().

126  {
127  $this->tpl->setCurrentBlock('grading_msg_entry');
128  $this->tpl->setVariable('LABEL', $label);
129  $this->tpl->setVariable('VALUE', $value);
130  $this->tpl->parseCurrentBlock();
131  }
+ Here is the caller graph for this function:

◆ sendMessage()

ilTestGradingMessageBuilder::sendMessage ( )

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

References getFullMessage().

68  {
69  if (!$this->testOBJ->isShowGradingStatusEnabled()) {
70  $this->main_tpl->setOnScreenMessage('info', $this->getFullMessage());
71  } elseif ($this->result->isPassed()) {
72  $this->main_tpl->setOnScreenMessage('success', $this->getFullMessage());
73  } else {
74  $this->main_tpl->setOnScreenMessage('info', $this->getFullMessage());
75  }
76  }
+ Here is the call graph for this function:

Field Documentation

◆ $messageText

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

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

◆ $tpl

ilTemplate ilTestGradingMessageBuilder::$tpl
private

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


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