ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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.

58 {
59 $this->messageText[] = $msgPart;
60 }

Referenced by buildMessage().

+ Here is the caller graph for this function:

◆ buildGradingMarkMsg()

ilTestGradingMessageBuilder::buildGradingMarkMsg ( )
private

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

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 }

References ILIAS\Repository\lng().

Referenced by buildMessage().

+ 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.

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 }

References ILIAS\Repository\lng().

Referenced by buildMessage().

+ 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.

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 }

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

+ Here is the call graph for this function:

◆ buildMessage()

ilTestGradingMessageBuilder::buildMessage ( )

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

47 {
48 if ($this->testOBJ->isShowGradingStatusEnabled()) {
50 }
51
52 if ($this->testOBJ->isShowGradingMarkEnabled()) {
53 $this->addMessagePart($this->buildGradingMarkMsg());
54 }
55 }

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

+ Here is the call graph for this function:

◆ getFullMessage()

ilTestGradingMessageBuilder::getFullMessage ( )
private

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

62 : string
63 {
64 return implode(' ', $this->messageText);
65 }

Referenced by sendMessage().

+ 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.

121 {
122 $this->tpl = new ilTemplate('tpl.tst_grading_msg_list.html', true, true, 'components/ILIAS/Test');
123 }
special template class to simplify handling of ITX/PEAR

Referenced by buildList().

+ Here is the caller graph for this function:

◆ parseListTemplate()

ilTestGradingMessageBuilder::parseListTemplate ( )
private

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

134 {
135 $this->tpl->setCurrentBlock('grading_msg_list');
136 $this->tpl->parseCurrentBlock();
137 }

Referenced by buildList().

+ Here is the caller graph for this function:

◆ populateListEntry()

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

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

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 }

Referenced by buildList().

+ Here is the caller graph for this function:

◆ sendMessage()

ilTestGradingMessageBuilder::sendMessage ( )

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

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 }

References getFullMessage().

+ 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: