ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilSkillCertificateAdapter Class Reference

Skill certificate adapter. More...

+ Inheritance diagram for ilSkillCertificateAdapter:
+ Collaboration diagram for ilSkillCertificateAdapter:

Public Member Functions

 __construct ($a_skill, $a_skill_level_id)
 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...
 
- 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
 

Private Attributes

 $skill
 
 $skill_level_id
 

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

Skill certificate adapter.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 14 of file class.ilSkillCertificateAdapter.php.

Constructor & Destructor Documentation

◆ __construct()

ilSkillCertificateAdapter::__construct (   $a_skill,
  $a_skill_level_id 
)

Contructor.

Parameters
objectskill object
objectskill level id

Definition at line 26 of file class.ilSkillCertificateAdapter.php.

References $lng.

27  {
28  global $lng;
29 
30  $lng->loadLanguageModule("skmg");
31 
32  $this->skill = $a_skill;
33  $this->skill_level_id = $a_skill_level_id;
34  }
global $lng
Definition: privfeed.php:40

Member Function Documentation

◆ addAdditionalFormElements()

ilSkillCertificateAdapter::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 161 of file class.ilSkillCertificateAdapter.php.

References $lng.

162  {
163  global $lng;
164  /*$short_name = new ilTextInputGUI($lng->txt("certificate_short_name"), "short_name");
165  $short_name->setRequired(TRUE);
166  require_once "./Services/Utilities/classes/class.ilStr.php";
167  $short_name->setValue(strlen($form_fields["short_name"]) ? $form_fields["short_name"] : ilStr::subStr($this->object->getTitle(), 0, 30));
168  $short_name->setSize(30);
169  if (strlen($form_fields["short_name"])) {
170  $short_name->setInfo(str_replace("[SHORT_TITLE]", $form_fields["short_name"], $lng->txt("certificate_short_name_description")));
171  } else {
172  $short_name->setInfo($lng->txt("certificate_short_name_description"));
173  }
174  if (count($_POST)) $short_name->checkInput();
175  $form->addItem($short_name);
176 
177  $visibility = new ilCheckboxInputGUI($lng->txt("certificate_enabled_scorm"), "certificate_enabled_scorm");
178  $visibility->setInfo($lng->txt("certificate_enabled_scorm_introduction"));
179  $visibility->setValue(1);
180  if ($form_fields["certificate_enabled_scorm"])
181  {
182  $visibility->setChecked(TRUE);
183  }
184  if (count($_POST)) $visibility->checkInput();
185  $form->addItem($visibility);*/
186  }
global $lng
Definition: privfeed.php:40

◆ addFormFieldsFromObject()

ilSkillCertificateAdapter::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 210 of file class.ilSkillCertificateAdapter.php.

References $ilSetting.

211  {
212  global $ilSetting;
213  //$scormSetting = new ilSetting("scorm");
214  //$form_fields["certificate_enabled_scorm"] = $scormSetting->get("certificate_" . $this->object->getId());
215  //$form_fields["short_name"] = $scormSetting->get("certificate_short_name_" . $this->object->getId());
216  }
global $ilSetting
Definition: privfeed.php:40

◆ addFormFieldsFromPOST()

ilSkillCertificateAdapter::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 196 of file class.ilSkillCertificateAdapter.php.

197  {
198  //$form_fields["certificate_enabled_scorm"] = $_POST["certificate_enabled_scorm"];
199  //$form_fields["short_name"] = $_POST["short_name"];
200  }

◆ deleteCertificate()

ilSkillCertificateAdapter::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 284 of file class.ilSkillCertificateAdapter.php.

References $ilSetting.

285  {
286  global $ilSetting;
287  //$scormSetting = new ilSetting("scorm");
288  //$scormSetting->delete("certificate_" . $this->object->getId());
289  }
global $ilSetting
Definition: privfeed.php:40

◆ getAdapterType()

