ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilSCORMCertificateAdapter Class Reference

SCORM certificate adapter. More...

+ Inheritance diagram for ilSCORMCertificateAdapter:
+ Collaboration diagram for ilSCORMCertificateAdapter:

Public Member Functions

 __construct ($object)
 ilSCORMCertificateAdapter contructor More...
 
 getCertificatePath ()
 Returns the certificate path (with a trailing path separator) More...
 
 getCertificateVariablesForPreview ()
 Returns an array containing all variables and values which can be exchanged in the certificate. More...
 
 getCertificateVariablesForPresentation ($params=array())
 Returns an array containing all variables and values which can be exchanged in the certificate The values should be calculated from real data. More...
 
 getCertificateVariablesDescription ()
 Returns a description of the available certificate parameters. More...
 
 addAdditionalFormElements (&$form, $form_fields)
 Allows to add additional form fields to the certificate editor form This method will be called when the certificate editor form will built using the ilPropertyFormGUI class. More...
 
 addFormFieldsFromPOST (&$form_fields)
 Allows to add additional form values to the array of form values evaluating a HTTP POST action. More...
 
 addFormFieldsFromObject (&$form_fields)
 Allows to add additional form values to the array of form values evaluating the associated adapter class if one exists This method will be called when the certificate editor form will be shown and the content of the form has to be retrieved from wherever the form values are saved. More...
 
 saveFormFields (&$form_fields)
 Allows to save additional adapter form fields This method will be called when the certificate editor form is complete and the form values will be saved. More...
 
 getAdapterType ()
 Returns the adapter type This value will be used to generate file names for the certificates. More...
 
 getCertificateID ()
 Returns a certificate ID This value will be used to generate unique file names for the certificates. More...
 
 getCertificateFilename ($params=array())
 Set the name of the certificate file This method will be called when the certificate will be generated. More...
 
 deleteCertificate ()
 Is called when the certificate is deleted Add some adapter specific code if more work has to be done when the certificate file was deleted. More...
 
 getUserIdForParams ($a_params)
 Get user id for params. More...
 
- Public Member Functions inherited from ilCertificateAdapter
 __construct ()
 ilCertificateAdapter constructor. More...
 
 getCertificatePath ()
 Returns the certificate path (with a trailing path separator) More...
 
 getCertificateVariablesForPreview ()
 Returns an array containing all variables and values which can be exchanged in the certificate. More...
 
 getCertificateVariablesForPresentation ($params=array())
 Returns an array containing all variables and values which can be exchanged in the certificate The values should be calculated from real data. More...
 
 getCertificateVariablesDescription ()
 Returns a description of the available certificate parameters. More...
 
 getAdapterType ()
 Returns the adapter type This value will be used to generate file names for the certificates. More...
 
 getCertificateID ()
 Returns a certificate ID This value will be used to generate unique file names for the certificates. More...
 
 addAdditionalFormElements (&$form, $form_fields)
 Allows to add additional form fields to the certificate editor form This method will be called when the certificate editor form will built using the ilPropertyFormGUI class. More...
 
 addFormFieldsFromPOST (&$form_fields)
 Allows to add additional form values to the array of form values evaluating a HTTP POST action. More...
 
 addFormFieldsFromObject (&$form_fields)
 Allows to add additional form values to the array of form values evaluating the associated adapter class if one exists This method will be called when the certificate editor form will be shown and the content of the form has to be retrieved from wherever the form values are saved. More...
 
 saveFormFields (&$form_fields)
 Allows to save additional adapter form fields This method will be called when the certificate editor form is complete and the form values will be saved. More...
 
 deleteCertificate ()
 Is called when the certificate is deleted Add some adapter specific code if more work has to be done when the certificate file was deleted. More...
 
 getCertificateFilename ($params=array())
 Set the name of the certificate file This method will be called when the certificate will be generated. More...
 
 getUserIdForParams ($a_params)
 Get user id for params. More...
 

Protected Attributes

 $object
 
