ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Renderer.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
20
22
27use ILIAS\UI\Component\Chart\ProgressMeter\Standard as UIStandardProgressMeter;
28use ILIAS\UI\Component\Item\Standard as UIStandardItem;
31use ILIAS\UI\Component\Symbol\Icon\Standard as UIStandardIcon;
33use ilLPStatus;
35
37{
38 public function __construct(
39 protected UIServices $ui
40 ) {
41 }
42
43 public function standardProgressMeter(
44 LPInterface $lp_info
45 ): UIStandardProgressMeter {
46 return $this->ui->factory()->chart()->progressMeter()->standard(
47 100,
48 $this->determinePercentage($lp_info)
49 );
50 }
51
52 public function fixedSizeProgressMeter(
53 LPInterface $lp_info
54 ): UIStandardProgressMeter {
55 return $this->ui->factory()->chart()->progressMeter()->fixedSize(
56 100,
57 $this->determinePercentage($lp_info)
58 );
59 }
60
61 public function standardItem(
62 ObjectDataInterface $object_info,
63 PropertyListInterface $property_list,
64 ?URI $title_link = null
65 ): UIStandardItem {
66 $properties = [];
67 foreach ($property_list as $property) {
68 $properties[$property_list->key()] = $property;
69 }
70 $icon = $this->ui->factory()->symbol()->icon()->standard(
71 $object_info->getType(),
72 $object_info->getType() . " Icon",
73 UIIconIcon::MEDIUM
74 );
75 $title = $object_info->getTitle();
76 if ($title_link !== null) {
77 $title = $this->ui->factory()->link()->standard($title, (string) $title_link);
78 }
79 return $this->ui->factory()->item()->standard($title)
80 ->withProperties($properties)
81 ->withDescription($object_info->getDescription())
82 ->withLeadIcon($icon);
83 }
84
85 protected function determinePercentage(
86 LPInterface $lp_info
87 ): int {
88 $percentage = $lp_info->getPercentage();
89 $percentage_by_status = $lp_info->getLPStatus() === ilLPStatus::LP_STATUS_COMPLETED_NUM ? 100 : 0;
90 return !$lp_info->hasPercentage() ? $percentage_by_status : $percentage;
91 }
92}
factory()
Provides fluid interface to RBAC services.
Definition: UIServices.php:25
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
standardProgressMeter(LPInterface $lp_info)
Definition: Renderer.php:43
__construct(protected UIServices $ui)
Definition: Renderer.php:38
fixedSizeProgressMeter(LPInterface $lp_info)
Definition: Renderer.php:52
standardItem(ObjectDataInterface $object_info, PropertyListInterface $property_list, ?URI $title_link=null)
The optional link is applied to the title.
Definition: Renderer.php:61
determinePercentage(LPInterface $lp_info)
Definition: Renderer.php:85
Abstract class ilLPStatus for all learning progress modes E.g ilLPStatusManual, ilLPStatusObjectives ...
const LP_STATUS_COMPLETED_NUM
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This describes a Standard Dropdown.
Definition: Standard.php:27
This describes how an icon could be modified during construction of UI.
Definition: Icon.php:29
This describes the specific behavior of an ILIAS standard icon.
Definition: Standard.php:27