ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilObjTestVerification.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 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 = "tstv";
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 "result" => self::TYPE_STRING,
29 "mark" => self::TYPE_STRING
30 */
31 );
32 }
33
40 public static function createFromTest(ilObjTest $a_test, $a_user_id)
41 {
42 global $lng;
43
44 $lng->loadLanguageModule("wsp");
45
46 $newObj = new self();
47 $newObj->setTitle($a_test->getTitle());
48 $newObj->setDescription($a_test->getDescription());
49
50 $active_id = $a_test->getActiveIdOfUser($a_user_id);
51 $pass = ilObjTest::_getResultPass($active_id);
52
53 $date = $a_test->getPassFinishDate($active_id, $pass);
54 $newObj->setProperty("issued_on", new ilDate($date, IL_CAL_UNIX));
55
56 // create certificate
57 include_once "Services/Certificate/classes/class.ilCertificate.php";
58 include_once "Modules/Test/classes/class.ilTestCertificateAdapter.php";
60 $certificate = $certificate->outCertificate(array("active_id" => $active_id, "pass" => $pass), false);
61
62 // save pdf file
63 if($certificate)
64 {
65 // we need the object id for storing the certificate file
66 $newObj->create();
67
68 $path = self::initStorage($newObj->getId(), "certificate");
69
70 $file_name = "tst_".$a_test->getId()."_".$a_user_id."_".$active_id.".pdf";
71 if(file_put_contents($path.$file_name, $certificate))
72 {
73 $newObj->setProperty("file", $file_name);
74 $newObj->update();
75
76 return $newObj;
77 }
78
79 // file creation failed, so remove to object, too
80 $newObj->delete();
81 }
82 }
83}
84
85?>
const IL_CAL_UNIX
Create PDF certificates.
Class for single dates.
static createFromTest(ilObjTest $a_test, $a_user_id)
Import relevant properties from given test.
getPropertyMap()
Return property map (name => type)
getPassFinishDate($active_id, $pass)
Retrieves the number of answered questions for a given user in a given test.
getActiveIdOfUser($user_id="", $anonymous_id="")
Gets the active id of a given user.
_getResultPass($active_id)
Retrieves the pass number that should be counted for a given user.
getDescription()
get object description
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
$path
Definition: index.php:22