ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
4include_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(
48 "issued_on",
49 new ilDate($lp_marks->getStatusChanged(), IL_CAL_DATETIME)
50 );
51
52 // create certificate
53 if (!stristr(get_class($a_lm), "2004")) {
54 $last_access = ilObjSCORMLearningModule::_lookupLastAccess($a_lm->getId(), $a_user_id);
55 } else {
56 $last_access = ilObjSCORM2004LearningModule::_lookupLastAccess($a_lm->getId(), $a_user_id);
57 }
58 $params = array(
59 "user_data" => ilObjUser::_lookupFields($a_user_id),
60 "last_access" => $last_access
61 );
62 include_once "Services/Certificate/classes/class.ilCertificate.php";
63 include_once "Modules/ScormAicc/classes/class.ilSCORMCertificateAdapter.php";
65 $certificate = $certificate->outCertificate($params, false);
66
67 // save pdf file
68 if ($certificate) {
69 // we need the object id for storing the certificate file
70 $newObj->create();
71
72 $path = self::initStorage($newObj->getId(), "certificate");
73
74 $file_name = "sahs_" . $a_lm->getId() . "_" . $a_user_id . ".pdf";
75 if (file_put_contents($path . $file_name, $certificate)) {
76 $newObj->setProperty("file", $file_name);
77 $newObj->update();
78
79 return $newObj;
80 }
81
82 // file creation failed, so remove to object, too
83 $newObj->delete();
84 }
85 }
86}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATETIME
Create PDF certificates.
Class for single dates.
Class ilObjSCORMLearningModule.
static _lookupLastAccess($a_obj_id, $a_usr_id)
Return the last access timestamp for a given user.
static _lookupLastAccess($a_obj_id, $a_usr_id)
Return the last access timestamp for a given user.
static createFromSCORMLM(ilObjSAHSLearningModule $a_lm, $a_user_id)
Import relevant properties from given learning module.
getPropertyMap()
Return property map (name => type)
static _lookupFields($a_user_id)
lookup fields (deprecated; use more specific methods instead)
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
$params
Definition: disable.php:11