ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilPRGActionNoteBuilder Class Reference

Builds PageContent "Note". More...

+ Collaboration diagram for ilPRGActionNoteBuilder:

Public Member Functions

 __construct (UIFactory $ui_factory, Renderer $ui_renderer, ilLanguage $lng, ilCtrl $ctrl, ilTemplate $tpl, PRGAssignmentRepository $repo_assignment, ilStudyProgrammeSettingsRepository $repo_settings, int $usr_id)
 
 getNoteFor (int $prg_obj_id)
 

Protected Member Functions

 sortByDeadline (array $progresses)
 
 getUserDateFormat ()
 

Protected Attributes

UIFactory $ui_factory
 
Renderer $ui_renderer
 
ilLanguage $lng
 
ilCtrl $ctrl
 
ilTemplate $tpl
 
PRGAssignmentRepository $repo_assignment
 
ilStudyProgrammeSettingsRepository $repo_settings
 
int $usr_id
 

Detailed Description

Builds PageContent "Note".

Definition at line 27 of file ilPRGActionNoteBuilder.php.

Constructor & Destructor Documentation

◆ __construct()

ilPRGActionNoteBuilder::__construct ( UIFactory  $ui_factory,
Renderer  $ui_renderer,
ilLanguage  $lng,
ilCtrl  $ctrl,
ilTemplate  $tpl,
PRGAssignmentRepository  $repo_assignment,
ilStudyProgrammeSettingsRepository  $repo_settings,
int  $usr_id 
)

Definition at line 38 of file ilPRGActionNoteBuilder.php.

References $ctrl, $DIC, $repo_assignment, $repo_settings, $tpl, $ui_factory, $ui_renderer, $usr_id, ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

47  {
48  global $DIC;
49  $this->ui_factory = $ui_factory;
50  $this->ui_renderer = $ui_renderer;
51  $this->lng = $DIC->language();
52  $this->ctrl = $ctrl;
53  $this->tpl = $tpl;
54  $this->repo_assignment = $repo_assignment;
55  $this->repo_settings = $repo_settings;
56  $this->usr_id = $usr_id;
57  }
ilStudyProgrammeSettingsRepository $repo_settings
PRGAssignmentRepository $repo_assignment
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ getNoteFor()

ilPRGActionNoteBuilder::getNoteFor ( int  $prg_obj_id)

Definition at line 59 of file ilPRGActionNoteBuilder.php.

References ilUtil\getImagePath(), getUserDateFormat(), ILIAS\Repository\lng(), null, and sortByDeadline().

59  : string
60  {
61  $ass = $this->repo_assignment->getLatestAssignment($prg_obj_id, $this->usr_id);
62  $instruction = '';
63  $icon = 'page_editor/icon_pean.svg';
64  $dealine_str = '';
65 
66  if ($ass) {
67  $progresses[] = $ass->getProgressTree();
68  $now = new DateTimeImmutable();
69  $deadline = null;
70  $in_progress = array_filter($progresses, fn($pgs) => $pgs->isInProgress());
71  $accredited_or_completed = array_filter($progresses, fn($pgs) => $pgs->isSuccessful());
72  if (count($in_progress) === 0) {
73  $failed = array_filter($progresses, fn($pgs) => $pgs->isFailed());
74  $failed = $this->sortByDeadline($failed);
75  if (count($accredited_or_completed) > 0) {
76  $instruction = 'pc_prgactionnote_no_actions_required';
77  }
78  if (count($failed) > 0 && count($accredited_or_completed) === 0) {
79  $instruction = 'pc_prgactionnote_no_actions_required';
80  $deadline = array_shift($failed)->getDeadline();
81  $dealine_str = ' ' . $deadline->format($this->getUserDateFormat());
82  }
83  } elseif($accredited_or_completed) {
84  $instruction = 'pc_prgactionnote_no_actions_required';
85  } else {
86  $instruction = 'pc_prgactionnote_complete_content';
87  $in_progress_with_deadline = $this->sortByDeadline($in_progress);
88  $in_progress_with_deadline = array_filter(
89  $in_progress_with_deadline,
90  fn($pgs) => $pgs->getDeadline()->format('Y-m-d') >= $now->format('Y-m-d')
91  );
92  if (count($in_progress_with_deadline) > 0) {
93  $deadline = array_shift($in_progress_with_deadline)->getDeadline();
94  }
95 
96  if (!is_null($deadline)) {
97  $dealine_str = ' ' . $deadline->format($this->getUserDateFormat()) . '.';
98  $instruction = 'pc_prgactionnote_complete_content_with_deadline';
99  }
100  }
101  } else {
102  $instruction = 'pc_prgactionnote_no_actions_required';
103  }
104 
105  $icon = $this->ui_renderer->render(
106  $this->ui_factory->symbol()->icon()->custom(
107  ilUtil::getImagePath($icon),
108  $this->lng->txt($instruction)
109  )->withSize('large')
110  );
111 
112  $this->tpl->setVariable("HEADLINE", $this->lng->txt('pc_prgactionnote_headline'));
113  $this->tpl->setVariable("ICON", $icon);
114  $this->tpl->setVariable("NOTE_TEXT", $this->lng->txt($instruction) . $dealine_str);
115  return $this->tpl->get();
116  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
sortByDeadline(array $progresses)
+ Here is the call graph for this function:

◆ getUserDateFormat()

ilPRGActionNoteBuilder::getUserDateFormat ( )
protected

Definition at line 135 of file ilPRGActionNoteBuilder.php.

References ilCalendarUtil\getUserDateFormat().

Referenced by getNoteFor().

135  : string
136  {
137  return ilCalendarUtil::getUserDateFormat(0, true);
138  }
static getUserDateFormat(int $a_add_time=0, bool $a_for_parsing=false)
Parse current user setting into date/time format.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sortByDeadline()

ilPRGActionNoteBuilder::sortByDeadline ( array  $progresses)
protected

Definition at line 118 of file ilPRGActionNoteBuilder.php.

References Vendor\Package\$a, Vendor\Package\$b, and ilPRGProgress\getDeadline().

Referenced by getNoteFor().

118  : array
119  {
120  $progresses = array_filter($progresses, fn($pgs) => $pgs->getDeadline());
121  usort(
122  $progresses,
123  static function (ilPRGProgress $a, ilPRGProgress $b): int {
124  $a_dat = $a->getDeadline();
125  $b_dat = $b->getDeadline();
126  if ($a_dat === $b_dat) {
127  return 0;
128  }
129  return ($a_dat < $b_dat) ? -1 : 1;
130  }
131  );
132  return $progresses;
133  }
A Progress is the status of a user on a single node of an assignment; it is unique by assignment_id:u...
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilPRGActionNoteBuilder::$ctrl
protected

Definition at line 32 of file ilPRGActionNoteBuilder.php.

Referenced by __construct().

◆ $lng

ilLanguage ilPRGActionNoteBuilder::$lng
protected

Definition at line 31 of file ilPRGActionNoteBuilder.php.

◆ $repo_assignment

PRGAssignmentRepository ilPRGActionNoteBuilder::$repo_assignment
protected

Definition at line 34 of file ilPRGActionNoteBuilder.php.

Referenced by __construct().

◆ $repo_settings

ilStudyProgrammeSettingsRepository ilPRGActionNoteBuilder::$repo_settings
protected

Definition at line 35 of file ilPRGActionNoteBuilder.php.

Referenced by __construct().

◆ $tpl

ilTemplate ilPRGActionNoteBuilder::$tpl
protected

Definition at line 33 of file ilPRGActionNoteBuilder.php.

Referenced by __construct().

◆ $ui_factory

UIFactory ilPRGActionNoteBuilder::$ui_factory
protected

Definition at line 29 of file ilPRGActionNoteBuilder.php.

Referenced by __construct().

◆ $ui_renderer

Renderer ilPRGActionNoteBuilder::$ui_renderer
protected

Definition at line 30 of file ilPRGActionNoteBuilder.php.

Referenced by __construct().

◆ $usr_id

int ilPRGActionNoteBuilder::$usr_id
protected

Definition at line 36 of file ilPRGActionNoteBuilder.php.

Referenced by __construct().


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