ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  $visibility = new ilRadioMatrixInputGUI($lng->txt("certificate_visibility"), "certificate_visibility");
149  $options = array(
150  0 => $lng->txt("certificate_visibility_always"),
151  1 => $lng->txt("certificate_visibility_passed_exercise"),
152  2 => $lng->txt("certificate_visibility_never")
153  );
154  $visibility->setOptions($options);
155  $visibility->setValue($form_fields["certificate_visibility"]);
156  if (count($_POST)) $visibility->checkInput();
157  $form->addItem($visibility);
158  }
159 
160  public function addFormFieldsFromPOST(&$form_fields)
161  {
162  $form_fields["certificate_visibility"] = $_POST["certificate_visibility"];
163  }
164 
165  public function addFormFieldsFromObject(&$form_fields)
166  {
167  $form_fields["certificate_visibility"] = $this->object->getCertificateVisibility();
168  }
169 
170  public function saveFormFields(&$form_fields)
171  {
172  $this->object->saveCertificateVisibility($form_fields["certificate_visibility"]);
173  }
174 
181  public function getAdapterType()
182  {
183  return "exc";
184  }
185 
192  public function getCertificateID()
193  {
194  return $this->object->getId();
195  }
196 }
197 
198 ?>