ILIAS  release_7 Revision v7.30-3-g800a261c036
ilStudyProgrammeDashboardViewGUI Class Reference
+ Inheritance diagram for ilStudyProgrammeDashboardViewGUI:
+ Collaboration diagram for ilStudyProgrammeDashboardViewGUI:

Public Member Functions

 __construct (ilLanguage $lng, ilObjUser $user, ilAccess $access, ilSetting $setting, ILIAS\UI\Factory $factory, ILIAS\UI\Renderer $renderer, ilCtrl $ctrl, ilLogger $log)
 
 getHTML ()
 

Protected Member Functions

 getProgressRepository ()
 
 getAssignmentRepository ()
 
 getUsersAssignments ()
 
 isInProgress (int $current_status)
 
 fillValidation (?bool $valid, ?DateTimeImmutable $validation_expiry_date)
 
 fillMinimumCompletion (float $value)
 
 fillCurrentCompletion (float $value)
 
 fillStatus (string $status)
 
 fillFinishUntil (DateTimeImmutable $value=null)
 
 fillRestartFrom (DateTimeImmutable $value=null)
 
 getVisibleOnPDMode ()
 
 hasPermission (ilStudyProgrammeAssignment $assignment, string $permission)
 
 isReadable (ilStudyProgrammeAssignment $assignment)
 
 txt (string $code)
 
 calculatePercent (ilObjStudyProgramme $prg, int $current_points)
 
 findValidationValues (array $assignments)
 
 findValid (array $assignments)
 
 buildItem (ilObjStudyProgramme $prg, array $properties)
 
 getDefaultTargetUrl (int $prg_ref_id)
 

Protected Attributes

 $lng
 
 $user
 
 $access
 
 $setting
 
 $visible_on_pd_mode
 
 $log
 
 $factory
 
 $renderer
 
 $ctrl
 
 $progress_repository
 
 $assignment_repository
 

Detailed Description

Definition at line 7 of file class.ilStudyProgrammeDashboardViewGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilStudyProgrammeDashboardViewGUI::__construct ( ilLanguage  $lng,
ilObjUser  $user,
ilAccess  $access,
ilSetting  $setting,
ILIAS\UI\Factory  $factory,
ILIAS\UI\Renderer  $renderer,
ilCtrl  $ctrl,
ilLogger  $log 
)

Member Function Documentation

◆ buildItem()

ilStudyProgrammeDashboardViewGUI::buildItem ( ilObjStudyProgramme  $prg,
array  $properties 
)
protected

Definition at line 359 of file class.ilStudyProgrammeDashboardViewGUI.php.

363 $title = $prg->getTitle();
364 $link = $this->getDefaultTargetUrl((int) $prg->getRefId());
365 $title_btn = $this->factory->button()->shy($title, $link);
366 $description = $prg->getLongDescription() ?? "";
367 $max = $this->setting->get("rep_shorten_description_length");
368 if ($this->setting->get("rep_shorten_description") && $max) {
369 $description = ilUtil::shortenText($description, $max, true);
370 }
371
372 $icon = $this->factory->symbol()->icon()->standard('prg', $title, 'medium');
373 return $this->factory->item()->standard($title_btn)
374 ->withProperties(array_merge(...$properties))
375 ->withDescription($description)
376 ->withLeadIcon($icon)
377 ;
378 }
getRefId()
get reference id @access public
getLongDescription()
get object long description (stored in object_description)
getTitle()
get object title @access public
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
Common interface to all items.
Definition: Item.php:11

Referenced by getHTML().

+ Here is the caller graph for this function:

◆ calculatePercent()

ilStudyProgrammeDashboardViewGUI::calculatePercent ( ilObjStudyProgramme  $prg,
int  $current_points 
)
protected

Definition at line 293 of file class.ilStudyProgrammeDashboardViewGUI.php.

293 : array
294 {
295 $minimum_percents = 0;
296 $current_percents = 0;
297
298 if ($prg->hasLPChildren()) {
299 $minimum_percents = 100;
300 if ($current_points > 0) {
301 $current_percents = 100;
302 }
303 }
304
305 $children = $prg->getAllPrgChildren();
306 if (count($children) > 0) {
307 $max_points = 0;
308 foreach ($children as $child) {
309 $max_points += $child->getPoints();
310 }
311
312 if ($max_points > 0) {
313 $prg_points = $prg->getPoints();
314 $minimum_percents = round((100 * $prg_points / $max_points), 2);
315 }
316 if ($current_points > 0) {
317 $current_percents = round((100 * $current_points / $max_points), 2);
318 }
319 }
320
321 return [
322 $minimum_percents,
323 $current_percents
324 ];
325 }
getPoints()
Get the amount of points.

References ilObjStudyProgramme\getAllPrgChildren(), ilObjStudyProgramme\getPoints(), and ilObjStudyProgramme\hasLPChildren().