- Protected Attributes inherited from ilCertificateAdapter
 $lng
 

Additional Inherited Members

- Protected Member Functions inherited from ilCertificateAdapter
 getBaseVariablesDescription ($a_enable_last_access=true, $a_enable_completion_date=true)
 Get variable descriptions. More...
 
 getBaseVariablesForPreview ($a_enable_last_access=true, $a_enable_completion_date=true)
 Get variable dummys. More...
 
 getBaseVariablesForPresentation ($a_user_data, $a_last_access=null, $a_completion_date=false)
 Get variable values. More...
 
 getUserCompletionDate ($a_user_id, $a_object_id=null)
 Get completion for user. More...
 

Detailed Description

SCORM certificate adapter.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
$Id$

Definition at line 33 of file class.ilSCORMCertificateAdapter.php.

Constructor & Destructor Documentation

◆ __construct()

ilSCORMCertificateAdapter::__construct (   $object)

ilSCORMCertificateAdapter contructor

Parameters
object$objectA reference to a test object

Definition at line 42 of file class.ilSCORMCertificateAdapter.php.

References $object.

43  {
44  $this->object = $object;
45  parent::__construct();
46  }

Member Function Documentation

◆ addAdditionalFormElements()

ilSCORMCertificateAdapter::addAdditionalFormElements ( $form,
  $form_fields 
)

Allows to add additional form fields to the certificate editor form This method will be called when the certificate editor form will built using the ilPropertyFormGUI class.

Additional fields will be added at the bottom of the form.

Parameters
object$formAn ilPropertyFormGUI instance
array$form_fieldsAn array containing the form values. The array keys are the names of the form fields

Definition at line 247 of file class.ilSCORMCertificateAdapter.php.

References $_POST, $form, object, ilFormPropertyGUI\setRequired(), and ilStr\subStr().

248  {
249  $short_name = new ilTextInputGUI($this->lng->txt("certificate_short_name"), "short_name");
250  $short_name->setRequired(true);
251  require_once "./Services/Utilities/classes/class.ilStr.php";
252  $short_name->setValue(strlen($form_fields["short_name"]) ? $form_fields["short_name"] : ilStr::subStr($this->object->getTitle(), 0, 30));
253  $short_name->setSize(30);
254  if (strlen($form_fields["short_name"])) {
255  $short_name->setInfo(str_replace("[SHORT_TITLE]", $form_fields["short_name"], $this->lng->txt("certificate_short_name_description")));
256  } else {
257  $short_name->setInfo($this->lng->txt("certificate_short_name_description"));
258  }
259  if (count($_POST)) {
260  $short_name->checkInput();
261  }
262  $form->addItem($short_name);
263  }
static subStr($a_str, $a_start, $a_length=null)
Definition: class.ilStr.php:15
if(isset($_POST['submit'])) $form
This class represents a text property in a property form.
Create new PHPExcel object
obj_idprivate
$_POST["username"]
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:

◆ addFormFieldsFromObject()

ilSCORMCertificateAdapter::addFormFieldsFromObject ( $form_fields)

Allows to add additional form values to the array of form values evaluating the associated adapter class if one exists This method will be called when the certificate editor form will be shown and the content of the form has to be retrieved from wherever the form values are saved.

Parameters
array$form_fieldsA reference to the array of form values

Definition at line 287 of file class.ilSCORMCertificateAdapter.php.

References object.

288  {
289  $scormSetting = new ilSetting("scorm");
290  $form_fields["certificate_enabled_scorm"] = $scormSetting->get("certificate_" . $this->object->getId());
291  $form_fields["short_name"] = $scormSetting->get("certificate_short_name_" . $this->object->getId());
292  }
Create new PHPExcel object
obj_idprivate

◆ addFormFieldsFromPOST()

ilSCORMCertificateAdapter::addFormFieldsFromPOST ( $form_fields)

Allows to add additional form values to the array of form values evaluating a HTTP POST action.

