Skip to content

Commit 5c0dbe8

Browse files
authored
579 Fix dataformatlib.php No such file or dir (#587)
Remove require_once() for a core file removed in Moodle 4.4 (MDL-80409). This plugin requires Moodle 4.1 and so instead can use the replacement introduced in Moodle 3.9, dataformat::download_data().
1 parent a581289 commit 5c0dbe8

File tree

2 files changed

+48
-7
lines changed

2 files changed

+48
-7
lines changed

report.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@
485485

486486
case 'dfs':
487487
require_capability('mod/questionnaire:downloadresponses', $context);
488-
require_once($CFG->dirroot . '/lib/dataformatlib.php');
489488
// Use the questionnaire name as the file name. Clean it and change any non-filename characters to '_'.
490489
$name = clean_param($questionnaire->name, PARAM_FILE);
491490
$name = preg_replace("/[^A-Z0-9]+/i", "_", trim($name));
@@ -507,12 +506,7 @@
507506
// Check if email report was selected.
508507
$emailreport = optional_param('emailreport', '', PARAM_ALPHA);
509508
if (empty($emailreport)) {
510-
// In 3.9 forward, download_as_dataformat is replaced by \core\dataformat::download_data.
511-
if (method_exists('\\core\\dataformat', 'download_data')) {
512-
\core\dataformat::download_data($name, $dataformat, $columns, $output);
513-
} else {
514-
download_as_dataformat($name, $dataformat, $columns, $output);
515-
}
509+
\core\dataformat::download_data($name, $dataformat, $columns, $output);
516510
} else {
517511
// Emailreport button selected.
518512
if (get_config('questionnaire', 'allowemailreporting') && (!empty($emailroles) || !empty($emailextra))) {
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
@mod @mod_questionnaire
2+
Feature: Questionnaire responses can be downloaded as a CSV, etc.
3+
4+
Background:
5+
Given the following "users" exist:
6+
| username | firstname | lastname | email |
7+
| teacher1 | Teacher | 1 | teacher1@example.com |
8+
| student1 | Student | 1 | student1@example.com |
9+
And the following "courses" exist:
10+
| fullname | shortname | category |
11+
| Course 1 | C1 | 0 |
12+
And the following "course enrolments" exist:
13+
| user | course | role |
14+
| teacher1 | C1 | editingteacher |
15+
| student1 | C1 | student |
16+
And the following "activities" exist:
17+
| activity | name | introduction | course | idnumber |
18+
| questionnaire | Test questionnaire download | Test questionnaire description | C1 | questionnaire1 |
19+
And I log in as "teacher1"
20+
And I am on "Course 1" course homepage
21+
And I follow "Test questionnaire download"
22+
And I navigate to "Questions" in current page administration
23+
And I add a "Text Box" question and I fill the form with:
24+
| Question Name | Q1 |
25+
| No | n |
26+
| Input box length | 10 |
27+
| Max. text length | 15 |
28+
| Question Text | Enter some text |
29+
And I log out
30+
And I log in as "student1"
31+
And I am on "Course 1" course homepage
32+
And I follow "Test questionnaire download"
33+
And I navigate to "Answer the questions..." in current page administration
34+
And I set the field "Enter some text" to "Student response"
35+
And I press "Submit questionnaire"
36+
And I log out
37+
38+
@javascript
39+
Scenario: Download responses
40+
Given I log in as "teacher1"
41+
And I am on "Course 1" course homepage
42+
And I follow "Test questionnaire download"
43+
And I navigate to "View all responses" in current page administration
44+
Then I click on "Download" "link"
45+
# Without the ability to check the downloaded file, the absence of an
46+
# exception being thrown here is considered a success.
47+
And I click on "Download" "button"

0 commit comments

Comments
 (0)