19 declare(strict_types=1);
45 if (null === $language) {
47 $language = $DIC->language();
48 $language->loadLanguageModule(
'certificate');
52 if (null === $defaultPlaceholderValues) {
55 $this->defaultPlaceholderValuesObject = $defaultPlaceholderValues;
57 if (null === $objectHelper) {
62 if (null === $testObjectHelper) {
67 if (null === $userObjectHelper) {
72 if (null === $lpStatusHelper) {
77 if (null === $utilHelper) {
82 if (null === $dateHelper) {
102 $testObject = $this->objectHelper->getInstanceByObjId($objId);
104 $active_id = $testObject->getActiveIdOfUser($userId);
105 if ($active_id === null) {
109 $pass = $this->testObjectHelper->getResultPass($active_id);
111 $result_array = &$testObject->getTestResult($active_id);
112 if ($pass !== null) {
113 $result_array = &$testObject->getTestResult($active_id, $pass);
116 $passed = $this->
language->txt(
'certificate_failed');
117 if ($result_array[
'test'][
'passed']) {
118 $passed = $this->
language->txt(
'certificate_passed');
122 if ($result_array[
'test'][
'total_max_points']) {
123 $percentage = ($result_array[
'test'][
'total_reached_points'] / $result_array[
'test'][
'total_max_points']) * 100;
126 $mark_obj = $testObject->getMarkSchema()->getMatchingMark($percentage);
127 $user_data = $this->userObjectHelper->lookupFields($userId);
129 $completionDate =
false;
130 if ($user_data[
'usr_id'] > 0) {
131 $completionDate = $this->lpStatusHelper->lookupStatusChanged($objId, $userId);
134 $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValues($userId, $objId);
136 $placeholders[
'RESULT_PASSED'] = $this->utilHelper->prepareFormOutput($passed);
137 $placeholders[
'RESULT_POINTS'] = $this->utilHelper->prepareFormOutput((
string) $result_array[
'test'][
'total_reached_points']);
138 $placeholders[
'RESULT_PERCENT'] = sprintf(
'%2.2f', $percentage) .
'%';
139 $placeholders[
'MAX_POINTS'] = $this->utilHelper->prepareFormOutput((
string) $result_array[
'test'][
'total_max_points']);
140 $placeholders[
'RESULT_MARK_SHORT'] = $this->utilHelper->prepareFormOutput($mark_obj->getShortName());
141 $placeholders[
'RESULT_MARK_LONG'] = $this->utilHelper->prepareFormOutput($mark_obj->getOfficialName());
142 $placeholders[
'TEST_TITLE'] = $this->utilHelper->prepareFormOutput($testObject->getTitle());
143 $placeholders[
'DATE_COMPLETED'] =
'';
144 $placeholders[
'DATETIME_COMPLETED'] =
'';
146 if ($completionDate !==
false && $completionDate !==
'') {
147 $placeholders[
'DATE_COMPLETED'] = $this->dateHelper->formatDate($completionDate);
148 $placeholders[
'DATETIME_COMPLETED'] = $this->dateHelper->formatDateTime($completionDate);
151 return $placeholders;
161 $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValuesForPreview($userId, $objId);
163 $object = $this->objectHelper->getInstanceByObjId($objId);
165 $placeholders[
'RESULT_PASSED'] = $this->utilHelper->prepareFormOutput($this->
language->txt(
'certificate_var_result_passed'));
166 $placeholders[
'RESULT_POINTS'] = $this->utilHelper->prepareFormOutput($this->
language->txt(
'certificate_var_result_points'));
167 $placeholders[
'RESULT_PERCENT'] = $this->utilHelper->prepareFormOutput($this->
language->txt(
'certificate_var_result_percent'));
168 $placeholders[
'MAX_POINTS'] = $this->utilHelper->prepareFormOutput($this->
language->txt(
'certificate_var_max_points'));
169 $placeholders[
'RESULT_MARK_SHORT'] = $this->utilHelper->prepareFormOutput($this->
language->txt(
'certificate_var_result_mark_short'));
170 $placeholders[
'RESULT_MARK_LONG'] = $this->utilHelper->prepareFormOutput($this->
language->txt(
'certificate_var_result_mark_long'));
171 $placeholders[
'TEST_TITLE'] = $this->utilHelper->prepareFormOutput($object->getTitle());
173 return $placeholders;
getPlaceholderValuesForPreview(int $userId, int $objId)
This method is different then the 'getPlaceholderValues' method, this method is used to create a plac...
Collection of basic placeholder values that can be used.
__construct(?ilDefaultPlaceholderValues $defaultPlaceholderValues=null, ?ilLanguage $language=null, ?ilCertificateObjectHelper $objectHelper=null, ?ilCertificateTestObjectHelper $testObjectHelper=null, ?ilCertificateUserObjectHelper $userObjectHelper=null, ?ilCertificateLPStatusHelper $lpStatusHelper=null, ?ilCertificateUtilHelper $utilHelper=null, ?ilCertificateDateHelper $dateHelper=null)
readonly ilCertificateLPStatusHelper $lpStatusHelper
readonly ilCertificateTestObjectHelper $testObjectHelper
readonly ilDefaultPlaceholderValues $defaultPlaceholderValuesObject
readonly ilCertificateUtilHelper $utilHelper
Just a wrapper class to create Unit Test for other classes.
readonly ilLanguage $language
getPlaceholderValues(int $userId, int $objId)
This method MUST return an array that contains the actual data for the given user of the given object...
readonly ilCertificateUserObjectHelper $userObjectHelper
readonly ilCertificateDateHelper $dateHelper
readonly ilCertificateObjectHelper $objectHelper