ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilObjCourseVerification.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once ('./Services/Verification/classes/class.ilVerificationObject.php');
5
16{
17 protected function initType()
18 {
19 $this->type = "crsv";
20 }
21
22 protected function getPropertyMap()
23 {
24 return array("issued_on" => self::TYPE_DATE,
25 "file" => self::TYPE_STRING
26 );
27 }
28
35 public static function createFromCourse(ilObjCourse $a_course, $a_user_id)
36 {
37 global $lng;
38
39 $lng->loadLanguageModule("crs");
40
41 $newObj = new self();
42 $newObj->setTitle($a_course->getTitle());
43 $newObj->setDescription($a_course->getDescription());
44
45 include_once "Services/Tracking/classes/class.ilLPMarks.php";
46 $lp_marks = new ilLPMarks($a_course->getId(), $a_user_id);
47 $newObj->setProperty("issued_on",
48 new ilDate($lp_marks->getStatusChanged(), IL_CAL_DATETIME));
49
50 // create certificate
51 include_once "Services/Certificate/classes/class.ilCertificate.php";
52 include_once "Modules/Course/classes/class.ilCourseCertificateAdapter.php";
54 $certificate = $certificate->outCertificate(array("user_id" => $a_user_id), false);
55
56 // save pdf file
57 if($certificate)
58 {
59 // we need the object id for storing the certificate file
60 $newObj->create();
61
62 $path = self::initStorage($newObj->getId(), "certificate");
63
64 $file_name = "crs_".$a_course->getId()."_".$a_user_id.".pdf";
65 if(file_put_contents($path.$file_name, $certificate))
66 {
67 $newObj->setProperty("file", $file_name);
68 $newObj->update();
69
70 return $newObj;
71 }
72
73 // file creation failed, so remove to object, too
74 $newObj->delete();
75 }
76 }
77}
78
79?>
const IL_CAL_DATETIME
Create PDF certificates.
Class for single dates.
getPropertyMap()
Return property map (name => type)
static createFromCourse(ilObjCourse $a_course, $a_user_id)
Import relevant properties from given course.
Class ilObjCourse.
getDescription()
get object description
getId()
get object id @access public
getTitle()
get object title @access public
Verification object base class.
static initStorage($a_id, $a_subdir=null)
if(@file_exists(dirname(__FILE__).'/lang/eng.php')) $certificate
Definition: example_052.php:77
$path
Definition: index.php:22