From 379d21c8cbd2b211e340311fdba995c35c825443 Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Tue, 16 Feb 2021 16:25:50 +0100 Subject: [PATCH] MDL-70912 mod_data: Add filepicker to the H5P Atto button The filepicker wasn't displayed fot the H5P Atto button when a text area database field was created because some options were missing in the textarea field class. --- mod/data/field/textarea/field.class.php | 10 ++++++++++ mod/data/tests/behat/add_entries.feature | 19 ++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/mod/data/field/textarea/field.class.php b/mod/data/field/textarea/field.class.php index 6dd703f3e04..96194617f3f 100644 --- a/mod/data/field/textarea/field.class.php +++ b/mod/data/field/textarea/field.class.php @@ -138,9 +138,19 @@ class data_field_textarea extends data_field_base { $link_options->env = 'editor'; $link_options->itemid = $draftitemid; + // H5P plugin. + $args->accepted_types = ['h5p']; + $h5poptions = initialise_filepicker($args); + $h5poptions->context = $this->context; + $h5poptions->client_id = uniqid(); + $h5poptions->maxbytes = $options['maxbytes']; + $h5poptions->env = 'editor'; + $h5poptions->itemid = $draftitemid; + $fpoptions['image'] = $image_options; $fpoptions['media'] = $media_options; $fpoptions['link'] = $link_options; + $fpoptions['h5p'] = $h5poptions; } $editor = editors_get_preferred_editor($format); diff --git a/mod/data/tests/behat/add_entries.feature b/mod/data/tests/behat/add_entries.feature index 13169202149..febc2e64066 100644 --- a/mod/data/tests/behat/add_entries.feature +++ b/mod/data/tests/behat/add_entries.feature @@ -4,8 +4,7 @@ Feature: Users can add entries to database activities As a user I need to add entries to databases - @javascript - Scenario: Students can add entries to a database + Background: Given the following "users" exist: | username | firstname | lastname | email | | student1 | Student | 1 | student1@example.com | @@ -20,7 +19,10 @@ Feature: Users can add entries to database activities And the following "activities" exist: | activity | name | intro | course | idnumber | | data | Test database name | n | C1 | data1 | - And I log in as "teacher1" + + @javascript + Scenario: Students can add entries to a database + Given I log in as "teacher1" And I am on "Course 1" course homepage And I add a "Text input" field to "Test database name" database and I fill the form with: | Field name | Test field name | @@ -76,3 +78,14 @@ Feature: Users can add entries to database activities And I press "Delete selected" And I press "Delete" And I should see "No entries in database" + + @javascript @editor @editor_atto @atto @atto_h5p + Scenario: If a new text area entry is added, the filepicker is displayed in the H5P Atto button + Given I log in as "teacher1" + And I am on "Course 1" course homepage + And I add a "Text area" field to "Test database name" database and I fill the form with: + | Field name | Textarea field name | + When I add an entry to "Test database name" database with: + | Textarea field name | This is the content | + And I click on "Insert H5P" "button" + Then I should see "Browse repositories..." -- 2.11.4.GIT