ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilCourseCertificateAdapter.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  protected static $has_certificate = array();
37 
43  public function __construct($object)
44  {
45  $this->object = $object;
46  parent::__construct();
47  }
48 
54  public function getCertificatePath()
55  {
56  return CLIENT_WEB_DIR . "/course/certificates/" . $this->object->getId() . "/";
57  }
58 
66  {
67  $vars = $this->getBaseVariablesForPreview(false);
68  $vars["COURSE_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle());
69 
70  $insert_tags = array();
71  foreach ($vars as $id => $caption) {
72  $insert_tags["[" . $id . "]"] = $caption;
73  }
74  return $insert_tags;
75  }
76 
86  {
87  $user_id = $params["user_id"];
88 
89  include_once './Services/User/classes/class.ilObjUser.php';
90  $user_data = ilObjUser::_lookupFields($user_id);
91 
92  include_once './Modules/Course/classes/class.ilCourseParticipants.php';
93  $completion_date = ilCourseParticipants::getDateTimeOfPassed($this->object->getId(), $user_id);
94 
95  $vars = $this->getBaseVariablesForPresentation($user_data, null, $completion_date);
96  $vars["COURSE_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle());
97 
98  $insert_tags = array();
99  foreach ($vars as $id => $caption) {
100  $insert_tags["[" . $id . "]"] = $caption;
101  }
102  return $insert_tags;
103  }
104 
112  {
113  $vars = $this->getBaseVariablesDescription(false);
114  $vars["COURSE_TITLE"] = $this->lng->txt("crs_title");
115 
116  $template = new ilTemplate("tpl.il_as_tst_certificate_edit.html", true, true, "Modules/Test");
117  $template->setCurrentBlock("items");
118  foreach ($vars as $id => $caption) {
119  $template->setVariable("ID", $id);
120  $template->setVariable("TXT", $caption);
121  $template->parseCurrentBlock();
122  }
123 
124  $template->setVariable("PH_INTRODUCTION", $this->lng->txt("certificate_ph_introduction"));
125 
126  return $template->get();
127  }
128 
135  public function getAdapterType()
136  {
137  return "course";
138  }
139 
146  public function getCertificateID()
147  {
148  return $this->object->getId();
149  }
150 
159  public static function _preloadListData($a_usr_ids, $a_obj_ids)
160  {
161  if (!is_array($a_usr_ids)) {
162  $a_usr_ids = array($a_usr_ids);
163  }
164  if (!is_array($a_obj_ids)) {
165  $a_obj_ids = array($a_obj_ids);
166  }
167  foreach ($a_usr_ids as $usr_id) {
168  foreach ($a_obj_ids as $obj_id) {
169  self::$has_certificate[$usr_id][$obj_id] = false;
170  }
171  }
172 
173  include_once "Services/Certificate/classes/class.ilCertificate.php";
174  if (ilCertificate::isActive()) {
175  $obj_active = ilCertificate::areObjectsActive($a_obj_ids);
176 
177  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
178  $data = ilCourseParticipants::getPassedUsersForObjects($a_obj_ids, $a_usr_ids);
179  foreach ($data as $rec) {
180  if ($obj_active[$rec["obj_id"]]) {
181  self::$has_certificate[$rec["usr_id"]][$rec["obj_id"]] = true;
182  }
183  }
184  }
185  }
186 
196  public static function _hasUserCertificate($a_usr_id, $a_obj_id)
197  {
198  self::_preloadListData($a_usr_id, $a_obj_id);
199 
200  if (isset(self::$has_certificate[$a_usr_id][$a_obj_id])) {
201  return self::$has_certificate[$a_usr_id][$a_obj_id];
202  }
203  return false;
204  }
205 }
$params
Definition: disable.php:11
__construct($object)
ilTestCertificateAdapter contructor
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
$template
static getDateTimeOfPassed($a_obj_id, $a_usr_id)
getCertificateVariablesForPreview()
Returns an array containing all variables and values which can be exchanged in the certificate...
if(!array_key_exists('StateId', $_REQUEST)) $id
static getPassedUsersForObjects(array $a_obj_ids, array $a_usr_ids)
static _preloadListData($a_usr_ids, $a_obj_ids)
Get certificate/passed status for all given objects and users.
getCertificateVariablesForPresentation($params=array())
Returns an array containing all variables and values which can be exchanged in the certificate The va...
special template class to simplify handling of ITX/PEAR
static _hasUserCertificate($a_usr_id, $a_obj_id)
Check if user has certificate for course.
getBaseVariablesDescription($a_enable_last_access=true, $a_enable_completion_date=true)
Get variable descriptions.
Create styles array
The data for the language used.
getAdapterType()
Returns the adapter type This value will be used to generate file names for the certificates.
Create new PHPExcel object
obj_idprivate
getCertificatePath()
Returns the certificate path (with a trailing path separator)
Adapter class to provide certificate data for the certificate generator.
getCertificateVariablesDescription()
Returns a description of the available certificate parameters.
static _lookupFields($a_user_id)
lookup fields (deprecated; use more specific methods instead)
getCertificateID()
Returns a certificate ID This value will be used to generate unique file names for the certificates...
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.