This method will be called when the certificate editor form will be saved using the form save button.

Parameters
array$form_fieldsA reference to the array of form values

Definition at line 273 of file class.ilSCORMCertificateAdapter.php.

References $_POST.

274  {
275  $form_fields["certificate_enabled_scorm"] = $_POST["certificate_enabled_scorm"];
276  $form_fields["short_name"] = $_POST["short_name"];
277  }
$_POST["username"]

◆ deleteCertificate()

ilSCORMCertificateAdapter::deleteCertificate ( )

Is called when the certificate is deleted Add some adapter specific code if more work has to be done when the certificate file was deleted.

Definition at line 356 of file class.ilSCORMCertificateAdapter.php.

References object.

357  {
358  $scormSetting = new ilSetting("scorm");
359  $scormSetting->delete("certificate_" . $this->object->getId());
360  }
Create new PHPExcel object
obj_idprivate

◆ getAdapterType()

ilSCORMCertificateAdapter::getAdapterType ( )

Returns the adapter type This value will be used to generate file names for the certificates.

Returns
string A string value to represent the adapter type

Definition at line 314 of file class.ilSCORMCertificateAdapter.php.

315  {
316  return "scorm";
317  }

◆ getCertificateFilename()

ilSCORMCertificateAdapter::getCertificateFilename (   $params = array())

Set the name of the certificate file This method will be called when the certificate will be generated.

Returns
string The certificate file name

Definition at line 336 of file class.ilSCORMCertificateAdapter.php.

References $ilSetting, $params, object, and time.

337  {
338  $basename = parent::getCertificateFilename($params);
339 
340  $user_data = $params["user_data"];
341  if (!is_array($user_data)) {
342  global $ilSetting;
343  $scormSetting = new ilSetting("scorm");
344  $short_title = $scormSetting->get("certificate_short_name_" . $this->object->getId());
345  return strftime("%y%m%d", time()) . "_" . $this->lng->txt("certificate_var_user_lastname") . "_" . $short_title . "_" . $basename;
346  } else {
347  return strftime("%y%m%d", time()) . "_" . $user_data["lastname"] . "_" . $params["short_title"] . "_.$basename";
348  }
349  }
$params
Definition: disable.php:11
Create new PHPExcel object
obj_idprivate
global $ilSetting
Definition: privfeed.php:17
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.

◆ getCertificateID()

ilSCORMCertificateAdapter::getCertificateID ( )

Returns a certificate ID This value will be used to generate unique file names for the certificates.

Returns
mixed A unique ID which represents a certificate

Definition at line 325 of file class.ilSCORMCertificateAdapter.php.

326  {
327  return $this->object->getId();
328  }

◆ getCertificatePath()

ilSCORMCertificateAdapter::getCertificatePath ( )

Returns the certificate path (with a trailing path separator)

Returns
string The certificate path

Definition at line 53 of file class.ilSCORMCertificateAdapter.php.

54  {
55  return CLIENT_WEB_DIR . "/certificates/scorm/" . $this->object->getId() . "/";
56  }

◆ getCertificateVariablesDescription()

ilSCORMCertificateAdapter::getCertificateVariablesDescription ( )

Returns a description of the available certificate parameters.

The description will be shown at the bottom of the certificate editor text area.

Returns
string The certificate parameters description

Definition at line 177 of file class.ilSCORMCertificateAdapter.php.

References $counter, $id, $template, ilCertificateAdapter\getBaseVariablesDescription(), ilObjectLP\getInstance(), and object.

