ILIAS  release_8 Revision v8.24
class.ilTestExportFilename.php
Go to the documentation of this file.
1<?php
2
25{
29 protected $test;
30
34 protected $timestamp = 0;
35
39 public function __construct(ilObjTest $test)
40 {
41 $this->test = $test;
42 $this->timestamp = time();
43 }
44
48 public function getTimestamp(): int
49 {
50 return $this->timestamp;
51 }
52
59 public function getPathname($extension, $additional = ''): string
60 {
61 if (!is_string($extension) || !strlen($extension)) {
62 throw new ilException('Missing file extension! Please pass a file extension of type string.');
63 } elseif (substr_count($extension, '.') > 1 || (strpos($extension, '.') !== false && strpos($extension, '.') !== 0)) {
64 throw new ilException('Please use at most one dot in your file extension.');
65 } elseif (strpos($extension, '.') === 0) {
66 $extension = substr($extension, 1);
67 }
68
69 if (!is_string($additional)) {
70 } elseif (strlen($additional)) {
71 if (strpos($additional, '__') === 0) {
72 throw new ilException('The additional file part may not contain __ at the beginning!');
73 }
74
75 $additional = '__' . $additional . '_';
76 } else {
77 $additional = '_';
78 }
79
80 return $this->test->getExportDirectory() . DIRECTORY_SEPARATOR . $this->getTimestamp() . '__' . IL_INST_ID . '__' . $this->test->getType() . $additional . $this->test->getId() . '.' . $extension;
81 }
82}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getPathname($extension, $additional='')
const IL_INST_ID
Definition: constants.php:40
$additional
Definition: goto.php:53