ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilExercisePlaceholderValues.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
8 {
12  private $language;
13 
18 
22  private $lpMarksHelper;
23 
27  private $objectHelper;
28 
33 
37  private $lpStatusHelper;
38 
42  private $utilHelper;
43 
47  private $dateHelper;
48 
59  public function __construct(
60  ilDefaultPlaceholderValues $defaultPlaceholderValues = null,
61  ilLanguage $language = null,
68  ) {
69  if (null === $language) {
70  global $DIC;
71  $language = $DIC->language();
72  }
73  $language->loadLanguageModule('exercise');
74  $language->loadLanguageModule('exc');
75 
76  $this->language = $language;
77 
78  if (null === $defaultPlaceholderValues) {
79  $defaultPlaceholderValues = new ilDefaultPlaceholderValues();
80  }
81  $this->defaultPlaceholderValuesObject = $defaultPlaceholderValues;
82 
83  if (null === $objectHelper) {
85  }
86  $this->objectHelper = $objectHelper;
87 
88  if (null === $lpMarksHelper) {
90  }
91  $this->lpMarksHelper = $lpMarksHelper;
92 
93  if (null === $exerciseMembersHelper) {
95  }
96  $this->exerciseMembersHelper = $exerciseMembersHelper;
97 
98  if (null === $lpStatusHelper) {
100  }
101  $this->lpStatusHelper = $lpStatusHelper;
102 
103  if (null === $utilHelper) {
105  }
106  $this->utilHelper = $utilHelper;
107 
108  if (null === $dateHelper) {
110  }
111  $this->dateHelper = $dateHelper;
112  }
113 
128  public function getPlaceholderValues(int $userId, int $objId) : array
129  {
130  $exerciseObject = $this->objectHelper->getInstanceByObjId($objId);
131 
132  $mark = (string) $this->lpMarksHelper->lookUpMark($userId, $objId);
133  $status = $this->exerciseMembersHelper->lookUpStatus($objId, $userId);
134 
135  $completionDate = $this->lpStatusHelper->lookupStatusChanged($objId, $userId);
136 
137  $placeHolders = $this->defaultPlaceholderValuesObject->getPlaceholderValues($userId, $objId);
138 
139  $placeHolders['RESULT_PASSED'] = $this->utilHelper->prepareFormOutput($this->language->txt('exc_' . $status));
140  $placeHolders['RESULT_MARK'] = $this->utilHelper->prepareFormOutput($mark);
141  $placeHolders['EXERCISE_TITLE'] = $this->utilHelper->prepareFormOutput($exerciseObject->getTitle());
142  $placeHolders['DATE_COMPLETED'] = '';
143  $placeHolders['DATETIME_COMPLETED'] = '';
144 
145  if ($completionDate !== false &&
146  $completionDate !== null &&
147  $completionDate !== ''
148  ) {
149  $placeHolders['DATE_COMPLETED'] = $this->dateHelper->formatDate($completionDate);
150  $placeHolders['DATETIME_COMPLETED'] = $this->dateHelper->formatDateTime($completionDate);
151  }
152 
153  return $placeHolders;
154  }
155 
165  public function getPlaceholderValuesForPreview(int $userId, int $objId) : array
166  {
167  $placeholders = $this->defaultPlaceholderValuesObject->getPlaceholderValuesForPreview($userId, $objId);
168 
169  $object = $this->objectHelper->getInstanceByObjId($objId);
170 
171  $placeholders['RESULT_PASSED'] = $this->utilHelper->prepareFormOutput($this->language->txt('certificate_var_result_passed'));
172  $placeholders['RESULT_MARK'] = $this->utilHelper->prepareFormOutput($this->language->txt('certificate_var_result_mark_short'));
173  $placeholders['EXERCISE_TITLE'] = $this->utilHelper->prepareFormOutput($object->getTitle());
174 
175  return $placeholders;
176  }
177 }
Collection of basic placeholder values that can be used.
global $DIC
Definition: saml.php:7
getPlaceholderValues(int $userId, int $objId)
This method MUST return an array that contains the actual data for the given user of the given object...
getPlaceholderValuesForPreview(int $userId, int $objId)
This method is different then the &#39;getPlaceholderValues&#39; method, this method is used to create a plac...
Just a wrapper class to create Unit Test for other classes.
__construct(ilDefaultPlaceholderValues $defaultPlaceholderValues=null, ilLanguage $language=null, ilCertificateObjectHelper $objectHelper=null, ilCertificateLPMarksHelper $lpMarksHelper=null, ilCertificateExerciseMembersHelper $exerciseMembersHelper=null, ilCertificateLPStatusHelper $lpStatusHelper=null, ilCertificateUtilHelper $utilHelper=null, ilCertificateDateHelper $dateHelper=null)
language handling