diff --git a/mod/h5pactivity/lang/en/h5pactivity.php b/mod/h5pactivity/lang/en/h5pactivity.php index 83edd8fb60c..6d48fa01d30 100644 --- a/mod/h5pactivity/lang/en/h5pactivity.php +++ b/mod/h5pactivity/lang/en/h5pactivity.php @@ -53,6 +53,9 @@ $string['attempts_report'] = 'Attempts report'; $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'; @@ -130,5 +133,6 @@ $string['statement_received'] = 'xAPI statement received'; $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 content bank (opens in new window) to manage your H5P files'; $string['view'] = 'View'; $string['view_report'] = 'View report'; diff --git a/mod/h5pactivity/mod_form.php b/mod/h5pactivity/mod_form.php index 090a1a33fb2..bb5227ad217 100644 --- a/mod/h5pactivity/mod_form.php +++ b/mod/h5pactivity/mod_form.php @@ -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; @@ -73,6 +73,14 @@ class mod_h5pactivity_mod_form extends moodleform_mod { $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(); diff --git a/mod/h5pactivity/tests/behat/contentbank_link.feature b/mod/h5pactivity/tests/behat/contentbank_link.feature new file mode 100644 index 00000000000..15ce71ef63f --- /dev/null +++ b/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"