Show
Setup
For this testing we will need a course with few enrolled users (student, teacher).
You'll also need a forum activity with few discussions and posts.
Basic testing
Log in as admin.
Go to a course and then to the forum
In the discussions list, click on the cog.
Make sure a new option Export is now available in the forum menu.
Click on Export link.
Make sure the Export page is rendered without any errors.
Make sure there are three fields available: Users, Discussions and Format.
Click on the Export button.
Make sure the forum gets exported in CSV format.
Open that file.
Make sure the whole forum got exported and the content makes sense.
Visibility and capability testing
Log in as s1 and go to that forum.
Click on the cog to see the options.
Make sure the Export option is not available.
Try to access the export directly, by changing the URL in the browser to:
http://localhost/stable_master/mod/forum/export.php?id=X
Where X is the Forum ID, that can be found in the discussion list page URL (id=X)
– Make sure you get an error: You cannot export this forum
Now, open a new incognito window and log in as admin .
Go to Site administration > Users > Permissions > Capability overview
Search for exportforum and click Get the overview button.
Make sure that capability is only allowed to Manager , Teacher and Non-editing teacher .
Please note Student role is marked as Not set , click on the Student role link to edit that role.
In the role edit page, click Edit button.
Again, search for mod/forum:exportforum and check the Allow checkbox and click Save changes
On window 1 (as student), refresh the discussion page.
Click on the cog .
Make sure the Export option is now available for the student.
Click on the Export link.
Make sure the Export page was rendered.
Click on Export button.
Make sure the forum content gets exported.
On window 2 as admin, edit student role again.
Unassign that capability mod/forum:exportforum from student role and save.
On window 1 , refresh the page.
Make sure you get an error: You cannot export this forum
Filters testing
As admin or teacher, go to the forum export page.
On Users field, click down arrow.
Make sure it displays all enrolled users in this course.
Select a user and click Export .
Make sure only the data of the user you've chose has been exported.
Now, on Discussions field, click down arrow.
Make sure all discussions of this forum are displayed.
Select one discussion and click Export .
Make sure only the data of the discussion you've chose has been exported.
Choose an user and a discussion in the filter.
Make sure just the data of the combination you've choose has been exported.
Clear all fields and click Export again.
Make sure all discussions and posts data from that forum has been exported.
Formats
As admin or teacher, go to the forum export page.
Expand the Format field, note all possible export format options:
Comma separated values (.csv)
Microsoft Excel (.xlsx)
HTML table
Javascript Object Notation (.json)
OpenDocument (.ods)
Portable Document Forumat (.pdf)
Go through each available format and export.
Each exported file should have following fields:
id, discussion, parent, userid, created, modified, mailed, subject, message, messageformat, messagetrust, attachment, totalscore, mailnow, deleted, privatereplyto
Compare each field in the exported data file against the mdl_forum_posts table, make sure exported content is equal to the data in the table. In particular:
The 'parent' column must have an integer value and must not be empty.
The 'mailed' column must have an integer value and must not be empty.
The 'messageformat' column must have an integer value and must not be empty.
The 'messagetrust' column must have an integer value and must not be empty.
The 'attachment' column must have an integer value and must not be empty.
The 'totalscore' column must have an integer value and must not be empty.
The 'mailnow' column must have an integer value and must not be empty.
The 'deleted' column must have an integer value and must not be empty.
The 'privatereplyto' column must have an integer value and must not be empty.