ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilStudyProgrammePlaceholderValues Class Reference
+ Inheritance diagram for ilStudyProgrammePlaceholderValues:
+ Collaboration diagram for ilStudyProgrammePlaceholderValues:

Public Member Functions

 __construct (?ilDefaultPlaceholderValues $defaultPlaceholderValues=null, ?ilLanguage $language=null, ?ilCertificateObjectHelper $objectHelper=null, ?ilCertificateParticipantsHelper $participantsHelper=null, ?ilCertificateUtilHelper $ilUtilHelper=null)
 
 getPlaceholderValues (int $userId, int $objId)
 This method MUST return an array that contains the actual data for the given user of the given object. More...
 
 getPlaceholderValuesForPreview (int $userId, int $objId)
 This method is different then the 'getPlaceholderValues' method, this method is used to create a placeholder value array containing dummy values that is used to create a preview certificate. More...
 

Protected Member Functions

 getRelevantProgressFromAssignments (array $assignments)
 
 getLatestSuccessfulAssignment (array $assignments)
 

Private Attributes

ilDefaultPlaceholderValues $defaultPlaceholderValuesObject
 
ilLanguage $language
 
ilCertificateObjectHelper $objectHelper
 
ilCertificateParticipantsHelper $participantsHelper
 
ilCertificateUtilHelper $ilUtilHelper
 

Detailed Description

Definition at line 21 of file class.ilStudyProgrammePlaceholderValues.php.

Constructor & Destructor Documentation

◆ __construct()

ilStudyProgrammePlaceholderValues::__construct ( ?ilDefaultPlaceholderValues  $defaultPlaceholderValues = null,
?ilLanguage  $language = null,
?ilCertificateObjectHelper  $objectHelper = null,
?ilCertificateParticipantsHelper  $participantsHelper = null,
?ilCertificateUtilHelper  $ilUtilHelper = null 
)

Definition at line 29 of file class.ilStudyProgrammePlaceholderValues.php.

References $DIC, $ilUtilHelper, $language, $objectHelper, $participantsHelper, ILIAS\UI\examples\Symbol\Glyph\Language\language(), and ilLanguage\loadLanguageModule().

35  {
36  if (null === $language) {
37  global $DIC;
38  $language = $DIC->language();
39  $language->loadLanguageModule('certificate');
40  }
41  $this->language = $language;
42 
43  if (null === $defaultPlaceholderValues) {
44  $defaultPlaceholderValues = new ilDefaultPlaceholderValues();
45  }
46 
47  if (null === $objectHelper) {
49  }
50  $this->objectHelper = $objectHelper;
51 
52  if (null === $participantsHelper) {
54  }
55  $this->participantsHelper = $participantsHelper;
56 
57  if (null === $ilUtilHelper) {
59  }
60  $this->ilUtilHelper = $ilUtilHelper;
61 
62  $this->defaultPlaceholderValuesObject = $defaultPlaceholderValues;
63  }
Collection of basic placeholder values that can be used.
loadLanguageModule(string $a_module)
Load language module.
global $DIC
Definition: feed.php:28
Just a wrapper class to create Unit Test for other classes.
+ Here is the call graph for this function:

Member Function Documentation

◆ getLatestSuccessfulAssignment()

ilStudyProgrammePlaceholderValues::getLatestSuccessfulAssignment ( array  $assignments)
protected

Definition at line 139 of file class.ilStudyProgrammePlaceholderValues.php.

References Vendor\Package\$a, Vendor\Package\$b, and ilPRGAssignment\getProgressTree().

Referenced by getRelevantProgressFromAssignments().

139  : ?ilPRGAssignment
140  {
141  $successful = array_filter(
142  $assignments,
143  fn ($ass) => $ass->getProgressTree()->isSuccessful()
144  );
145  if (count($successful) === 0) {
146  return null;
147  }
148 
149  //is there an unlimited validity? if so, take latest.
150  $unlimited = array_filter(
151  $successful,
152  fn ($ass) => is_null($ass->getProgressTree()->getValidityOfQualification())
153  );
154  if (count($unlimited) > 0) {
155  $successful = $unlimited;
156  usort($successful, static function (ilPRGAssignment $a, ilPRGAssignment $b): int {
157  $a_dat = $a->getProgressTree()->getCompletionDate();
158  $b_dat = $b->getProgressTree()->getCompletionDate();
159  if ($a_dat > $b_dat) {
160  return -1;
161  } elseif ($a_dat < $b_dat) {
162  return 1;
163  } else {
164  return 0;
165  }
166  });
167  } else {
168  //there are (only) limited validities: take the one that lasts the longest.
169  $limited = array_filter(
170  $successful,
171  fn ($ass) => !is_null($ass->getProgressTree()->getValidityOfQualification())
172  );
173  $successful = $limited;
174  usort($successful, static function (ilPRGAssignment $a, ilPRGAssignment $b): int {
175  $a_dat = $a->getProgressTree()->getValidityOfQualification();
176  $b_dat = $b->getProgressTree()->getValidityOfQualification();
177  if ($a_dat > $b_dat) {
178  return -1;
179  } elseif ($a_dat < $b_dat) {
180  return 1;
181  } else {
182  return 0;
183  }
184  });
185  }
186  return array_shift($successful);
187  }
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
Assignments are relations of users to a PRG; They hold progress-information for (sub-)nodes of the PR...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPlaceholderValues()

ilStudyProgrammePlaceholderValues::getPlaceholderValues ( int  $userId,
int  $objId 
)

This method MUST return an array that contains the actual data for the given user of the given object.

ilInvalidCertificateException MUST be thrown if the data could not be determined or the user did NOT achieve the certificate.

