Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
f832e4f2
Commit
f832e4f2
authored
Sep 12, 2014
by
Kevin Luo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert unicode emails to byte strings for CSV grade reports
parent
825dbddd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
1 deletions
+63
-1
lms/djangoapps/instructor_task/tasks_helper.py
+1
-1
lms/djangoapps/instructor_task/tests/test_tasks_helper.py
+62
-0
No files found.
lms/djangoapps/instructor_task/tasks_helper.py
View file @
f832e4f2
...
...
@@ -547,7 +547,7 @@ def push_grades_to_s3(_xmodule_instance_args, _entry_id, course_id, _task_input,
# possible for a student to have a 0.0 show up in their row but
# still have 100% for the course.
row_percents
=
[
percents
.
get
(
label
,
0.0
)
for
label
in
header
]
rows
.
append
([
student
.
id
,
student
.
email
,
student
.
username
,
gradeset
[
'percent'
]]
+
row_percents
)
rows
.
append
([
student
.
id
,
unicode
(
student
.
email
)
.
encode
(
'utf-8'
)
,
student
.
username
,
gradeset
[
'percent'
]]
+
row_percents
)
else
:
# An empty gradeset means we failed to grade a student.
num_failed
+=
1
...
...
lms/djangoapps/instructor_task/tests/test_tasks_helper.py
0 → 100644
View file @
f832e4f2
"""
Unit tests for LMS instructor-initiated background tasks helper functions.
Tests that CSV grade report generation works with unicode emails.
"""
import
os
import
shutil
import
ddt
from
mock
import
Mock
,
patch
from
django.conf
import
settings
from
django.test.testcases
import
TestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
student.tests.factories
import
CourseEnrollmentFactory
,
UserFactory
from
instructor_task.tasks_helper
import
push_grades_to_s3
TEST_COURSE_ORG
=
'edx'
TEST_COURSE_NAME
=
'test_course'
TEST_COURSE_NUMBER
=
'1.23x'
@ddt.ddt
class
TestInstructorGradeReport
(
TestCase
):
"""
Tests that CSV grade report generation works.
"""
def
setUp
(
self
):
self
.
course
=
CourseFactory
.
create
(
org
=
TEST_COURSE_ORG
,
number
=
TEST_COURSE_NUMBER
,
display_name
=
TEST_COURSE_NAME
)
def
tearDown
(
self
):
if
os
.
path
.
exists
(
settings
.
GRADES_DOWNLOAD
[
'ROOT_PATH'
]):
shutil
.
rmtree
(
settings
.
GRADES_DOWNLOAD
[
'ROOT_PATH'
])
def
create_student
(
self
,
username
,
email
):
student
=
UserFactory
.
create
(
username
=
username
,
email
=
email
)
CourseEnrollmentFactory
.
create
(
user
=
student
,
course_id
=
self
.
course
.
id
)
@ddt.data
([
u'student@example.com'
,
u'ni
\xf1
o@example.com'
])
def
test_unicode_emails
(
self
,
emails
):
"""
Test that students with unicode characters in emails is handled.
"""
i
=
0
for
email
in
emails
:
self
.
create_student
(
'student{0}'
.
format
(
i
),
email
)
i
+=
1
self
.
current_task
=
Mock
()
self
.
current_task
.
update_state
=
Mock
()
with
patch
(
'instructor_task.tasks_helper._get_current_task'
)
as
mock_current_task
:
mock_current_task
.
return_value
=
self
.
current_task
result
=
push_grades_to_s3
(
None
,
None
,
self
.
course
.
id
,
None
,
'graded'
)
#This assertion simply confirms that the generation completed with no errors
self
.
assertEquals
(
result
[
'succeeded'
],
result
[
'attempted'
])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment