ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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.

References getDefaultTargetUrl(), ilObject\getLongDescription(), ilObject\getRefId(), ilObject\getTitle(), and ilUtil\shortenText().

Referenced by getHTML().

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  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
getTitle()
get object title public
getLongDescription()
get object long description (stored in object_description)
getRefId()
get reference id public
+ Here is the call graph for this function:
+ 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.

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

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

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.
+ 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.

References txt().

Referenced by getHTML().

206  : array
207  {
208  $title = $value . " " . $this->txt('percentage');
209  return [
210  $this->txt('prg_dash_label_gain') => $title
211  ];
212  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fillFinishUntil()

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

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

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

Referenced by getHTML().

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  }
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
Class for single dates.
const IL_CAL_DATE
$ret
Definition: parser.php:6
+ 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.

References txt().

Referenced by getHTML().

198  : array
199  {
200  $title = $value . " " . $this->txt('percentage');
201  return [
202  $this->txt('prg_dash_label_minimum') => $title
203  ];
204  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fillRestartFrom()

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

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

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

Referenced by getHTML().

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  }
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
Class for single dates.
const IL_CAL_DATE
$ret
Definition: parser.php:6
+ 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.

References txt().

Referenced by getHTML().

214  : array
215  {
216  return [
217  $this->txt('prg_dash_label_status') => $this->txt('prg_status_' . $status)
218  ];
219  }
+ Here is the call graph for this function:
+ 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.

References ilDatePresentation\formatDate(), IL_CAL_DATE, and txt().

Referenced by getHTML().

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
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
Class for single dates.
const IL_CAL_DATE
+ 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.

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

Referenced by findValidationValues().

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  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findValidationValues()

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

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

References findValid().

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  }
+ Here is the call graph for this function:

◆ getAssignmentRepository()

ilStudyProgrammeDashboardViewGUI::getAssignmentRepository ( )
protected

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

References $assignment_repository, and ilStudyProgrammeDIC\dic().

Referenced by getUsersAssignments().

94  {
95  if (!$this->assignment_repository) {
96  $this->assignment_repository = ilStudyProgrammeDIC::dic()['ilStudyProgrammeUserAssignmentDB'];
97  }
99  }
+ 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.

Referenced by buildItem().

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  }
+ Here is the caller graph for this function:

◆ getHTML()

ilStudyProgrammeDashboardViewGUI::getHTML ( )
Exceptions
ilException

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

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

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  }
fillValidation(?bool $valid, ?DateTimeImmutable $validation_expiry_date)
isReadable(ilStudyProgrammeAssignment $assignment)
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
Definition: imgupload.php:138
$valid
calculatePercent(ilObjStudyProgramme $prg, int $current_points)
buildItem(ilObjStudyProgramme $prg, array $properties)
+ Here is the call graph for this function:

◆ getProgressRepository()

ilStudyProgrammeDashboardViewGUI::getProgressRepository ( )
protected

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

References $progress_repository, and ilStudyProgrammeDIC\dic().

Referenced by getHTML().

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).
+ 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.

References getAssignmentRepository(), and user().

Referenced by getHTML().

104  : array
105  {
106  return $this->getAssignmentRepository()->getDashboardInstancesforUser($this->user->getId());
107  }
user()
Definition: user.php:4
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getVisibleOnPDMode()

ilStudyProgrammeDashboardViewGUI::getVisibleOnPDMode ( )
protected

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

References $visible_on_pd_mode, ilObjStudyProgrammeAdmin\SETTING_VISIBLE_ON_PD, and ilObjStudyProgrammeAdmin\SETTING_VISIBLE_ON_PD_READ.

Referenced by isReadable().

249  : string
250  {
251  if (is_null($this->visible_on_pd_mode)) {
252  $this->visible_on_pd_mode =
253  $this->setting->get(
256  );
257  }
259  }
+ Here is the caller graph for this function:

◆ hasPermission()

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

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

References Vendor\Package\$e, ilObjStudyProgramme\getInstanceByObjId(), and ilStudyProgrammeAssignment\getRootId().

Referenced by isReadable().

267  : bool {
268  try {
269  $prg = ilObjStudyProgramme::getInstanceByObjId($assignment->getRootId());
270  } catch (\ilException $e) {
271  return false;
272  }
273  return $this->access->checkAccess($permission, "", $prg->getRefId(), "prg", $prg->getId());
274  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isInProgress()

ilStudyProgrammeDashboardViewGUI::isInProgress ( int  $current_status)
protected

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

References ilStudyProgrammeProgress\STATUS_IN_PROGRESS.

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

◆ isReadable()

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

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

References getVisibleOnPDMode(), hasPermission(), and ilObjStudyProgrammeAdmin\SETTING_VISIBLE_ON_PD_ALLWAYS.

Referenced by getHTML().

279  : bool
280  {
282  return true;
283  }
284 
285  return $this->hasPermission($assignment, "read");
286  }
hasPermission(ilStudyProgrammeAssignment $assignment, string $permission)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ txt()

ilStudyProgrammeDashboardViewGUI::txt ( string  $code)
protected

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

Referenced by fillCurrentCompletion(), fillFinishUntil(), fillMinimumCompletion(), fillRestartFrom(), fillStatus(), and fillValidation().

288  : string
289  {
290  return $this->lng->txt($code);
291  }
+ 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.

Referenced by getVisibleOnPDMode().


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