ILIAS  release_7 Revision v7.30-3-g800a261c036
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...
 
 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 Attributes

 $defaultPlaceholderValuesObject
 
 $language
 
 $objectHelper
 
 $participantsHelper
 
 $ilUtilHelper
 

Detailed Description

Definition at line 4 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 
)
Parameters
ilDefaultPlaceholderValues$defaultPlaceholderValues
ilLanguage | null$language
ilCertificateObjectHelper | null$objectHelper
ilCertificateParticipantsHelper | null$participantsHelper
ilCertificateUtilHelper$ilUtilHelper
ilCertificateDateHelper | null$ilDateHelper

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

45 {
46 if (null === $language) {
47 global $DIC;
48 $language = $DIC->language();
49 $language->loadLanguageModule('certificate');
50 }
51 $this->language = $language;
52
53 if (null === $defaultPlaceholderValues) {
54 $defaultPlaceholderValues = new ilDefaultPlaceholderValues();
55 }
56
57 if (null === $objectHelper) {
59 }
60 $this->objectHelper = $objectHelper;
61
62 if (null === $participantsHelper) {
64 }
65 $this->participantsHelper = $participantsHelper;
66
67 if (null === $ilUtilHelper) {
69 }
70 $this->ilUtilHelper = $ilUtilHelper;
71
72 $this->defaultPlaceholderValuesObject = $defaultPlaceholderValues;
73 }
Just a wrapper class to create Unit Test for other classes.
Collection of basic placeholder values that can be used.
global $DIC
Definition: goto.php:24
language()
Definition: language.php:2

References $DIC, $ilUtilHelper, $language, $objectHelper, $participantsHelper, and language().

+ Here is the call graph for this function:

Member Function Documentation

◆ 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
$userId
$objId
Returns
mixed - [PLACEHOLDER] => 'actual value'
Exceptions
ilException

Implements ilCertificatePlaceholderValues.

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

88 : array
89 {
90 $object = $this->objectHelper->getInstanceByObjId($objId);
91 $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValues($userId, $objId);
92 $latest_progress = array_reduce(
93 $object->getProgressesOf($userId),
94 function ($one, $other) {
95 if ($one !== null && $one->isSuccessful() && $other !== null && $other->isSuccessful()) {
96 return
97 $one->getCompletionDate()->format('Y-m-d H:i:s') > $other->getCompletionDate()->format('Y-m-d H:i:s') ?
98 $one :
99 $other;
100 }
101 if ($one !== null && $one->isSuccessful()) {
102 return $one;
103 }
104 if ($other !== null && $other->isSuccessful()) {
105 return $other;
106 }
107 return null;
108 }
109 );
110
111 if (!$latest_progress) {
112 throw new \ilInvalidCertificateException('PRG: no valid progress for user ' . $userId . ' while generating certificate');
113 }
114
115 $type = $object->getSubType();
116 $placeholders['PRG_TITLE'] = ilUtil::prepareFormOutput($object->getTitle());
117 $placeholders['PRG_DESCRIPTION'] = ilUtil::prepareFormOutput($object->getDescription());
118 $placeholders['PRG_TYPE'] = ilUtil::prepareFormOutput($type ? $type->getTitle() : '');
119 $placeholders['PRG_POINTS'] = ilUtil::prepareFormOutput($object->getPoints());
120 $placeholders['PRG_COMPLETION_DATE'] = ilUtil::prepareFormOutput($latest_progress->getCompletionDate() instanceof \DateTimeImmutable ? $latest_progress->getCompletionDate()->format('d.m.Y') : '');
121 $placeholders['PRG_EXPIRES_AT'] = ilUtil::prepareFormOutput($latest_progress->getValidityOfQualification() instanceof \DateTimeImmutable ? $latest_progress->getValidityOfQualification()->format('d.m.Y') : '');
122 return $placeholders;
123 }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
if(!file_exists(getcwd() . '/ilias.ini.php'))
registration confirmation script for ilias
Definition: confirmReg.php:12
$type
$objId
Definition: xapitoken.php:39

References $objId, $type, if, and ilUtil\prepareFormOutput().

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

Implements ilCertificatePlaceholderValues.

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

135 {
136 $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValuesForPreview($userId, $objId);
137
138 $object = $this->objectHelper->getInstanceByObjId($objId);
139 $type = $object->getSubType();
140 $today = ilUtil::prepareFormOutput((new DateTime())->format('d.m.Y'));
141 $placeholders['PRG_TITLE'] = ilUtil::prepareFormOutput($object->getTitle());
142 $placeholders['PRG_DESCRIPTION'] = ilUtil::prepareFormOutput($object->getDescription());
143 $placeholders['PRG_TYPE'] = ilUtil::prepareFormOutput($type ? $type->getTitle() : '');
144 $placeholders['PRG_POINTS'] = ilUtil::prepareFormOutput($object->getPoints());
145 $placeholders['PRG_COMPLETION_DATE'] = $today;
146 $placeholders['PRG_EXPIRES_AT'] = $today;
147 return $placeholders;
148 }

References $objId, $type, and ilUtil\prepareFormOutput().

+ Here is the call graph for this function:

Field Documentation

◆ $defaultPlaceholderValuesObject

ilStudyProgrammePlaceholderValues::$defaultPlaceholderValuesObject
private

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

◆ $ilUtilHelper

ilStudyProgrammePlaceholderValues::$ilUtilHelper
private

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

Referenced by __construct().

◆ $language

ilStudyProgrammePlaceholderValues::$language
private

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

Referenced by __construct().

◆ $objectHelper

ilStudyProgrammePlaceholderValues::$objectHelper
private

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

Referenced by __construct().

◆ $participantsHelper

ilStudyProgrammePlaceholderValues::$participantsHelper
private

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

Referenced by __construct().


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