ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 264 of file class.ilSCORMCertificateAdapter.php.

References $_POST, ilCertificateAdapter\$lng, object, ilFormPropertyGUI\setInfo(), ilFormPropertyGUI\setRequired(), and ilStr\subStr().

265  {
266  global $lng;
267  $short_name = new ilTextInputGUI($lng->txt("certificate_short_name"), "short_name");
268  $short_name->setRequired(TRUE);
269  require_once "./Services/Utilities/classes/class.ilStr.php";
270  $short_name->setValue(strlen($form_fields["short_name"]) ? $form_fields["short_name"] : ilStr::subStr($this->object->getTitle(), 0, 30));
271  $short_name->setSize(30);
272  if (strlen($form_fields["short_name"])) {
273  $short_name->setInfo(str_replace("[SHORT_TITLE]", $form_fields["short_name"], $lng->txt("certificate_short_name_description")));
274  } else {
275  $short_name->setInfo($lng->txt("certificate_short_name_description"));
276  }
277  if (count($_POST)) $short_name->checkInput();
278  $form->addItem($short_name);
279 
280  $visibility = new ilCheckboxInputGUI($lng->txt("certificate_enabled_scorm"), "certificate_enabled_scorm");
281  $visibility->setInfo($lng->txt("certificate_enabled_scorm_introduction"));
282  $visibility->setValue(1);
283  if ($form_fields["certificate_enabled_scorm"])
284  {
285  $visibility->setChecked(TRUE);
286  }
287  if (count($_POST)) $visibility->checkInput();
288  $form->addItem($visibility);
289  }
This class represents a checkbox property in a property form.
setInfo($a_info)
Set Information Text.
This class represents a text property in a property form.
Create new PHPExcel object
obj_idprivate
static subStr($a_str, $a_start, $a_length=NULL)
Definition: class.ilStr.php:15
$_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 313 of file class.ilSCORMCertificateAdapter.php.

References $ilSetting, and object.

314  {
315  global $ilSetting;
316  $scormSetting = new ilSetting("scorm");
317  $form_fields["certificate_enabled_scorm"] = $scormSetting->get("certificate_" . $this->object->getId());
318  $form_fields["short_name"] = $scormSetting->get("certificate_short_name_" . $this->object->getId());
319  }
ILIAS Setting Class.
Create new PHPExcel object
obj_idprivate
global $ilSetting
Definition: privfeed.php:17

◆ 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 299 of file class.ilSCORMCertificateAdapter.php.

References $_POST.

300  {
301  $form_fields["certificate_enabled_scorm"] = $_POST["certificate_enabled_scorm"];
302  $form_fields["short_name"] = $_POST["short_name"];
303  }
$_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 389 of file class.ilSCORMCertificateAdapter.php.

References $ilSetting, and object.

390  {
391  global $ilSetting;
392  $scormSetting = new ilSetting("scorm");
393  $scormSetting->delete("certificate_" . $this->object->getId());
394  }
ILIAS Setting Class.
Create new PHPExcel object
obj_idprivate
global $ilSetting
Definition: privfeed.php:17

◆ 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 342 of file class.ilSCORMCertificateAdapter.php.

343  {
344  return "scorm";
345  }

◆ 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 364 of file class.ilSCORMCertificateAdapter.php.

References $ilSetting, ilCertificateAdapter\$lng, $params, object, and time.

365  {
366  global $lng;
367 
368  $basename = parent::getCertificateFilename($params);
369 
370  $user_data = $params["user_data"];
371  if (!is_array($user_data))
372  {
373  global $ilSetting;
374  $scormSetting = new ilSetting("scorm");
375  $short_title = $scormSetting->get("certificate_short_name_" . $this->object->getId());
376  return strftime("%y%m%d", time()) . "_" . $lng->txt("certificate_var_user_lastname") . "_" . $short_title . "_" . $basename;
377  }
378  else
379  {
380  return strftime("%y%m%d", time()) . "_" . $user_data["lastname"] . "_" . $params["short_title"] . "_.$basename";
381  }
382  }
ILIAS Setting Class.
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.
$params
Definition: example_049.php:96

◆ 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 353 of file class.ilSCORMCertificateAdapter.php.

354  {
355  return $this->object->getId();
356  }

◆ 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 187 of file class.ilSCORMCertificateAdapter.php.

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

