ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjExerciseVerification.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 = "excv";
20  }
21 
22  protected function getPropertyMap()
23  {
24  return array("issued_on" => self::TYPE_DATE,
25  "file" => self::TYPE_STRING
26  /*
27  "success" => self::TYPE_BOOL,
28  "mark" => self::TYPE_STRING,
29  "comment" => self::TYPE_STRING
30  */
31  );
32  }
33 
40  public static function createFromExercise(ilObjExercise $a_exercise, $a_user_id)
41  {
42  global $DIC;
43 
44  $lng = $DIC->language();
45 
46  $lng->loadLanguageModule("exercise");
47 
48  $newObj = new self();
49  $newObj->setTitle($a_exercise->getTitle());
50  $newObj->setDescription($a_exercise->getDescription());
51 
52  include_once "Services/Tracking/classes/class.ilLPMarks.php";
53  $lp_marks = new ilLPMarks($a_exercise->getId(), $a_user_id);
54  $newObj->setProperty(
55  "issued_on",
56  new ilDate($lp_marks->getStatusChanged(), IL_CAL_DATETIME)
57  );
58 
59  // create certificate
60  include_once "Services/Certificate/classes/class.ilCertificate.php";
61  include_once "Modules/Exercise/classes/class.ilExerciseCertificateAdapter.php";
63  $certificate = $certificate->outCertificate(array("user_id" => $a_user_id), false);
64 
65  // save pdf file
66  if ($certificate) {
67  // we need the object id for storing the certificate file
68  $newObj->create();
69 
70  $path = self::initStorage($newObj->getId(), "certificate");
71 
72  $file_name = "exc_" . $a_exercise->getId() . "_" . $a_user_id . ".pdf";
73  if (file_put_contents($path . $file_name, $certificate)) {
74  $newObj->setProperty("file", $file_name);
75  $newObj->update();
76 
77  return $newObj;
78  }
79 
80  // file creation failed, so remove to object, too
81  $newObj->delete();
82  }
83  }
84 }
const IL_CAL_DATETIME
static createFromExercise(ilObjExercise $a_exercise, $a_user_id)
Import relevant properties from given exercise.
global $DIC
Definition: saml.php:7
if(@file_exists(dirname(__FILE__).'/lang/eng.php')) $certificate
Definition: example_052.php:77
Verification object base class.
Class ilObjExercise.
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.