diff --git a/h5p-default-storage.class.php b/h5p-default-storage.class.php index 5b8ffeb..a1cd27f 100644 --- a/h5p-default-storage.class.php +++ b/h5p-default-storage.class.php @@ -151,6 +151,17 @@ class H5PDefaultStorage implements \H5PFileStorage { } } + /** + * Check if the given export file exists + * + * @param string $filename + * @return boolean + */ + public function hasExport($filename) { + $target = "{$this->path}/exports/{$filename}"; + return file_exists($target); + } + /** * Will concatenate all JavaScrips and Stylesheets into two files in order * to improve page performance. diff --git a/h5p-file-storage.interface.php b/h5p-file-storage.interface.php index dfaa67a..3e4de89 100644 --- a/h5p-file-storage.interface.php +++ b/h5p-file-storage.interface.php @@ -90,6 +90,14 @@ interface H5PFileStorage { */ public function deleteExport($filename); + /** + * Check if the given export file exists + * + * @param string $filename + * @return boolean + */ + public function hasExport($filename); + /** * Will concatenate all JavaScrips and Stylesheets into two files in order * to improve page performance. diff --git a/h5p.classes.php b/h5p.classes.php index 660351c..c1892cd 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1812,7 +1812,10 @@ class H5PCore { * @return Object NULL on failure. */ public function filterParameters(&$content) { - if (isset($content['filtered']) && $content['filtered'] !== '') { + if (!empty($content['filtered']) && + (!$this->exportEnabled || + ($content['slug'] && + $this->fs->hasExport($content['slug'] . '-' . $content['id'] . '.h5p')))) { return $content['filtered']; }