ILIAS  release_7 Revision v7.30-3-g800a261c036
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 $language->loadLanguageModule('certificate');
55 }
56 $this->language = $language;
57
58 if (null === $defaultPlaceholderDescriptionObject) {
59 $defaultPlaceholderDescriptionObject = new ilDefaultPlaceholderDescription($language, $userDefinedFieldPlaceHolderDescriptionObject);
60 }
61 $this->defaultPlaceHolderDescriptionObject = $defaultPlaceholderDescriptionObject;
62
63 if (null === $learningProgressObject) {
64 $learningProgressObject = ilObjectLP::getInstance($this->object->getId());
65 }
66 $this->learningProgressObject = $learningProgressObject;
67
68 $this->placeholder = $this->defaultPlaceHolderDescriptionObject->getPlaceholderDescriptions();
69
70 $this->placeholder['SCORM_TITLE'] = $language->txt('certificate_ph_scormtitle');
71 $this->placeholder['SCORM_POINTS'] = $language->txt('certificate_ph_scormpoints');
72 $this->placeholder['SCORM_POINTS_MAX'] = $language->txt('certificate_ph_scormmaxpoints');
73 $this->placeholder['DATE_COMPLETED'] = ilUtil::prepareFormOutput($language->txt('certificate_ph_date_completed'));
74 $this->placeholder['DATETIME_COMPLETED'] = ilUtil::prepareFormOutput($language->txt('certificate_ph_datetime_completed'));
75 }
76
84 public function createPlaceholderHtmlDescription(ilTemplate $template = null) : string
85 {
86 if (null === $template) {
87 $template = new ilTemplate('tpl.scorm_description.html', true, true, 'Services/Certificate');
88 }
89
90 $template->setCurrentBlock('items');
91
92 foreach ($this->placeholder as $id => $caption) {
93 $template->setVariable('ID', $id);
94 $template->setVariable('TXT', $caption);
95 $template->parseCurrentBlock();
96 }
97
98 $template->setVariable('PH_INTRODUCTION', $this->language->txt('certificate_ph_introduction'));
99
100 $collection = $this->learningProgressObject->getCollectionInstance();
101 if ($collection) {
102 $items = $collection->getPossibleItems();
103 }
104
105 if (!$items) {
106 $template->setCurrentBlock('NO_SCO');
107 $template->setVariable('PH_NO_SCO', $this->language->txt('certificate_ph_no_sco'));
108 $template->parseCurrentBlock();
109 } else {
110 $template->setCurrentBlock('SCOS');
111 $template->setVariable('PH_SCOS', $this->language->txt('certificate_ph_scos'));
112 $template->parseCurrentBlock();
113 $template->setCurrentBlock('SCO_HEADER');
114 $template->setVariable('PH_TITLE_SCO', $this->language->txt('certificate_ph_title_sco'));
115 $template->setVariable('PH_SCO_TITLE', $this->language->txt('certificate_ph_sco_title'));
116 $template->setVariable('PH_SCO_POINTS_RAW', $this->language->txt('certificate_ph_sco_points_raw'));
117 $template->setVariable('PH_SCO_POINTS_MAX', $this->language->txt('certificate_ph_sco_points_max'));
118 $template->setVariable('PH_SCO_POINTS_SCALED', $this->language->txt('certificate_ph_sco_points_scaled'));
119 $template->parseCurrentBlock();
120 }
121
122 if ($collection) {
123 $counter = 0;
124 foreach ($items as $item_id => $sahs_item) {
125 if ($collection->isAssignedEntry($item_id)) {
126 $template->setCurrentBlock('SCO');
127 $template->setVariable('SCO_TITLE', $sahs_item['title']);
128 $template->setVariable('PH_SCO_TITLE', '[SCO_T_' . $counter . ']');
129 $template->setVariable('PH_SCO_POINTS_RAW', '[SCO_P_' . $counter . ']');
130 $template->setVariable('PH_SCO_POINTS_MAX', '[SCO_PM_' . $counter . ']');
131 $template->setVariable('PH_SCO_POINTS_SCALED', '[SCO_PP_' . $counter . ']');
132 $template->parseCurrentBlock();
133 $counter++;
134 }
135 }
136 }
137
138 return $template->get();
139 }
140
147 public function getPlaceholderDescriptions() : array
148 {
149 return $this->placeholder;
150 }
151}
An exception for terminatinating execution or to throw for unit testing.
Collection of basic placeholder values that can be used.
language handling
static getInstance($a_obj_id)
Class ilObject Basic functions for all objects.
createPlaceholderHtmlDescription(ilTemplate $template=null)
This methods MUST return an array containing an array with the the description as array value.
__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.
special template class to simplify handling of ITX/PEAR
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
global $DIC
Definition: goto.php:24
language()
Definition: language.php:2