ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
24include_once "./Services/Certificate/classes/class.ilCertificateAdapter.php";
25
34{
35 protected $object;
36 protected static $has_certificate = array();
37
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 global $lng;
68
69 $vars = $this->getBaseVariablesForPreview(false);
70 $vars["COURSE_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle());
71
72 $insert_tags = array();
73 foreach($vars as $id => $caption)
74 {
75 $insert_tags["[".$id."]"] = $caption;
76 }
77 return $insert_tags;
78 }
79
89 {
90 global $lng;
91
92 $user_id = $params["user_id"];
93
94 include_once './Services/User/classes/class.ilObjUser.php';
95 $user_data = ilObjUser::_lookupFields($user_id);
96
97 include_once './Modules/Course/classes/class.ilCourseParticipants.php';
98 $completion_date = ilCourseParticipants::getDateTimeOfPassed($this->object->getId(), $user_id);
99
100 $vars = $this->getBaseVariablesForPresentation($user_data, null, $completion_date);
101 $vars["COURSE_TITLE"] = ilUtil::prepareFormOutput($this->object->getTitle());
102
103 $insert_tags = array();
104 foreach($vars as $id => $caption)
105 {
106 $insert_tags["[".$id."]"] = $caption;
107 }
108 return $insert_tags;
109 }
110
118 {
119 global $lng;
120
121 $vars = $this->getBaseVariablesDescription(false);
122 $vars["COURSE_TITLE"] = $lng->txt("crs_title");
123
124 $template = new ilTemplate("tpl.il_as_tst_certificate_edit.html", TRUE, TRUE, "Modules/Test");
125 $template->setCurrentBlock("items");
126 foreach($vars as $id => $caption)
127 {
128 $template->setVariable("ID", $id);
129 $template->setVariable("TXT", $caption);
130 $template->parseCurrentBlock();
131 }
132
133 $template->setVariable("PH_INTRODUCTION", $lng->txt("certificate_ph_introduction"));
134
135 return $template->get();
136 }
137
144 public function getAdapterType()
145 {
146 return "course";
147 }
148
155 public function getCertificateID()
156 {
157 return $this->object->getId();
158 }
159
168 static function _preloadListData($a_usr_ids, $a_obj_ids)
169 {
170 global $ilDB;
171
172 if (!is_array($a_usr_ids))
173 {
174 $a_usr_ids = array($a_usr_ids);
175 }
176 if (!is_array($a_obj_ids))
177 {
178 $a_obj_ids = array($a_obj_ids);
179 }
180 foreach ($a_usr_ids as $usr_id)
181 {
182 foreach ($a_obj_ids as $obj_id)
183 {
184 self::$has_certificate[$usr_id][$obj_id] = false;
185 }
186 }
187
188 include_once "Services/Certificate/classes/class.ilCertificate.php";
190 {
191 $obj_active = ilCertificate::areObjectsActive($a_obj_ids);
192
193 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
194 $data = ilCourseParticipants::getPassedUsersForObjects($a_obj_ids, $a_usr_ids);
195 foreach($data as $rec)
196 {
197 if($obj_active[$rec["obj_id"]])
198 {
199 self::$has_certificate[$rec["usr_id"]][$rec["obj_id"]] = true;
200 }
201 }
202 }
203 }
204
214 static function _hasUserCertificate($a_usr_id, $a_obj_id)
215 {
216 self::_preloadListData($a_usr_id, $a_obj_id);
217
218 if(isset(self::$has_certificate[$a_usr_id][$a_obj_id]))
219 {
220 return self::$has_certificate[$a_usr_id][$a_obj_id];
221 }
222 return false;
223 }
224
225}
226
227?>
An exception for terminatinating execution or to throw for unit testing.
Adapter class to provide certificate data for the certificate generator.
getBaseVariablesForPresentation($a_user_data, $a_last_access=null, $a_completion_date=false)
Get variable values.
getBaseVariablesForPreview($a_enable_last_access=true, $a_enable_completion_date=true)
Get variable dummys.
getBaseVariablesDescription($a_enable_last_access=true, $a_enable_completion_date=true)
Get variable descriptions.
getCertificateVariablesDescription()
Returns a description of the available certificate parameters.
getCertificateVariablesForPresentation($params=array())
Returns an array containing all variables and values which can be exchanged in the certificate The va...
__construct(&$object)
ilTestCertificateAdapter contructor
getAdapterType()
Returns the adapter type This value will be used to generate file names for the certificates.
getCertificateVariablesForPreview()
Returns an array containing all variables and values which can be exchanged in the certificate.
static _preloadListData($a_usr_ids, $a_obj_ids)
Get certificate/passed status for all given objects and users.
getCertificatePath()
Returns the certificate path (with a trailing path separator)
static _hasUserCertificate($a_usr_id, $a_obj_id)
Check if user has certificate for course.
getCertificateID()
Returns a certificate ID This value will be used to generate unique file names for the certificates.
static getDateTimeOfPassed($a_obj_id, $a_usr_id)
static getPassedUsersForObjects(array $a_obj_ids, array $a_usr_ids)
static _lookupFields($a_user_id)
lookup fields (deprecated; use more specific methods instead)
special template class to simplify handling of ITX/PEAR
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
$params
Definition: example_049.php:96
global $ilDB