Skip to content

Commit

Permalink
MDL-70912 mod_data: Add filepicker to the H5P Atto button
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sarjona committed Feb 16, 2021
1 parent 41037ef commit 1be2350
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
10 changes: 10 additions & 0 deletions mod/data/field/textarea/field.class.php
Expand Up @@ -138,9 +138,19 @@ function display_add_field($recordid = 0, $formdata = null) {
$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);
Expand Down
19 changes: 16 additions & 3 deletions mod/data/tests/behat/add_entries.feature
Expand Up @@ -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 |
Expand All @@ -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 |
Expand Down Expand Up @@ -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..."

0 comments on commit 1be2350

Please sign in to comment.