-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix wrong data for column in exported csv in Reports->Lessons #4975
Fix wrong data for column in exported csv in Reports->Lessons #4975
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 All columns and data in their places :) Thanks!
@@ -351,7 +351,7 @@ public function generate_report( $report ) { | |||
|
|||
// Process each row. | |||
foreach ( $this->items as $item ) { | |||
$data[] = $this->get_row_data( $item ); | |||
$data[] = array_replace( $columns, $this->get_row_data( $item ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it doesn't cause any performance issues?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about this too, but hopefully in this particular case it won't come to that, the loop will be running for number of rows * number of properties time in total, we don't have that many properties (columns) usually, and for the number of rows to become an issue, I think we'll be facing out of memory or something like that before that happens :p So I think compared to the time it takes to fetch the data and prepare a row, the time taken here hopefully won't become too significant
I'm not sure how I missed this one. 😄 GJ finding the issue! |
Fixes the issue mentioned here #4964 (review)
Changes proposed in this Pull Request
The column data was not sorted according to the column headers. So when 'module' column was added in the headers, the data was not being sorted, so the module column appeared after the title column, but the data for the module column was in the last column in each row. So it resulted in all columns except the title showing wrong data (1 right circular shift except the title). Here we're sorting the data as per column headers to make them appear in the same order.
Testing instructions
Screenshot / Video
Before - (Notice that the students column is showing a date, also the rest of the columns)
After-