Referenced by getHTML(), and mockSPRGDashGUI\mockCalculatePercent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fillCurrentCompletion()

ilStudyProgrammeDashboardViewGUI::fillCurrentCompletion ( float  $value)
protected

Definition at line 206 of file class.ilStudyProgrammeDashboardViewGUI.php.

206 : array
207 {
208 $title = $value . " " . $this->txt('percentage');
209 return [
210 $this->txt('prg_dash_label_gain') => $title
211 ];
212 }

Referenced by getHTML().

+ Here is the caller graph for this function:

◆ fillFinishUntil()

ilStudyProgrammeDashboardViewGUI::fillFinishUntil ( DateTimeImmutable  $value = null)
protected

Definition at line 221 of file class.ilStudyProgrammeDashboardViewGUI.php.

221 : array
222 {
223 $ret = [];
224 if (!is_null($value)) {
225 $date = new ilDate(
226 $value->format('Y-m-d'),
228 );
229 $date_string = ilDatePresentation::formatDate($date);
230 $ret[$this->txt('prg_dash_label_finish_until')] = $date_string;
231 }
232 return $ret;
233 }
const IL_CAL_DATE
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
Class for single dates.
$ret
Definition: parser.php:6

References $ret, ilDatePresentation\formatDate(), and IL_CAL_DATE.

Referenced by getHTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fillMinimumCompletion()

ilStudyProgrammeDashboardViewGUI::fillMinimumCompletion ( float  $value)
protected

Definition at line 198 of file class.ilStudyProgrammeDashboardViewGUI.php.

198 : array
199 {
200 $title = $value . " " . $this->txt('percentage');
201 return [
202 $this->txt('prg_dash_label_minimum') => $title
203 ];
204 }

Referenced by getHTML().

+ Here is the caller graph for this function:

◆ fillRestartFrom()

ilStudyProgrammeDashboardViewGUI::fillRestartFrom ( DateTimeImmutable  $value = null)
protected

Definition at line 235 of file class.ilStudyProgrammeDashboardViewGUI.php.

235 : array
236 {
237 $ret = [];
238 if (!is_null($value)) {
239 $date = new ilDate(
240 $value->format('Y-m-d'),
242 );
243 $date_string = ilDatePresentation::formatDate($date);
244 $ret[$this->txt('prg_dash_label_restart_from')] = $date_string;
245 }
246 return $ret;
247 }

References $ret, ilDatePresentation\formatDate(), and IL_CAL_DATE.

Referenced by getHTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fillStatus()

ilStudyProgrammeDashboardViewGUI::fillStatus ( string  $status)
protected

Definition at line 214 of file class.ilStudyProgrammeDashboardViewGUI.php.

214 : array
215 {
216 return [
217 $this->txt('prg_dash_label_status') => $this->txt('prg_status_' . $status)
218 ];
219 }

Referenced by getHTML().

+ Here is the caller graph for this function:

◆ fillValidation()

ilStudyProgrammeDashboardViewGUI::fillValidation ( ?bool  $valid,
?DateTimeImmutable  $validation_expiry_date 
)
protected

Definition at line 178 of file class.ilStudyProgrammeDashboardViewGUI.php.

181 : array {
182 if (!$valid) {
183 $validation = $this->txt('no');
184 }
185 if ($valid && is_null($validation_expiry_date)) {
186 $validation = $this->txt('yes');
187 }
188 if ($valid && !is_null($validation_expiry_date)) {
189 $date = new ilDate($validation_expiry_date->format('Y-m-d'), IL_CAL_DATE);
190 $validation = ilDatePresentation::formatDate($date);
191 }
192
193 return [
194 $this->txt('prg_dash_label_valid') => $validation
195 ];
196 }
$valid

References txt().

Referenced by getHTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findValid()

ilStudyProgrammeDashboardViewGUI::findValid ( array  $assignments)
protected

Definition at line 342 of file class.ilStudyProgrammeDashboardViewGUI.php.

343 {
344 $status = [
347 ];
348 foreach ($assignments as $key => $assignment) {
349 $prg = ilObjStudyProgramme::getInstanceByObjId($assignment->getRootId());
350 $progress = $prg->getProgressForAssignment($assignment->getId());
351
352 if (in_array($progress->getStatus(), $status)) {
353 return $progress->getValidityOfQualification();
354 }
355 }
356 return null;
357 }

References ilObjStudyProgramme\getInstanceByObjId(), ilStudyProgrammeProgress\STATUS_ACCREDITED, and ilStudyProgrammeProgress\STATUS_COMPLETED.

+ Here is the call graph for this function:

◆ findValidationValues()

ilStudyProgrammeDashboardViewGUI::findValidationValues ( array  $assignments)
protected
Exceptions
ilException

