From 654dd7c81d778bb510d694b2e51d1fcdc070ad4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20B=C3=B6sch?= Date: Wed, 29 Nov 2023 01:33:51 +0100 Subject: [PATCH] MDL-80283 url: url page less wide. --- mod/url/tests/behat/display_url.feature | 72 +++++++++++++++++++++++++ mod/url/view.php | 4 ++ 2 files changed, 76 insertions(+) create mode 100644 mod/url/tests/behat/display_url.feature diff --git a/mod/url/tests/behat/display_url.feature b/mod/url/tests/behat/display_url.feature new file mode 100644 index 0000000000000..114c2e399652f --- /dev/null +++ b/mod/url/tests/behat/display_url.feature @@ -0,0 +1,72 @@ +@mod @mod_url +Feature: Teacher can specify different display options for a url + In order to specify different display options for a url + As a teacher + I need to be able to set either auto, embed, open or pop-up + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Vinnie | Student1 | student1@example.com | + | teacher1 | Darrell | Teacher1 | teacher1@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + | teacher1 | C1 | editingteacher | + And the following config values are set as admin: + | displayoptions | 0,1,2,3,4,5,6 | url | + + Scenario: URL resource module with auto display option to an external website shows in limited width + Given the following "activity" exists: + | activity | url | + | course | C1 | + | idnumber | Music history | + | name | Music history | + | intro | URL description | + | externalurl | https://moodle.org/ | + | display | 0 | + When I am on the "Music history" "url activity" page logged in as student1 + Then "Music history" "link" should exist + And the "class" attribute of "body" "css_element" should contain "limitedwidth" + + Scenario: URL resource module with force download display option to an external website shows in limited width + Given the following "activity" exists: + | activity | url | + | course | C1 | + | idnumber | Music history | + | name | Music history | + | intro | URL description | + | externalurl | https://moodle.org/ | + | display | 4 | + When I am on the "Music history" "url activity" page logged in as student1 + Then "Music history" "link" should exist + And the "class" attribute of "body" "css_element" should contain "limitedwidth" + + Scenario: URL resource module with in frame display option to an external website shows in full width + Given the following "activity" exists: + | activity | url | + | course | C1 | + | idnumber | Music history | + | name | Music history | + | intro | URL description | + | externalurl | https://moodle.org/ | + | display | 2 | + When I am on the "Music history" "url activity" page logged in as student1 + Then "Music history" "link" should exist + And the "class" attribute of "body" "css_element" should not contain "limitedwidth" + + Scenario: URL resource module with embed display option to an external website shows in full width + Given the following "activity" exists: + | activity | url | + | course | C1 | + | idnumber | Music history | + | name | Music history | + | intro | URL description | + | externalurl | https://moodle.org/ | + | display | 1 | + When I am on the "Music history" "url activity" page logged in as student1 + Then "Music history" "link" should exist + And the "class" attribute of "body" "css_element" should not contain "limitedwidth" diff --git a/mod/url/view.php b/mod/url/view.php index 00119759a57a6..97911630c62ac 100644 --- a/mod/url/view.php +++ b/mod/url/view.php @@ -69,6 +69,10 @@ $redirect = true; } +if ($displaytype == RESOURCELIB_DISPLAY_AUTO || $displaytype == RESOURCELIB_DISPLAY_DOWNLOAD) { + $PAGE->add_body_class('limitedwidth'); +} + if ($redirect && !$forceview) { // coming from course page or url index page, // the redirection is needed for completion tracking and logging