178  {
179  $vars = $this->getBaseVariablesDescription();
180  $vars["SCORM_TITLE"] = $this->lng->txt("certificate_ph_scormtitle");
181  $vars["SCORM_POINTS"] = $this->lng->txt("certificate_ph_scormpoints");
182  $vars["SCORM_POINTS_MAX"] = $this->lng->txt("certificate_ph_scormmaxpoints");
183 
184  $template = new ilTemplate("tpl.certificate_edit.html", true, true, "Modules/ScormAicc");
185  $template->setCurrentBlock("items");
186  foreach ($vars as $id => $caption) {
187  $template->setVariable("ID", $id);
188  $template->setVariable("TXT", $caption);
189  $template->parseCurrentBlock();
190  }
191 
192  $template->setVariable("PH_INTRODUCTION", $this->lng->txt("certificate_ph_introduction"));
193 
194  include_once 'Services/Object/classes/class.ilObjectLP.php';
195  $olp = ilObjectLP::getInstance($this->object->getId());
196  $collection = $olp->getCollectionInstance();
197  if ($collection) {
198  $items = $collection->getPossibleItems();
199  }
200 
201  if (!$items) {
202  $template->setCurrentBlock('NO_SCO');
203  $template->setVariable('PH_NO_SCO', $this->lng->txt('certificate_ph_no_sco'));
204  $template->parseCurrentBlock();
205  } else {
206  $template->setCurrentBlock('SCOS');
207  $template->setVariable('PH_SCOS', $this->lng->txt('certificate_ph_scos'));
208  $template->parseCurrentBlock();
209  $template->setCurrentBlock('SCO_HEADER');
210  $template->setVariable('PH_TITLE_SCO', $this->lng->txt('certificate_ph_title_sco'));
211  //$template->setVariable('PH_PH',$lng->txt('certificate_ph_ph'));
212  $template->setVariable('PH_SCO_TITLE', $this->lng->txt('certificate_ph_sco_title'));
213  $template->setVariable('PH_SCO_POINTS_RAW', $this->lng->txt('certificate_ph_sco_points_raw'));
214  $template->setVariable('PH_SCO_POINTS_MAX', $this->lng->txt('certificate_ph_sco_points_max'));
215  $template->setVariable('PH_SCO_POINTS_SCALED', $this->lng->txt('certificate_ph_sco_points_scaled'));
216  $template->parseCurrentBlock();
217  }
218 
219  if ($collection) {
220  $counter=0;
221  foreach ($items as $item_id => $sahs_item) {
222  if ($collection->isAssignedEntry($item_id)) {
223  $template->setCurrentBlock("SCO");
224  $template->setVariable('SCO_TITLE', $sahs_item['title']);
225  $template->setVariable('PH_SCO_TITLE', '[SCO_T_' . $counter . ']');
226  $template->setVariable('PH_SCO_POINTS_RAW', '[SCO_P_' . $counter . ']');
227  $template->setVariable('PH_SCO_POINTS_MAX', '[SCO_PM_' . $counter . ']');
228  $template->setVariable('PH_SCO_POINTS_SCALED', '[SCO_PP_' . $counter . ']');
229  $template->parseCurrentBlock();
230  $counter++;
231  }
232  }
233  }
234 
235  return $template->get();
236  }
$template
if(!array_key_exists('StateId', $_REQUEST)) $id
$counter
special template class to simplify handling of ITX/PEAR
getBaseVariablesDescription($a_enable_last_access=true, $a_enable_completion_date=true)
Get variable descriptions.
Create new PHPExcel object
obj_idprivate
static getInstance($a_obj_id)
+ Here is the call graph for this function:

◆ getCertificateVariablesForPresentation()

ilSCORMCertificateAdapter::getCertificateVariablesForPresentation (   $params = array())

Returns an array containing all variables and values which can be exchanged in the certificate The values should be calculated from real data.

The $params parameter array should contain all necessary information to calculate the values.

Parameters
array$paramsAn array of parameters to calculate the certificate parameter values
Returns
array The certificate variables

Definition at line 103 of file class.ilSCORMCertificateAdapter.php.

References $counter, $GLOBALS, $id, $params, ilCertificateAdapter\getBaseVariablesForPresentation(), ilObjectLP\getInstance(), ilCertificateAdapter\getUserCompletionDate(), object, and ilUtil\prepareFormOutput().

