diff --git a/filter/displayh5p/db/upgrade.php b/filter/displayh5p/db/upgrade.php
index 97c4a3b8191..734f1c19b17 100644
--- a/filter/displayh5p/db/upgrade.php
+++ b/filter/displayh5p/db/upgrade.php
@@ -45,5 +45,17 @@ function xmldb_filter_displayh5p_upgrade($oldversion) {
// Automatically generated Moodle v3.8.0 release upgrade line.
// Put any upgrade step following this.
+ if ($oldversion < 2020031700) {
+ // References to h5p.org has to be removed as default value for the allowedsources in the filter because H5P is going
+ // to close it down completely so that only the author can see the test content.
+ $h5porgurl = 'https://h5p.org/h5p/embed/[id]';
+ $config = get_config('filter_displayh5p', 'allowedsources');
+ if (strpos($config, $h5porgurl) !== false) {
+ set_config('allowedsources', str_replace($h5porgurl, '', $config), 'filter_displayh5p');
+ }
+
+ upgrade_plugin_savepoint(true, 2020031700, 'filter', 'displayh5p');
+ }
+
return true;
}
diff --git a/filter/displayh5p/lang/en/filter_displayh5p.php b/filter/displayh5p/lang/en/filter_displayh5p.php
index dfb1f12c938..d8fc4313d10 100644
--- a/filter/displayh5p/lang/en/filter_displayh5p.php
+++ b/filter/displayh5p/lang/en/filter_displayh5p.php
@@ -27,6 +27,10 @@ defined('MOODLE_INTERNAL') || die;
$string['allowedsourceslist'] = 'Allowed sources';
$string['allowedsourceslistdesc'] = 'A list of URLs from which users can embed H5P content. If none are specified, all URLs will remain as links and not be displayed as embedded H5P content.
-\'[id]\' is a placeholder for the H5P content ID in the external source.';
+\'[id]\' is a placeholder for the H5P content ID in the external source.
+For example:
+
+- H5P.com: https://[xxxxxx].h5p.com/content/[id]
+- Wordpress: http://myserver/wp-admin/admin-ajax.php?action=h5p_embed&id=[id]';
$string['filtername'] = 'Display H5P';
$string['privacy:metadata'] = 'The display H5P filter does not store any personal data.';
diff --git a/filter/displayh5p/settings.php b/filter/displayh5p/settings.php
index 3bed622ac2e..329155a6b73 100644
--- a/filter/displayh5p/settings.php
+++ b/filter/displayh5p/settings.php
@@ -30,5 +30,5 @@ if ($ADMIN->fulltree) {
get_string('allowedsourceslist',
'filter_displayh5p'),
get_string('allowedsourceslistdesc', 'filter_displayh5p'),
- "https://h5p.org/h5p/embed/[id]"));
+ ''));
}
diff --git a/filter/displayh5p/version.php b/filter/displayh5p/version.php
index 88a30383656..e936737a100 100644
--- a/filter/displayh5p/version.php
+++ b/filter/displayh5p/version.php
@@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die;
-$plugin->version = 2019111800;
+$plugin->version = 2020031700;
$plugin->requires = 2019111200;
$plugin->component = 'filter_displayh5p';
diff --git a/lib/editor/atto/plugins/h5p/lang/en/atto_h5p.php b/lib/editor/atto/plugins/h5p/lang/en/atto_h5p.php
index feefb27e26a..0469ddca5b7 100644
--- a/lib/editor/atto/plugins/h5p/lang/en/atto_h5p.php
+++ b/lib/editor/atto/plugins/h5p/lang/en/atto_h5p.php
@@ -30,11 +30,12 @@ $string['embedbutton'] = 'Embed button';
$string['enterurl'] = 'URL or embed code';
$string['h5p:addembed'] = 'Add embedded H5P';
$string['h5pfile'] = 'H5P file upload';
+$string['h5pfileorurl'] = 'H5P URL or file upload';
$string['h5poptions'] = 'H5P options';
$string['h5pproperties'] = 'H5P properties';
$string['h5purl'] = 'H5P URL';
$string['invalidh5purl'] = 'Invalid URL';
-$string['instructions'] = 'You can insert H5P content by either entering a URL or embed code from an external H5P site or by uploading an H5P file.';
+$string['instructions'] = 'You can insert H5P content by either entering a URL or by uploading an H5P file.';
$string['noh5pcontent'] = 'No H5P content added';
$string['pluginname'] = 'Insert H5P';
$string['privacy:metadata'] = 'The atto_h5p plugin does not store any personal data.';
diff --git a/lib/editor/atto/plugins/h5p/lib.php b/lib/editor/atto/plugins/h5p/lib.php
index 60b34e7c604..174d420b8a3 100644
--- a/lib/editor/atto/plugins/h5p/lib.php
+++ b/lib/editor/atto/plugins/h5p/lib.php
@@ -67,16 +67,13 @@ function atto_h5p_strings_for_js() {
'copyrightbutton',
'downloadbutton',
'instructions',
- 'either',
'embedbutton',
- 'enterurl',
'h5pfile',
'h5poptions',
- 'h5pproperties',
'h5purl',
+ 'h5pfileorurl',
'invalidh5purl',
'noh5pcontent',
- 'or',
'pluginname'
);
diff --git a/lib/editor/atto/plugins/h5p/tests/behat/h5p.feature b/lib/editor/atto/plugins/h5p/tests/behat/h5p.feature
index 4ea2e13b538..d0da200c851 100644
--- a/lib/editor/atto/plugins/h5p/tests/behat/h5p.feature
+++ b/lib/editor/atto/plugins/h5p/tests/behat/h5p.feature
@@ -17,7 +17,7 @@ Feature: Add h5ps to Atto
| page | PageName1 | PageDesc1 | 1 | C1 | H5Ptest | 1 | 1 |
And the "displayh5p" filter is "on"
And the following config values are set as admin:
- | allowedsources | https://moodle.h5p.com/content/[id]/embed | filter_displayh5p |
+ | allowedsources | https://moodle.h5p.com/content/[id] | filter_displayh5p |
@javascript @external
Scenario: Insert an embedded h5p
@@ -27,7 +27,7 @@ Feature: Add h5ps to Atto
And I follow "PageName1"
And I navigate to "Edit settings" in current page administration
And I click on "Insert H5P" "button" in the "#fitem_id_page" "css_element"
- And I set the field with xpath "//textarea[@data-region='h5purl']" to "https://moodle.h5p.com/content/1290772960722742119/embed"
+ And I set the field with xpath "//input[@data-region='h5pfile']" to "https://moodle.h5p.com/content/1290772960722742119"
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"
@@ -64,7 +64,7 @@ Feature: Add h5ps to Atto
And I navigate to "Edit settings" in current page administration
And I click on "Insert H5P" "button" in the "#fitem_id_page" "css_element"
# This is not a real external URL, so this scenario shouldn't be labeled as external.
- And I set the field with xpath "//textarea[@data-region='h5purl']" to "ftp://moodle.h5p.com/content/1290772960722742119/embed"
+ And I set the field with xpath "//input[@data-region='h5pfile']" to "ftp://moodle.h5p.com/content/1290772960722742119"
When I click on "Insert H5P" "button" in the "Insert H5P" "dialogue"
And I wait until the page is ready
Then I should see "Invalid URL" in the "Insert H5P" "dialogue"
@@ -91,7 +91,9 @@ Feature: Add h5ps to Atto
And I follow "PageName1"
When I navigate to "Edit settings" in current page administration
And I click on "Insert H5P" "button"
- Then I should not see "URL or embed code" in the "Insert H5P" "dialogue"
+ Then I should not see "H5P URL" in the "Insert H5P" "dialogue"
+ And I should see "H5P file upload" in the "Insert H5P" "dialogue"
+ And I should see "H5P options" in the "Insert H5P" "dialogue"
@javascript
Scenario: No upload h5p capabilities
@@ -104,6 +106,8 @@ Feature: Add h5ps to Atto
When I navigate to "Edit settings" in current page administration
And I click on "Insert H5P" "button"
Then I should not see "H5P file upload" in the "Insert H5P" "dialogue"
+ And I should see "H5P URL" in the "Insert H5P" "dialogue"
+ And I should not see "H5P options" in the "Insert H5P" "dialogue"
@javascript @external
Scenario: Edit H5P content
@@ -132,7 +136,7 @@ Feature: Add h5ps to Atto
And I click on ".h5p-placeholder" "css_element"
And I click on "Insert H5P" "button" in the "#fitem_id_page" "css_element"
# External URL
- And I set the field with xpath "//textarea[@data-region='h5purl']" to "https://moodle.h5p.com/content/1290772960722742119/embed"
+ And I set the field with xpath "//input[@data-region='h5pfile']" to "https://moodle.h5p.com/content/1290772960722742119"
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"
@@ -199,6 +203,32 @@ Feature: Add h5ps to Atto
And I should see "Embed"
And I should see "Rights of use"
+ @javascript @external
+ Scenario: H5P options are ignored for H5P URLs
+ Given I log in as "admin"
+ And I change window size to "large"
+ And I am on "Course 1" course homepage
+ And I follow "PageName1"
+ And I navigate to "Edit settings" in current page administration
+ And I click on "Insert H5P" "button" in the "#fitem_id_page" "css_element"
+ And I set the field with xpath "//input[@data-region='h5pfile']" to "https://moodle.h5p.com/content/1290752078589054689"
+ And I click on "H5P options" "link"
+ And I click on "Embed button" "checkbox"
+ 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"
+ Then ".h5p-placeholder" "css_element" should exist
+ And I wait until the page is ready
+ And I switch to "h5pcontent" iframe
+ And I should see "History of strawberries"
+ And I should not see "Embed"
+ And I switch to the main frame
+ And I navigate to "Edit settings" in current page administration
+ And I click on ".h5p-placeholder" "css_element"
+ And I click on "Insert H5P" "button" in the "#fitem_id_page" "css_element"
+ And I click on "H5P options" "link"
+ And "input[aria-label=\"Embed button\"]:not([checked=checked])" "css_element" should exist
+
@javascript
Scenario: Private H5P files are shown to students
Given the following "users" exist:
diff --git a/lib/editor/atto/plugins/h5p/yui/build/moodle-atto_h5p-button/moodle-atto_h5p-button-debug.js b/lib/editor/atto/plugins/h5p/yui/build/moodle-atto_h5p-button/moodle-atto_h5p-button-debug.js
index 29ed69b26e7..98d1d42fbac 100644
--- a/lib/editor/atto/plugins/h5p/yui/build/moodle-atto_h5p-button/moodle-atto_h5p-button-debug.js
+++ b/lib/editor/atto/plugins/h5p/yui/build/moodle-atto_h5p-button/moodle-atto_h5p-button-debug.js
@@ -38,7 +38,6 @@ var CSS = {
H5PBROWSER: 'openh5pbrowser',
INPUTALT: 'atto_h5p_altentry',
INPUTH5PFILE: 'atto_h5p_file',
- INPUTH5PURL: 'atto_h5p_url',
INPUTSUBMIT: 'atto_h5p_urlentrysubmit',
OPTION_DOWNLOAD_BUTTON: 'atto_h5p_option_download_button',
OPTION_COPYRIGHT_BUTTON: 'atto_h5p_option_copyright_button',
@@ -49,7 +48,6 @@ var CSS = {
CONTENTWARNING: '.' + CSS.CONTENTWARNING,
H5PBROWSER: '.' + CSS.H5PBROWSER,
INPUTH5PFILE: '.' + CSS.INPUTH5PFILE,
- INPUTH5PURL: '.' + CSS.INPUTH5PURL,
INPUTSUBMIT: '.' + CSS.INPUTSUBMIT,
OPTION_DOWNLOAD_BUTTON: '.' + CSS.OPTION_DOWNLOAD_BUTTON,
OPTION_COPYRIGHT_BUTTON: '.' + CSS.OPTION_COPYRIGHT_BUTTON,
@@ -64,65 +62,71 @@ var CSS = {
'