Parameters
int$userId
int$objId
Returns
array - [PLACEHOLDER] => 'actual value'
Exceptions
ilDatabaseException
ilException
ilObjectNotFoundException

Implements ilCertificatePlaceholderValues.

Definition at line 78 of file class.ilStudyProgrammePlaceholderValues.php.

References $type, getRelevantProgressFromAssignments(), and ilLegacyFormElementsUtil\prepareFormOutput().

78  : array
79  {
80  $object = $this->objectHelper->getInstanceByObjId($objId);
81  $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValues($userId, $objId);
82  $assignments = $object->getAssignmentsOfSingleProgramForUser($userId);
83  $latest_progress = $this->getRelevantProgressFromAssignments($assignments);
84  $type = $object->getSubType();
85 
86  $placeholders['PRG_TITLE'] = ilLegacyFormElementsUtil::prepareFormOutput($object->getTitle());
87  $placeholders['PRG_DESCRIPTION'] = ilLegacyFormElementsUtil::prepareFormOutput($object->getDescription());
88  $placeholders['PRG_TYPE'] = ilLegacyFormElementsUtil::prepareFormOutput($type ? $type->getTitle() : '');
89  $placeholders['PRG_POINTS'] = ilLegacyFormElementsUtil::prepareFormOutput(
90  $latest_progress ? (string) $latest_progress->getCurrentAmountOfPoints() : ''
91  );
92  $placeholders['PRG_COMPLETION_DATE'] = ilLegacyFormElementsUtil::prepareFormOutput(
93  $latest_progress ? $latest_progress->getCompletionDate()->format('d.m.Y') : ''
94  );
95  $placeholders['PRG_EXPIRES_AT'] = ilLegacyFormElementsUtil::prepareFormOutput(
96  $latest_progress && $latest_progress->getValidityOfQualification() ?
97  $latest_progress->getValidityOfQualification()->format('d.m.Y') : ''
98  );
99  return $placeholders;
100  }
$type
$objId
Definition: xapitoken.php:57
static prepareFormOutput($a_str, bool $a_strip=false)
+ Here is the call graph for this function:

◆ getPlaceholderValuesForPreview()

ilStudyProgrammePlaceholderValues::getPlaceholderValuesForPreview ( int  $userId,
int  $objId 
)

This method is different then the 'getPlaceholderValues' method, this method is used to create a placeholder value array containing dummy values that is used to create a preview certificate.

Parameters
int$userId
int$objId
Returns
array

Implements ilCertificatePlaceholderValues.

Definition at line 110 of file class.ilStudyProgrammePlaceholderValues.php.

References $type, and ilLegacyFormElementsUtil\prepareFormOutput().

110  : array
111  {
112  $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValuesForPreview($userId, $objId);
113 
114  $object = $this->objectHelper->getInstanceByObjId($objId);
115  $type = $object->getSubType();
116  $today = ilLegacyFormElementsUtil::prepareFormOutput((new DateTime())->format('d.m.Y'));
117  $placeholders['PRG_TITLE'] = ilLegacyFormElementsUtil::prepareFormOutput($object->getTitle());
118  $placeholders['PRG_DESCRIPTION'] = ilLegacyFormElementsUtil::prepareFormOutput($object->getDescription());
119  $placeholders['PRG_TYPE'] = ilLegacyFormElementsUtil::prepareFormOutput($type ? $type->getTitle() : '');
120  $placeholders['PRG_POINTS'] = ilLegacyFormElementsUtil::prepareFormOutput((string) $object->getPoints());
121  $placeholders['PRG_COMPLETION_DATE'] = $today;
122  $placeholders['PRG_EXPIRES_AT'] = $today;
123  return $placeholders;
124  }
$type
$objId
Definition: xapitoken.php:57
static prepareFormOutput($a_str, bool $a_strip=false)
+ Here is the call graph for this function:

◆ getRelevantProgressFromAssignments()

ilStudyProgrammePlaceholderValues::getRelevantProgressFromAssignments ( array  $assignments)
protected

Definition at line 126 of file class.ilStudyProgrammePlaceholderValues.php.

References getLatestSuccessfulAssignment().

Referenced by getPlaceholderValues(), and PRGPlaceholderMock\getRelevantProgress().

126  : ?ilPRGProgress
127  {
128  if (count($assignments) === 0) {
129  return null;
130  }
131  $latest_progress = null;
132  $latest_successful = $this->getLatestSuccessfulAssignment($assignments);
133  if ($latest_successful) {
134  $latest_progress = $latest_successful->getProgressTree();
135  }
136  return $latest_progress;
137  }
A Progress is the status of a user on a single node of an assignment; it is unique by assignment_id:u...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $defaultPlaceholderValuesObject

ilDefaultPlaceholderValues ilStudyProgrammePlaceholderValues::$defaultPlaceholderValuesObject
private

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

◆ $ilUtilHelper

ilCertificateUtilHelper ilStudyProgrammePlaceholderValues::$ilUtilHelper
private

Definition at line 27 of file class.ilStudyProgrammePlaceholderValues.php.

Referenced by __construct().

◆ $language

ilLanguage ilStudyProgrammePlaceholderValues::$language
private

Definition at line 24 of file class.ilStudyProgrammePlaceholderValues.php.

Referenced by __construct().

◆ $objectHelper

ilCertificateObjectHelper ilStudyProgrammePlaceholderValues::$objectHelper
private

Definition at line 25 of file class.ilStudyProgrammePlaceholderValues.php.

Referenced by __construct().

◆ $participantsHelper

ilCertificateParticipantsHelper ilStudyProgrammePlaceholderValues::$participantsHelper
private

Definition at line 26 of file class.ilStudyProgrammePlaceholderValues.php.

Referenced by __construct().


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