diff --git a/h5p/classes/player.php b/h5p/classes/player.php index 040246053a9..518ae483109 100644 --- a/h5p/classes/player.php +++ b/h5p/classes/player.php @@ -317,6 +317,7 @@ class player { $systemcontext = \context_system::instance(); $slug = $this->content['slug'] ? $this->content['slug'] . '-' : ''; + $filename = "{$slug}{$this->content['id']}.h5p"; // We have to build the right URL. // Depending the request was made through webservice/pluginfile.php or pluginfile.php. if (strpos($this->url, '/webservice/pluginfile.php')) { @@ -326,7 +327,7 @@ class player { \core_h5p\file_storage::EXPORT_FILEAREA, '', '', - "{$slug}{$this->content['id']}.h5p" + $filename ); } else { // If the request is made by tokenpluginfile.php we need to indicates to generate a token for current user. @@ -340,12 +341,17 @@ class player { \core_h5p\file_storage::EXPORT_FILEAREA, '', '', - "{$slug}{$this->content['id']}.h5p", + $filename, false, $includetoken ); } + // Get the required info from the export file to be able to get the export file by third apps. + $file = helper::get_export_info($filename, $url); + if ($file) { + $url->param('modified', $file['timemodified']); + } return $url; } @@ -514,13 +520,16 @@ class player { /** * Return the info export file for Mobile App. * - * @return array + * @return array or null */ - public function get_export_file(): array { + public function get_export_file(): ?array { // Get the export url. $exporturl = $this->get_export_settings(true); // Get the filename of the export url. $path = $exporturl->out_as_local_url(); + // Check if the URL has parameters. + $parts = explode('?', $path); + $path = array_shift($parts); $parts = explode('/', $path); $filename = array_pop($parts); // Get the required info from the export file to be able to get the export file by third apps. diff --git a/h5p/tests/external/external_test.php b/h5p/tests/external/external_test.php index d8936857b7c..dc4c1e9d130 100644 --- a/h5p/tests/external/external_test.php +++ b/h5p/tests/external/external_test.php @@ -96,8 +96,8 @@ class external_test extends externallib_advanced_testcase { $this->assertEquals($deployedfile['mimetype'], $result['files'][0]['mimetype']); $this->assertEquals($deployedfile['filesize'], $result['files'][0]['filesize']); $this->assertEquals($deployedfile['timemodified'], $result['files'][0]['timemodified']); - $this->assertEquals($deployedfile['filename'], $result['files'][0]['filename']); - $this->assertEquals($deployedfile['fileurl'], $result['files'][0]['fileurl']); + $this->assertStringContainsString($deployedfile['filename'], $result['files'][0]['filename']); + $this->assertStringContainsString($deployedfile['fileurl'], $result['files'][0]['fileurl']); } /** @@ -196,8 +196,8 @@ class external_test extends externallib_advanced_testcase { $this->assertEquals($deployedfile['mimetype'], $result['files'][0]['mimetype']); $this->assertEquals($deployedfile['filesize'], $result['files'][0]['filesize']); $this->assertEquals($deployedfile['timemodified'], $result['files'][0]['timemodified']); - $this->assertEquals($deployedfile['filename'], $result['files'][0]['filename']); - $this->assertEquals($deployedfile['fileurl'], $result['files'][0]['fileurl']); + $this->assertStringContainsString($deployedfile['filename'], $result['files'][0]['filename']); + $this->assertStringContainsString($deployedfile['fileurl'], $result['files'][0]['fileurl']); } /** @@ -244,7 +244,7 @@ class external_test extends externallib_advanced_testcase { $this->assertEquals($deployedfile['mimetype'], $result['files'][0]['mimetype']); $this->assertEquals($deployedfile['filesize'], $result['files'][0]['filesize']); $this->assertEquals($deployedfile['timemodified'], $result['files'][0]['timemodified']); - $this->assertEquals($deployedfile['filename'], $result['files'][0]['filename']); - $this->assertEquals($deployedfile['fileurl'], $result['files'][0]['fileurl']); + $this->assertStringContainsString($deployedfile['filename'], $result['files'][0]['filename']); + $this->assertStringContainsString($deployedfile['fileurl'], $result['files'][0]['fileurl']); } }