Merge pull request #6648 from edx/hotfix/2015-01-15
Fixed unicode error in CSV grade report generation.
This commit is contained in:
@@ -572,8 +572,7 @@ def upload_grades_csv(_xmodule_instance_args, _entry_id, course_id, _task_input,
|
||||
# We were able to successfully grade this student for this course.
|
||||
task_progress.succeeded += 1
|
||||
if not header:
|
||||
# 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']]
|
||||
header = [section['label'] for section in gradeset[u'section_breakdown']]
|
||||
rows.append(
|
||||
["id", "email", "username", "grade"] + header + cohorts_header + group_configs_header
|
||||
)
|
||||
|
||||
@@ -139,6 +139,23 @@ class TestInstructorGradeReport(TestReportMixin, InstructorTaskCourseTestCase):
|
||||
_groups = [group.name for group in self.course.user_partitions[0].groups]
|
||||
self.assertEqual(_groups, user_groups)
|
||||
|
||||
@patch('instructor_task.tasks_helper._get_current_task')
|
||||
@patch('instructor_task.tasks_helper.iterate_grades_for')
|
||||
def test_unicode_in_csv_header(self, mock_iterate_grades_for, _mock_current_task):
|
||||
"""
|
||||
Tests that CSV grade report works if unicode in headers.
|
||||
"""
|
||||
# mock a response from `iterate_grades_for`
|
||||
mock_iterate_grades_for.return_value = [
|
||||
(
|
||||
self.create_student('username', 'student@example.com'),
|
||||
{'section_breakdown': [{'label': u'\u8282\u540e\u9898 01'}], 'percent': 0},
|
||||
'Cannot grade student'
|
||||
)
|
||||
]
|
||||
result = upload_grades_csv(None, None, self.course.id, None, 'graded')
|
||||
self.assertDictContainsSubset({'attempted': 1, 'succeeded': 1, 'failed': 0}, result)
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class TestStudentReport(TestReportMixin, InstructorTaskCourseTestCase):
|
||||
|
||||
@@ -5,6 +5,7 @@ from django.utils.translation import ungettext
|
||||
from django.core.urlresolvers import reverse
|
||||
from courseware.courses import course_image_url, get_course_about_section, get_course_by_id
|
||||
%>
|
||||
<%! from microsite_configuration import microsite %>
|
||||
|
||||
<%block name="billing_details_highlight">
|
||||
% if order_type == 'business':
|
||||
@@ -371,6 +372,8 @@ from courseware.courses import course_image_url, get_course_about_section, get_c
|
||||
<span class="pull-right">${_("Total")}: <b> ${currency_symbol}${"{0:0.2f}".format(order.total_cost)} ${currency.upper()}</b></span>
|
||||
</div>
|
||||
</div>
|
||||
## Allow for a microsite to be able to insert additional text at the bottom of the page
|
||||
<%include file="${microsite.get_template_path('receipt_custom_pane.html')}" />
|
||||
</section>
|
||||
</div>
|
||||
</%block>
|
||||
|
||||
Reference in New Issue
Block a user