19 declare(strict_types=1);
45 if (null === $language) {
47 $language = $DIC->language();
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) {
105 $testObject = $this->objectHelper->getInstanceByObjId($objId);
107 $active_id = $testObject->getActiveIdOfUser($userId);
108 $pass = (string) $this->testObjectHelper->getResultPass($active_id);
110 $result_array = &$testObject->getTestResult($active_id);
112 $result_array = &$testObject->getTestResult($active_id, $pass);
115 $passed = $this->
language->txt(
'certificate_failed');
116 if ($result_array[
'test'][
'passed']) {
117 $passed = $this->
language->txt(
'certificate_passed');
121 if ($result_array[
'test'][
'total_max_points']) {
122 $percentage = ($result_array[
'test'][
'total_reached_points'] / $result_array[
'test'][
'total_max_points']) * 100;
125 $mark_obj = $testObject->getMarkSchema()->getMatchingMark($percentage);
126 $user_data = $this->userObjectHelper->lookupFields($userId);
128 $completionDate =
false;
129 if ($user_data[
'usr_id'] > 0) {
130 $completionDate = $this->lpStatusHelper->lookupStatusChanged($objId, $userId);
133 $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValues($userId, $objId);
135 $placeholders[
'RESULT_PASSED'] = $this->utilHelper->prepareFormOutput($passed);
136 $placeholders[
'RESULT_POINTS'] = $this->utilHelper->prepareFormOutput((
string) $result_array[
'test'][
'total_reached_points']);
137 $placeholders[
'RESULT_PERCENT'] = sprintf(
'%2.2f', $percentage) .
'%';
138 $placeholders[
'MAX_POINTS'] = $this->utilHelper->prepareFormOutput((
string) $result_array[
'test'][
'total_max_points']);
139 $placeholders[
'RESULT_MARK_SHORT'] = $this->utilHelper->prepareFormOutput($mark_obj->getShortName());
140 $placeholders[
'RESULT_MARK_LONG'] = $this->utilHelper->prepareFormOutput($mark_obj->getOfficialName());
141 $placeholders[
'TEST_TITLE'] = $this->utilHelper->prepareFormOutput($testObject->getTitle());
142 $placeholders[
'DATE_COMPLETED'] =
'';
143 $placeholders[
'DATETIME_COMPLETED'] =
'';
145 if ($completionDate !==
false && $completionDate !==
'') {
146 $placeholders[
'DATE_COMPLETED'] = $this->dateHelper->formatDate($completionDate);
147 $placeholders[
'DATETIME_COMPLETED'] = $this->dateHelper->formatDateTime($completionDate);
150 return $placeholders;
163 $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValuesForPreview($userId, $objId);
165 $object = $this->objectHelper->getInstanceByObjId($objId);
167 $placeholders[
'RESULT_PASSED'] = $this->utilHelper->prepareFormOutput($this->
language->txt(
'certificate_var_result_passed'));
168 $placeholders[
'RESULT_POINTS'] = $this->utilHelper->prepareFormOutput($this->
language->txt(
'certificate_var_result_points'));
169 $placeholders[
'RESULT_PERCENT'] = $this->utilHelper->prepareFormOutput($this->
language->txt(
'certificate_var_result_percent'));
170 $placeholders[
'MAX_POINTS'] = $this->utilHelper->prepareFormOutput($this->
language->txt(
'certificate_var_max_points'));
171 $placeholders[
'RESULT_MARK_SHORT'] = $this->utilHelper->prepareFormOutput($this->
language->txt(
'certificate_var_result_mark_short'));
172 $placeholders[
'RESULT_MARK_LONG'] = $this->utilHelper->prepareFormOutput($this->
language->txt(
'certificate_var_result_mark_long'));
173 $placeholders[
'TEST_TITLE'] = $this->utilHelper->prepareFormOutput($object->getTitle());
175 return $placeholders;
getPlaceholderValuesForPreview(int $userId, int $objId)
This method is different then the 'getPlaceholderValues' method, this method is used to create a plac...
ilCertificateDateHelper $dateHelper
ilCertificateUtilHelper $utilHelper
Collection of basic placeholder values that can be used.
ilCertificateLPStatusHelper $lpStatusHelper
__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)
loadLanguageModule(string $a_module)
Load language module.
ilCertificateTestObjectHelper $testObjectHelper
ilCertificateUserObjectHelper $userObjectHelper
ilDefaultPlaceholderValues $defaultPlaceholderValuesObject
Just a wrapper class to create Unit Test for other classes.
ilCertificateObjectHelper $objectHelper
getPlaceholderValues(int $userId, int $objId)
This method MUST return an array that contains the actual data for the given user of the given object...