Skip to content

Commit

Permalink
MDL-73914 course: remove download course content button
Browse files Browse the repository at this point in the history
  • Loading branch information
lameze committed Mar 22, 2022
1 parent 0d0f09b commit b74b470
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
3 changes: 1 addition & 2 deletions course/tests/behat/course_download_content.feature
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ Feature: Course content can be downloaded
Scenario: A student can download course content when the feature is enabled in their course
Given I log in as "student1"
When I am on "Hockey 101" course homepage
And "Download course content" "button" should exist
And I press "Download course content"
And I navigate to "Download course content" in current page administration
Then I should see "You are about to download a zip file"
# Without the ability to check the downloaded file, the absence of an exception being thrown here is considered a success.
And I click on "Download" "button" in the "Download course content" "dialogue"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,18 @@ Feature: Access to downloading course content can be controlled
And I set the field "Enable download course content" to "Yes"
And I press "Save and display"
And I log out
# Check student can see download button.
# Check student can see the download link.
And I log in as "student1"
And I am on "Hockey 101" course homepage
And "Download course content" "button" should exist
And "Download course content" "link" should exist in current page administration
And I log out
And I log in as "admin"
# Remove student's capability for download course content.
When I set the following system permissions of "Student" role:
| capability | permission |
| moodle/course:downloadcoursecontent | Prohibit |
And I log out
# Check student can no longer see download button.
# Check student can no longer see the download link.
And I log in as "student1"
And I am on "Hockey 101" course homepage
Then "Download course content" "link" should not exist in current page administration
6 changes: 0 additions & 6 deletions course/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,6 @@
if ($PAGE->user_allowed_editing()) {
$buttons = $OUTPUT->edit_button($PAGE->url);
$PAGE->set_button($buttons);
} else if ($candownloadcourse) {
// Show the download course content button if user has permission to access it.
// Only showing this if user doesn't have edit rights, since those who do will access it via the actions menu.
$buttonattr = \core_course\output\content_export_link::get_attributes($context);
$button = new single_button($buttonattr->url, $buttonattr->displaystring, 'post', false, $buttonattr->elementattributes);
$PAGE->set_button($OUTPUT->render($button));
}

// If viewing a section, make the title more specific
Expand Down
2 changes: 1 addition & 1 deletion lib/navigationlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -4737,7 +4737,7 @@ protected function load_course_settings($forceopen = false) {

// Prepare data for course content download functionality if it is enabled.
// Will only be included here if the action menu is already in use, otherwise a button will be added to the UI elsewhere.
if (\core\content::can_export_context($coursecontext, $USER) && !empty($coursenode->get_children_key_list())) {
if (\core\content::can_export_context($coursecontext, $USER)) {
$linkattr = \core_course\output\content_export_link::get_attributes($coursecontext);
$actionlink = new action_link($linkattr->url, $linkattr->displaystring, null, $linkattr->elementattributes);

Expand Down

0 comments on commit b74b470

Please sign in to comment.