ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Renderer.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=0);
20 
22 
27 use ILIAS\UI\Component\Chart\ProgressMeter\Standard as UIStandardProgressMeter;
32 use ilLPObjSettings;
33 use ilLPStatus;
34 use ILIAS\Data\URI;
35 
36 class Renderer implements RendererInterface
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 }
const LP_STATUS_COMPLETED_NUM
__construct(protected UIServices $ui)
Definition: Renderer.php:38
standardProgressMeter(LPInterface $lp_info)
Definition: Renderer.php:43
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Provides fluid interface to RBAC services.
Definition: UIServices.php:24
fixedSizeProgressMeter(LPInterface $lp_info)
Definition: Renderer.php:52