ilSkillCertificateAdapter::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 239 of file class.ilSkillCertificateAdapter.php.

240  {
241  return "skill";
242  }

◆ getCertificateFilename()

ilSkillCertificateAdapter::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 261 of file class.ilSkillCertificateAdapter.php.

References $lng.

262  {
263  global $lng;
264 
265  $basename = parent::getCertificateFilename($params);
266 
267  $user_data = $params["user_data"];
268  if (!is_array($user_data))
269  {
270  $short_title = $this->skill->getShortTitleForCertificate();
271  return strftime("%y%m%d", time()) . "_" . $lng->txt("certificate_var_user_lastname") . "_" . $short_title . "_" . $basename;
272  }
273  else
274  {
275  return strftime("%y%m%d", time()) . "_" . $user_data["lastname"] . "_" . $params["short_title"] . "_" . $basename;
276  }
277  }
global $lng
Definition: privfeed.php:40

◆ getCertificateID()

ilSkillCertificateAdapter::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 250 of file class.ilSkillCertificateAdapter.php.

References $skill_level_id.

◆ getCertificatePath()

ilSkillCertificateAdapter::getCertificatePath ( )

Returns the certificate path (with a trailing path separator)

Returns
string The certificate path

Definition at line 41 of file class.ilSkillCertificateAdapter.php.

42  {
43  return CLIENT_WEB_DIR."/certificates/skill/".$this->skill->getId().
44  "/".$this->skill_level_id."/";
45  }

◆ getCertificateVariablesDescription()

ilSkillCertificateAdapter::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 127 of file class.ilSkillCertificateAdapter.php.

References $lng, and ilCertificateAdapter\getBaseVariablesDescription().

128  {
129  global $lng;
130 
131  $lng->loadLanguageModule("skmg");
132 
133  $vars = $this->getBaseVariablesDescription();
134  $vars["SKILL_TITLE"] = $lng->txt("skmg_cert_skill_title");
135  $vars["SKILL_LEVEL_TITLE"] = $lng->txt("skmg_cert_skill_level_title");
136  $vars["SKILL_TRIGGER_TITLE"] = $lng->txt("skmg_cert_skill_trigger_title");
137 
138  $template = new ilTemplate("tpl.certificate_edit.html", TRUE, TRUE, "Services/Skill");
139  $template->setCurrentBlock("items");
140  foreach($vars as $id => $caption)
141  {
142  $template->setVariable("ID", $id);
143  $template->setVariable("TXT", $caption);
144  $template->parseCurrentBlock();
145  }
146 
147  $template->setVariable("PH_INTRODUCTION", $lng->txt("certificate_ph_introduction"));
148 
149  return $template->get();
150  }
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
+ Here is the call graph for this function:

◆ getCertificateVariablesForPresentation()

ilSkillCertificateAdapter::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 83 of file class.ilSkillCertificateAdapter.php.

References $lng, ilDatePresentation\formatDate(), ilCertificateAdapter\getBaseVariablesForPresentation(), IL_CAL_DATETIME, ilBasicSkill\lookupLevelAchievementDate(), ilUtil\prepareFormOutput(), ilDatePresentation\setUseRelativeDates(), and ilDatePresentation\useRelativeDates().

