ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilTestCertificateAdapter Class Reference

Test certificate adapter. More...

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

Public Member Functions

 __construct (&$object)
 ilTestCertificateAdapter contructor
 getCertificatePath ()
 Returns the certificate path (with a trailing path separator)
 getCertificateVariablesForPreview ()
 Returns an array containing all variables and values which can be exchanged in the certificate.
 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.
 getCertificateVariablesDescription ()
 Returns a description of the available certificate parameters.
 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.
 addFormFieldsFromPOST (&$form_fields)
 Allows to add additional form values to the array of form values evaluating a HTTP POST action.
 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.
 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.
 getAdapterType ()
 Returns the adapter type This value will be used to generate file names for the certificates.
 getCertificateID ()
 Returns a certificate ID This value will be used to generate unique file names for the certificates.
- Public Member Functions inherited from ilCertificateAdapter
 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.
 getCertificateFilename ($params=array())
 Set the name of the certificate file This method will be called when the certificate will be generated.

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.
 getBaseVariablesForPreview ($a_enable_last_access=true, $a_enable_completion_date=true)
 Get variable dummys.
 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.

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:
class.ilTestCertificateAdapter.php 30898 2011-09-29 12:47:24Z jluetzen

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

Constructor & Destructor Documentation

ilTestCertificateAdapter::__construct ( $object)

ilTestCertificateAdapter contructor

Parameters
object$objectA reference to a test object

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

References $lng, and $object.

{
global $lng;
$this->object =& $object;
$lng->loadLanguageModule('certificate');
}

Member Function Documentation

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

References $_POST, $lng, and ilRadioMatrixInputGUI\setOptions().

{
global $lng;
$visibility = new ilRadioMatrixInputGUI($lng->txt("certificate_visibility"), "certificate_visibility");
$options = array(
0 => $lng->txt("certificate_visibility_always"),
1 => $lng->txt("certificate_visibility_passed"),
2 => $lng->txt("certificate_visibility_never")
);
$visibility->setOptions($options);
$visibility->setInfo($lng->txt("certificate_visibility_introduction"));
$visibility->setValue($form_fields["certificate_visibility"]);
if (count($_POST)) $visibility->checkInput();
$form->addItem($visibility);
}

+ Here is the call graph for this function:

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

{
$form_fields["certificate_visibility"] = $this->object->getCertificateVisibility();
}
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 216 of file class.ilTestCertificateAdapter.php.

References $_POST.

{
$form_fields["certificate_visibility"] = $_POST["certificate_visibility"];
}
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 252 of file class.ilTestCertificateAdapter.php.

{
return "test";
}
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 263 of file class.ilTestCertificateAdapter.php.

{
return $this->object->getId();
}
ilTestCertificateAdapter::getCertificatePath ( )

Returns the certificate path (with a trailing path separator)

Returns
string The certificate path

Reimplemented from ilCertificateAdapter.

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

{
return CLIENT_WEB_DIR . "/assessment/certificates/" . $this->object->getId() . "/";
}
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 156 of file class.ilTestCertificateAdapter.php.

References $lng, and ilCertificateAdapter\getBaseVariablesDescription().

{
global $lng;
$vars = $this->getBaseVariablesDescription(false);
$vars["RESULT_PASSED"] = $lng->txt("certificate_ph_passed");
$vars["RESULT_POINTS"] = $lng->txt("certificate_ph_resultpoints");
$vars["RESULT_PERCENT"] = $lng->txt("certificate_ph_resultpercent");
$vars["MAX_POINTS"] = $lng->txt("certificate_ph_maxpoints");
$vars["RESULT_MARK_SHORT"] = $lng->txt("certificate_ph_markshort");
$vars["RESULT_MARK_LONG"] = $lng->txt("certificate_ph_marklong");
$vars["TEST_TITLE"] = $lng->txt("certificate_ph_testtitle");
$template = new ilTemplate("tpl.il_as_tst_certificate_edit.html", TRUE, TRUE, "Modules/Test");
$template->setCurrentBlock("items");
foreach($vars as $id => $caption)
{
$template->setVariable("ID", $id);
$template->setVariable("TXT", $caption);
$template->parseCurrentBlock();
}
$template->setVariable("PH_INTRODUCTION", $lng->txt("certificate_ph_introduction"));
return $template->get();
}

+ Here is the call graph for this function:

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

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

{
global $lng;
$active_id = $params["active_id"];
$pass = $params["pass"];
$userfilter = array_key_exists("userfilter", $params) ? $params["userfilter"] : "";
$passedonly = array_key_exists("passedonly", $params) ? $params["passedonly"] : FALSE;
if (strlen($pass))
{
$result_array =& $this->object->getTestResult($active_id, $pass);
}
else
{
$result_array =& $this->object->getTestResult($active_id);
}
if (($passedonly) && ($result_array["test"]["passed"] == FALSE)) return "";
$passed = $result_array["test"]["passed"] ? $lng->txt("certificate_passed") : $lng->txt("certificate_failed");
if (!$result_array["test"]["total_max_points"])
{
$percentage = 0;
}
else
{
$percentage = ($result_array["test"]["total_reached_points"]/$result_array["test"]["total_max_points"])*100;
}
$mark_obj = $this->object->mark_schema->getMatchingMark($percentage);
$user_id = $this->object->_getUserIdFromActiveId($active_id);
include_once './Services/User/classes/class.ilObjUser.php';
$user_data = ilObjUser::_lookupFields($user_id);
if (strlen($userfilter))
{
if (!@preg_match("/$userfilter/i", $user_data["lastname"] . ", " . $user_data["firstname"] . " " . $user_data["title"]))
{
return "";
}
}
$completion_date = $this->getUserCompletionDate($user_data["usr_id"]);
$vars = $this->getBaseVariablesForPresentation($user_data, null, $completion_date);
$vars["RESULT_PASSED"] = ilUtil::prepareFormOutput($passed);
$vars["RESULT_POINTS"] = ilUtil::prepareFormOutput($result_array["test"]["total_reached_points"]);
$vars["RESULT_PERCENT"] = sprintf("%2.2f", $percentage) . "%";
$vars["MAX_POINTS"] = ilUtil::prepareFormOutput($result_array["test"]["total_max_points"]);
$vars["RESULT_MARK_SHORT"] = ilUtil::prepareFormOutput($mark_obj->getShortName());
$vars["RESULT_MARK_LONG"] = ilUtil::prepareFormOutput($mark_obj->getOfficialName());
$vars["TEST_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle());
foreach($vars as $id => $caption)
{
$insert_tags["[".$id."]"] = $caption;
}
return $insert_tags;
}

+ Here is the call graph for this function:

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

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

{
global $lng;
$vars = $this->getBaseVariablesForPreview(false);
$vars["RESULT_PASSED"] = ilUtil::prepareFormOutput($lng->txt("certificate_var_result_passed"));
$vars["RESULT_POINTS"] = ilUtil::prepareFormOutput($lng->txt("certificate_var_result_points"));
$vars["RESULT_PERCENT"] = ilUtil::prepareFormOutput($lng->txt("certificate_var_result_percent"));
$vars["MAX_POINTS"] = ilUtil::prepareFormOutput($lng->txt("certificate_var_max_points"));
$vars["RESULT_MARK_SHORT"] = ilUtil::prepareFormOutput($lng->txt("certificate_var_result_mark_short"));
$vars["RESULT_MARK_LONG"] = ilUtil::prepareFormOutput($lng->txt("certificate_var_result_mark_long"));
$vars["TEST_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle());
$insert_tags = array();
foreach($vars as $id => $caption)
{
$insert_tags["[".$id."]"] = $caption;
}
return $insert_tags;
}

+ Here is the call graph for this function:

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

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

Field Documentation

ilTestCertificateAdapter::$object
protected

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

Referenced by __construct().


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