188  {
189  global $lng;
190 
191  $vars = $this->getBaseVariablesDescription();
192  $vars["SCORM_TITLE"] = $lng->txt("certificate_ph_scormtitle");
193  $vars["SCORM_POINTS"] = $lng->txt("certificate_ph_scormpoints");
194  $vars["SCORM_POINTS_MAX"] = $lng->txt("certificate_ph_scormmaxpoints");
195 
196  $template = new ilTemplate("tpl.certificate_edit.html", TRUE, TRUE, "Modules/ScormAicc");
197  $template->setCurrentBlock("items");
198  foreach($vars as $id => $caption)
199  {
200  $template->setVariable("ID", $id);
201  $template->setVariable("TXT", $caption);
202  $template->parseCurrentBlock();
203  }
204 
205  $template->setVariable("PH_INTRODUCTION", $lng->txt("certificate_ph_introduction"));
206 
207  include_once 'Services/Object/classes/class.ilObjectLP.php';
208  $olp = ilObjectLP::getInstance($this->object->getId());
209  $collection = $olp->getCollectionInstance();
210  if($collection)
211  {
212  $items = $collection->getPossibleItems();
213  }
214 
215  if(!$items) {
216  $template->setCurrentBlock('NO_SCO');
217  $template->setVariable('PH_NO_SCO',$lng->txt('certificate_ph_no_sco'));
218  $template->parseCurrentBlock();
219  }
220  else {
221  $template->setCurrentBlock('SCOS');
222  $template->setVariable('PH_SCOS',$lng->txt('certificate_ph_scos'));
223  $template->parseCurrentBlock();
224  $template->setCurrentBlock('SCO_HEADER');
225  $template->setVariable('PH_TITLE_SCO',$lng->txt('certificate_ph_title_sco'));
226  //$template->setVariable('PH_PH',$lng->txt('certificate_ph_ph'));
227  $template->setVariable('PH_SCO_TITLE',$lng->txt('certificate_ph_sco_title'));
228  $template->setVariable('PH_SCO_POINTS_RAW',$lng->txt('certificate_ph_sco_points_raw'));
229  $template->setVariable('PH_SCO_POINTS_MAX',$lng->txt('certificate_ph_sco_points_max'));
230  $template->setVariable('PH_SCO_POINTS_SCALED',$lng->txt('certificate_ph_sco_points_scaled'));
231  $template->parseCurrentBlock();
232  }
233 
234  if($collection)
235  {
236  $counter=0;
237  foreach($items as $item_id => $sahs_item)
238  {
239  if($collection->isAssignedEntry($item_id)) {
240  $template->setCurrentBlock("SCO");
241  $template->setVariable('SCO_TITLE',$sahs_item['title']);
242  $template->setVariable('PH_SCO_TITLE','[SCO_T_'.$counter.']');
243  $template->setVariable('PH_SCO_POINTS_RAW','[SCO_P_'.$counter.']');
244  $template->setVariable('PH_SCO_POINTS_MAX','[SCO_PM_'.$counter.']');
245  $template->setVariable('PH_SCO_POINTS_SCALED','[SCO_PP_'.$counter.']');
246  $template->parseCurrentBlock();
247  $counter++;
248  }
249  }
250  }
251 
252  return $template->get();
253  }
$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 108 of file class.ilSCORMCertificateAdapter.php.

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

