ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
4 include_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(
48  "issued_on",
49  new ilDate($lp_marks->getStatusChanged(), IL_CAL_DATETIME)
50  );
51 
52  // create certificate
53  include_once "Services/Certificate/classes/class.ilCertificate.php";
54  include_once "Modules/Course/classes/class.ilCourseCertificateAdapter.php";
56  $certificate = $certificate->outCertificate(array("user_id" => $a_user_id), false);
57 
58  // save pdf file
59  if ($certificate) {
60  // we need the object id for storing the certificate file
61  $newObj->create();
62 
63  $path = self::initStorage($newObj->getId(), "certificate");
64 
65  $file_name = "crs_" . $a_course->getId() . "_" . $a_user_id . ".pdf";
66  if (file_put_contents($path . $file_name, $certificate)) {
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 }
const IL_CAL_DATETIME
static createFromCourse(ilObjCourse $a_course, $a_user_id)
Import relevant properties from given course.
if(@file_exists(dirname(__FILE__).'/lang/eng.php')) $certificate
Definition: example_052.php:77
Verification object base class.
Class ilObjCourse.
Class for single dates.
getId()
get object id public
getTitle()
get object title public
getDescription()
get object description
Create styles array
The data for the language used.
Create PDF certificates.