Show
Prerequisites/setup
Have the ability to run 3 Moodle sessions at once (eg one browser with incognito/private browsing mode, and a second browser).
Have the ability to add a PHP file to the backend of your test site.
Create a new course, with at least one editing teacher and one student enrolled.
CONFIRM you are able to create the course without any errors.
Add the following activities to the course:
Forum.
Two File activities, one smaller than 500KB and one larger than 500KB.
Page.
Folder.
Label.
Download the exporter.php file attached to this issue (it will be used in the final test).
Make sure debugging is disabled on your Moodle site (Site administration > Development > Debugging, set "Debug messages" to "NONE" and save).
Open your site's version.php file in your IDE and bump the version number.
Log in as admin and perform the upgrade steps when prompted, then clear all caches.
Note: References to the action menu are the action menu cog in Boost, or the left margin navigation in Classic.
Testing - download UI and site level settings
Log in as admin (this will be referred to as the "admin window").
In a separate session (eg in incognito/private browsing mode) also log in as the teacher (this will be referred to as the teacher window).
In a separate session (eg in a different browser) also log in as the student (this will be referred to as the student window).
In the admin window, navigate to Site administration > Courses > Download course content.
CONFIRM "Download course content feature available" checkbox is unchecked, then press "Save changes".
In the teacher window, navigate to the course and expand the actions menu.
CONFIRM you do not see the "Download course content" option in the menu.
In the actions menu, select "Edit course".
Under the General section, CONFIRM you do not see "Enable download course content" below "Course visibility".
Return to the course homepage.
In the student window, log in and navigate to the course.
CONFIRM you do not see a "Download course content" button at the top right of the course page.
In the admin window, check the "Download course content feature available" checkbox, and set "Maximum size per file when downloading course content" to "500 KB", then press "Save changes".
On the same page, click on the hyperlink to "Course default settings" (in the description for "Download course content feature available").
CONFIRM you are taken to the "Course default settings" page in a new tab.
Set the "Enable download course content" setting to "No" and press "Save changes".
In the student window, refresh the course page and CONFIRM you still do not see a "Download course content" button at the top right of the course page.
In the teacher window, refresh the course homepage, expand the actions menu and CONFIRM you still do not see the "Download course content" option in the menu.
Select the "Edit course" option.
Under the General section, CONFIRM you do see "Enable download course content" below "Course visibility", and CONFIRM it is set to "Site default (No)".
In the admin window, change the "Enable download course content" setting to "Yes" and press "Save changes".
In the teacher window, refresh the edit course page and CONFIRM the "Enable download course content" value is now set to "Site default (Yes)".
In the student window, refresh the course homepage and CONFIRM you now see a "Download course content" button at the top right of the course page.
In the teacher window, return to the course homepage, open the actions menu and CONFIRM the "Download course content" option is now available.
Click "Download course content".
CONFIRM you see a "Download course content" modal and CONFIRM the end of the text says "(excluding any files larger than 500KB)" (paying attention to ensure the size mentioned is "500KB").
Click "Cancel" on the modal and CONFIRM you are returned to the course page.
Again click the "Download course content" from the action menu.
Click the "Download" button in the modal.
CONFIRM you are prompted to download the zip file, then download it.
CONFIRM you are then returned to the course homepage.
Extract the zip file you just downloaded.
Navigate into the extracted folder, and open the index.html file in one of your web browsers, so you can view it.
CONFIRM the index page shows the correct course name/short name and CONFIRM the six activities you created in the course during setup are all listed.
In the student window, click the "Download course content" button, and CONFIRM you see a modal with the same text as in step 26.
Repeat steps 29-34 and CONFIRM you see the same results.
Testing - Further course settings and capabilities
In the admin window (the tab titled "Course default settings"), change the "Enable download course content" setting to "No" and press "Save changes".
In the teacher window, select "edit course" from the actions menu.
CONFIRM "Enable download course content" is set to "Site default (No)".
Change the "Enable download course content" to "No" and press "Save and Display".
When you are redirected to the course homepage, CONFIRM the "Download course content" option is not available in the actions menu.
Select "edit course" from the actions menu.
Change the "Enable download course content" to "Yes" and press "Save and Display".
When you are redirected to the course homepage, CONFIRM the "Download course content" option is available in the actions menu.
Right click on the "Download course content" option, and choose "inspect element".
Find the "data-download-link" value for that element, which will be a URL in the format <wwwroot>/course/downloadcontent.php?contextid=xxxx&download=1 . Copy that URL and paste it into a new tab in the teacher window, then press enter (to load it).
CONFIRM you receive a sesskey error. You can now close just that one tab.
In the admin window, return to the first browser tab (the one titled "Download course content").
Uncheck the "Download course content feature available" checkbox, then press "Save changes".
In the student window, refresh the course homepage and CONFIRM the "Download course content" button is not visible on the page (this confirms disabling on the site overrides course-level settings).
In the admin window,check the "Download course content feature available" checkbox again, then press "Save changes".
In the student window, refresh the course homepage and CONFIRM the "Download course content" button is visible on the page.
In the admin window, remove the "moodle/course:downloadcontentexport" capability from both the editing teacher and student roles.
Also remove the "moodle/course:configurecontentexport" capability from the editing teacher role.
In the student window, do not refresh the page, but click the "Download course content" button.
CONFIRM a new tab opens, but is immediately redirected to the course homepage.
CONFIRM on that page, the "Download course content" button is no longer available.
In the teacher window, refresh the page and CONFIRM the "Download course content" option has been removed from the action menu.
Select the "Edit course" option from the menu.
CONFIRM you can see the "Enable download course content" item in the General section, but are no longer able to modify it.
Testing - developer debugging displays errors
In the admin window, navigate to Site administration > Development > Debugging and set the following:
Set Debug messages to DEVELOPER.
Check/enable Display debug messages.
Press "Save changes".
Navigate to the course homepage (still in the admin window).
In the actions menu, press "Download course content" and then press "Download" in the modal popup.
CONFIRM the zip file downloads and CONFIRM you are able to extract that zip file.
Also CONFIRM you are redirected back to the course homepage.
Either in your IDE or whichever directory explorer you use on your computer, open up/navigate to /path/to/wwwroot/mod/label/classes/ .
Create a new directory in that classes directory called "content", then navigate into that directory.
At the start of testing, you downloaded a test exporter.php file from this issue. Move that into the "content" directory you just created.
Do a version bump, either with this plugin or a main version bump.
Again from the course homepage, in the actions menu, press "Download course content" and then press "Download" in the modal popup.
CONFIRM you now see an error message and CONFIRM no zip file is downloaded.
Testing - course creation throws no exceptions
In the admin window, navigate to Site administration > Courses > Download course content.
If the "Download course content feature available" checkbox is unchecked, check it and press "Save changes".
Navigate to Site administration > Courses > Add a new course.
CONFIRM the add course page loads without errors and CONFIRM you can see "Enable download course content " under the General section.
Fill in the form with some test details, but set "Enable download course content " to "No" and press "Save and display".
CONFIRM the course creates without errors.
In the new course, navigate to "Edit course" and CONFIRM that "Enable download course content " is set to "No".