ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
class.ilStudyProgrammeProgressListGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
28{
29 private const SUCCESSFUL_PROGRESS_CSS_CLASS = "ilCourseObjectiveProgressBarCompleted";
30 private const NON_SUCCESSFUL_PROGRESS_CSS_CLASS = "ilCourseObjectiveProgressBarNeutral";
31
32 protected static string $tpl_file = "tpl.progress_list_item.html";
33
34 protected ilLanguage $lng;
35 protected ilCtrl $ctrl;
36 protected ilAccess $access;
39 protected ?string $html;
40 protected bool $show_info_message;
41 protected string $visible_on_pd_mode;
42 protected bool $only_relevant = false;
43
44 public function __construct(ilPRGProgress $a_progress)
45 {
46 global $DIC;
47 $this->lng = $DIC['lng'];
48 $this->lng->loadLanguageModule("prg");
49 $this->ctrl = $DIC['ilCtrl'];
50 $this->access = $DIC['ilAccess'];
51
52 $this->progress = $a_progress;
53 $this->tpl = null;
54 $this->html = null;
55 $this->show_info_message = false;
56 $this->visible_on_pd_mode = "read";
57 }
58
59 public function getHTML(): string
60 {
61 if ($this->html === null) {
62 $tpl = $this->getTemplate("Modules/StudyProgramme", static::$tpl_file, true, true);
63 $this->fillTemplate($tpl);
64 $this->html = $tpl->get();
65 }
66 return $this->html;
67 }
68
69 protected function fillTemplate(ilTemplate $tpl): void
70 {
71 $programme = ilObjStudyProgramme::getInstanceByObjId($this->progress->getNodeId());
72 $title_and_icon_target = $this->getTitleAndIconTarget($this->progress);
73
74 if ($title_and_icon_target) {
75 $tpl->setCurrentBlock("linked_icon");
76 $tpl->setVariable("SRC_ICON", $this->getIconPath($programme->getId()));
77 $tpl->setVariable("ALT_ICON", $this->getAltIcon($programme->getId()));
78 $tpl->setVariable("ICON_HREF", $title_and_icon_target);
80
81 $tpl->setCurrentBlock("linked_title");
82 $tpl->setVariable("TXT_TITLE", $this->getTitleForItem($programme));
83 $tpl->setVariable("HREF_TITLE", $title_and_icon_target);
85 } else {
86 $tpl->setCurrentBlock("not_linked_icon");
87 $tpl->setVariable("SRC_ICON", $this->getIconPath($programme->getId()));
88 $tpl->setVariable("ALT_ICON", $this->getAltIcon($programme->getId()));
90
91 $tpl->setCurrentBlock("not_linked_title");
92 $tpl->setVariable("TXT_TITLE", $this->getTitleForItem($programme));
94 }
95
96 if ($this->show_info_message && $this->showMoreObjectsInfo($programme)) {
97 $tpl->setVariable("MORE_OBJECTS", $this->lng->txt("prg_more_objects_without_read_permission"));
98 }
99 $tpl->setVariable("TXT_DESC", $programme->getDescription());
100 $tpl->setVariable("PROGRESS_BAR", $this->buildProgressBar($this->progress));
101 }
102
103 protected function getTitleForItem(ilObjStudyProgramme $programme): string
104 {
105 return $programme->getTitle();
106 }
107
108 protected function getTemplate(
109 string $component,
110 string $file,
111 bool $remove_unknown_vars,
112 bool $remove_empty_blocks
113 ): ilTemplate {
114 return new ilTemplate($file, $remove_unknown_vars, $remove_empty_blocks, $component);
115 }
116
117 protected function getIconPath(int $obj_id): string
118 {
119 return ilObject::_getIcon($obj_id, "small", "prg");
120 }
121
122 protected function getAltIcon(): string
123 {
124 return $this->lng->txt("icon") . " " . $this->lng->txt("obj_prg");
125 }
126
127 protected function getTitleAndIconTarget(ilPRGProgress $progress): ?string
128 {
129 $this->ctrl->setParameterByClass("ilDashboardGUI", "prg_progress_id", $progress->getId());
130 $this->ctrl->setParameterByClass("ilDashboardGUI", "expand", 1);
131 $link = $this->ctrl->getLinkTargetByClass("ilDashboardGUI", "jumpToSelectedItems");
132 $this->ctrl->setParameterByClass("ilDashboardGUI", "prg_progress_id", null);
133 $this->ctrl->setParameterByClass("ilDashboardGUI", "expand", null);
134 return $link;
135 }
136
137 protected function buildProgressBar(ilPRGProgress $progress): string
138 {
139 $tooltip_id = "prg_" . $progress->getId();
140 $required_amount_of_points = $progress->getAmountOfPoints();
141
142 $maximum_possible_amount_of_points = $progress->getPossiblePointsOfRelevantChildren();
143
144 $current_amount_of_points = $progress->getCurrentAmountOfPoints();
145 $current_percent = 0;
146 $required_percent = 0;
147
148 if ($maximum_possible_amount_of_points > 0) {
149 $current_percent = (int) ($current_amount_of_points * 100 / $maximum_possible_amount_of_points);
150 $required_percent = (int) ($required_amount_of_points * 100 / $maximum_possible_amount_of_points);
151 } elseif ($progress->isSuccessful()) {
152 $current_percent = 100;
153 $required_percent = 100;
154 }
155
156 //required to dodge bug in ilContainerObjectiveGUI::renderProgressBar
157 if ($required_percent === 0) {
158 $required_percent = 0.1;
159 }
160
161 $tooltip_txt = $this->buildToolTip($progress);
162 $progress_status = $this->buildProgressStatus($progress);
163
164 if ($progress->isSuccessful()) {
165 $css_class = self::SUCCESSFUL_PROGRESS_CSS_CLASS;
166 } else {
167 $css_class = self::NON_SUCCESSFUL_PROGRESS_CSS_CLASS;
168 }
169
171 (int)$current_percent,
172 (int)$required_percent,
173 $css_class,
174 $progress_status,
175 null,
176 $tooltip_id,
177 $tooltip_txt
178 );
179 }
180
181 protected function buildToolTip(ilPRGProgress $progress): string
182 {
183 return sprintf(
184 $this->lng->txt("prg_progress_info"),
185 $progress->getCurrentAmountOfPoints(),
186 $progress->getAmountOfPoints()
187 );
188 }
189
190 protected function buildProgressStatus(ilPRGProgress $progress): string
191 {
192 $lang_val = "prg_progress_status";
193 $max_points = $progress->getAmountOfPoints();
194 $programme = ilObjStudyProgramme::getInstanceByObjId($progress->getNodeId());
195
196 if ($programme->hasChildren() && !$programme->hasLPChildren()) {
197 $lang_val = "prg_progress_status_with_child_sp";
198 }
199
200 if ($programme->hasChildren()) {
201 $max_points = $progress->getPossiblePointsOfRelevantChildren($progress);
202 }
203
204 return sprintf(
205 $this->lng->txt($lang_val),
206 $progress->getCurrentAmountOfPoints(),
207 $max_points
208 );
209 }
210
211 public function setShowInfoMessage(bool $show_info_message): void
212 {
213 $this->show_info_message = $show_info_message;
214 }
215
216 public function setVisibleOnPDMode(string $visible_on_pd_mode): void
217 {
218 $this->visible_on_pd_mode = $visible_on_pd_mode;
219 }
220
221 public function setOnlyRelevant(bool $only_relevant): void
222 {
223 $this->only_relevant = $only_relevant;
224 }
225
226 protected function showMoreObjectsInfo(ilObjStudyProgramme $programme): bool
227 {
228 $children = $programme->getChildren();
229 foreach ($children as $child) {
230 $read = $this->access->checkAccess("read", "", $child->getRefId(), "prg", $child->getId());
231 if (!$read && $this->visible_on_pd_mode !== ilObjStudyProgrammeAdmin::SETTING_VISIBLE_ON_PD_ALLWAYS) {
232 return true;
233 }
234 }
235
236 return false;
237 }
238}
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static renderProgressBar(int $a_perc_result=null, int $a_perc_limit=null, string $a_css=null, string $a_caption=null, string $a_url=null, string $a_tt_id=null, string $a_tt_txt=null, string $a_next_step=null, bool $a_sub=false, int $a_sub_style=30)
Render progress bar(s)
Class ilCtrl provides processing control methods.
language handling
static getInstanceByObjId(int $obj_id)
getChildren(bool $include_references=false)
Get all ilObjStudyProgrammes that are direct children of this object.
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
A Progress is the status of a user on a single node of an assignment; it is unique by assignment_id:u...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getTemplate(string $component, string $file, bool $remove_unknown_vars, bool $remove_empty_blocks)
special template class to simplify handling of ITX/PEAR
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.