ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLSCurriculumBuilder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27{
30 protected ilLanguage $lng;
31 protected string $goto_command;
33
34 public function __construct(
36 ILIAS\UI\Factory $ui_factory,
37 ilLanguage $language,
38 string $goto_command,
40 ) {
41 $this->ls_items = $ls_items;
42 $this->ui_factory = $ui_factory;
43 $this->lng = $language;
44 $this->goto_command = $goto_command;
45 $this->url_builder = $url_builder;
46 }
47
48 public function getLearnerCurriculum(bool $with_action = false): ILIAS\UI\Component\Listing\Workflow\Linear
49 {
50 $steps = [];
51 $items = $this->ls_items->getItems();
52 foreach ($items as $item) {
53 $action = '#';
54 if ($with_action) {
55 $action = $this->url_builder->getHref($this->goto_command, $item->getRefId());
56 }
57
58 $steps[] = $this->ui_factory->listing()->workflow()->step(
59 $item->getTitle(),
60 $item->getDescription(),
61 $action
62 )
63 ->withAvailability($item->getAvailability())
64 ->withStatus(
65 $this->translateLPStatus(
66 $item->getLearningProgressStatus()
67 )
68 );
69 }
70
71 $workflow = $this->ui_factory->listing()->workflow()->linear(
72 $this->lng->txt('curriculum'),
73 $steps
74 );
75
76 if ($steps !== []) {
77 $current_position = max(0, $this->ls_items->getCurrentItemPosition());
78 if ($items[$current_position]->getAvailability() === Step::AVAILABLE) {
79 $workflow = $workflow->withActive($current_position);
80 }
81 }
82
83 return $workflow;
84 }
85
86 /*
87 Step
88 const NOT_STARTED = 1;
89 const IN_PROGRESS = 2;
90 const SUCCESSFULLY = 3;
91 const UNSUCCESSFULLY= 4;
92
93 Services/Tracking/class.ilLPStatus.php
94 const LP_STATUS_NOT_ATTEMPTED_NUM = 0;
95 const LP_STATUS_IN_PROGRESS_NUM = 1;
96 const LP_STATUS_COMPLETED_NUM = 2;
97 const LP_STATUS_FAILED_NUM = 3;
98 */
99 protected function translateLPStatus(int $il_lp_status): int
100 {
101 switch ($il_lp_status) {
102 case \ilLPStatus::LP_STATUS_IN_PROGRESS_NUM:
103 return Step::IN_PROGRESS;
104 case \ilLPStatus::LP_STATUS_COMPLETED_NUM:
105 return Step::SUCCESSFULLY;
106 case \ilLPStatus::LP_STATUS_FAILED_NUM:
107 return Step::UNSUCCESSFULLY;
108 case \ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM:
109 default:
110 return Step::NOT_STARTED;
111 }
112 }
113}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Builds the overview (curriculum) of a LearningSequence.
__construct(ilLSLearnerItemsQueries $ls_items, ILIAS\UI\Factory $ui_factory, ilLanguage $language, string $goto_command, ?LSUrlBuilder $url_builder=null)
getLearnerCurriculum(bool $with_action=false)
ilLSLearnerItemsQueries $ls_items
This combines calls to ProgressDB and StateDB to handle learner-items in the context of a specific LS...
language handling
This describes a Workflow Step.
Definition: Step.php:30
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.