ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilScormPlaceholderDescription.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 {
13 
17  private $language;
18 
22  private $placeholder;
23 
27  private $object;
28 
33 
41  public function __construct(
43  ilDefaultPlaceholderDescription $defaultPlaceholderDescriptionObject = null,
44  ilLanguage $language = null,
46  ilUserDefinedFieldsPlaceholderDescription $userDefinedFieldPlaceHolderDescriptionObject = null
47  ) {
48  global $DIC;
49 
50  $this->object = $object;
51 
52  if (null === $language) {
53  $language = $DIC->language();
54  }
55  $this->language = $language;
56 
57  if (null === $defaultPlaceholderDescriptionObject) {
58  $defaultPlaceholderDescriptionObject = new ilDefaultPlaceholderDescription($language, $userDefinedFieldPlaceHolderDescriptionObject);
59  }
60  $this->defaultPlaceHolderDescriptionObject = $defaultPlaceholderDescriptionObject;
61 
62  if (null === $learningProgressObject) {
63  $learningProgressObject = ilObjectLP::getInstance($this->object->getId());
64  }
65  $this->learningProgressObject = $learningProgressObject;
66 
67  $this->placeholder = $this->defaultPlaceHolderDescriptionObject->getPlaceholderDescriptions();
68 
69  $this->placeholder['SCORM_TITLE'] = $language->txt('certificate_ph_scormtitle');
70  $this->placeholder['SCORM_POINTS'] = $language->txt('certificate_ph_scormpoints');
71  $this->placeholder['SCORM_POINTS_MAX'] = $language->txt('certificate_ph_scormmaxpoints');
72  $this->placeholder['DATE_COMPLETED'] = ilUtil::prepareFormOutput($language->txt('certificate_ph_date_completed'));
73  $this->placeholder['DATETIME_COMPLETED'] = ilUtil::prepareFormOutput($language->txt('certificate_ph_datetime_completed'));
74  }
75 
83  public function createPlaceholderHtmlDescription(ilTemplate $template = null) : string
84  {
85  if (null === $template) {
86  $template = new ilTemplate('tpl.scorm_description.html', true, true, 'Services/Certificate');
87  }
88 
89  $template->setCurrentBlock('items');
90 
91  foreach ($this->placeholder as $id => $caption) {
92  $template->setVariable('ID', $id);
93  $template->setVariable('TXT', $caption);
94  $template->parseCurrentBlock();
95  }
96 
97  $template->setVariable('PH_INTRODUCTION', $this->language->txt('certificate_ph_introduction'));
98 
99  $collection = $this->learningProgressObject->getCollectionInstance();
100  if ($collection) {
101  $items = $collection->getPossibleItems();
102  }
103 
104  if (!$items) {
105  $template->setCurrentBlock('NO_SCO');
106  $template->setVariable('PH_NO_SCO', $this->language->txt('certificate_ph_no_sco'));
107  $template->parseCurrentBlock();
108  } else {
109  $template->setCurrentBlock('SCOS');
110  $template->setVariable('PH_SCOS', $this->language->txt('certificate_ph_scos'));
111  $template->parseCurrentBlock();
112  $template->setCurrentBlock('SCO_HEADER');
113  $template->setVariable('PH_TITLE_SCO', $this->language->txt('certificate_ph_title_sco'));
114  $template->setVariable('PH_SCO_TITLE', $this->language->txt('certificate_ph_sco_title'));
115  $template->setVariable('PH_SCO_POINTS_RAW', $this->language->txt('certificate_ph_sco_points_raw'));
116  $template->setVariable('PH_SCO_POINTS_MAX', $this->language->txt('certificate_ph_sco_points_max'));
117  $template->setVariable('PH_SCO_POINTS_SCALED', $this->language->txt('certificate_ph_sco_points_scaled'));
118  $template->parseCurrentBlock();
119  }
120 
121  if ($collection) {
122  $counter = 0;
123  foreach ($items as $item_id => $sahs_item) {
124  if ($collection->isAssignedEntry($item_id)) {
125  $template->setCurrentBlock('SCO');
126  $template->setVariable('SCO_TITLE', $sahs_item['title']);
127  $template->setVariable('PH_SCO_TITLE', '[SCO_T_' . $counter . ']');
128  $template->setVariable('PH_SCO_POINTS_RAW', '[SCO_P_' . $counter . ']');
129  $template->setVariable('PH_SCO_POINTS_MAX', '[SCO_PM_' . $counter . ']');
130  $template->setVariable('PH_SCO_POINTS_SCALED', '[SCO_PP_' . $counter . ']');
131  $template->parseCurrentBlock();
132  $counter++;
133  }
134  }
135  }
136 
137  return $template->get();
138  }
139 
146  public function getPlaceholderDescriptions() : array
147  {
148  return $this->placeholder;
149  }
150 }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
$template
global $DIC
Definition: saml.php:7
if(!array_key_exists('StateId', $_REQUEST)) $id
__construct(ilObject $object, ilDefaultPlaceholderDescription $defaultPlaceholderDescriptionObject=null, ilLanguage $language=null, ilObjectLP $learningProgressObject=null, ilUserDefinedFieldsPlaceholderDescription $userDefinedFieldPlaceHolderDescriptionObject=null)
getPlaceholderDescriptions()
This method MUST return an array containing an array with the the description as array value...
createPlaceholderHtmlDescription(ilTemplate $template=null)
This methods MUST return an array containing an array with the the description as array value...
special template class to simplify handling of ITX/PEAR
Collection of basic placeholder values that can be used.
language handling
static getInstance($a_obj_id)