84  {
85  global $lng;
86 
87  $lng->loadLanguageModule('certificate');
88 
89  $user_data = $params["user_data"];
90 
91  $vars = $this->getBaseVariablesForPresentation($user_data, $params["last_access"], null);
92  $vars["SKILL_TITLE"] = ilUtil::prepareFormOutput($this->skill->getTitleForCertificate());
93  $vars["SKILL_LEVEL_TITLE"] = ilUtil::prepareFormOutput($this->skill->getLevelTitleForCertificate($this->skill_level_id));
94  $vars["SKILL_TRIGGER_TITLE"] = ilUtil::prepareFormOutput($this->skill->getTriggerTitleForCertificate($this->skill_level_id));
95 
96  // custom completion date
97  $achievement_date = ilBasicSkill::lookupLevelAchievementDate($user_data["usr_id"], $this->skill_level_id);
98  if ($achievement_date !== false)
99  {
102 
103  $vars["DATE_COMPLETED"] = ilDatePresentation::formatDate(new ilDate($achievement_date, IL_CAL_DATETIME));
104  $vars["DATETIME_COMPLETED"] = ilDatePresentation::formatDate(new ilDateTime($achievement_date, IL_CAL_DATETIME));
105 
107  }
108  else
109  {
110  $vars["DATE_COMPLETED"] = "";
111  $vars["DATETIME_COMPLETED"] = "";
112  }
113 
114  foreach($vars as $id => $caption)
115  {
116  $insert_tags["[".$id."]"] = $caption;
117  }
118  return $insert_tags;
119  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
const IL_CAL_DATETIME
static setUseRelativeDates($a_status)
set use relative dates
static useRelativeDates()
check if relative dates are used
Class for single dates.
lookupLevelAchievementDate($a_user_id, $a_level_id, $a_self_eval=0)
Lookup level achievement date.
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
global $lng
Definition: privfeed.php:40
getBaseVariablesForPresentation($a_user_data, $a_last_access=null, $a_completion_date=false)
Get variable values.
+ Here is the call graph for this function:

◆ getCertificateVariablesForPreview()

ilSkillCertificateAdapter::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 53 of file class.ilSkillCertificateAdapter.php.

References $ilUser, $lng, ilCertificateAdapter\getBaseVariablesForPreview(), ilUtil\prepareFormOutput(), ilDatePresentation\setUseRelativeDates(), and ilDatePresentation\useRelativeDates().

54  {
55  global $lng, $ilUser;
56 
59 
60  $vars = $this->getBaseVariablesForPreview();
61  $vars["SKILL_TITLE"] = ilUtil::prepareFormOutput($this->skill->getTitleForCertificate());
62  $vars["SKILL_LEVEL_TITLE"] = ilUtil::prepareFormOutput($this->skill->getLevelTitleForCertificate($this->skill_level_id));
63  $vars["SKILL_TRIGGER_TITLE"] = ilUtil::prepareFormOutput($this->skill->getTriggerTitleForCertificate($this->skill_level_id));
64 
66 
67  $insert_tags = array();
68  foreach($vars as $id => $caption)
69  {
70  $insert_tags["[".$id."]"] = $caption;
71  }
72  return $insert_tags;
73  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
static setUseRelativeDates($a_status)
set use relative dates
static useRelativeDates()
check if relative dates are used
global $ilUser
Definition: imgupload.php:15
global $lng
Definition: privfeed.php:40
getBaseVariablesForPreview($a_enable_last_access=true, $a_enable_completion_date=true)
Get variable dummys.
+ Here is the call graph for this function:

◆ saveFormFields()

ilSkillCertificateAdapter::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 225 of file class.ilSkillCertificateAdapter.php.

References $ilSetting.

226  {
227  global $ilSetting;
228  //$scormSetting = new ilSetting("scorm");
229  //$scormSetting->set("certificate_" . $this->object->getId(), $form_fields["certificate_enabled_scorm"]);
230  //$scormSetting->set("certificate_short_name_" . $this->object->getId(), $form_fields["short_name"]);
231  }
global $ilSetting
Definition: privfeed.php:40

Field Documentation

◆ $object

ilSkillCertificateAdapter::$object
protected

Definition at line 16 of file class.ilSkillCertificateAdapter.php.

◆ $skill

ilSkillCertificateAdapter::$skill
private

Definition at line 17 of file class.ilSkillCertificateAdapter.php.

◆ $skill_level_id

ilSkillCertificateAdapter::$skill_level_id
private

Definition at line 18 of file class.ilSkillCertificateAdapter.php.

Referenced by getCertificateID().


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