Definition at line 331 of file class.ilStudyProgrammeDashboardViewGUI.php.

331 : array
332 {
333 $validation_date = $this->findValid($assignments);
334
335 return [
336 !is_null($validation_date) && $validation_date->format("Y-m-d") > date("Y-m-d"),
337 $validation_date
338 ];
339 }

◆ getAssignmentRepository()

ilStudyProgrammeDashboardViewGUI::getAssignmentRepository ( )
protected

Definition at line 93 of file class.ilStudyProgrammeDashboardViewGUI.php.

94 {
95 if (!$this->assignment_repository) {
96 $this->assignment_repository = ilStudyProgrammeDIC::dic()['ilStudyProgrammeUserAssignmentDB'];
97 }
99 }

References $assignment_repository, and ilStudyProgrammeDIC\dic().

Referenced by getUsersAssignments().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultTargetUrl()

ilStudyProgrammeDashboardViewGUI::getDefaultTargetUrl ( int  $prg_ref_id)
protected

Definition at line 380 of file class.ilStudyProgrammeDashboardViewGUI.php.

380 : string
381 {
382 $this->ctrl->setParameterByClass(
383 ilObjStudyProgrammeGUI::class,
384 'ref_id',
385 $prg_ref_id
386 );
387 $link = $this->ctrl->getLinkTargetByClass(
388 [
389 ilRepositoryGUI::class,
390 ilObjStudyProgrammeGUI::class,
391 ]
392 );
393 $this->ctrl->setParameterByClass(
394 ilObjStudyProgrammeGUI::class,
395 'ref_id',
396 null
397 );
398 return $link;
399 }

◆ getHTML()

ilStudyProgrammeDashboardViewGUI::getHTML ( )
Exceptions
ilException

Definition at line 112 of file class.ilStudyProgrammeDashboardViewGUI.php.

112 : string
113 {
114 $items = [];
115 $now = new DateTimeImmutable();
116
117 foreach ($this->getUsersAssignments() as $assignments) {
118 $properties = [];
119 krsort($assignments);
120
121 $assignment = current($assignments);
122 if (!$this->isReadable($assignment)) {
123 continue;
124 }
125
126 $progress = $this->getProgressRepository()->getRootProgressOf($assignment);
127
128 $current_prg = ilObjStudyProgramme::getInstanceByObjId($assignment->getRootId());
129 list($minimum_percents, $current_percents) = $this->calculatePercent(
130 $current_prg,
131 $progress->getCurrentAmountOfPoints()
132 );
133
134 $current_status = $progress->getStatus();
135 $deadline = $progress->getDeadline();
136 $restart_date = $assignment->getRestartDate();
137
138 $properties[] = $this->fillMinimumCompletion($minimum_percents);
139 $properties[] = $this->fillCurrentCompletion($current_percents);
140 $properties[] = $this->fillStatus((string) $current_status);
141
142 if ($progress->isSuccessful()) {
143 $properties[] = $this->fillRestartFrom($restart_date);
144
145 $valid = $progress->hasValidQualification($now);
146 $validation_expiry_date = $progress->getValidityOfQualification();
147 $properties[] = $this->fillValidation($valid, $validation_expiry_date);
148 }
149 if ($progress->isInProgress()) {
150 $properties[] = $this->fillFinishUntil($deadline);
151 }
152
153
154
155 $items[] = $this->buildItem($current_prg, $properties);
156 }
157
158 if (count($items) == 0) {
159 return "";
160 }
161
162 $group[] = $this->factory->item()->group("", $items);
163 $panel = $this->factory->panel()->listing()->standard($this->lng->txt("dash_studyprogramme"), $group);
164
165 return $this->renderer->render($panel);
166 }
isReadable(ilStudyProgrammeAssignment $assignment)
buildItem(ilObjStudyProgramme $prg, array $properties)
fillValidation(?bool $valid, ?DateTimeImmutable $validation_expiry_date)
calculatePercent(ilObjStudyProgramme $prg, int $current_points)
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
Definition: imgupload.php:138

References $panel, $valid, buildItem(), calculatePercent(), fillCurrentCompletion(), fillFinishUntil(), fillMinimumCompletion(), fillRestartFrom(), fillStatus(), fillValidation(), ilObjStudyProgramme\getInstanceByObjId(), getProgressRepository(), getUsersAssignments(), and isReadable().

+ Here is the call graph for this function:

◆ getProgressRepository()

ilStudyProgrammeDashboardViewGUI::getProgressRepository ( )
protected

Definition at line 81 of file class.ilStudyProgrammeDashboardViewGUI.php.

82 {
83 if (!$this->progress_repository) {
84 $this->progress_repository = ilStudyProgrammeDIC::dic()['ilStudyProgrammeUserProgressDB'];
85 }
87 }
Covers the persistence of settings belonging to a study programme (SP).

