ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
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
 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
 

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  }

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

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

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

References $ilSetting.

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

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

References $_POST.

299  {
300  $form_fields["certificate_enabled_scorm"] = $_POST["certificate_enabled_scorm"];
301  $form_fields["short_name"] = $_POST["short_name"];
302  }
$_POST['username']
Definition: cron.php:12

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

References $ilSetting.

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

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

342  {
343  return "scorm";
344  }

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

References $ilSetting, and $lng.

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

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

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

◆ getCertificatePath()

ilSCORMCertificateAdapter::getCertificatePath ( )

Returns the certificate path (with a trailing path separator)

Returns
string The certificate path

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

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

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

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

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

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

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

References $lng, ilCertificateAdapter\getBaseVariablesForPreview(), ilObjectLP\getInstance(), and ilUtil\prepareFormOutput().

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

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

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

References $ilSetting.

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

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: