ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
 __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...
 
 hasAdditionalFormElements ()
 
 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

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.

23 {
24 $this->object = $object;
25 parent::__construct();
26 }

References $object.

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

Reimplemented from ilCertificateAdapter.

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

166 {
167 $visibility = new ilRadioGroupInputGUI($this->lng->txt("certificate_visibility"), "certificate_visibility");
168 $visibility->addOption(new ilRadioOption($this->lng->txt("certificate_visibility_always"), 0));
169 $visibility->addOption(new ilRadioOption($this->lng->txt("certificate_visibility_passed"), 1));
170 $visibility->addOption(new ilRadioOption($this->lng->txt("certificate_visibility_never"), 2));
171 $visibility->setInfo($this->lng->txt("certificate_visibility_introduction"));
172 $visibility->setValue($form_fields["certificate_visibility"]);
173 if (count($_POST)) {
174 $visibility->checkInput();
175 }
176 $form->addItem($visibility);
177 }
$_POST["username"]
This class represents a property in a property form.
This class represents an option in a radio group.
if(isset($_POST['submit'])) $form

References $_POST, and $form.

◆ 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

Reimplemented from ilCertificateAdapter.

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

201 {
202 $form_fields["certificate_visibility"] = $this->object->getCertificateVisibility();
203 }

◆ 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

Reimplemented from ilCertificateAdapter.

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

188 {
189 $form_fields["certificate_visibility"] = $_POST["certificate_visibility"];
190 }

References $_POST.

◆ 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

Reimplemented from ilCertificateAdapter.

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

224 {
225 return "test";
226 }

◆ 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

Reimplemented from ilCertificateAdapter.

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

235 {
236 return $this->object->getId();
237 }

◆ getCertificatePath()

ilTestCertificateAdapter::getCertificatePath ( )

Returns the certificate path (with a trailing path separator)

Returns
string The certificate path

Reimplemented from ilCertificateAdapter.

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

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

◆ 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

Reimplemented from ilCertificateAdapter.

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

132 {
133 $vars = $this->getBaseVariablesDescription(false);
134 $vars["RESULT_PASSED"] = $this->lng->txt("certificate_ph_passed");
135 $vars["RESULT_POINTS"] = $this->lng->txt("certificate_ph_resultpoints");
136 $vars["RESULT_PERCENT"] = $this->lng->txt("certificate_ph_resultpercent");
137 $vars["MAX_POINTS"] = $this->lng->txt("certificate_ph_maxpoints");
138 $vars["RESULT_MARK_SHORT"] = $this->lng->txt("certificate_ph_markshort");
139 $vars["RESULT_MARK_LONG"] = $this->lng->txt("certificate_ph_marklong");
140 $vars["TEST_TITLE"] = $this->lng->txt("certificate_ph_testtitle");
141
142 $template = new ilTemplate("tpl.il_as_tst_certificate_edit.html", true, true, "Modules/Test");
143 $template->setCurrentBlock("items");
144 foreach ($vars as $id => $caption) {
145 $template->setVariable("ID", $id);
146 $template->setVariable("TXT", $caption);
147 $template->parseCurrentBlock();
148 }
149
150
151 $template->setVariable("PH_INTRODUCTION", $this->lng->txt("certificate_ph_introduction"));
152
153 return $template->get();
154 }
getBaseVariablesDescription($a_enable_last_access=true, $a_enable_completion_date=true)
Get variable descriptions.
special template class to simplify handling of ITX/PEAR
$template
if(!array_key_exists('StateId', $_REQUEST)) $id

References $id, $template, and ilCertificateAdapter\getBaseVariablesDescription().

+ 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

Reimplemented from ilCertificateAdapter.

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

72 {
73 $active_id = $params["active_id"];
74 $pass = $params["pass"];
75 $userfilter = array_key_exists("userfilter", $params) ? $params["userfilter"] : "";
76 $passedonly = array_key_exists("passedonly", $params) ? $params["passedonly"] : false;
77 if (strlen($pass)) {
78 $result_array = &$this->object->getTestResult($active_id, $pass);
79 } else {
80 $result_array = &$this->object->getTestResult($active_id);
81 }
82 if (($passedonly) && ($result_array["test"]["passed"] == false)) {
83 return "";
84 }
85 $passed = $result_array["test"]["passed"] ? $this->lng->txt("certificate_passed") : $this->lng->txt("certificate_failed");
86 if (!$result_array["test"]["total_max_points"]) {
87 $percentage = 0;
88 } else {
89 $percentage = ($result_array["test"]["total_reached_points"] / $result_array["test"]["total_max_points"]) * 100;
90 }
91 $mark_obj = $this->object->mark_schema->getMatchingMark($percentage);
92 $user_id = $this->object->_getUserIdFromActiveId($active_id);
93 include_once './Services/User/classes/class.ilObjUser.php';
94 $user_data = ilObjUser::_lookupFields($user_id);
95
96 if (strlen($userfilter)) {
97 if (!@preg_match("/$userfilter/i", $user_data["lastname"] . ", " . $user_data["firstname"] . " " . $user_data["title"])) {
98 return "";
99 }
100 }
101
102 if (ilObjUserTracking::_enabledLearningProgress() && $user_data["usr_id"] > 0) {
103 $completion_date = $this->getUserCompletionDate($user_data["usr_id"]);
104 } else {
105 $dt = new ilDateTime($result_array['test']['result_tstamp'], IL_CAL_UNIX);
106 $completion_date = $dt->get(IL_CAL_DATETIME);
107 }
108
109 $vars = $this->getBaseVariablesForPresentation($user_data, null, $completion_date);
110 $vars["RESULT_PASSED"] = ilUtil::prepareFormOutput($passed);
111 $vars["RESULT_POINTS"] = ilUtil::prepareFormOutput($result_array["test"]["total_reached_points"]);
112 $vars["RESULT_PERCENT"] = sprintf("%2.2f", $percentage) . "%";
113 $vars["MAX_POINTS"] = ilUtil::prepareFormOutput($result_array["test"]["total_max_points"]);
114 $vars["RESULT_MARK_SHORT"] = ilUtil::prepareFormOutput($mark_obj->getShortName());
115 $vars["RESULT_MARK_LONG"] = ilUtil::prepareFormOutput($mark_obj->getOfficialName());
116 $vars["TEST_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle());
117
118 foreach ($vars as $id => $caption) {
119 $insert_tags["[" . $id . "]"] = $caption;
120 }
121
122 return $insert_tags;
123 }
const IL_CAL_UNIX
const IL_CAL_DATETIME
getBaseVariablesForPresentation($a_user_data, $a_last_access=null, $a_completion_date=false)
Get variable values.
getUserCompletionDate($a_user_id, $a_object_id=null)
Get completion for user.
@classDescription Date and time handling
static _enabledLearningProgress()
check wether learing progress is enabled or not
static _lookupFields($a_user_id)
lookup fields (deprecated; use more specific methods instead)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public

References $id, PHPMailer\PHPMailer\$params, $pass, ilObjUserTracking\_enabledLearningProgress(), ilObjUser\_lookupFields(), ilCertificateAdapter\getBaseVariablesForPresentation(), ilCertificateAdapter\getUserCompletionDate(), IL_CAL_DATETIME, IL_CAL_UNIX, and ilUtil\prepareFormOutput().

+ 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

Reimplemented from ilCertificateAdapter.

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

45 {
46 $vars = $this->getBaseVariablesForPreview(false);
47 $vars["RESULT_PASSED"] = ilUtil::prepareFormOutput($this->lng->txt("certificate_var_result_passed"));
48 $vars["RESULT_POINTS"] = ilUtil::prepareFormOutput($this->lng->txt("certificate_var_result_points"));
49 $vars["RESULT_PERCENT"] = ilUtil::prepareFormOutput($this->lng->txt("certificate_var_result_percent"));
50 $vars["MAX_POINTS"] = ilUtil::prepareFormOutput($this->lng->txt("certificate_var_max_points"));
51 $vars["RESULT_MARK_SHORT"] = ilUtil::prepareFormOutput($this->lng->txt("certificate_var_result_mark_short"));
52 $vars["RESULT_MARK_LONG"] = ilUtil::prepareFormOutput($this->lng->txt("certificate_var_result_mark_long"));
53 $vars["TEST_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle());
54
55 $insert_tags = array();
56 foreach ($vars as $id => $caption) {
57 $insert_tags["[" . $id . "]"] = $caption;
58 }
59
60 return $insert_tags;
61 }
getBaseVariablesForPreview($a_enable_last_access=true, $a_enable_completion_date=true)
Get variable dummys.

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

+ Here is the call graph for this function:

◆ getUserIdForParams()

ilTestCertificateAdapter::getUserIdForParams (   $a_params)

Get user id for params.

Parameters

return

Reimplemented from ilCertificateAdapter.

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

246 {
247 return $this->object->_getUserIdFromActiveId($a_params["active_id"]);
248 }

◆ 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

Reimplemented from ilCertificateAdapter.

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

213 {
214 $this->object->saveCertificateVisibility($form_fields["certificate_visibility"]);
215 }

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: