ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
4 include_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  // 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 = "tst_" . $a_test->getId() . "_" . $a_user_id . "_" . $active_id . ".pdf";
70  if (file_put_contents($path . $file_name, $certificate)) {
71  $newObj->setProperty("file", $file_name);
72  $newObj->update();
73 
74  return $newObj;
75  }
76 
77  // file creation failed, so remove to object, too
78  $newObj->delete();
79  }
80  }
81 }
static createFromTest(ilObjTest $a_test, $a_user_id)
Import relevant properties from given test.
const IL_CAL_UNIX
getActiveIdOfUser($user_id="", $anonymous_id="")
Gets the active id of 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
static _getResultPass($active_id)
Retrieves the pass number that should be counted for a given user.
getTitle()
get object title public
getDescription()
get object description
Create styles array
The data for the language used.
Create PDF certificates.