19 declare(strict_types=1);
41 } elseif ($component instanceof
Mini) {
55 $hasComparison = ($component->getComparison() !=
null && $component->getComparison() > 0);
56 $tpl = $this->
getTemplate(
"tpl.progressmeter.html",
true,
true);
68 $hasComparison = ($component->getComparison() !=
null && $component->getComparison() > 0);
69 $tpl = $this->
getTemplate(
"tpl.progressmeter.html",
true,
true);
71 $tpl->setCurrentBlock(
'fixed');
72 $tpl->setVariable(
'FIXED_CLASS',
'fixed-size');
73 $tpl->parseCurrentBlock();
85 $tpl = $this->
getTemplate(
"tpl.progressmeter_mini.html",
true,
true);
87 $main_percentage = $component->getMainValueAsPercent();
90 $color_class =
'no-success';
91 if ($this->
getIsReached($main_percentage, $component->getRequiredAsPercent())) {
92 $color_class =
'success';
94 $tpl->setVariable(
'COLOR_ONE_CLASS', $color_class);
96 $tpl->setVariable(
'BAR_ONE_WIDTH', (86.5 * ($main_percentage / 100)));
98 $needle_class =
'no-needle';
101 $tpl->setVariable(
'ROTATE_ONE', $this->
getMarkerPos($component->getRequiredAsPercent()));
103 $tpl->setVariable(
'NEEDLE_ONE_CLASS', $needle_class);
105 $tpl->parseCurrentBlock();
113 $hasComparison =
false 115 $main_percentage = $component->getMainValueAsPercent();
117 $visual_percentage = $main_percentage;
119 if ($hasComparison) {
123 $color_one_class =
'no-success';
124 if ($this->
getIsReached($main_percentage, $component->getRequiredAsPercent())) {
125 $color_one_class =
'success';
127 $tpl->
setVariable(
'COLOR_ONE_CLASS', $color_one_class);
129 $tpl->
setVariable(
'BAR_ONE_WIDTH', $visual_percentage);
132 $color_two_class =
'active';
134 $color_two_class =
'not-active';
136 $tpl->
setVariable(
'COLOR_TWO_CLASS', $color_two_class);
138 $tpl->
setVariable(
'BAR_TWO_WIDTH', (88.8 * ($component->getComparisonAsPercent() / 100)));
145 $visual_percentage = $main_percentage - 4;
146 if ($visual_percentage < 0) {
147 $visual_percentage = 0;
150 $color_class =
'no-success';
151 if ($this->
getIsReached($main_percentage, $component->getRequiredAsPercent())) {
152 $color_class =
'success';
154 $tpl->
setVariable(
'COLOR_ONE_CLASS', $color_class);
156 $tpl->
setVariable(
'BAR_ONE_WIDTH', $visual_percentage);
165 $needle_class =
'no-needle';
166 if ($component->getRequired() != $component->getMaximum()) {
168 $needle_value = (270 / 100 * $component->getRequiredAsPercent() - 133);
171 $compensated_needle_value = $needle_value - (7 * (1 - (2 * $main_percentage / 100)));
172 $tpl->
setVariable(
'ROTATE_ONE', $compensated_needle_value);
174 $tpl->
setVariable(
'NEEDLE_ONE_CLASS', $needle_class);
186 $tpl->
setVariable(
"MAIN", $component->getMainValueAsPercent() .
' %');
187 if ($component->getRequired() != $component->getMaximum()) {
188 $tpl->
setVariable(
"REQUIRED", $component->getRequiredAsPercent() .
' %');
194 if (!is_null($component->getMainText())) {
195 $main_text = $component->getMainText();
199 if (!is_null($component->getRequiredText())) {
200 $required_text = $component->getRequiredText();
202 $tpl->
setVariable(
"TEXT_MAIN", htmlspecialchars($main_text));
203 $tpl->
setVariable(
"TEXT_REQUIRED", htmlspecialchars($required_text));
215 $needle_value = round((230 / 100 * ($percentage * 1)) - 115, 2, PHP_ROUND_HALF_UP);
216 $compensated_needle_value = $needle_value - (16 * (1 - (2 * $percentage / 100)));
217 return $compensated_needle_value;
227 return (isset($val) && $val > 0);
241 return ($a_val >= $b_val);
modifyVisibleValues(Template $tpl, Component\Component $component)
Modify visible template variables.
renderMini(Mini $component)
Render mini progressmeter.
render(Component\Component $component, RendererInterface $default_renderer)
getIsReached($a_val, $b_val)
Test if $a_val has reached $b_val.
renderStandard(Component\Chart\ProgressMeter\Standard $component)
Render standard progressmeter.
renderFixedSize(Component\Chart\ProgressMeter\FixedSize $component)
Render fixed size progressmeter.
getDefaultGraphicByComponent(Component\Chart\ProgressMeter\ProgressMeter $component, Template $tpl, $hasComparison=false)
setCurrentBlock(string $name)
Set the block to work on.
setVariable(string $name, $value)
Set a variable in the current block.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getMaximum()
Get maximum value.
getTemplate(string $name, bool $purge_unfilled_vars, bool $purge_unused_blocks)
Get template of component this renderer is made for.
cannotHandleComponent(Component $component)
This method MUST be called by derived component renderers, if.
getRequired()
Get required value.
parseCurrentBlock()
Parse the block that is currently worked on.
getIsValueSet($val)
Test if value is not zero.
getMarkerPos(int $percentage)
get marker position by percent
Base class for all component renderers.