ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTestCertificateAdapter Class Reference

Test certificate adapter. More...

+ Inheritance diagram for ilTestCertificateAdapter:
+ Collaboration diagram for ilTestCertificateAdapter:

Public Member Functions

 __construct (&$object)
 ilTestCertificateAdapter 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...
 
 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

Test 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 13 of file class.ilTestCertificateAdapter.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestCertificateAdapter::__construct ( $object)

ilTestCertificateAdapter contructor

Parameters
object$objectA reference to a test object

Definition at line 22 of file class.ilTestCertificateAdapter.php.

References $lng, and $object.

23  {
24  global $lng;
25  $this->object =& $object;
26  $lng->loadLanguageModule('certificate');
27  }
global $lng
Definition: privfeed.php:40

Member Function Documentation

◆ addAdditionalFormElements()

ilTestCertificateAdapter::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 183 of file class.ilTestCertificateAdapter.php.

References $_POST, $lng, and ilRadioGroupInputGUI\addOption().

184  {
185  global $lng;
186 
187  $visibility = new ilRadioGroupInputGUI($lng->txt("certificate_visibility"), "certificate_visibility");
188  $visibility->addOption(new ilRadioOption($lng->txt("certificate_visibility_always"), 0));
189  $visibility->addOption(new ilRadioOption($lng->txt("certificate_visibility_passed"), 1));
190  $visibility->addOption(new ilRadioOption($lng->txt("certificate_visibility_never"), 2));
191  $visibility->setInfo($lng->txt("certificate_visibility_introduction"));
192  $visibility->setValue($form_fields["certificate_visibility"]);
193  if (count($_POST)) $visibility->checkInput();
194  $form->addItem($visibility);
195  }
This class represents an option in a radio group.
$_POST['username']
Definition: cron.php:12
This class represents a property in a property form.
addOption($a_option)
Add Option.
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

◆ addFormFieldsFromObject()

ilTestCertificateAdapter::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 218 of file class.ilTestCertificateAdapter.php.

219  {
220  $form_fields["certificate_visibility"] = $this->object->getCertificateVisibility();
221  }

◆ addFormFieldsFromPOST()

ilTestCertificateAdapter::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 205 of file class.ilTestCertificateAdapter.php.

References $_POST.

206  {
207  $form_fields["certificate_visibility"] = $_POST["certificate_visibility"];
208  }
$_POST['username']
Definition: cron.php:12

◆ getAdapterType()

ilTestCertificateAdapter::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 241 of file class.ilTestCertificateAdapter.php.

242  {
243  return "test";
244  }

◆ getCertificateID()

ilTestCertificateAdapter::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 252 of file class.ilTestCertificateAdapter.php.

253  {
254  return $this->object->getId();
255  }

◆ getCertificatePath()

ilTestCertificateAdapter::getCertificatePath ( )

Returns the certificate path (with a trailing path separator)

Returns
string The certificate path

Definition at line 34 of file class.ilTestCertificateAdapter.php.

35  {
36  return CLIENT_WEB_DIR . "/assessment/certificates/" . $this->object->getId() . "/";
37  }

◆ getCertificateVariablesDescription()

ilTestCertificateAdapter::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 146 of file class.ilTestCertificateAdapter.php.

References $lng, and ilCertificateAdapter\getBaseVariablesDescription().

147  {
148  global $lng;
149 
150  $vars = $this->getBaseVariablesDescription(false);
151  $vars["RESULT_PASSED"] = $lng->txt("certificate_ph_passed");
152  $vars["RESULT_POINTS"] = $lng->txt("certificate_ph_resultpoints");
153  $vars["RESULT_PERCENT"] = $lng->txt("certificate_ph_resultpercent");
154  $vars["MAX_POINTS"] = $lng->txt("certificate_ph_maxpoints");
155  $vars["RESULT_MARK_SHORT"] = $lng->txt("certificate_ph_markshort");
156  $vars["RESULT_MARK_LONG"] = $lng->txt("certificate_ph_marklong");
157  $vars["TEST_TITLE"] = $lng->txt("certificate_ph_testtitle");
158 
159  $template = new ilTemplate("tpl.il_as_tst_certificate_edit.html", TRUE, TRUE, "Modules/Test");
160  $template->setCurrentBlock("items");
161  foreach($vars as $id => $caption)
162  {
163  $template->setVariable("ID", $id);
164  $template->setVariable("TXT", $caption);
165  $template->parseCurrentBlock();
166  }
167 
168 
169  $template->setVariable("PH_INTRODUCTION", $lng->txt("certificate_ph_introduction"));
170 
171  return $template->get();
172  }
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()

ilTestCertificateAdapter::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 75 of file class.ilTestCertificateAdapter.php.

References $lng, $pass, ilObjUser\_lookupFields(), ilCertificateAdapter\getBaseVariablesForPresentation(), ilCertificateAdapter\getUserCompletionDate(), and ilUtil\prepareFormOutput().