References $progress_repository, and ilStudyProgrammeDIC\dic().

Referenced by getHTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUsersAssignments()

ilStudyProgrammeDashboardViewGUI::getUsersAssignments ( )
protected
Returns
ilStudyProgrammeAssignment[]

Definition at line 104 of file class.ilStudyProgrammeDashboardViewGUI.php.

104 : array
105 {
106 return $this->getAssignmentRepository()->getDashboardInstancesforUser($this->user->getId());
107 }

References getAssignmentRepository(), and user().

Referenced by getHTML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getVisibleOnPDMode()

ilStudyProgrammeDashboardViewGUI::getVisibleOnPDMode ( )
protected

◆ hasPermission()

ilStudyProgrammeDashboardViewGUI::hasPermission ( ilStudyProgrammeAssignment  $assignment,
string  $permission 
)
protected
Exceptions
ilException

Definition at line 264 of file class.ilStudyProgrammeDashboardViewGUI.php.

267 : bool {
268 try {
270 } catch (\ilException $e) {
271 return false;
272 }
273 return $this->access->checkAccess($permission, "", $prg->getRefId(), "prg", $prg->getId());
274 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ isInProgress()

ilStudyProgrammeDashboardViewGUI::isInProgress ( int  $current_status)
protected

Definition at line 170 of file class.ilStudyProgrammeDashboardViewGUI.php.

170 : bool
171 {
172 $status = [
174 ];
175 return in_array($current_status, $status);
176 }

References ilStudyProgrammeProgress\STATUS_IN_PROGRESS.

◆ isReadable()

ilStudyProgrammeDashboardViewGUI::isReadable ( ilStudyProgrammeAssignment  $assignment)
protected
Exceptions
ilException

Definition at line 279 of file class.ilStudyProgrammeDashboardViewGUI.php.

279 : bool
280 {
282 return true;
283 }
284
285 return $this->hasPermission($assignment, "read");
286 }
hasPermission(ilStudyProgrammeAssignment $assignment, string $permission)

References ilObjStudyProgrammeAdmin\SETTING_VISIBLE_ON_PD_ALLWAYS.

Referenced by getHTML().

+ Here is the caller graph for this function:

◆ txt()

ilStudyProgrammeDashboardViewGUI::txt ( string  $code)
protected

Definition at line 288 of file class.ilStudyProgrammeDashboardViewGUI.php.

288 : string
289 {
290 return $this->lng->txt($code);
291 }

Referenced by fillValidation().

+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilStudyProgrammeDashboardViewGUI::$access
protected

Definition at line 23 of file class.ilStudyProgrammeDashboardViewGUI.php.

Referenced by __construct().

◆ $assignment_repository

ilStudyProgrammeDashboardViewGUI::$assignment_repository
protected

Definition at line 92 of file class.ilStudyProgrammeDashboardViewGUI.php.

Referenced by getAssignmentRepository().

◆ $ctrl

ilStudyProgrammeDashboardViewGUI::$ctrl
protected

Definition at line 53 of file class.ilStudyProgrammeDashboardViewGUI.php.

Referenced by __construct().

◆ $factory

ilStudyProgrammeDashboardViewGUI::$factory
protected

Definition at line 43 of file class.ilStudyProgrammeDashboardViewGUI.php.

Referenced by __construct().

◆ $lng

ilStudyProgrammeDashboardViewGUI::$lng
protected

Definition at line 13 of file class.ilStudyProgrammeDashboardViewGUI.php.

Referenced by __construct().

◆ $log

ilStudyProgrammeDashboardViewGUI::$log
protected

Definition at line 38 of file class.ilStudyProgrammeDashboardViewGUI.php.

Referenced by __construct().

◆ $progress_repository

ilStudyProgrammeDashboardViewGUI::$progress_repository
protected

Definition at line 80 of file class.ilStudyProgrammeDashboardViewGUI.php.

Referenced by getProgressRepository().

◆ $renderer

ilStudyProgrammeDashboardViewGUI::$renderer
protected

Definition at line 48 of file class.ilStudyProgrammeDashboardViewGUI.php.

Referenced by __construct().

◆ $setting

ilStudyProgrammeDashboardViewGUI::$setting
protected

Definition at line 28 of file class.ilStudyProgrammeDashboardViewGUI.php.

Referenced by __construct().

◆ $user

ilStudyProgrammeDashboardViewGUI::$user
protected

Definition at line 18 of file class.ilStudyProgrammeDashboardViewGUI.php.

Referenced by __construct().

◆ $visible_on_pd_mode

ilStudyProgrammeDashboardViewGUI::$visible_on_pd_mode
protected

Definition at line 33 of file class.ilStudyProgrammeDashboardViewGUI.php.


The documentation for this class was generated from the following file: