ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilCoursePlaceholderValues Class Reference
+ Inheritance diagram for ilCoursePlaceholderValues:
+ Collaboration diagram for ilCoursePlaceholderValues:

Public Member Functions

 __construct (?ilObjectCustomUserFieldsPlaceholderValues $customUserFieldsPlaceholderValues=null, ?ilDefaultPlaceholderValues $defaultPlaceholderValues=null, ?ilLanguage $language=null, ?ilCertificateObjectHelper $objectHelper=null, ?ilCertificateParticipantsHelper $participantsHelper=null, ?ilCertificateUtilHelper $ilUtilHelper=null, ?ilCertificateDateHelper $dateHelper=null, ?ilCertificateLPStatusHelper $lpStatusHelper=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...
 

Private Member Functions

 hasCompletionDate ($possibleDate)
 

Private Attributes

readonly ilDefaultPlaceholderValues $defaultPlaceholderValuesObject
 
readonly ilObjectCustomUserFieldsPlaceholderValues $customUserFieldsPlaceholderValuesObject
 
readonly ilCertificateObjectHelper $objectHelper
 
readonly ilCertificateParticipantsHelper $participantsHelper
 
readonly ilCertificateUtilHelper $ilUtilHelper
 
readonly ilCertificateDateHelper $dateHelper
 
readonly ilCertificateLPStatusHelper $lpStatusHelper
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCoursePlaceholderValues::__construct ( ?ilObjectCustomUserFieldsPlaceholderValues  $customUserFieldsPlaceholderValues = null,
?ilDefaultPlaceholderValues  $defaultPlaceholderValues = null,
?ilLanguage  $language = null,
?ilCertificateObjectHelper  $objectHelper = null,
?ilCertificateParticipantsHelper  $participantsHelper = null,
?ilCertificateUtilHelper  $ilUtilHelper = null,
?ilCertificateDateHelper  $dateHelper = null,
?ilCertificateLPStatusHelper  $lpStatusHelper = null 
)

Definition at line 34 of file class.ilCoursePlaceholderValues.php.

References $dateHelper, $DIC, $ilUtilHelper, $lpStatusHelper, $objectHelper, and $participantsHelper.

43  {
44  if (null === $language) {
45  global $DIC;
46  $language = $DIC->language();
47  $language->loadLanguageModule('certificate');
48  }
49 
50  if (null === $defaultPlaceholderValues) {
51  $defaultPlaceholderValues = new ilDefaultPlaceholderValues();
52  }
53 
54  if (null === $customUserFieldsPlaceholderValues) {
55  $customUserFieldsPlaceholderValues = new ilObjectCustomUserFieldsPlaceholderValues();
56  }
57 
58  if (null === $objectHelper) {
60  }
61  $this->objectHelper = $objectHelper;
62 
63  if (null === $participantsHelper) {
65  }
66  $this->participantsHelper = $participantsHelper;
67 
68  if (null === $ilUtilHelper) {
70  }
71  $this->ilUtilHelper = $ilUtilHelper;
72 
73  if (null === $dateHelper) {
75  }
76  $this->dateHelper = $dateHelper;
77 
78  if (null === $lpStatusHelper) {
80  }
81  $this->lpStatusHelper = $lpStatusHelper;
82 
83  $this->customUserFieldsPlaceholderValuesObject = $customUserFieldsPlaceholderValues;
84  $this->defaultPlaceholderValuesObject = $defaultPlaceholderValues;
85  }
Collection of basic placeholder values that can be used.
readonly ilCertificateLPStatusHelper $lpStatusHelper
global $DIC
Definition: feed.php:28
readonly ilCertificateUtilHelper $ilUtilHelper
readonly ilCertificateParticipantsHelper $participantsHelper
Just a wrapper class to create Unit Test for other classes.
readonly ilCertificateDateHelper $dateHelper
readonly ilCertificateObjectHelper $objectHelper

Member Function Documentation

◆ getPlaceholderValues()

ilCoursePlaceholderValues::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.

Exceptions
ilDatabaseException
ilDateTimeException
ilException
ilInvalidCertificateException
ilObjectNotFoundException

Implements ilCertificatePlaceholderValues.

Definition at line 111 of file class.ilCoursePlaceholderValues.php.

References ilObjUser\_lookupLanguage(), hasCompletionDate(), and ilLegacyFormElementsUtil\prepareFormOutput().

111  : array
112  {
113  $courseObject = $this->objectHelper->getInstanceByObjId($objId);
114 
115  $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValues($userId, $objId);
116 
117  $customUserFieldsPlaceholders = $this->customUserFieldsPlaceholderValuesObject->getPlaceholderValues(
118  $userId,
119  $objId
120  );
121 
122  $placeholders = array_merge($placeholders, $customUserFieldsPlaceholders);
123 
124  $completionDate = $this->participantsHelper->getDateTimeOfPassed($objId, $userId);
125  if (!$this->hasCompletionDate($completionDate)) {
126  $completionDate = $this->lpStatusHelper->lookupStatusChanged($objId, $userId);
127  }
128 
129  if ($this->hasCompletionDate($completionDate)) {
130  $placeholders['DATE_COMPLETED'] = $this->dateHelper->formatDate($completionDate);
131  $placeholders['DATETIME_COMPLETED'] = $this->dateHelper->formatDateTime($completionDate);
132  }
133 
134  $lng_code = ilObjUser::_lookupLanguage($userId);
135  $course_translation = $courseObject->getObjectTranslation();
136  $title = $courseObject->getTitle();
137  if ($course_translation instanceof ilObjectTranslation) {
138  $languages = $course_translation->getLanguages();
139  foreach ($languages as $trans) {
140  if ($trans->getLanguageCode() === $lng_code) {
141  $title = $trans->getTitle();
142  break;
143  }
144  }
145  }
146 
147  $placeholders['COURSE_TITLE'] = ilLegacyFormElementsUtil::prepareFormOutput($title);
148 
149  return $placeholders;
150  }
static _lookupLanguage(int $a_usr_id)
$objId
Definition: xapitoken.php:57
static prepareFormOutput($a_str, bool $a_strip=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ getPlaceholderValuesForPreview()

ilCoursePlaceholderValues::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.

Exceptions
ilDatabaseException
ilDateTimeException
ilException
ilObjectNotFoundException

Implements ilCertificatePlaceholderValues.

Definition at line 161 of file class.ilCoursePlaceholderValues.php.

References ilLegacyFormElementsUtil\prepareFormOutput().

161  : array
162  {
163  $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValuesForPreview($userId, $objId);
164 
165  $customUserFieldsPlaceholders = $this->customUserFieldsPlaceholderValuesObject->getPlaceholderValuesForPreview(
166  $userId,
167  $objId
168  );
169 
170  $placeholders = array_merge($placeholders, $customUserFieldsPlaceholders);
171 
172  $object = $this->objectHelper->getInstanceByObjId($objId);
173 
174  $placeholders['COURSE_TITLE'] = ilLegacyFormElementsUtil::prepareFormOutput($object->getTitle());
175 
176  return $placeholders;
177  }
$objId
Definition: xapitoken.php:57
static prepareFormOutput($a_str, bool $a_strip=false)
+ Here is the call graph for this function:

◆ hasCompletionDate()

ilCoursePlaceholderValues::hasCompletionDate (   $possibleDate)
private
Parameters
mixed$possibleDate

Definition at line 90 of file class.ilCoursePlaceholderValues.php.

Referenced by getPlaceholderValues().

90  : bool
91  {
92  return (
93  $possibleDate !== false &&
94  $possibleDate !== null &&
95  $possibleDate !== ''
96  );
97  }
+ Here is the caller graph for this function:

Field Documentation

◆ $customUserFieldsPlaceholderValuesObject

readonly ilObjectCustomUserFieldsPlaceholderValues ilCoursePlaceholderValues::$customUserFieldsPlaceholderValuesObject
private

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

◆ $dateHelper

readonly ilCertificateDateHelper ilCoursePlaceholderValues::$dateHelper
private

Definition at line 31 of file class.ilCoursePlaceholderValues.php.

Referenced by __construct().

◆ $defaultPlaceholderValuesObject

readonly ilDefaultPlaceholderValues ilCoursePlaceholderValues::$defaultPlaceholderValuesObject
private

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

◆ $ilUtilHelper

readonly ilCertificateUtilHelper ilCoursePlaceholderValues::$ilUtilHelper
private

Definition at line 30 of file class.ilCoursePlaceholderValues.php.

Referenced by __construct().

◆ $lpStatusHelper

readonly ilCertificateLPStatusHelper ilCoursePlaceholderValues::$lpStatusHelper
private

Definition at line 32 of file class.ilCoursePlaceholderValues.php.

Referenced by __construct().

◆ $objectHelper

readonly ilCertificateObjectHelper ilCoursePlaceholderValues::$objectHelper
private

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

Referenced by __construct().

◆ $participantsHelper

readonly ilCertificateParticipantsHelper ilCoursePlaceholderValues::$participantsHelper
private

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

Referenced by __construct().


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