ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilObjSCORMVerification.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 = "scov";
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 createFromSCORMLM(ilObjSAHSLearningModule $a_lm, $a_user_id)
36  {
37  global $lng;
38 
39  $lng->loadLanguageModule("sahs");
40 
41  $newObj = new self();
42  $newObj->setTitle($a_lm->getTitle());
43  $newObj->setDescription($a_lm->getDescription());
44 
45  include_once "Services/Tracking/classes/class.ilLPMarks.php";
46  $lp_marks = new ilLPMarks($a_lm->getId(), $a_user_id);
47  $newObj->setProperty("issued_on",
48  new ilDate($lp_marks->getStatusChanged(), IL_CAL_DATETIME));
49 
50  // create certificate
51  if(!stristr(get_class($a_lm), "2004"))
52  {
53  $last_access = ilObjSCORMLearningModule::_lookupLastAccess($a_lm->getId(), $a_user_id);
54  }
55  else
56  {
57  $last_access = ilObjSCORM2004LearningModule::_lookupLastAccess($a_lm->getId(), $a_user_id);
58  }
59  $params = array(
60  "user_data" => ilObjUser::_lookupFields($a_user_id),
61  "last_access" => $last_access
62  );
63  include_once "Services/Certificate/classes/class.ilCertificate.php";
64  include_once "Modules/ScormAicc/classes/class.ilSCORMCertificateAdapter.php";
66  $certificate = $certificate->outCertificate($params, false);
67 
68  // save pdf file
69  if($certificate)
70  {
71  // we need the object id for storing the certificate file
72  $newObj->create();
73 
74  $path = self::initStorage($newObj->getId(), "certificate");
75 
76  $file_name = "sahs_".$a_lm->getId()."_".$a_user_id.".pdf";
77  if(file_put_contents($path.$file_name, $certificate))
78  {
79  $newObj->setProperty("file", $file_name);
80  $newObj->update();
81 
82  return $newObj;
83  }
84 
85  // file creation failed, so remove to object, too
86  $newObj->delete();
87  }
88  }
89 }
90 
91 ?>
static _lookupLastAccess($a_obj_id, $a_usr_id)
Return the last access timestamp for a given user.
$path
Definition: aliased.php:25
const IL_CAL_DATETIME
static createFromSCORMLM(ilObjSAHSLearningModule $a_lm, $a_user_id)
Import relevant properties from given learning module.
static _lookupLastAccess($a_obj_id, $a_usr_id)
Return the last access timestamp for a given user.
if(@file_exists(dirname(__FILE__).'/lang/eng.php')) $certificate
Definition: example_052.php:77
Verification object base class.
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.
static _lookupFields($a_user_id)
lookup fields (deprecated; use more specific methods instead)
$params
Definition: example_049.php:96
Class ilObjSCORMLearningModule.