Skip to content

Commit

Permalink
Wiki: Participation Excel downloads error [ISSUE81] #348393
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason.Platts authored and sammarshallou committed Aug 27, 2019
1 parent 59a5e9d commit 61b49e7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
12 changes: 8 additions & 4 deletions participation_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function setup($download = '') {
global $CFG;

// extra headers for export only
if (!empty($download)) {
if (!empty($download) && !in_array($download, ['ods', 'excel'])) {
$this->extraheaders = array(
format_string($this->course->shortname, true),
format_string($this->ouwiki->name, true),
Expand Down Expand Up @@ -183,7 +183,9 @@ public function start_output() {
$this->started_output = true;
if ($this->exportclass !== null) {
$this->exportclass->start_table($this->sheettitle);
$this->exportclass->output_headers($this->extraheaders);
if ($this->extraheaders) {
$this->exportclass->output_headers($this->extraheaders);
}
$this->exportclass->output_headers($this->headers);
} else {
$this->start_html();
Expand Down Expand Up @@ -224,7 +226,7 @@ public function setup($download = '') {
global $CFG;

// extra headers for export only
if (!empty($download)) {
if (!empty($download) && !in_array($download, ['ods', 'excel'])) {
$this->extraheaders = array(
format_string($this->course->shortname, true),
format_string($this->ouwiki->name, true),
Expand Down Expand Up @@ -311,7 +313,9 @@ public function start_output() {
$this->started_output = true;
if ($this->exportclass !== null) {
$this->exportclass->start_table($this->sheettitle);
$this->exportclass->output_headers($this->extraheaders);
if ($this->extraheaders) {
$this->exportclass->output_headers($this->extraheaders);
}
$this->exportclass->output_headers($this->headers);
} else {
$this->start_html();
Expand Down
36 changes: 36 additions & 0 deletions tests/behat/viewdetails.feature
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,39 @@ Feature: Test view details against a user
And I should see "User grade"
And I should see "+3"
And I should see "+2"

Scenario: Check User participation and downloads
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Test 1"
And I press "Create page"
And I set the field "Content" to "Test content 1"
And I press "Save changes"
And I log out
# Add extra content as student.
Given I log in as "student2"
And I am on "Course 1" course homepage
And I follow "Test 1"
When I click on "Edit" "link"
And I set the field "Content" to "Test content 1 some other stuff"
And I press "Save changes"
And I log out
Given I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Test 1"
And I follow "Participation by user"
# Very imprecise, would be good to check column value without xpath
Then I should see "1" in the "Student 2" "table_row"
And I should see "1" in the "Teacher 1" "table_row"
And I should see "3" in the "Student 2" "table_row"
And I should see "3" in the "Teacher 1" "table_row"
Given I set the field "Download table data as" to "Microsoft Excel (.xlsx)"
And I press "Download"
# Only seems to be a behat step to check download from link not form.
And I am on "Course 1" course homepage
And I follow "Test 1"
And I follow "Participation by user"
And I click on "detail" "link" in the "Student 2" "table_row"
Then I should see "+3"
Given I set the field "Download table data as" to "Microsoft Excel (.xlsx)"
And I press "Download"

0 comments on commit 61b49e7

Please sign in to comment.