ILIAS  Release_4_0_x_branch Revision 61816
 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.

Private Attributes

 $object

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 24172 2010-06-10 18:31:27Z hschottm

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 206 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 243 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 230 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 266 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 277 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 169 of file class.ilTestCertificateAdapter.php.

References $lng.

{
global $lng;
$template = new ilTemplate("tpl.il_as_tst_certificate_edit.html", TRUE, TRUE, "Modules/Test");
$template->setVariable("PH_INTRODUCTION", $lng->txt("certificate_ph_introduction"));
$template->setVariable("PH_USER_FULLNAME", $lng->txt("certificate_ph_fullname"));
$template->setVariable("PH_USER_FIRSTNAME", $lng->txt("certificate_ph_firstname"));
$template->setVariable("PH_USER_LASTNAME", $lng->txt("certificate_ph_lastname"));
$template->setVariable("PH_RESULT_PASSED", $lng->txt("certificate_ph_passed"));
$template->setVariable("PH_RESULT_POINTS", $lng->txt("certificate_ph_resultpoints"));
$template->setVariable("PH_RESULT_PERCENT", $lng->txt("certificate_ph_resultpercent"));
$template->setVariable("PH_USER_TITLE", $lng->txt("certificate_ph_title"));
$template->setVariable("PH_USER_STREET", $lng->txt("certificate_ph_street"));
$template->setVariable("PH_USER_INSTITUTION", $lng->txt("certificate_ph_institution"));
$template->setVariable("PH_USER_DEPARTMENT", $lng->txt("certificate_ph_department"));
$template->setVariable("PH_USER_CITY", $lng->txt("certificate_ph_city"));
$template->setVariable("PH_USER_ZIPCODE", $lng->txt("certificate_ph_zipcode"));
$template->setVariable("PH_USER_COUNTRY", $lng->txt("certificate_ph_country"));
$template->setVariable("PH_MAX_POINTS", $lng->txt("certificate_ph_maxpoints"));
$template->setVariable("PH_RESULT_MARK_SHORT", $lng->txt("certificate_ph_markshort"));
$template->setVariable("PH_RESULT_MARK_LONG", $lng->txt("certificate_ph_marklong"));
$template->setVariable("PH_TEST_TITLE", $lng->txt("certificate_ph_testtitle"));
$template->setVariable("PH_DATE", $lng->txt("certificate_ph_date"));
$template->setVariable("PH_DATETIME", $lng->txt("certificate_ph_datetime"));
return $template->get();
}
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 101 of file class.ilTestCertificateAdapter.php.

References $lng, $params, $pass, ilObjUser\_lookupFields(), ilFormat\formatDate(), ilUtil\prepareFormOutput(), and ilFormat\unixtimestamp2datetime().

{
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 "";
}
}
include_once "./classes/class.ilFormat.php";
$insert_tags = array(
"[USER_FULLNAME]" => ilUtil::prepareFormOutput(trim($user_data["title"] . " " . $user_data["firstname"] . " " . $user_data["lastname"])),
"[USER_FIRSTNAME]" => ilUtil::prepareFormOutput($user_data["firstname"]),
"[USER_LASTNAME]" => ilUtil::prepareFormOutput($user_data["lastname"]),
"[USER_TITLE]" => ilUtil::prepareFormOutput($user_data["title"]),
"[USER_INSTITUTION]" => ilUtil::prepareFormOutput($user_data["institution"]),
"[USER_DEPARTMENT]" => ilUtil::prepareFormOutput($user_data["department"]),
"[USER_STREET]" => ilUtil::prepareFormOutput($user_data["street"]),
"[USER_CITY]" => ilUtil::prepareFormOutput($user_data["city"]),
"[USER_ZIPCODE]" => ilUtil::prepareFormOutput($user_data["zipcode"]),
"[USER_COUNTRY]" => ilUtil::prepareFormOutput($user_data["country"]),
"[RESULT_PASSED]" => ilUtil::prepareFormOutput($passed),
"[RESULT_POINTS]" => ilUtil::prepareFormOutput($result_array["test"]["total_reached_points"]),
"[RESULT_PERCENT]" => sprintf("%2.2f", $percentage) . "%",
"[MAX_POINTS]" => ilUtil::prepareFormOutput($result_array["test"]["total_max_points"]),
"[RESULT_MARK_SHORT]" => ilUtil::prepareFormOutput($mark_obj->getShortName()),
"[RESULT_MARK_LONG]" => ilUtil::prepareFormOutput($mark_obj->getOfficialName()),
"[TEST_TITLE]" => ilUtil::prepareFormOutput($this->object->getTitle()),
"[DATE]" => ilFormat::formatDate(ilFormat::unixtimestamp2datetime(time()), "date", FALSE, FALSE),
"[DATETIME]" => ilFormat::formatDate(ilFormat::unixtimestamp2datetime(time()), "datetime", TRUE, FALSE)
);
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, ilFormat\formatDate(), ilUtil\prepareFormOutput(), and ilFormat\unixtimestamp2datetime().

{
global $lng;
include_once "./classes/class.ilFormat.php";
$insert_tags = array(
"[USER_FULLNAME]" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_fullname")),
"[USER_FIRSTNAME]" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_firstname")),
"[USER_LASTNAME]" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_lastname")),
"[USER_TITLE]" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_title")),
"[USER_INSTITUTION]" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_institution")),
"[USER_DEPARTMENT]" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_department")),
"[USER_STREET]" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_street")),
"[USER_CITY]" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_city")),
"[USER_ZIPCODE]" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_zipcode")),
"[USER_COUNTRY]" => ilUtil::prepareFormOutput($lng->txt("certificate_var_user_country")),
"[RESULT_PASSED]" => ilUtil::prepareFormOutput($lng->txt("certificate_var_result_passed")),
"[RESULT_POINTS]" => ilUtil::prepareFormOutput($lng->txt("certificate_var_result_points")),
"[RESULT_PERCENT]" => ilUtil::prepareFormOutput($lng->txt("certificate_var_result_percent")),
"[MAX_POINTS]" => ilUtil::prepareFormOutput($lng->txt("certificate_var_max_points")),
"[RESULT_MARK_SHORT]" => ilUtil::prepareFormOutput($lng->txt("certificate_var_result_mark_short")),
"[RESULT_MARK_LONG]" => ilUtil::prepareFormOutput($lng->txt("certificate_var_result_mark_long")),
"[TEST_TITLE]" => ilUtil::prepareFormOutput($this->object->getTitle()),
"[DATE]" => ilFormat::formatDate(ilFormat::unixtimestamp2datetime(time()), "date", FALSE, FALSE),
"[DATETIME]" => ilFormat::formatDate(ilFormat::unixtimestamp2datetime(time()), "datetime", TRUE, FALSE)
);
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 255 of file class.ilTestCertificateAdapter.php.

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

Field Documentation

ilTestCertificateAdapter::$object
private

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

Referenced by __construct().


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