ILIAS  release_7 Revision v7.30-3-g800a261c036
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(ilStudyProgrammeProgress $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 = ilObjStudyProgramme::getInstanceByObjId($this->progress->getNodeId());
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
137 protected function getTitleAndIconTarget(ilStudyProgrammeProgress $a_progress)
138 {
139 $this->il_ctrl->setParameterByClass("ilDashboardGUI", "prg_progress_id", $a_progress->getId());
140 $this->il_ctrl->setParameterByClass("ilDashboardGUI", "expand", 1);
141 $link = $this->il_ctrl->getLinkTargetByClass("ilDashboardGUI", "jumpToSelectedItems");
142 $this->il_ctrl->setParameterByClass("ilDashboardGUI", "prg_progress_id", null);
143 $this->il_ctrl->setParameterByClass("ilDashboardGUI", "expand", null);
144 return $link;
145 }
146
147 protected function buildProgressBar(ilStudyProgrammeProgress $a_progress)
148 {
149 $tooltip_id = "prg_" . $a_progress->getId();
150 $required_amount_of_points = $a_progress->getAmountOfPoints();
151
152 $programme = ilObjStudyProgramme::getInstanceByObjId($a_progress->getNodeId());
153 $maximum_possible_amount_of_points = $programme->getPossiblePointsOfRelevantChildren($a_progress, true);
154
155 $current_amount_of_points = $a_progress->getCurrentAmountOfPoints();
156
157 if ($maximum_possible_amount_of_points > 0) {
158 $current_percent = (int) ($current_amount_of_points * 100 / $maximum_possible_amount_of_points);
159 $required_percent = (int) ($required_amount_of_points * 100 / $maximum_possible_amount_of_points);
160 } else {
161 if ($a_progress->isSuccessful()) {
162 $current_percent = 100;
163 $required_percent = 100;
164 } else {
165 $current_percent = 0;
166 $required_percent = 0;
167 }
168 }
169
170 //required to dodge bug in ilContainerObjectiveGUI::renderProgressBar
171 if ($required_percent == 0) {
172 $required_percent = 0.1;
173 }
174
175 $tooltip_txt = $this->buildToolTip($a_progress);
176 $progress_status = $this->buildProgressStatus($a_progress);
177
178 if ($a_progress->isSuccessful()) {
180 } else {
182 }
183
184 require_once("Services/Container/classes/class.ilContainerObjectiveGUI.php");
185 return ilContainerObjectiveGUI::renderProgressBar($current_percent, $required_percent, $css_class, $progress_status, null, $tooltip_id, $tooltip_txt);
186 }
187
188 protected function buildToolTip(ilStudyProgrammeProgress $a_progress)
189 {
190 return sprintf(
191 $this->il_lng->txt("prg_progress_info"),
192 $a_progress->getCurrentAmountOfPoints(),
193 $a_progress->getAmountOfPoints()
194 );
195 }
196
197 protected function buildProgressStatus(ilStudyProgrammeProgress $a_progress)
198 {
199 $lang_val = "prg_progress_status";
200 $max_points = $a_progress->getAmountOfPoints();
201 $programme = ilObjStudyProgramme::getInstanceByObjId($a_progress->getNodeId());
202
203 if ($programme->hasChildren() && !$programme->hasLPChildren()) {
204 $lang_val = "prg_progress_status_with_child_sp";
205 }
206
207 if ($programme->hasChildren()) {
208 $max_points = $programme->getPossiblePointsOfRelevantChildren($a_progress, $this->only_relevant);
209 }
210
211 return sprintf(
212 $this->il_lng->txt($lang_val),
213 $a_progress->getCurrentAmountOfPoints(),
214 $max_points
215 );
216 }
217
219 {
220 $this->show_info_mesage = $show_info_mesage;
221 }
222
224 {
225 $this->visible_on_pd_mode = $visible_on_pd_mode;
226 }
227
229 {
230 $this->only_relevant = $only_relevant;
231 }
232
233 protected function showMoreObjectsInfo($programme)
234 {
235 $children = $programme->getChildren();
236 foreach ($children as $key => $child) {
237 $read = $this->il_access->checkAccess("read", "", $child->getRefId(), "prg", $child->getId());
238 if (!$read && $this->visible_on_pd_mode != ilObjStudyProgrammeAdmin::SETTING_VISIBLE_ON_PD_ALLWAYS) {
239 return true;
240 }
241 }
242
243 return false;
244 }
245}
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)
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
getTitle()
get object title @access public
Class ilStudyProgrammeProgressListGUI.
buildToolTip(ilStudyProgrammeProgress $a_progress)
buildProgressStatus(ilStudyProgrammeProgress $a_progress)
getTitleAndIconTarget(ilStudyProgrammeProgress $a_progress)
getTemplate($a_component, $a_file, $a_remove_unknown_vars, $a_remove_empty_blocks)
buildProgressBar(ilStudyProgrammeProgress $a_progress)
__construct(ilStudyProgrammeProgress $a_progress)
Class ilStudyProgrammeProgress.
getId()
Get the id of the progress.
getAmountOfPoints()
Get the amount of points the user needs to achieve on the subnodes of this node.
getNodeId()
Get the obj_id of the program node this progress belongs to.
special template class to simplify handling of ITX/PEAR
global $DIC
Definition: goto.php:24
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$lng