ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.ilLPProgressBlockGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Tracking\View\Factory as ViewFactory;
22use ILIAS\Tracking\View\DataRetrieval\FactoryInterface as DataRetrievalFactoryInterface;
24
29{
30 protected DataRetrievalFactoryInterface $data_retrieval;
31 protected RendererInterface $tracking_renderer;
32
33 public function __construct()
34 {
36
37 $view_factory = new ViewFactory();
38 $this->data_retrieval = $view_factory->dataRetrieval();
39 $this->tracking_renderer = $view_factory->renderer()->service();
40
41 $this->lng->loadLanguageModule('trac');
42
43 $this->setBlockId('lpprogress_' . $this->ctrl->getContextObjId());
44 $this->setTitle($this->lng->txt('trac_progress_block_title'));
45 $this->setPresentation(self::PRES_SEC_LEG);
46 $this->setActions();
47 }
48
49 public function getBlockType(): string
50 {
51 return 'lpprogress';
52 }
53
54 protected function isRepositoryObject(): bool
55 {
56 return false;
57 }
58
59 protected function getLegacyContent(): string
60 {
61 $filter = $this->data_retrieval
62 ->filter()
63 ->withObjectIds(ilObject::_lookupObjectId($this->requested_ref_id))
64 ->withUserIds($this->user->getId());
65 $lp_info = $this->data_retrieval
66 ->service()
67 ->retrieveViewInfo($filter)
68 ->lpInfoIterator()
69 ->current();
70
71 $status = $lp_info->getLPStatus();
72
73 $progress = $this->tracking_renderer->fixedSizeProgressMeter($lp_info);
74 $mode_and_status = $this->ui->factory()->item()->standard(
76 )->withDescription(
77 $this->lng->txt('trac_mode_collection')
78 );
79
80 return $this->ui->renderer()->render([
81 $progress,
82 $mode_and_status
83 ]);
84 }
85
86 protected function setActions(): void
87 {
88 $read_only_allowed = true;
89 if ($this->supportsMembers($this->requested_ref_id)) {
90 $read_only_allowed = ilParticipants::_isParticipant($this->requested_ref_id, $this->user->getId());
91 }
92 if (!ilLearningProgressAccess::checkAccess($this->requested_ref_id, $read_only_allowed)) {
93 return;
94 }
95 $this->ctrl->setParameterByClass(ilLearningProgressGUI::class, 'ref_id', $this->requested_ref_id);
96 $link = $this->ctrl->getLinkTargetByClass(ilLearningProgressGUI::class);
97 $this->ctrl->clearParameterByClass(ilLearningProgressGUI::class, 'ref_id');
98 $this->addBlockCommand($link, $this->lng->txt('trac_progress_block_details'));
99 }
100
101 protected function supportsMembers(int $ref_id): bool
102 {
103 try {
105 return true;
106 } catch (Exception) {
107 return false;
108 }
109 }
110}
This class represents a block method of a block.
setTitle(string $a_title)
setPresentation(int $type)
addBlockCommand(string $a_href, string $a_text, string $a_onclick="", ?RoundTrip $modal=null)
setBlockId(string $a_block_id="0")
@ilCtrl_IsCalledBy ilLPProgressBlockGUI: ilColumnGUI
DataRetrievalFactoryInterface $data_retrieval
RendererInterface $tracking_renderer
getLegacyContent()
Get legacy content.
isRepositoryObject()
Returns whether block has a corresponding repository object.
static checkAccess(int $a_ref_id, bool $a_allow_only_read=true)
check access to learning progress
static _getStatusText(int $a_status, ?ilLanguage $a_lng=null)
Get status alt text.
static _lookupObjectId(int $ref_id)
static getInstance(int $a_ref_id)
static _isParticipant(int $a_ref_id, int $a_usr_id)
Static function to check if a user is a participant of the container object.
$ref_id
Definition: ltiauth.php:66
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc