ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilExerciseCertificateAdapter Class Reference

Exercise certificate adapter. More...

+ Inheritance diagram for ilExerciseCertificateAdapter:
+ Collaboration diagram for ilExerciseCertificateAdapter:

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)
 
 addFormFieldsFromPOST (&$form_fields)
 
 addFormFieldsFromObject (&$form_fields)
 
 saveFormFields (&$form_fields)
 
 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...
 
- 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...
 
 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

Exercise certificate adapter.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilExerciseCertificateAdapter::__construct ( $object)

ilTestCertificateAdapter contructor

Parameters
object$objectA reference to a test object

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

References $object.

43  {
44  $this->object =& $object;
45  parent::__construct();
46  }

Member Function Documentation

◆ addAdditionalFormElements()

ilExerciseCertificateAdapter::addAdditionalFormElements ( $form,
  $form_fields 
)

Definition at line 144 of file class.ilExerciseCertificateAdapter.php.

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

145  {
146  global $lng;
147 
148  $visibility = new ilRadioGroupInputGUI($lng->txt("certificate_visibility"), "certificate_visibility");
149  $visibility->addOption(new ilRadioOption($lng->txt("certificate_visibility_always"), 0));
150  $visibility->addOption(new ilRadioOption($lng->txt("certificate_visibility_passed_exercise"), 1));
151  $visibility->addOption(new ilRadioOption($lng->txt("certificate_visibility_never"), 2));
152  $visibility->setValue($form_fields["certificate_visibility"]);
153  if (count($_POST)) $visibility->checkInput();
154  $form->addItem($visibility);
155  }
This class represents an option in a radio group.
This class represents a property in a property form.
addOption($a_option)
Add Option.
$_POST["username"]
+ Here is the call graph for this function:

◆ addFormFieldsFromObject()

ilExerciseCertificateAdapter::addFormFieldsFromObject ( $form_fields)

Definition at line 162 of file class.ilExerciseCertificateAdapter.php.

163  {
164  $form_fields["certificate_visibility"] = $this->object->getCertificateVisibility();
165  }

◆ addFormFieldsFromPOST()

ilExerciseCertificateAdapter::addFormFieldsFromPOST ( $form_fields)

Definition at line 157 of file class.ilExerciseCertificateAdapter.php.

References $_POST.

158  {
159  $form_fields["certificate_visibility"] = $_POST["certificate_visibility"];
160  }
$_POST["username"]

◆ getAdapterType()

ilExerciseCertificateAdapter::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 178 of file class.ilExerciseCertificateAdapter.php.

179  {
180  return "exc";
181  }

◆ getCertificateID()

ilExerciseCertificateAdapter::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 189 of file class.ilExerciseCertificateAdapter.php.

190  {
191  return $this->object->getId();
192  }

◆ getCertificatePath()

ilExerciseCertificateAdapter::getCertificatePath ( )

Returns the certificate path (with a trailing path separator)

Returns
string The certificate path

Definition at line 53 of file class.ilExerciseCertificateAdapter.php.

54  {
55  return CLIENT_WEB_DIR . "/exercise/certificates/" . $this->object->getId() . "/";
56  }

◆ getCertificateVariablesDescription()

ilExerciseCertificateAdapter::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 121 of file class.ilExerciseCertificateAdapter.php.

References ilCertificateAdapter\$lng, and ilCertificateAdapter\getBaseVariablesDescription().