109  {
110  global $lng,$ilUser;
111 
112  $lng->loadLanguageModule('certificate');
113 
114  $points = $this->object->getPointsInPercent();
115  $txtPoints = "";
116  if (is_null($points))
117  {
118  $txtPoints = $lng->txt("certificate_points_notavailable");
119  }
120  else
121  {
122  $txtPoints = number_format($points, 1, $lng->txt("lang_sep_decimal"), $lng->txt("lang_sep_thousand")) . " %";
123  }
124 
125  $max_points = $this->object->getMaxPoints();
126  $txtMaxPoints = '';
127  if (is_null($max_points))
128  {
129  $txtMaxPoints = $lng->txt("certificate_points_notavailable");
130  }
131  else
132  {
133  if($max_points != floor($max_points))
134  {
135  $txtMaxPoints = number_format($max_points, 1, $lng->txt("lang_sep_decimal"), $lng->txt("lang_sep_thousand"));
136  }
137  else
138  {
139  $txtMaxPoints = $max_points;
140  }
141  }
142 
143  $user_data = $params["user_data"];
144  $completion_date = $this->getUserCompletionDate($user_data["usr_id"]);
145 
146  $vars = $this->getBaseVariablesForPresentation($user_data, $params["last_access"], $completion_date);
147  $vars["SCORM_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle());
148  $vars["SCORM_POINTS"] = $txtPoints;
149  $vars["SCORM_POINTS_MAX"] = $txtMaxPoints;
150 
151  foreach($vars as $id => $caption)
152  {
153  $insert_tags["[".$id."]"] = $caption;
154  }
155 
156  include_once 'Services/Object/classes/class.ilObjectLP.php';
157  $olp = ilObjectLP::getInstance($this->object->getId());
158  $collection = $olp->getCollectionInstance();
159  if($collection)
160  {
161  $counter=0;
162  foreach($collection->getPossibleItems() as $item_id => $sahs_item)
163  {
164  if($collection->isAssignedEntry($item_id)) {
165  $insert_tags['[SCO_T_'.$counter.']'] = $sahs_item['title'];//." getId=".$this->object->getId()." item_id=".$item_id." user_id=".$ilUser->getId()
166  $a_scores = $collection->getScoresForUserAndCP_Node_Id($item_id, $ilUser->getId());
167  if ($a_scores["raw"] == null) $insert_tags['[SCO_P_'.$counter.']'] = $lng->txt("certificate_points_notavailable");
168  else $insert_tags['[SCO_P_'.$counter.']'] = number_format($a_scores["raw"], 1, $lng->txt("lang_sep_decimal"), $lng->txt("lang_sep_thousand"));
169  if ($a_scores["max"] == null) $insert_tags['[SCO_PM_'.$counter.']'] = $lng->txt("certificate_points_notavailable");
170  else $insert_tags['[SCO_PM_'.$counter.']'] = number_format($a_scores["max"], 1, $lng->txt("lang_sep_decimal"), $lng->txt("lang_sep_thousand"));
171  if ($a_scores["scaled"] == null) $insert_tags['[SCO_PP_'.$counter.']'] = $lng->txt("certificate_points_notavailable");
172  else $insert_tags['[SCO_PP_'.$counter.']'] = number_format(($a_scores["scaled"]*100), 1, $lng->txt("lang_sep_decimal"), $lng->txt("lang_sep_thousand")) . " %";
173  $counter++;
174  }
175  }
176  }
177 
178  return $insert_tags;
179  }
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.
$counter
$ilUser
Definition: imgupload.php:18
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)
$params
Definition: example_049.php:96
+ 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, ilCertificateAdapter\$lng, array, ilCertificateAdapter\getBaseVariablesForPreview(), ilObjectLP\getInstance(), object, and ilUtil\prepareFormOutput().

65  {
66  global $lng;
67 
68  $vars = $this->getBaseVariablesForPreview();
69  $vars["SCORM_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle());
70  $vars["SCORM_POINTS"] = number_format(80.7, 1, $lng->txt("lang_sep_decimal"), $lng->txt("lang_sep_thousand")) . " %";
71  $vars["SCORM_POINTS_MAX"] = number_format(90, 0, $lng->txt("lang_sep_decimal"), $lng->txt("lang_sep_thousand"));
72 
73  $insert_tags = array();
74  foreach($vars as $id => $caption)
75  {
76  $insert_tags["[".$id."]"] = $caption;
77  }
78 
79  include_once 'Services/Object/classes/class.ilObjectLP.php';
80  $olp = ilObjectLP::getInstance($this->object->getId());
81  $collection = $olp->getCollectionInstance();
82  if($collection)
83  {
84  $counter=0;
85  foreach($collection->getPossibleItems() as $item_id => $sahs_item)
86  {
87  if($collection->isAssignedEntry($item_id)) {
88  $insert_tags['[SCO_T_'.$counter.']'] = $sahs_item['title'];
89  $insert_tags['[SCO_P_'.$counter.']'] = number_format(30.3, 1, $lng->txt("lang_sep_decimal"), $lng->txt("lang_sep_thousand"));
90  $insert_tags['[SCO_PM_'.$counter.']'] = number_format(90.9, 1, $lng->txt("lang_sep_decimal"), $lng->txt("lang_sep_thousand"));
91  $insert_tags['[SCO_PP_'.$counter.']'] = number_format(33.3333, 1, $lng->txt("lang_sep_decimal"), $lng->txt("lang_sep_thousand")) . " %";
92  $counter++;
93  }
94  }
95  }
96 
97  return $insert_tags;
98  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
$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 402 of file class.ilSCORMCertificateAdapter.php.

403  {
404  return $a_params["user_data"]["usr_id"];
405  }

◆ 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 328 of file class.ilSCORMCertificateAdapter.php.

References $ilSetting, and object.

329  {
330  global $ilSetting;
331  $scormSetting = new ilSetting("scorm");
332  $scormSetting->set("certificate_" . $this->object->getId(), $form_fields["certificate_enabled_scorm"]);
333  $scormSetting->set("certificate_short_name_" . $this->object->getId(), $form_fields["short_name"]);
334  }
ILIAS Setting Class.
Create new PHPExcel object
obj_idprivate
global $ilSetting
Definition: privfeed.php:17

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: