Navigation Menu

Skip to content

Commit

Permalink
MDL-68826 mod_h5pactivity: content bank message in form
Browse files Browse the repository at this point in the history
  • Loading branch information
ferranrecio committed Jun 4, 2020
1 parent 709cab7 commit 7f60263
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
4 changes: 4 additions & 0 deletions mod/h5pactivity/lang/en/h5pactivity.php
Expand Up @@ -53,6 +53,9 @@
$string['attempts_none'] = 'This user has no attempts to display.';
$string['choice'] = 'Choice';
$string['completion'] = 'Completion';
$string['contentbank'] = 'more information about the content bank';
$string['contentbank_help'] = 'Within the content bank you can create and store contents using several authoring
tools which includes an integrated H5P packacge creator.';
$string['correct_answer'] = 'Correct answer';
$string['deleteallattempts'] = 'Delete all H5P attempts';
$string['displayexport'] = 'Allow download';
Expand Down Expand Up @@ -130,5 +133,6 @@
$string['totalscore'] = 'Total score';
$string['tracking_messages'] = 'Some H5P provide attempt tracking data for advanced reporting such as number of attempts, responses and grades. Note: Some H5P don\'t provide attempt tracking data. In such cases, the following settings will have no effect.';
$string['true'] = 'True';
$string['usecontentbank'] = 'Use the <a href="{$a}" target="_blank">content bank (opens in new window)</a> to manage your H5P files';
$string['view'] = 'View';
$string['view_report'] = 'View report';
10 changes: 9 additions & 1 deletion mod/h5pactivity/mod_form.php
Expand Up @@ -42,7 +42,7 @@ class mod_h5pactivity_mod_form extends moodleform_mod {
* Defines forms elements
*/
public function definition(): void {
global $CFG;
global $CFG, $OUTPUT;

$mform = $this->_form;

Expand Down Expand Up @@ -73,6 +73,14 @@ public function definition(): void {
$mform->addElement('filemanager', 'packagefile', get_string('package', 'mod_h5pactivity'), null, $options);
$mform->addHelpButton('packagefile', 'package', 'mod_h5pactivity');

// Add a link to the Content Bank if the user can access.
if (has_capability('moodle/contentbank:access', $this->context)) {
$url = new moodle_url('/contentbank/index.php', ['contextid' => $this->context->id]);
$msg = get_string('usecontentbank', 'mod_h5pactivity', $url->out());
$msg .= ' '.$OUTPUT->help_icon('contentbank', 'mod_h5pactivity');
$mform->addElement('static', 'contentbank', '', $msg);
}

// H5P displaying options.
$factory = new \core_h5p\factory();
$core = $factory->get_core();
Expand Down
35 changes: 35 additions & 0 deletions mod/h5pactivity/tests/behat/contentbank_link.feature
@@ -0,0 +1,35 @@
@mod @mod_h5pactivity @core_h5p @_file_upload @_switch_iframe @current
Feature: Content bank link in the activity settings form
In order to have direct access to the Content bank
As a teacher
I need to see a Content bank link in the activity settings

Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |

@javascript
Scenario: The content bank link should go to the course Content bank
When I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "H5P" to section "1"
Then I should see "Use the Content bank (opens in new window) to manage your H5P files"
And I click on "Content bank (opens in new window)" "link" in the "General" "fieldset"
And I should see "C1" in the "page-navbar" "region"
And I close all opened windows

Scenario: Content bank is not displayed if the user don't have access to the content bank
Given the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| moodle/contentbank:access | Prevent | editingteacher | Course | C1 |
When I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "H5P" to section "1"
Then I should not see "Use the Content Bank (opens in new window) to manage your H5P files"

0 comments on commit 7f60263

Please sign in to comment.