ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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)
 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...
 
 hasUserCertificate (int $userId)
 This code was orignaly located in ilObjExercise and has been moved here for ilCertificateMigrationJob 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

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.

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

References $object.

Member Function Documentation

◆ addAdditionalFormElements()

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

136 {
137 $visibility = new ilRadioGroupInputGUI($this->lng->txt("certificate_visibility"), "certificate_visibility");
138 $visibility->addOption(new ilRadioOption($this->lng->txt("certificate_visibility_always"), 0));
139 $visibility->addOption(new ilRadioOption($this->lng->txt("certificate_visibility_passed_exercise"), 1));
140 $visibility->addOption(new ilRadioOption($this->lng->txt("certificate_visibility_never"), 2));
141 $visibility->setValue($form_fields["certificate_visibility"]);
142 if (count($_POST)) {
143 $visibility->checkInput();
144 }
145 $form->addItem($visibility);
146 }
$_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()

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

154 {
155 $form_fields["certificate_visibility"] = $this->object->getCertificateVisibility();
156 }

◆ addFormFieldsFromPOST()

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

149 {
150 $form_fields["certificate_visibility"] = $_POST["certificate_visibility"];
151 }

References $_POST.

◆ 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

Reimplemented from ilCertificateAdapter.

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

170 {
171 return "exc";
172 }

◆ 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

Reimplemented from ilCertificateAdapter.

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

181 {
182 return $this->object->getId();
183 }

◆ getCertificatePath()

ilExerciseCertificateAdapter::getCertificatePath ( )

Returns the certificate path (with a trailing path separator)

Returns
string The certificate path

Reimplemented from ilCertificateAdapter.

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

Reimplemented from ilCertificateAdapter.

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

116 {
117 $vars = $this->getBaseVariablesDescription(false);
118 $vars["RESULT_PASSED"] = $this->lng->txt("certificate_ph_passed_exercise");
119 $vars["RESULT_MARK"] = $this->lng->txt("certificate_ph_mark");
120 $vars["EXERCISE_TITLE"] = $this->lng->txt("certificate_ph_exercisetitle");
121
122 $template = new ilTemplate("tpl.certificate_edit.html", true, true, "Modules/Exercise");
123 $template->setCurrentBlock("items");
124 foreach ($vars as $id => $caption) {
125 $template->setVariable("ID", $id);
126 $template->setVariable("TXT", $caption);
127 $template->parseCurrentBlock();
128 }
129
130 $template->setVariable("PH_INTRODUCTION", $this->lng->txt("certificate_ph_introduction"));
131
132 return $template->get();
133 }
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()

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

Reimplemented from ilCertificateAdapter.

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

87 {
88 $user_id = $params["user_id"];
89
90 include_once 'Services/Tracking/classes/class.ilLPMarks.php';
91 $mark = ilLPMarks::_lookupMark($user_id, $this->object->getId());
92 include_once 'Modules/Exercise/classes/class.ilExerciseMembers.php';
93 $status = ilExerciseMembers::_lookupStatus($this->object->getId(), $user_id);
94
95 $user_data = ilObjUser::_lookupFields($user_id);
96 $completion_date = $this->getUserCompletionDate($user_id);
97
98 $vars = $this->getBaseVariablesForPresentation($user_data, null, $completion_date);
99 $vars["RESULT_PASSED"] = ilUtil::prepareFormOutput($this->lng->txt("exc_" . $status));
100 $vars["RESULT_MARK"] = ilUtil::prepareFormOutput($mark);
101 $vars["EXERCISE_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle());
102
103 foreach ($vars as $id => $caption) {
104 $insert_tags["[" . $id . "]"] = $caption;
105 }
106 return $insert_tags;
107 }
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.
static _lookupStatus($a_obj_id, $a_user_id)
Lookup current status (notgraded|passed|failed)
static _lookupMark($a_usr_id, $a_obj_id)
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, ilObjUser\_lookupFields(), ilLPMarks\_lookupMark(), ilExerciseMembers\_lookupStatus(), ilCertificateAdapter\getBaseVariablesForPresentation(), ilCertificateAdapter\getUserCompletionDate(), and ilUtil\prepareFormOutput().

+ 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

Reimplemented from ilCertificateAdapter.

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

65 {
66 $vars = $this->getBaseVariablesForPreview(false);
67 $vars["RESULT_PASSED"] = ilUtil::prepareFormOutput($this->lng->txt("certificate_var_result_passed"));
68 $vars["RESULT_MARK"] = ilUtil::prepareFormOutput($this->lng->txt("certificate_var_result_mark_short"));
69 $vars["EXERCISE_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle());
70
71 $insert_tags = array();
72 foreach ($vars as $id => $caption) {
73 $insert_tags["[" . $id . "]"] = $caption;
74 }
75 return $insert_tags;
76 }
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:

◆ hasUserCertificate()

ilExerciseCertificateAdapter::hasUserCertificate ( int  $userId)

This code was orignaly located in ilObjExercise and has been moved here for ilCertificateMigrationJob

Parameters
int$objectId
int$userId
Returns
bool

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

194 {
195 // show certificate?
196 if (ilCertificate::isActive() && ilCertificate::isObjectActive($this->object->getId())) {
197 $certificate_visible = $this->object->getCertificateVisibility();
198 // if not never
199 if ($certificate_visible != 2) {
200 // if passed only
201 $status = ilExerciseMembers::_lookupStatus($this->object->getId(), $userId);
202 if ($certificate_visible == 1 && $status == "passed") {
203 return true;
204 }
205
206 // always (excluding notgraded)
207 elseif ($certificate_visible == 0 && $status != "notgraded") {
208 return true;
209 }
210 }
211 }
212
213 return false;
214 }
static isObjectActive($a_obj_id)

References ilExerciseMembers\_lookupStatus(), ilCertificate\isActive(), and ilCertificate\isObjectActive().

+ Here is the call graph for this function:

◆ saveFormFields()

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

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

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: