From ca37dd3bafbede2c964fce82945c775c86a89ad8 Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Fri, 16 Dec 2022 11:55:26 +0100 Subject: [PATCH] MDL-76691 core_h5p: Add core lib changes after upgrading it Apart from applying the points described in readme_moodle.txt, the following changes have been done too: - The parameter $folderName from the method libraryToString() have been removed and a new method, libraryToFolderName() has been added to the H5PCore API. References to libraryToString() with the $folderName set to true have been replaced to the new method. - missing-main-library has been added and replaces in some cases to missing-required-library. - The framework saveLibraryData method must be called before saveLibrary (h5p.classes.php file has been patched to leave the original order because libraryid is required to save the itemid). - The getLibraryId() method from H5PCore has been rewritten to use MUC, in order to avoid PHPUnit failures. --- .../behat/teacher_upload_content.feature | 4 +- h5p/classes/api.php | 11 ++++ h5p/classes/core.php | 60 ++++++++++++++----- h5p/classes/file_storage.php | 24 ++++++-- h5p/classes/framework.php | 3 + .../joubel/core/h5p-default-storage.class.php | 18 +++--- .../joubel/core/h5p-development.class.php | 2 + .../v124/joubel/core/h5p-event-base.class.php | 2 + .../core/h5p-file-storage.interface.php | 4 +- .../v124/joubel/core/h5p-metadata.class.php | 3 + h5p/h5plib/v124/joubel/core/h5p.classes.php | 29 +++++---- h5p/h5plib/v124/joubel/core/readme_moodle.txt | 6 ++ h5p/h5plib/v124/thirdpartylibs.xml | 2 +- h5p/tests/helper_test.php | 4 +- lang/en/cache.php | 1 + lang/en/h5p.php | 3 + lib/db/caches.php | 7 +++ .../atto/plugins/h5p/tests/behat/h5p.feature | 15 ++--- .../tiny/plugins/h5p/tests/behat/h5p.feature | 10 ++-- .../tests/behat/add_h5pactivity.feature | 21 ++----- 20 files changed, 152 insertions(+), 77 deletions(-) diff --git a/contentbank/contenttype/h5p/tests/behat/teacher_upload_content.feature b/contentbank/contenttype/h5p/tests/behat/teacher_upload_content.feature index 02aeb6fdc2843..cfdaf88f12cc1 100644 --- a/contentbank/contenttype/h5p/tests/behat/teacher_upload_content.feature +++ b/contentbank/contenttype/h5p/tests/behat/teacher_upload_content.feature @@ -156,7 +156,7 @@ Feature: H5P file upload to content bank for non admins And I switch to "h5p-player" class iframe And I switch to "h5p-iframe" class iframe Then I should see "Of which countries" - Then I should not see "missing-required-library" + Then I should not see "missing-main-library" And I switch to the main frame Given I log out And I log in as "admin" @@ -178,4 +178,4 @@ Feature: H5P file upload to content bank for non admins And I should see "filltheblanks.h5p" And I click on "filltheblanks.h5p" "link" And I switch to "h5p-player" class iframe - And I should see "missing-required-library" + And I should see "missing-main-library" diff --git a/h5p/classes/api.php b/h5p/classes/api.php index d2e9974dad252..46272dcd8eb7d 100644 --- a/h5p/classes/api.php +++ b/h5p/classes/api.php @@ -67,6 +67,17 @@ public static function delete_library(factory $factory, \stdClass $library): voi $DB->delete_records('h5p_library_dependencies', array('libraryid' => $library->id)); $DB->delete_records('h5p_libraries', array('id' => $library->id)); + // Remove the library from the cache. + $libscache = \cache::make('core', 'h5p_libraries'); + $libarray = [ + 'machineName' => $library->machinename, + 'majorVersion' => $library->majorversion, + 'minorVersion' => $library->minorversion, + ]; + $libstring = H5PCore::libraryToString($libarray); + $librarykey = helper::get_cache_librarykey($libstring); + $libscache->delete($librarykey); + // Remove the libraries using this library. $requiredlibraries = self::get_dependent_libraries($library->id); foreach ($requiredlibraries as $requiredlibrary) { diff --git a/h5p/classes/core.php b/h5p/classes/core.php index 1a60d55a1e99c..b04dc07611712 100644 --- a/h5p/classes/core.php +++ b/h5p/classes/core.php @@ -14,14 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * H5P core class. - * - * @package core_h5p - * @copyright 2019 Sara Arjona - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - namespace core_h5p; defined('MOODLE_INTERNAL') || die(); @@ -35,6 +27,9 @@ use moodle_url; use core_h5p\local\library\autoloader; +// phpcs:disable moodle.NamingConventions.ValidFunctionName.LowercaseMethod +// phpcs:disable moodle.NamingConventions.ValidVariableName.VariableNameLowerCase + /** * H5P core class, containing functions and storage shared by the other H5P classes. * @@ -74,7 +69,7 @@ public function __construct(H5PFrameworkInterface $framework, $path, string $url protected function getDependencyPath(array $dependency): string { $library = $this->find_library($dependency); - return "libraries/{$library->id}/{$library->machinename}-{$library->majorversion}.{$library->minorversion}"; + return "libraries/{$library->id}/" . H5PCore::libraryToFolderName($dependency); } /** @@ -89,7 +84,7 @@ public function get_dependency_roots(int $id): array { $context = \context_system::instance(); foreach ($dependencies as $dependency) { $library = $this->find_library($dependency); - $roots[self::libraryToString($dependency, true)] = (moodle_url::make_pluginfile_url( + $roots[self::libraryToFolderName($dependency)] = (moodle_url::make_pluginfile_url( $context->id, 'core_h5p', 'libraries', @@ -412,10 +407,45 @@ public function is_required_core_api($coreapi): bool { * @return string The string name on the form {machineName} {majorVersion}.{minorVersion}. */ public static function record_to_string(stdClass $record, bool $foldername = false): string { - return static::libraryToString([ - 'machineName' => $record->machinename, - 'majorVersion' => $record->majorversion, - 'minorVersion' => $record->minorversion, - ], $foldername); + if ($foldername) { + return static::libraryToFolderName([ + 'machineName' => $record->machinename, + 'majorVersion' => $record->majorversion, + 'minorVersion' => $record->minorversion, + ]); + } else { + return static::libraryToString([ + 'machineName' => $record->machinename, + 'majorVersion' => $record->majorversion, + 'minorVersion' => $record->minorversion, + ]); + } + } + + /** + * Small helper for getting the library's ID. + * This method is rewritten to use MUC (instead of an static variable which causes some problems with PHPUnit). + * + * @param array $library + * @param string $libString + * @return int Identifier, or FALSE if non-existent + */ + public function getLibraryId($library, $libString = null) { + if (!$libString) { + $libString = self::libraryToString($library); + } + + // Check if this information has been saved previously into the cache. + $libcache = \cache::make('core', 'h5p_libraries'); + $librarykey = helper::get_cache_librarykey($libString); + $libraryId = $libcache->get($librarykey); + if ($libraryId === false) { + $libraryId = $this->h5pF->getLibraryId($library['machineName'], $library['majorVersion'], $library['minorVersion']); + $libcache->set($librarykey, $libraryId); + } + + return $libraryId; + } + } diff --git a/h5p/classes/file_storage.php b/h5p/classes/file_storage.php index ab7497a12b142..9ae0606c47d45 100644 --- a/h5p/classes/file_storage.php +++ b/h5p/classes/file_storage.php @@ -29,6 +29,8 @@ use Moodle\H5peditorFile; use Moodle\H5PFileStorage; +// phpcs:disable moodle.NamingConventions.ValidFunctionName.LowercaseMethod + /** * Class to handle storage and export of H5P Content. * @@ -86,8 +88,8 @@ public function saveLibrary($library) { 'contextid' => $this->context->id, 'component' => self::COMPONENT, 'filearea' => self::LIBRARY_FILEAREA, - 'filepath' => '/' . H5PCore::libraryToString($library, true) . '/', - 'itemid' => $library['libraryId'] + 'filepath' => '/' . H5PCore::libraryToFolderName($library) . '/', + 'itemid' => $library['libraryId'], ]; // Easiest approach: delete the existing library version and copy the new one. @@ -95,6 +97,18 @@ public function saveLibrary($library) { $this->copy_directory($library['uploadDirectory'], $options); } + /** + * Delete library folder. + * + * @param array $library + */ + public function deleteLibrary($library) { + // Although this class had a method (delete_library()) for removing libraries before this was added to the interface, + // it's not safe to call it from here because looking at the place where it's called, it's not clear what are their + // expectation. This method will be implemented once more information will be added to the H5P technical doc. + } + + /** * Store the content folder. * @@ -162,7 +176,7 @@ public function exportContent($id, $target) { * @param string $target Where the library folder will be saved */ public function exportLibrary($library, $target) { - $folder = H5PCore::libraryToString($library, true); + $folder = H5PCore::libraryToFolderName($library); $this->export_file_tree($target . '/' . $folder, $this->context->id, self::LIBRARY_FILEAREA, '/' . $folder . '/', $library['libraryId']); } @@ -432,7 +446,7 @@ public function moveContentDirectory($source, $contentid = null) { // Move all temporary content files to editor. $it = new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator($contentsource,\RecursiveDirectoryIterator::SKIP_DOTS), + new \RecursiveDirectoryIterator($contentsource, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST ); @@ -583,7 +597,7 @@ public function delete_library(array $library): void { global $DB; // A library ID of false would result in all library files being deleted, which we don't want. Return instead. - if ($library['libraryId'] === false) { + if (empty($library['libraryId'])) { return; } diff --git a/h5p/classes/framework.php b/h5p/classes/framework.php index 77ef1cb94568a..711cefcea37d0 100644 --- a/h5p/classes/framework.php +++ b/h5p/classes/framework.php @@ -447,6 +447,9 @@ public function t($message, $replacements = array()) { 'Keywords already exists!' => 'keywordsExits', 'Some of these keywords already exist' => 'someKeywordsExits', 'Assistive Technologies label' => 'a11yTitle:label', + 'width' => 'width', + 'height' => 'height', + 'Missing main library @library' => 'missingmainlibrary', ]; if (isset($translationsmap[$message])) { diff --git a/h5p/h5plib/v124/joubel/core/h5p-default-storage.class.php b/h5p/h5plib/v124/joubel/core/h5p-default-storage.class.php index c1eeaeca8b2c8..108ba1775fecd 100644 --- a/h5p/h5plib/v124/joubel/core/h5p-default-storage.class.php +++ b/h5p/h5plib/v124/joubel/core/h5p-default-storage.class.php @@ -1,5 +1,7 @@ path . '/libraries/' . \H5PCore::libraryToFolderName($library); + $dest = $this->path . '/libraries/' . H5PCore::libraryToFolderName($library); // Make sure destination dir doesn't exist - \H5PCore::deleteFileTree($dest); + H5PCore::deleteFileTree($dest); // Move library folder self::copyFileTree($library['uploadDirectory'], $dest); @@ -64,7 +66,7 @@ public function saveContent($source, $content) { $dest = "{$this->path}/content/{$content['id']}"; // Remove any old content - \H5PCore::deleteFileTree($dest); + H5PCore::deleteFileTree($dest); self::copyFileTree($source, $dest); } @@ -76,7 +78,7 @@ public function saveContent($source, $content) { * Content properties */ public function deleteContent($content) { - \H5PCore::deleteFileTree("{$this->path}/content/{$content['id']}"); + H5PCore::deleteFileTree("{$this->path}/content/{$content['id']}"); } /** @@ -137,7 +139,7 @@ public function exportContent($id, $target) { * Folder that library resides in */ public function exportLibrary($library, $target, $developmentPath=NULL) { - $folder = \H5PCore::libraryToFolderName($library); + $folder = H5PCore::libraryToFolderName($library); $srcPath = ($developmentPath === NULL ? "/libraries/{$folder}" : $developmentPath); self::copyFileTree("{$this->path}{$srcPath}", "{$target}/{$folder}"); @@ -297,7 +299,7 @@ public function getContent($file_path) { * Save files uploaded through the editor. * The files must be marked as temporary until the content form is saved. * - * @param \H5peditorFile $file + * @param H5peditorFile $file * @param int $contentid */ public function saveFile($file, $contentId) { diff --git a/h5p/h5plib/v124/joubel/core/h5p-development.class.php b/h5p/h5plib/v124/joubel/core/h5p-development.class.php index c2244025b25a1..b85df27150dba 100644 --- a/h5p/h5plib/v124/joubel/core/h5p-development.class.php +++ b/h5p/h5plib/v124/joubel/core/h5p-development.class.php @@ -1,5 +1,7 @@ h5pC->fs->saveLibrary($library); - + // MOODLE PATCH: The library needs to be saved in database first before creating the files, because the libraryid is used + // as itemid for the files. // Update our DB $this->h5pF->saveLibraryData($library, $new); + // Save library folder + $this->h5pC->fs->saveLibrary($library); + // Remove cached assets that uses this library if ($this->h5pC->aggregateAssets && isset($library['libraryId'])) { $removedKeys = $this->h5pF->deleteCachedAssets($library['libraryId']); @@ -2132,7 +2139,7 @@ class H5PCore { * * @param H5PFrameworkInterface $H5PFramework * The frameworks implementation of the H5PFrameworkInterface - * @param string|\H5PFileStorage $path H5P file storage directory or class. + * @param string|H5PFileStorage $path H5P file storage directory or class. * @param string $url To file storage directory. * @param string $language code. Defaults to english. * @param boolean $export enabled? @@ -2140,7 +2147,7 @@ class H5PCore { public function __construct(H5PFrameworkInterface $H5PFramework, $path, $url, $language = 'en', $export = FALSE) { $this->h5pF = $H5PFramework; - $this->fs = ($path instanceof \H5PFileStorage ? $path : new \H5PDefaultStorage($path)); + $this->fs = ($path instanceof H5PFileStorage ? $path : new H5PDefaultStorage($path)); $this->url = $url; $this->exportEnabled = $export; @@ -3307,21 +3314,23 @@ private static function getTimeFactor() { * @return string */ private static function hashToken($action, $time_factor) { - if (!isset($_SESSION['h5p_token'])) { + global $SESSION; + + if (!isset($SESSION->h5p_token)) { // Create an unique key which is used to create action tokens for this session. if (function_exists('random_bytes')) { - $_SESSION['h5p_token'] = base64_encode(random_bytes(15)); + $SESSION->h5p_token = base64_encode(random_bytes(15)); } else if (function_exists('openssl_random_pseudo_bytes')) { - $_SESSION['h5p_token'] = base64_encode(openssl_random_pseudo_bytes(15)); + $SESSION->h5p_token = base64_encode(openssl_random_pseudo_bytes(15)); } else { - $_SESSION['h5p_token'] = uniqid('', TRUE); + $SESSION->h5p_token = uniqid('', TRUE); } } // Create hash and return - return substr(hash('md5', $action . $time_factor . $_SESSION['h5p_token']), -16, 13); + return substr(hash('md5', $action . $time_factor . $SESSION->h5p_token), -16, 13); } /** diff --git a/h5p/h5plib/v124/joubel/core/readme_moodle.txt b/h5p/h5plib/v124/joubel/core/readme_moodle.txt index 7d023a51c8526..d9a2c3ac2ceb4 100644 --- a/h5p/h5plib/v124/joubel/core/readme_moodle.txt +++ b/h5p/h5plib/v124/joubel/core/readme_moodle.txt @@ -29,3 +29,9 @@ Changed: 3. Check if there are changes in the getLocalization() method in h5p.classes.php and update lang/en/h5p.php accordingly. If there are changes, check the t() method in h5p/classes/framework.php too (updating or adding new ones). + +4. In saveLibraries() method in core/h5p.classes.php, check $this->h5pF->saveLibraryData is called before $this->h5pC->fs->saveLibrary. +The library needs to be saved in the database first before creating the files, because the libraryid is used as itemid for the files. + +5. Check if new methods have been added to any of the interfaces. If that's the case, implement them in the proper class. For +instance, if a new method is added to h5p-file-storage.interface.php, it should be implemented in h5p/classes/file_storage.php. diff --git a/h5p/h5plib/v124/thirdpartylibs.xml b/h5p/h5plib/v124/thirdpartylibs.xml index 4a4e5c7e91e52..14e1e5644b19a 100644 --- a/h5p/h5plib/v124/thirdpartylibs.xml +++ b/h5p/h5plib/v124/thirdpartylibs.xml @@ -4,7 +4,7 @@ joubel/core h5p-php-library The general H5P library. - moodle-1.22.4 + moodle-1.23 GPL 3.0+ https://github.com/h5p/h5p-php-library/ diff --git a/h5p/tests/helper_test.php b/h5p/tests/helper_test.php index 5e8622015d5ff..390ad685b9b30 100644 --- a/h5p/tests/helper_test.php +++ b/h5p/tests/helper_test.php @@ -154,8 +154,8 @@ public function test_save_h5p_missing_libraries(): void { $errors = $factory->get_framework()->getMessages('error'); $this->assertCount(1, $errors); $error = reset($errors); - $this->assertEquals('missing-required-library', $error->code); - $this->assertEquals('Missing required library H5P.GreetingCard 1.0', $error->message); + $this->assertEquals('missing-main-library', $error->code); + $this->assertEquals('Missing main library H5P.GreetingCard 1.0', $error->message); } /** diff --git a/lang/en/cache.php b/lang/en/cache.php index 668d890ae7ded..30ecda933a777 100644 --- a/lang/en/cache.php +++ b/lang/en/cache.php @@ -65,6 +65,7 @@ $string['cachedef_suspended_userids'] = 'List of suspended users per course'; $string['cachedef_groupdata'] = 'Course group information'; $string['cachedef_h5p_content_type_translations'] = 'H5P content-type libraries translations'; +$string['cachedef_h5p_libraries'] = 'H5P libraries'; $string['cachedef_h5p_library_files'] = 'H5P library files'; $string['cachedef_htmlpurifier'] = 'HTML Purifier - cleaned content'; $string['cachedef_langmenu'] = 'List of available languages'; diff --git a/lang/en/h5p.php b/lang/en/h5p.php index f36928bbe735a..872aa07a2f432 100644 --- a/lang/en/h5p.php +++ b/lang/en/h5p.php @@ -137,6 +137,7 @@ $string['h5ppackage'] = 'H5P content type'; $string['h5ppackage_help'] = 'An H5P content type is a file with an H5P or ZIP extension containing all libraries required to display the content.'; $string['h5psettings'] = 'H5P settings'; +$string['height'] = 'height'; $string['helpChoosingLicense'] = 'Help me choose a license'; $string['hideadvanced'] = 'Hide advanced'; $string['icon'] = 'Icon'; @@ -202,6 +203,7 @@ $string['missingcoreversion'] = 'The system was unable to install the {$a->%component} component from the package, as it requires a newer version of the H5P plugin. This site is currently running version {$a->%current}, whereas the required version is {$a->%required} or higher. Please upgrade and then try again.'; $string['missingdependency'] = 'Missing dependency {$a->@dep} required by {$a->@lib}.'; $string['missinglibrary'] = 'Missing required library {$a->@library}'; +$string['missingmainlibrary'] = 'Missing main library {$a->@library}'; $string['missinglibraryfile'] = 'The file "{$a->%file}" is missing from library: "{$a->%name}"'; $string['missinglibraryjson'] = 'Could not find library.json file with valid json format for library {$a->%name}'; $string['missinglibraryproperty'] = 'The required property {$a->%property} is missing from {$a->%library}'; @@ -286,6 +288,7 @@ $string['uploadlibraries'] = 'Upload H5P content types'; $string['updateRegistrationOnHub'] = 'Save account settings'; $string['uploadsuccess'] = 'H5P content types uploaded successfully'; +$string['width'] = 'width'; $string['wrongversion'] = 'The version of the H5P library {$a->%machineName} used in this content is not valid. Content contains {$a->%contentLibrary}, but it should be {$a->%semanticsLibrary}.'; $string['year'] = 'Year'; $string['years'] = 'Year(s)'; diff --git a/lib/db/caches.php b/lib/db/caches.php index d991e8418e17a..1e5458a82d873 100644 --- a/lib/db/caches.php +++ b/lib/db/caches.php @@ -487,6 +487,13 @@ 'simpledata' => true, ], + // File cache for H5P Library ids. + 'h5p_libraries' => [ + 'mode' => cache_store::MODE_APPLICATION, + 'simplekeys' => true, + 'canuselocalstore' => true + ], + // File cache for H5P Library files. 'h5p_library_files' => [ 'mode' => cache_store::MODE_APPLICATION, diff --git a/lib/editor/atto/plugins/h5p/tests/behat/h5p.feature b/lib/editor/atto/plugins/h5p/tests/behat/h5p.feature index b2a2ef41dd891..fc60fe9abf5e8 100644 --- a/lib/editor/atto/plugins/h5p/tests/behat/h5p.feature +++ b/lib/editor/atto/plugins/h5p/tests/behat/h5p.feature @@ -130,7 +130,7 @@ Feature: Add h5ps to Atto And I should not see "Cloudberries" @javascript - Scenario: Enable/disable H5P options + Scenario: Enable/disable H5P options atto Given I log in as "admin" And I follow "Manage private files..." And I upload "h5p/tests/fixtures/guess-the-answer.h5p" file to "Files" filemanager @@ -143,14 +143,11 @@ Feature: Add h5ps to Atto And I click on "Select this file" "button" # No display option button displayed And I click on "Insert H5P" "button" in the "Insert H5P" "dialogue" - And I wait until the page is ready When I click on "Save and display" "button" And I wait until the page is ready And I switch to "h5pcontent" iframe And I switch to "h5p-iframe" class iframe - Then I should not see "Reuse" - And I should not see "Embed" - And I should not see "Rights of use" + Then ".h5p-actions" "css_element" should not exist And I switch to the main frame And I navigate to "Settings" in current page administration And I click on ".h5p-placeholder" "css_element" @@ -159,12 +156,10 @@ Feature: Add h5ps to Atto # Only Allow Download button displayed And I click on "Allow download" "checkbox" And I click on "Insert H5P" "button" in the "Insert H5P" "dialogue" - And I wait until the page is ready And I click on "Save and display" "button" - And I wait until the page is ready And I switch to "h5pcontent" iframe And I switch to "h5p-iframe" class iframe - And I should see "Reuse" + And "Reuse" "text" should exist in the ".h5p-actions" "css_element" And I should not see "Embed" And I should not see "Rights of use" And I switch to the main frame @@ -176,12 +171,10 @@ Feature: Add h5ps to Atto And I click on "Embed button" "checkbox" And I click on "Copyright button" "checkbox" And I click on "Insert H5P" "button" in the "Insert H5P" "dialogue" - And I wait until the page is ready And I click on "Save and display" "button" - And I wait until the page is ready And I switch to "h5pcontent" iframe And I switch to "h5p-iframe" class iframe - And I should not see "Reuse" + And "Reuse" "text" should not exist in the ".h5p-actions" "css_element" And I should see "Embed" And I should see "Rights of use" diff --git a/lib/editor/tiny/plugins/h5p/tests/behat/h5p.feature b/lib/editor/tiny/plugins/h5p/tests/behat/h5p.feature index 162660868858e..81bacb607d594 100644 --- a/lib/editor/tiny/plugins/h5p/tests/behat/h5p.feature +++ b/lib/editor/tiny/plugins/h5p/tests/behat/h5p.feature @@ -103,7 +103,7 @@ Feature: Use the TinyMCE editor to upload an h5p package And I should not see "Cloudberries" @javascript - Scenario: Enable/disable H5P options + Scenario: Enable/disable H5P options tiny Given I log in as "admin" And I follow "Manage private files..." And I upload "h5p/tests/fixtures/guess-the-answer.h5p" file to "Files" filemanager @@ -118,9 +118,7 @@ Feature: Use the TinyMCE editor to upload an h5p package When I click on "Save and display" "button" And I switch to "h5pcontent" iframe And I switch to "h5p-iframe" class iframe - Then I should not see "Reuse" - And I should not see "Embed" - And I should not see "Rights of use" + Then ".h5p-actions" "css_element" should not exist And I switch to the main frame And I navigate to "Settings" in current page administration And I select the ".h5p-placeholder" "css_element" in the "Page content" TinyMCE editor @@ -132,7 +130,7 @@ Feature: Use the TinyMCE editor to upload an h5p package And I click on "Save and display" "button" And I switch to "h5pcontent" iframe And I switch to "h5p-iframe" class iframe - And I should see "Reuse" + And "Reuse" "text" should exist in the ".h5p-actions" "css_element" And I should not see "Embed" And I should not see "Rights of use" And I switch to the main frame @@ -147,7 +145,7 @@ Feature: Use the TinyMCE editor to upload an h5p package And I click on "Save and display" "button" And I switch to "h5pcontent" iframe And I switch to "h5p-iframe" class iframe - And I should not see "Reuse" + And "Reuse" "text" should not exist in the ".h5p-actions" "css_element" And I should see "Embed" And I should see "Rights of use" diff --git a/mod/h5pactivity/tests/behat/add_h5pactivity.feature b/mod/h5pactivity/tests/behat/add_h5pactivity.feature index 2145d8bcac69c..ca2570a825b61 100644 --- a/mod/h5pactivity/tests/behat/add_h5pactivity.feature +++ b/mod/h5pactivity/tests/behat/add_h5pactivity.feature @@ -36,7 +36,6 @@ Feature: Add H5P activity And I should not see "Reuse" And I should not see "Rights of use" And I should not see "Embed" - And I switch to the main frame @javascript Scenario: Add a h5pactivity activity with download @@ -47,13 +46,11 @@ Feature: Add H5P activity | displayoptions | 12 | | packagefilepath | h5p/tests/fixtures/ipsums.h5p | When I am on the "Awesome H5P package" "h5pactivity activity" page - And I wait until the page is ready Then I switch to "h5p-player" class iframe And I switch to "h5p-iframe" class iframe - And I should see "Reuse" + And "Reuse" "text" should exist in the ".h5p-actions" "css_element" And I should not see "Rights of use" And I should not see "Embed" - And I switch to the main frame @javascript Scenario: Add a h5pactivity activity with embed @@ -64,13 +61,11 @@ Feature: Add H5P activity | displayoptions | 10 | | packagefilepath | h5p/tests/fixtures/ipsums.h5p | When I am on the "Awesome H5P package" "h5pactivity activity" page - And I wait until the page is ready Then I switch to "h5p-player" class iframe And I switch to "h5p-iframe" class iframe - And I should not see "Reuse" + And "Reuse" "text" should not exist in the ".h5p-actions" "css_element" And I should not see "Rights of use" And I should see "Embed" - And I switch to the main frame @javascript Scenario: Add a h5pactivity activity with copyright @@ -81,13 +76,11 @@ Feature: Add H5P activity | displayoptions | 6 | | packagefilepath | h5p/tests/fixtures/guess-the-answer.h5p | When I am on the "Awesome H5P package" "h5pactivity activity" page - And I wait until the page is ready Then I switch to "h5p-player" class iframe And I switch to "h5p-iframe" class iframe - And I should not see "Reuse" + And "Reuse" "text" should not exist in the ".h5p-actions" "css_element" And I should see "Rights of use" And I should not see "Embed" - And I switch to the main frame @javascript Scenario: Add a h5pactivity activity with copyright in a content without copyright @@ -98,13 +91,11 @@ Feature: Add H5P activity | displayoptions | 6 | | packagefilepath | h5p/tests/fixtures/ipsums.h5p | When I am on the "Awesome H5P package" "h5pactivity activity" page - And I wait until the page is ready Then I switch to "h5p-player" class iframe And I switch to "h5p-iframe" class iframe - And I should not see "Reuse" + And "Reuse" "text" should not exist in the ".h5p-actions" "css_element" And I should not see "Rights of use" And I should not see "Embed" - And I switch to the main frame @javascript Scenario: Add a h5pactivity activity to a course with all display options enabled @@ -115,10 +106,8 @@ Feature: Add H5P activity | displayoptions | 0 | | packagefilepath | h5p/tests/fixtures/guess-the-answer.h5p | When I am on the "Awesome H5P package" "h5pactivity activity" page - And I wait until the page is ready Then I switch to "h5p-player" class iframe And I switch to "h5p-iframe" class iframe - And I should see "Reuse" + And "Reuse" "text" should exist in the ".h5p-actions" "css_element" And I should see "Rights of use" And I should see "Embed" - And I switch to the main frame