Commit 2c2c2382 by Sarina Canelake

Merge pull request #1817 from edx/sarina/lms-197

Encode header row (LMS-197)
parents a040f3f6 0426e51d
......@@ -133,8 +133,10 @@ def instructor_dashboard(request, course_id):
else:
response = file_pointer
writer = csv.writer(response, dialect='excel', quotechar='"', quoting=csv.QUOTE_ALL)
writer.writerow(datatable['header'])
encoded_row = [unicode(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)
encoded_row = [unicode(s).encode('utf-8') for s in datarow]
writer.writerow(encoded_row)
return response
......
......@@ -523,7 +523,8 @@ def push_grades_to_s3(_xmodule_instance_args, _entry_id, course_id, _task_input,
# We were able to successfully grade this student for this course.
num_succeeded += 1
if not header:
header = [section['label'] for section in gradeset[u'section_breakdown']]
# Encode the header row in utf-8 encoding in case there are unicode characters
header = [section['label'].encode('utf-8') for section in gradeset[u'section_breakdown']]
rows.append(["id", "email", "username", "grade"] + header)
percents = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment