ILIAS  trunk Revision v11.0_alpha-1702-gfd3ecb7f852
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ExercisePlaceholderValues.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
23 use ilLanguage;
24 use ilException;
35 use ilObjUser;
36 
41 {
42  private readonly ilLanguage $language;
50 
51  public function __construct(
52  ?ilDefaultPlaceholderValues $defaultPlaceholderValues = null,
53  ?ilLanguage $language = null,
54  ?ilCertificateObjectHelper $objectHelper = null,
55  ?ilCertificateLPMarksHelper $lpMarksHelper = null,
56  ?CertificateExerciseMembersHelper $exerciseMembersHelper = null,
57  ?ilCertificateLPStatusHelper $lpStatusHelper = null,
58  ?ilCertificateUtilHelper $utilHelper = null,
59  ?ilCertificateDateHelper $dateHelper = null
60  ) {
61  if (null === $language) {
62  global $DIC;
63  $language = $DIC->language();
64  $language->loadLanguageModule('certificate');
65  }
66  $language->loadLanguageModule('exercise');
67  $language->loadLanguageModule('exc');
68 
69  $this->language = $language;
70 
71  if (null === $defaultPlaceholderValues) {
72  $defaultPlaceholderValues = new ilDefaultPlaceholderValues();
73  }
74  $this->defaultPlaceholderValuesObject = $defaultPlaceholderValues;
75 
76  if (null === $objectHelper) {
77  $objectHelper = new ilCertificateObjectHelper();
78  }
79  $this->objectHelper = $objectHelper;
80 
81  if (null === $lpMarksHelper) {
82  $lpMarksHelper = new ilCertificateLPMarksHelper();
83  }
84  $this->lpMarksHelper = $lpMarksHelper;
85 
86  if (null === $exerciseMembersHelper) {
87  $exerciseMembersHelper = new CertificateExerciseMembersHelper();
88  }
89  $this->exerciseMembersHelper = $exerciseMembersHelper;
90 
91  if (null === $lpStatusHelper) {
92  $lpStatusHelper = new ilCertificateLPStatusHelper();
93  }
94  $this->lpStatusHelper = $lpStatusHelper;
95 
96  if (null === $utilHelper) {
97  $utilHelper = new ilCertificateUtilHelper();
98  }
99  $this->utilHelper = $utilHelper;
100 
101  if (null === $dateHelper) {
102  $dateHelper = new ilCertificateDateHelper();
103  }
104  $this->dateHelper = $dateHelper;
105  }
106 
118  public function getPlaceholderValues(int $userId, int $objId): array
119  {
120  $exerciseObject = $this->objectHelper->getInstanceByObjId($objId);
121 
122  $mark = $this->lpMarksHelper->lookUpMark($userId, $objId);
123  $status = $this->exerciseMembersHelper->lookUpStatus($objId, $userId);
124 
125  $completionDate = $this->lpStatusHelper->lookupStatusChanged($objId, $userId);
126 
127  $placeHolders = $this->defaultPlaceholderValuesObject->getPlaceholderValues($userId, $objId);
128 
129  if ($status !== null) {
130  $placeHolders['RESULT_PASSED'] = $this->utilHelper->prepareFormOutput(
131  $this->language->txt('exc_' . $status)
132  );
133  }
134 
135  $placeHolders['RESULT_MARK'] = $this->utilHelper->prepareFormOutput($mark);
136  $placeHolders['EXERCISE_TITLE'] = $this->utilHelper->prepareFormOutput($exerciseObject->getTitle());
137  $placeHolders['DATE_COMPLETED'] = '';
138  $placeHolders['DATETIME_COMPLETED'] = '';
139 
140  if ($completionDate !== '') {
142  $user = $this->objectHelper->getInstanceByObjId($userId);
143  $placeHolders['DATE_COMPLETED'] = $this->dateHelper->formatDate($completionDate, $user);
144  $placeHolders['DATETIME_COMPLETED'] = $this->dateHelper->formatDateTime($completionDate, $user);
145  }
146 
147  return $placeHolders;
148  }
149 
155  public function getPlaceholderValuesForPreview(int $userId, int $objId): array
156  {
157  $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValuesForPreview($userId, $objId);
158 
159  $object = $this->objectHelper->getInstanceByObjId($objId);
160 
161  $placeholders['RESULT_PASSED'] = $this->utilHelper->prepareFormOutput(
162  $this->language->txt('certificate_var_result_passed')
163  );
164  $placeholders['RESULT_MARK'] = $this->utilHelper->prepareFormOutput(
165  $this->language->txt('certificate_var_result_mark_short')
166  );
167  $placeholders['EXERCISE_TITLE'] = $this->utilHelper->prepareFormOutput($object->getTitle());
168 
169  return $placeholders;
170  }
171 }
getPlaceholderValuesForPreview(int $userId, int $objId)
This method is different then the &#39;getPlaceholderValues&#39; method, this method is used to create a plac...
$objId
Definition: xapitoken.php:57
readonly ilDefaultPlaceholderValues $defaultPlaceholderValuesObject
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
__construct(?ilDefaultPlaceholderValues $defaultPlaceholderValues=null, ?ilLanguage $language=null, ?ilCertificateObjectHelper $objectHelper=null, ?ilCertificateLPMarksHelper $lpMarksHelper=null, ?CertificateExerciseMembersHelper $exerciseMembersHelper=null, ?ilCertificateLPStatusHelper $lpStatusHelper=null, ?ilCertificateUtilHelper $utilHelper=null, ?ilCertificateDateHelper $dateHelper=null)
readonly CertificateExerciseMembersHelper $exerciseMembersHelper
getPlaceholderValues(int $userId, int $objId)
This method MUST return an array that contains the actual data for the given user of the given object...
language()
description: > Example for rendring a language glyph.
Definition: language.php:41