76  {
77  global $lng;
78 
79  $active_id = $params["active_id"];
80  $pass = $params["pass"];
81  $userfilter = array_key_exists("userfilter", $params) ? $params["userfilter"] : "";
82  $passedonly = array_key_exists("passedonly", $params) ? $params["passedonly"] : FALSE;
83  if (strlen($pass))
84  {
85  $result_array =& $this->object->getTestResult($active_id, $pass);
86  }
87  else
88  {
89  $result_array =& $this->object->getTestResult($active_id);
90  }
91  if (($passedonly) && ($result_array["test"]["passed"] == FALSE)) return "";
92  $passed = $result_array["test"]["passed"] ? $lng->txt("certificate_passed") : $lng->txt("certificate_failed");
93  if (!$result_array["test"]["total_max_points"])
94  {
95  $percentage = 0;
96  }
97  else
98  {
99  $percentage = ($result_array["test"]["total_reached_points"]/$result_array["test"]["total_max_points"])*100;
100  }
101  $mark_obj = $this->object->mark_schema->getMatchingMark($percentage);
102  $user_id = $this->object->_getUserIdFromActiveId($active_id);
103  include_once './Services/User/classes/class.ilObjUser.php';
104  $user_data = ilObjUser::_lookupFields($user_id);
105 
106  if (strlen($userfilter))
107  {
108  if (!@preg_match("/$userfilter/i", $user_data["lastname"] . ", " . $user_data["firstname"] . " " . $user_data["title"]))
109  {
110  return "";
111  }
112  }
113 
114  if($user_data["usr_id"] > 0)
115  {
116  $completion_date = $this->getUserCompletionDate($user_data["usr_id"]);
117  }
118  else
119  {
120  $completion_date = false;
121  }
122 
123  $vars = $this->getBaseVariablesForPresentation($user_data, null, $completion_date);
124  $vars["RESULT_PASSED"] = ilUtil::prepareFormOutput($passed);
125  $vars["RESULT_POINTS"] = ilUtil::prepareFormOutput($result_array["test"]["total_reached_points"]);
126  $vars["RESULT_PERCENT"] = sprintf("%2.2f", $percentage) . "%";
127  $vars["MAX_POINTS"] = ilUtil::prepareFormOutput($result_array["test"]["total_max_points"]);
128  $vars["RESULT_MARK_SHORT"] = ilUtil::prepareFormOutput($mark_obj->getShortName());
129  $vars["RESULT_MARK_LONG"] = ilUtil::prepareFormOutput($mark_obj->getOfficialName());
130  $vars["TEST_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle());
131 
132  foreach($vars as $id => $caption)
133  {
134  $insert_tags["[".$id."]"] = $caption;
135  }
136 
137  return $insert_tags;
138  }
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.
_lookupFields($a_user_id)
lookup fields (deprecated; use more specific methods instead)
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()

ilTestCertificateAdapter::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 45 of file class.ilTestCertificateAdapter.php.

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

46  {
47  global $lng;
48 
49  $vars = $this->getBaseVariablesForPreview(false);
50  $vars["RESULT_PASSED"] = ilUtil::prepareFormOutput($lng->txt("certificate_var_result_passed"));
51  $vars["RESULT_POINTS"] = ilUtil::prepareFormOutput($lng->txt("certificate_var_result_points"));
52  $vars["RESULT_PERCENT"] = ilUtil::prepareFormOutput($lng->txt("certificate_var_result_percent"));
53  $vars["MAX_POINTS"] = ilUtil::prepareFormOutput($lng->txt("certificate_var_max_points"));
54  $vars["RESULT_MARK_SHORT"] = ilUtil::prepareFormOutput($lng->txt("certificate_var_result_mark_short"));
55  $vars["RESULT_MARK_LONG"] = ilUtil::prepareFormOutput($lng->txt("certificate_var_result_mark_long"));
56  $vars["TEST_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle());
57 
58  $insert_tags = array();
59  foreach($vars as $id => $caption)
60  {
61  $insert_tags["[".$id."]"] = $caption;
62  }
63 
64  return $insert_tags;
65  }
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.
+ Here is the call graph for this function:

◆ getUserIdForParams()

ilTestCertificateAdapter::getUserIdForParams (   $a_params)

Get user id for params.

Parameters

Definition at line 263 of file class.ilTestCertificateAdapter.php.

264  {
265  return $this->object->_getUserIdFromActiveId($a_params["active_id"]);
266  }

◆ saveFormFields()

ilTestCertificateAdapter::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 230 of file class.ilTestCertificateAdapter.php.

231  {
232  $this->object->saveCertificateVisibility($form_fields["certificate_visibility"]);
233  }

Field Documentation

◆ $object

ilTestCertificateAdapter::$object
protected

Definition at line 15 of file class.ilTestCertificateAdapter.php.

Referenced by __construct().


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