122  {
123  global $lng;
124 
125  $vars = $this->getBaseVariablesDescription(false);
126  $vars["RESULT_PASSED"] = $lng->txt("certificate_ph_passed_exercise");
127  $vars["RESULT_MARK"] = $lng->txt("certificate_ph_mark");
128  $vars["EXERCISE_TITLE"] = $lng->txt("certificate_ph_exercisetitle");
129 
130  $template = new ilTemplate("tpl.certificate_edit.html", TRUE, TRUE, "Modules/Exercise");
131  $template->setCurrentBlock("items");
132  foreach($vars as $id => $caption)
133  {
134  $template->setVariable("ID", $id);
135  $template->setVariable("TXT", $caption);
136  $template->parseCurrentBlock();
137  }
138 
139  $template->setVariable("PH_INTRODUCTION", $lng->txt("certificate_ph_introduction"));
140 
141  return $template->get();
142  }
special template class to simplify handling of ITX/PEAR
getBaseVariablesDescription($a_enable_last_access=true, $a_enable_completion_date=true)
Get variable descriptions.
+ Here is the call graph for this function:

◆ getCertificateVariablesForPresentation()

ilExerciseCertificateAdapter::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 89 of file class.ilExerciseCertificateAdapter.php.

References ilCertificateAdapter\$lng, $params, ilObjUser\_lookupFields(), ilLPMarks\_lookupMark(), ilExerciseMembers\_lookupStatus(), ilCertificateAdapter\getBaseVariablesForPresentation(), ilCertificateAdapter\getUserCompletionDate(), object, and ilUtil\prepareFormOutput().

90  {
91  global $lng;
92 
93  $user_id = $params["user_id"];
94 
95  include_once 'Services/Tracking/classes/class.ilLPMarks.php';
96  $mark = ilLPMarks::_lookupMark($user_id, $this->object->getId());
97  include_once 'Modules/Exercise/classes/class.ilExerciseMembers.php';
98  $status = ilExerciseMembers::_lookupStatus($this->object->getId(), $user_id);
99 
100  $user_data = ilObjUser::_lookupFields($user_id);
101  $completion_date = $this->getUserCompletionDate($user_id);
102 
103  $vars = $this->getBaseVariablesForPresentation($user_data, null, $completion_date);
104  $vars["RESULT_PASSED"] = ilUtil::prepareFormOutput($lng->txt("exc_".$status));
105  $vars["RESULT_MARK"] = ilUtil::prepareFormOutput($mark);
106  $vars["EXERCISE_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle());
107 
108  foreach($vars as $id => $caption)
109  {
110  $insert_tags["[".$id."]"] = $caption;
111  }
112  return $insert_tags;
113  }
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.
static _lookupStatus($a_obj_id, $a_user_id)
Lookup current status (notgraded|passed|failed)
Create new PHPExcel object
obj_idprivate
static _lookupFields($a_user_id)
lookup fields (deprecated; use more specific methods instead)
static _lookupMark($a_usr_id, $a_obj_id)
getBaseVariablesForPresentation($a_user_data, $a_last_access=null, $a_completion_date=false)
Get variable values.
$params
Definition: example_049.php:96
+ Here is the call graph for this function:

◆ getCertificateVariablesForPreview()

ilExerciseCertificateAdapter::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 64 of file class.ilExerciseCertificateAdapter.php.

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

65  {
66  global $lng;
67 
68  $vars = $this->getBaseVariablesForPreview(false);
69  $vars["RESULT_PASSED"] = ilUtil::prepareFormOutput($lng->txt("certificate_var_result_passed"));
70  $vars["RESULT_MARK"] = ilUtil::prepareFormOutput($lng->txt("certificate_var_result_mark_short"));
71  $vars["EXERCISE_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle());
72 
73  $insert_tags = array();
74  foreach($vars as $id => $caption)
75  {
76  $insert_tags["[".$id."]"] = $caption;
77  }
78  return $insert_tags;
79  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
Create styles array
The data for the language used.
Create new PHPExcel object
obj_idprivate
getBaseVariablesForPreview($a_enable_last_access=true, $a_enable_completion_date=true)
Get variable dummys.
+ Here is the call graph for this function:

◆ saveFormFields()

ilExerciseCertificateAdapter::saveFormFields ( $form_fields)

Definition at line 167 of file class.ilExerciseCertificateAdapter.php.

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

Field Documentation

◆ $object

ilExerciseCertificateAdapter::$object
protected

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

Referenced by __construct().


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