ILIAS  release_4-4 Revision
class.ilExerciseCertificateAdapter.php
Go to the documentation of this file.
1 <?php
2  /*
3  +----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +----------------------------------------------------------------------------+
22 */
23 
24 include_once "./Services/Certificate/classes/class.ilCertificateAdapter.php";
25 
34 {
35  protected $object;
36 
42  function __construct(&$object)
43  {
44  global $lng;
45  $this->object =& $object;
46  $lng->loadLanguageModule('certificate');
47  }
48 
54  public function getCertificatePath()
55  {
56  return CLIENT_WEB_DIR . "/exercise/certificates/" . $this->object->getId() . "/";
57  }
58 
66  {
67  global $lng;
68 
69  $vars = $this->getBaseVariablesForPreview(false);
70  $vars["RESULT_PASSED"] = ilUtil::prepareFormOutput($lng->txt("certificate_var_result_passed"));
71  $vars["RESULT_MARK"] = ilUtil::prepareFormOutput($lng->txt("certificate_var_result_mark_short"));
72  $vars["EXERCISE_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle());
73 
74  $insert_tags = array();
75  foreach($vars as $id => $caption)
76  {
77  $insert_tags["[".$id."]"] = $caption;
78  }
79  return $insert_tags;
80  }
81 
90  public function getCertificateVariablesForPresentation($params = array())
91  {
92  global $lng;
93 
94  $user_id = $params["user_id"];
95 
96  include_once 'Services/Tracking/classes/class.ilLPMarks.php';
97  $mark = ilLPMarks::_lookupMark($user_id, $this->object->getId());
98  include_once 'Modules/Exercise/classes/class.ilExerciseMembers.php';
99  $status = ilExerciseMembers::_lookupStatus($this->object->getId(), $user_id);
100 
101  $user_data = ilObjUser::_lookupFields($user_id);
102  $completion_date = $this->getUserCompletionDate($user_id);
103 
104  $vars = $this->getBaseVariablesForPresentation($user_data, null, $completion_date);
105  $vars["RESULT_PASSED"] = ilUtil::prepareFormOutput($lng->txt("exc_".$status));
106  $vars["RESULT_MARK"] = ilUtil::prepareFormOutput($mark);
107  $vars["EXERCISE_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle());
108 
109  foreach($vars as $id => $caption)
110  {
111  $insert_tags["[".$id."]"] = $caption;
112  }
113  return $insert_tags;
114  }
115 
123  {
124  global $lng;
125 
126  $vars = $this->getBaseVariablesDescription(false);
127  $vars["RESULT_PASSED"] = $lng->txt("certificate_ph_passed_exercise");
128  $vars["RESULT_MARK"] = $lng->txt("certificate_ph_mark");
129  $vars["EXERCISE_TITLE"] = $lng->txt("certificate_ph_exercisetitle");
130 
131  $template = new ilTemplate("tpl.certificate_edit.html", TRUE, TRUE, "Modules/Exercise");
132  $template->setCurrentBlock("items");
133  foreach($vars as $id => $caption)
134  {
135  $template->setVariable("ID", $id);
136  $template->setVariable("TXT", $caption);
137  $template->parseCurrentBlock();
138  }
139 
140  $template->setVariable("PH_INTRODUCTION", $lng->txt("certificate_ph_introduction"));
141 
142  return $template->get();
143  }
144 
145  public function addAdditionalFormElements(&$form, $form_fields)
146  {
147  global $lng;
148 
149  $visibility = new ilRadioGroupInputGUI($lng->txt("certificate_visibility"), "certificate_visibility");
150  $visibility->addOption(new ilRadioOption($lng->txt("certificate_visibility_always"), 0));
151  $visibility->addOption(new ilRadioOption($lng->txt("certificate_visibility_passed_exercise"), 1));
152  $visibility->addOption(new ilRadioOption($lng->txt("certificate_visibility_never"), 2));
153  $visibility->setValue($form_fields["certificate_visibility"]);
154  if (count($_POST)) $visibility->checkInput();
155  $form->addItem($visibility);
156  }
157 
158  public function addFormFieldsFromPOST(&$form_fields)
159  {
160  $form_fields["certificate_visibility"] = $_POST["certificate_visibility"];
161  }
162 
163  public function addFormFieldsFromObject(&$form_fields)
164  {
165  $form_fields["certificate_visibility"] = $this->object->getCertificateVisibility();
166  }
167 
168  public function saveFormFields(&$form_fields)
169  {
170  $this->object->saveCertificateVisibility($form_fields["certificate_visibility"]);
171  }
172 
179  public function getAdapterType()
180  {
181  return "exc";
182  }
183 
190  public function getCertificateID()
191  {
192  return $this->object->getId();
193  }
194 }
195 
196 ?>
getCertificateVariablesDescription()
Returns a description of the available certificate parameters.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
This class represents an option in a radio group.
__construct(&$object)
ilTestCertificateAdapter contructor
getUserCompletionDate($a_user_id, $a_object_id=null)
Get completion for user.
$_POST['username']
Definition: cron.php:12
getCertificateVariablesForPreview()
Returns an array containing all variables and values which can be exchanged in the certificate...
_lookupFields($a_user_id)
lookup fields (deprecated; use more specific methods instead)
_lookupMark($a_usr_id, $a_obj_id)
This class represents a property in a property form.
addOption($a_option)
Add Option.
special template class to simplify handling of ITX/PEAR
getCertificateVariablesForPresentation($params=array())
Returns an array containing all variables and values which can be exchanged in the certificate The va...
getBaseVariablesDescription($a_enable_last_access=true, $a_enable_completion_date=true)
Get variable descriptions.
_lookupStatus($a_obj_id, $a_user_id)
Lookup current status (notgraded|passed|failed)
global $lng
Definition: privfeed.php:40
getAdapterType()
Returns the adapter type This value will be used to generate file names for the certificates.
Adapter class to provide certificate data for the certificate generator.
getCertificatePath()
Returns the certificate path (with a trailing path separator)
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.
getCertificateID()
Returns a certificate ID This value will be used to generate unique file names for the certificates...