diff --git a/mod/resource/locallib.php b/mod/resource/locallib.php index b5a4d1216ec..1936b7d8304 100644 --- a/mod/resource/locallib.php +++ b/mod/resource/locallib.php @@ -434,11 +434,13 @@ function resource_get_intro(object $resource, object $cm, bool $ignoresettings = $content = ""; if ($ignoresettings || !empty($options['printintro']) || $extraintro) { - $gotintro = !html_is_blank($resource->intro); - if ($gotintro || $extraintro) { - if ($gotintro) { - $content = format_module_intro('resource', $resource, $cm->id); - } + $resourceintro = !empty($options['printintro']) && !html_is_blank($resource->intro); + + if ($resourceintro) { + $content .= format_module_intro('resource', $resource, $cm->id); + } + + if ($extraintro) { $content .= $extraintro; } } diff --git a/mod/resource/tests/behat/display_resource.feature b/mod/resource/tests/behat/display_resource.feature index 1f69a9ff299..3f232ff451f 100644 --- a/mod/resource/tests/behat/display_resource.feature +++ b/mod/resource/tests/behat/display_resource.feature @@ -1,4 +1,4 @@ -@mod @mod_resource @_file_upload +@mod @mod_resource Feature: Teacher can specify different display options for the resource In order to provide more information about a file As a teacher @@ -17,12 +17,11 @@ Feature: Teacher can specify different display options for the resource | teacher1 | C1 | editingteacher | | student1 | C1 | student | And the following "activities" exist: - | activity | course | name | defaultfilename | uploaded | - | resource | C1 | Myfile | mod/resource/tests/fixtures/samplefile.txt | 1 | + | activity | course | name | intro | defaultfilename | uploaded | + | resource | C1 | Myfile | My cool file | mod/resource/tests/fixtures/samplefile.txt | 1 | And I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on - @javascript Scenario: Specifying no additional display options for a file resource When I am on the "Myfile" "resource activity editing" page And I set the following fields to these values: @@ -34,7 +33,6 @@ Feature: Teacher can specify different display options for the resource And I am on "Course 1" course homepage And ".activity.resource .resourcelinkdetails" "css_element" should not exist - @javascript Scenario Outline: Specifying different display options for a file resource When I am on the "Myfile" "resource activity editing" page And I set the following fields to these values: @@ -50,7 +48,6 @@ Feature: Teacher can specify different display options for the resource And I see "6 bytes" in the ".activity.resource .resourcelinkdetails" "css_element" And I see "TXT" in the ".activity.resource .activitybadge" "css_element" And I see "Uploaded" in the ".activity.resource .resourcelinkdetails" "css_element" - Examples: | showsize | showtype | showdate | seesize | seetype | seedate | | 1 | 0 | 0 | should | should not | should not | @@ -60,6 +57,22 @@ Feature: Teacher can specify different display options for the resource | 0 | 1 | 1 | should not | should | should | | 1 | 1 | 1 | should | should | should | + Scenario Outline: Specify different display options for an embedded file resource + When I am on the "Myfile" "resource activity editing" page + And I set the following fields to these values: + | display | Embed | + | Show type | | + | Display resource description | | + And I press "Save and display" + Then I see "TXT" in the "region-main" "region" + And I see "My cool file" in the "region-main" "region" + Examples: + | showtype | showdesc | seetype | seedesc | + | 1 | 0 | should | should not | + | 1 | 1 | should | should | + | 0 | 1 | should not | should | + | 0 | 0 | should not | should not | + Scenario: Specifying only show type for a file resource When I am on the "Myfile" "resource activity editing" page And I set the following fields to these values: