Skip to content

Commit

Permalink
Fixing encoding of header row for posting to remote gradebook
Browse files Browse the repository at this point in the history
Posting to the remote gradebook via lmod proxy was failing due to a key error when parsing the CSV content. This was due to erroneously encoding a string object. This commit adds a check for the type of the header value to prevent double encoding it.
  • Loading branch information
blarghmatey committed Jun 3, 2021
1 parent a7e7103 commit f02f5bf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lms/djangoapps/remote_gradebook/task_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
def create_datatable_csv(csv_file, datatable):
"""Creates a CSV file from the contents of a datatable."""
writer = csv.writer(csv_file, dialect='excel', quotechar='"', quoting=csv.QUOTE_ALL)
encoded_row = [str(s).encode('utf-8') for s in datatable['header']]
encoded_row = [s if isinstance(s, str) else str(s).encode('utf-8')
for s in datatable['header']]
writer.writerow(encoded_row)
for datarow in datatable['data']:
# 's' here may be an integer, float (eg score) or string (eg student name)
Expand Down

0 comments on commit f02f5bf

Please sign in to comment.