72 $language->loadLanguageModule(
'certificate');
76 if (null === $defaultPlaceholderValues) {
79 $this->defaultPlaceholderValuesObject = $defaultPlaceholderValues;
129 $testObject = $this->objectHelper->getInstanceByObjId($objId);
131 $active_id = $testObject->getActiveIdOfUser($userId);
132 $pass = $this->testObjectHelper->getResultPass($active_id);
134 $result_array = &$testObject->getTestResult($active_id);
136 $result_array = &$testObject->getTestResult($active_id,
$pass);
139 $passed = $this->
language->txt(
'certificate_failed');
140 if ($result_array[
'test'][
'passed']) {
141 $passed = $this->
language->txt(
'certificate_passed');
145 if ($result_array[
'test'][
'total_max_points']) {
146 $percentage = ($result_array[
'test'][
'total_reached_points'] / $result_array[
'test'][
'total_max_points']) * 100;
149 $mark_obj = $testObject->getMarkSchema()->getMatchingMark($percentage);
150 $user_data = $this->userObjectHelper->lookupFields($userId);
152 $completionDate =
false;
153 if ($user_data[
'usr_id'] > 0) {
154 $completionDate = $this->lpStatusHelper->lookupStatusChanged($objId, $userId);
157 $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValues($userId, $objId);
159 $placeholders[
'RESULT_PASSED'] = $this->utilHelper->prepareFormOutput($passed);
160 $placeholders[
'RESULT_POINTS'] = $this->utilHelper->prepareFormOutput($result_array[
'test'][
'total_reached_points']);
161 $placeholders[
'RESULT_PERCENT'] = sprintf(
'%2.2f', $percentage) .
'%';
162 $placeholders[
'MAX_POINTS'] = $this->utilHelper->prepareFormOutput($result_array[
'test'][
'total_max_points']);
163 $placeholders[
'RESULT_MARK_SHORT'] = $this->utilHelper->prepareFormOutput($mark_obj->getShortName());
164 $placeholders[
'RESULT_MARK_LONG'] = $this->utilHelper->prepareFormOutput($mark_obj->getOfficialName());
165 $placeholders[
'TEST_TITLE'] = $this->utilHelper->prepareFormOutput($testObject->getTitle());
166 $placeholders[
'DATE_COMPLETED'] =
'';
167 $placeholders[
'DATETIME_COMPLETED'] =
'';
169 if ($completionDate !==
false &&
170 $completionDate !== null &&
171 $completionDate !==
'' 173 $placeholders[
'DATE_COMPLETED'] = $this->dateHelper->formatDate($completionDate);
174 $placeholders[
'DATETIME_COMPLETED'] = $this->dateHelper->formatDateTime($completionDate);
177 return $placeholders;
191 $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValuesForPreview($userId, $objId);
193 $object = $this->objectHelper->getInstanceByObjId($objId);
195 $placeholders[
'RESULT_PASSED'] = $this->utilHelper->prepareFormOutput($this->
language->txt(
'certificate_var_result_passed'));
196 $placeholders[
'RESULT_POINTS'] = $this->utilHelper->prepareFormOutput($this->
language->txt(
'certificate_var_result_points'));
197 $placeholders[
'RESULT_PERCENT'] = $this->utilHelper->prepareFormOutput($this->
language->txt(
'certificate_var_result_percent'));
198 $placeholders[
'MAX_POINTS'] = $this->utilHelper->prepareFormOutput($this->
language->txt(
'certificate_var_max_points'));
199 $placeholders[
'RESULT_MARK_SHORT'] = $this->utilHelper->prepareFormOutput($this->
language->txt(
'certificate_var_result_mark_short'));
200 $placeholders[
'RESULT_MARK_LONG'] = $this->utilHelper->prepareFormOutput($this->
language->txt(
'certificate_var_result_mark_long'));
201 $placeholders[
'TEST_TITLE'] = $this->utilHelper->prepareFormOutput($object->getTitle());
203 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)
Just a wrapper class to create Unit Test for other classes.
$defaultPlaceholderValuesObject
getPlaceholderValues(int $userId, int $objId)
This method MUST return an array that contains the actual data for the given user of the given object...