ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 $lng;
43 
44  $lng->loadLanguageModule("exercise");
45 
46  $newObj = new self();
47  $newObj->setTitle($a_exercise->getTitle());
48  $newObj->setDescription($a_exercise->getDescription());
49 
50  include_once "Services/Tracking/classes/class.ilLPMarks.php";
51  $lp_marks = new ilLPMarks($a_exercise->getId(), $a_user_id);
52  $newObj->setProperty("issued_on",
53  new ilDate($lp_marks->getStatusChanged(), IL_CAL_DATETIME));
54 
55  // create certificate
56  include_once "Services/Certificate/classes/class.ilCertificate.php";
57  include_once "Modules/Exercise/classes/class.ilExerciseCertificateAdapter.php";
59  $certificate = $certificate->outCertificate(array("user_id" => $a_user_id), false);
60 
61  // save pdf file
62  if($certificate)
63  {
64  // we need the object id for storing the certificate file
65  $newObj->create();
66 
67  $path = self::initStorage($newObj->getId(), "certificate");
68 
69  $file_name = "exc_".$a_exercise->getId()."_".$a_user_id.".pdf";
70  if(file_put_contents($path.$file_name, $certificate))
71  {
72  $newObj->setProperty("file", $file_name);
73  $newObj->update();
74 
75  return $newObj;
76  }
77 
78  // file creation failed, so remove to object, too
79  $newObj->delete();
80  }
81  }
82 }
83 
84 ?>
$path
Definition: aliased.php:25
const IL_CAL_DATETIME
static createFromExercise(ilObjExercise $a_exercise, $a_user_id)
Import relevant properties from given exercise.
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.