104  {
105  $this->lng->loadLanguageModule('certificate');
106 
107  $points = $this->object->getPointsInPercent();
108  $txtPoints = "";
109  if (is_null($points)) {
110  $txtPoints = $this->lng->txt("certificate_points_notavailable");
111  } else {
112  $txtPoints = number_format($points, 1, $this->lng->txt("lang_sep_decimal"), $this->lng->txt("lang_sep_thousand")) . " %";
113  }
114 
115  $max_points = $this->object->getMaxPoints();
116  $txtMaxPoints = '';
117  if (is_null($max_points)) {
118  $txtMaxPoints = $this->lng->txt("certificate_points_notavailable");
119  } else {
120  if ($max_points != floor($max_points)) {
121  $txtMaxPoints = number_format($max_points, 1, $this->lng->txt("lang_sep_decimal"), $this->lng->txt("lang_sep_thousand"));
122  } else {
123  $txtMaxPoints = $max_points;
124  }
125  }
126 
127  $user_data = $params["user_data"];
128  $completion_date = $this->getUserCompletionDate($user_data["usr_id"]);
129 
130  $vars = $this->getBaseVariablesForPresentation($user_data, $params["last_access"], $completion_date);
131  $vars["SCORM_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle());
132  $vars["SCORM_POINTS"] = $txtPoints;
133  $vars["SCORM_POINTS_MAX"] = $txtMaxPoints;
134 
135  foreach ($vars as $id => $caption) {
136  $insert_tags["[" . $id . "]"] = $caption;
137  }
138 
139  include_once 'Services/Object/classes/class.ilObjectLP.php';
140  $olp = ilObjectLP::getInstance($this->object->getId());
141  $collection = $olp->getCollectionInstance();
142  if ($collection) {
143  $counter=0;
144  foreach ($collection->getPossibleItems() as $item_id => $sahs_item) {
145  if ($collection->isAssignedEntry($item_id)) {
146  $insert_tags['[SCO_T_' . $counter . ']'] = $sahs_item['title'];//." getId=".$this->object->getId()." item_id=".$item_id." user_id=".$ilUser->getId()
147  $a_scores = $collection->getScoresForUserAndCP_Node_Id($item_id, $GLOBALS['DIC']['ilUser']->getId());
148  if ($a_scores["raw"] == null) {
149  $insert_tags['[SCO_P_' . $counter . ']'] = $this->lng->txt("certificate_points_notavailable");
150  } else {
151  $insert_tags['[SCO_P_' . $counter . ']'] = number_format($a_scores["raw"], 1, $this->lng->txt("lang_sep_decimal"), $this->lng->txt("lang_sep_thousand"));
152  }
153  if ($a_scores["max"] == null) {
154  $insert_tags['[SCO_PM_' . $counter . ']'] = $this->lng->txt("certificate_points_notavailable");
155  } else {
156  $insert_tags['[SCO_PM_' . $counter . ']'] = number_format($a_scores["max"], 1, $this->lng->txt("lang_sep_decimal"), $this->lng->txt("lang_sep_thousand"));
157  }
158  if ($a_scores["scaled"] == null) {
159  $insert_tags['[SCO_PP_' . $counter . ']'] = $this->lng->txt("certificate_points_notavailable");
160  } else {
161  $insert_tags['[SCO_PP_' . $counter . ']'] = number_format(($a_scores["scaled"]*100), 1, $this->lng->txt("lang_sep_decimal"), $this->lng->txt("lang_sep_thousand")) . " %";
162  }
163  $counter++;
164  }
165  }
166  }
167 
168  return $insert_tags;
169  }
$params
Definition: disable.php:11
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
getUserCompletionDate($a_user_id, $a_object_id=null)
Get completion for user.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
if(!array_key_exists('StateId', $_REQUEST)) $id
$counter
Create new PHPExcel object
obj_idprivate
getBaseVariablesForPresentation($a_user_data, $a_last_access=null, $a_completion_date=false)
Get variable values.
static getInstance($a_obj_id)
+ Here is the call graph for this function:

◆ getCertificateVariablesForPreview()

ilSCORMCertificateAdapter::getCertificateVariablesForPreview ( )

Returns an array containing all variables and values which can be exchanged in the certificate.

The values will be taken for the certificate preview.

Returns
array The certificate variables

Definition at line 64 of file class.ilSCORMCertificateAdapter.php.

References $counter, $id, array, ilCertificateAdapter\getBaseVariablesForPreview(), ilObjectLP\getInstance(), object, and ilUtil\prepareFormOutput().

65  {
66  $vars = $this->getBaseVariablesForPreview();
67  $vars["SCORM_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle());
68  $vars["SCORM_POINTS"] = number_format(80.7, 1, $this->lng->txt("lang_sep_decimal"), $this->lng->txt("lang_sep_thousand")) . " %";
69  $vars["SCORM_POINTS_MAX"] = number_format(90, 0, $this->lng->txt("lang_sep_decimal"), $this->lng->txt("lang_sep_thousand"));
70 
71  $insert_tags = array();
72  foreach ($vars as $id => $caption) {
73  $insert_tags["[" . $id . "]"] = $caption;
74  }
75 
76  include_once 'Services/Object/classes/class.ilObjectLP.php';
77  $olp = ilObjectLP::getInstance($this->object->getId());
78  $collection = $olp->getCollectionInstance();
79  if ($collection) {
80  $counter=0;
81  foreach ($collection->getPossibleItems() as $item_id => $sahs_item) {
82  if ($collection->isAssignedEntry($item_id)) {
83  $insert_tags['[SCO_T_' . $counter . ']'] = $sahs_item['title'];
84  $insert_tags['[SCO_P_' . $counter . ']'] = number_format(30.3, 1, $this->lng->txt("lang_sep_decimal"), $this->lng->txt("lang_sep_thousand"));
85  $insert_tags['[SCO_PM_' . $counter . ']'] = number_format(90.9, 1, $this->lng->txt("lang_sep_decimal"), $this->lng->txt("lang_sep_thousand"));
86  $insert_tags['[SCO_PP_' . $counter . ']'] = number_format(33.3333, 1, $this->lng->txt("lang_sep_decimal"), $this->lng->txt("lang_sep_thousand")) . " %";
87  $counter++;
88  }
89  }
90  }
91 
92  return $insert_tags;
93  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
if(!array_key_exists('StateId', $_REQUEST)) $id
$counter
Create styles array
The data for the language used.
Create new PHPExcel object
obj_idprivate
getBaseVariablesForPreview($a_enable_last_access=true, $a_enable_completion_date=true)
Get variable dummys.
static getInstance($a_obj_id)
+ Here is the call graph for this function:

◆ getUserIdForParams()

ilSCORMCertificateAdapter::getUserIdForParams (   $a_params)

Get user id for params.

Parameters

Definition at line 368 of file class.ilSCORMCertificateAdapter.php.

369  {
370  return $a_params["user_data"]["usr_id"];
371  }

◆ saveFormFields()

ilSCORMCertificateAdapter::saveFormFields ( $form_fields)

Allows to save additional adapter form fields This method will be called when the certificate editor form is complete and the form values will be saved.

Parameters
array$form_fieldsA reference to the array of form values

Definition at line 301 of file class.ilSCORMCertificateAdapter.php.

References object.

302  {
303  $scormSetting = new ilSetting("scorm");
304  $scormSetting->set("certificate_" . $this->object->getId(), $form_fields["certificate_enabled_scorm"]);
305  $scormSetting->set("certificate_short_name_" . $this->object->getId(), $form_fields["short_name"]);
306  }
Create new PHPExcel object
obj_idprivate

Field Documentation

◆ $object

ilSCORMCertificateAdapter::$object
protected

Definition at line 35 of file class.ilSCORMCertificateAdapter.php.

Referenced by __construct().


The documentation for this class was generated from the following file: