ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilStudyProgrammeProgressListGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2015 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
12require_once('./Modules/StudyProgramme/classes/class.ilObjStudyProgrammeAdmin.php');
14{
15 protected static $tpl_file = "tpl.progress_list_item.html";
16
17 const SUCCESSFUL_PROGRESS_CSS_CLASS = "ilCourseObjectiveProgressBarCompleted";
18 const NON_SUCCESSFUL_PROGRESS_CSS_CLASS = "ilCourseObjectiveProgressBarNeutral";
19
23 protected $il_lng;
24
28 protected $il_ctrl;
29
33 protected $progress;
34
38 protected $html;
39
44
49
53 protected $only_relevant = false;
54
55 public function __construct(ilStudyProgrammeUserProgress $a_progress)
56 {
57 global $DIC;
58 $lng = $DIC['lng'];
59 $ilCtrl = $DIC['ilCtrl'];
60 $this->il_lng = $lng;
61 $this->il_lng->loadLanguageModule("prg");
62 $this->il_ctrl = $ilCtrl;
63
64 $this->progress = $a_progress;
65 $this->tpl = null;
66 $this->html = null;
67 $this->show_info_mesage = false;
68 $this->visible_on_pd_mode = "read";
69 }
70
71 public function getHTML()
72 {
73 if ($this->html === null) {
74 $tpl = $this->getTemplate("Modules/StudyProgramme", static::$tpl_file, true, true);
75 $this->fillTemplate($tpl);
76 $this->html = $tpl->get();
77 }
78 return $this->html;
79 }
80
81 protected function fillTemplate($tpl)
82 {
83 $programme = $this->progress->getStudyProgramme();
84 $title_and_icon_target = $this->getTitleAndIconTarget($this->progress);
85
86 if ($title_and_icon_target) {
87 $tpl->setCurrentBlock("linked_icon");
88 $tpl->setVariable("SRC_ICON", $this->getIconPath($programme->getId()));
89 $tpl->setVariable("ALT_ICON", $this->getAltIcon($programme->getId()));
90 $tpl->setVariable("ICON_HREF", $title_and_icon_target);
91 $tpl->parseCurrentBlock();
92
93 $tpl->setCurrentBlock("linked_title");
94 $tpl->setVariable("TXT_TITLE", $this->getTitleForItem($programme));
95 $tpl->setVariable("HREF_TITLE", $title_and_icon_target);
96 $tpl->parseCurrentBlock();
97 } else {
98 $tpl->setCurrentBlock("not_linked_icon");
99 $tpl->setVariable("SRC_ICON", $this->getIconPath($programme->getId()));
100 $tpl->setVariable("ALT_ICON", $this->getAltIcon($programme->getId()));
101 $tpl->parseCurrentBlock();
102
103 $tpl->setCurrentBlock("not_linked_title");
104 $tpl->setVariable("TXT_TITLE", $this->getTitleForItem($programme));
105 $tpl->parseCurrentBlock();
106 }
107
108 if ($this->show_info_mesage) {
109 if ($this->showMoreObjectsInfo($programme)) {
110 $tpl->setVariable("MORE_OBJECTS", $this->il_lng->txt("prg_more_objects_without_read_permission"));
111 }
112 }
113 $tpl->setVariable("TXT_DESC", $programme->getDescription());
114 $tpl->setVariable("PROGRESS_BAR", $this->buildProgressBar($this->progress));
115 }
116
117 protected function getTitleForItem(ilObjStudyProgramme $a_programme)
118 {
119 return $a_programme->getTitle();
120 }
121
122 protected function getTemplate($a_component, $a_file, $a_remove_unknown_vars, $a_remove_empty_blocks)
123 {
124 return new ilTemplate($a_file, $a_remove_unknown_vars, $a_remove_empty_blocks, $a_component);
125 }
126
127 protected function getIconPath($a_obj_id)
128 {
129 return ilObject::_getIcon($a_obj_id, "small", "prg");
130 }
131
132 protected function getAltIcon($a_obj_id)
133 {
134 return $this->il_lng->txt("icon") . " " . $this->il_lng->txt("obj_prg");
135 }
136
138 {
139 $this->il_ctrl->setParameterByClass("ilPersonalDesktopGUI", "prg_progress_id", $a_progress->getId());
140 $this->il_ctrl->setParameterByClass("ilPersonalDesktopGUI", "expand", 1);
141 $link = $this->il_ctrl->getLinkTargetByClass("ilPersonalDesktopGUI", "jumpToSelectedItems");
142 $this->il_ctrl->setParameterByClass("ilPersonalDesktopGUI", "prg_progress_id", null);
143 $this->il_ctrl->setParameterByClass("ilPersonalDesktopGUI", "expand", null);
144 return $link;
145 }
146
147 protected function buildProgressBar(ilStudyProgrammeUserProgress $a_progress)
148 {
149 $tooltip_id = "prg_" . $a_progress->getId();
150
151 $required_amount_of_points = $a_progress->getAmountOfPoints();
152 $maximum_possible_amount_of_points = $a_progress->getMaximumPossibleAmountOfPoints(true);
153 $current_amount_of_points = $a_progress->getCurrentAmountOfPoints();
154
155 if ($maximum_possible_amount_of_points > 0) {
156 $current_percent = (int) ($current_amount_of_points * 100 / $maximum_possible_amount_of_points);
157 $required_percent = (int) ($required_amount_of_points * 100 / $maximum_possible_amount_of_points);
158 } else {
159 if ($a_progress->isSuccessful()) {
160 $current_percent = 100;
161 $required_percent = 100;
162 } else {
163 $current_percent = 0;
164 $required_percent = 0;
165 }
166 }
167
168 //required to dodge bug in ilContainerObjectiveGUI::renderProgressBar
169 if ($required_percent == 0) {
170 $required_percent = 0.1;
171 }
172
173 $tooltip_txt = $this->buildToolTip($a_progress);
174 $progress_status = $this->buildProgressStatus($a_progress);
175
176 if ($a_progress->isSuccessful()) {
178 } else {
180 }
181
182 require_once("Services/Container/classes/class.ilContainerObjectiveGUI.php");
183 return ilContainerObjectiveGUI::renderProgressBar($current_percent, $required_percent, $css_class, $progress_status, null, $tooltip_id, $tooltip_txt);
184 }
185
186 protected function buildToolTip(ilStudyProgrammeUserProgress $a_progress)
187 {
188 return sprintf(
189 $this->il_lng->txt("prg_progress_info"),
190 $a_progress->getCurrentAmountOfPoints(),
191 $a_progress->getAmountOfPoints()
192 );
193 }
194
195 protected function buildProgressStatus(ilStudyProgrammeUserProgress $a_progress)
196 {
197 $lang_val = "prg_progress_status";
198 $max_points = $a_progress->getAmountOfPoints();
199 $study_programm = $a_progress->getStudyProgramme();
200
201 if ($study_programm->hasChildren() && !$study_programm->hasLPChildren()) {
202 $lang_val = "prg_progress_status_with_child_sp";
203 }
204
205 if ($a_progress->getStudyProgramme()->hasChildren()) {
206 $max_points = $a_progress->getMaximumPossibleAmountOfPoints($this->only_relevant);
207 }
208 return sprintf(
209 $this->il_lng->txt($lang_val),
210 $a_progress->getCurrentAmountOfPoints(),
211 $max_points
212 );
213 }
214
216 {
217 $this->show_info_mesage = $show_info_mesage;
218 }
219
221 {
222 $this->visible_on_pd_mode = $visible_on_pd_mode;
223 }
224
226 {
227 $this->only_relevant = $only_relevant;
228 }
229
230 protected function showMoreObjectsInfo($programme)
231 {
232 $children = $programme->getChildren();
233 foreach ($children as $key => $child) {
234 $read = $this->il_access->checkAccess("read", "", $child->getRefId(), "prg", $child->getId());
235 if (!$read && $this->visible_on_pd_mode != ilObjStudyProgrammeAdmin::SETTING_VISIBLE_ON_PD_ALLWAYS) {
236 return true;
237 }
238 }
239
240 return false;
241 }
242}
html()
$tpl
Definition: ilias.php:10
An exception for terminatinating execution or to throw for unit testing.
static renderProgressBar( $a_perc_result=null, $a_perc_limit=null, $a_css=null, $a_caption=null, $a_url=null, $a_tt_id=null, $a_tt_txt=null, $a_next_step=null, $a_sub=false, $a_sub_style=30)
Render progress bar(s)
Class ilObjStudyProgramme.
getTitle()
get object title @access public
Class ilStudyProgrammeProgressListGUI.
buildProgressBar(ilStudyProgrammeUserProgress $a_progress)
buildToolTip(ilStudyProgrammeUserProgress $a_progress)
getTemplate($a_component, $a_file, $a_remove_unknown_vars, $a_remove_empty_blocks)
getTitleAndIconTarget(ilStudyProgrammeUserProgress $a_progress)
buildProgressStatus(ilStudyProgrammeUserProgress $a_progress)
__construct(ilStudyProgrammeUserProgress $a_progress)
Represents the progress of a user at one node of a study programme.
getMaximumPossibleAmountOfPoints($only_relevant=false)
Get the maximum possible amount of points a user can achieve for the completion of this node.
isSuccessful()
Check whether the user was successful on this node.
getCurrentAmountOfPoints()
Get the amount of points the user currently achieved.
getAmountOfPoints()
Get the amount of points needed to complete the node.
getStudyProgramme()
Get the program node where this progress belongs to was made.
special template class to simplify handling of ITX/PEAR
$key
Definition: croninfo.php:18
global $ilCtrl
Definition: ilias.php:18
global $DIC
Definition: saml.php:7
$lng