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
65352c9d
Commit
65352c9d
authored
May 08, 2017
by
Cliff Dyer
Committed by
GitHub
May 08, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15060 from edx/neem/handle-iter-errors
Neem/handle iter errors
parents
8231d2d0
5beae9d1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
14 deletions
+17
-14
lms/djangoapps/grades/new/course_grade_factory.py
+3
-3
lms/djangoapps/grades/tasks.py
+3
-1
lms/djangoapps/grades/tests/test_grades.py
+4
-4
lms/djangoapps/instructor_task/tasks_helper/grades.py
+4
-3
lms/djangoapps/instructor_task/tests/test_tasks_helper.py
+3
-3
No files found.
lms/djangoapps/grades/new/course_grade_factory.py
View file @
65352c9d
...
...
@@ -18,7 +18,7 @@ class CourseGradeFactory(object):
"""
Factory class to create Course Grade objects.
"""
GradeResult
=
namedtuple
(
'GradeResult'
,
[
'student'
,
'course_grade'
,
'err
_msg
'
])
GradeResult
=
namedtuple
(
'GradeResult'
,
[
'student'
,
'course_grade'
,
'err
or
'
])
def
create
(
self
,
user
,
course
=
None
,
collected_block_structure
=
None
,
course_structure
=
None
,
course_key
=
None
):
"""
...
...
@@ -108,7 +108,7 @@ class CourseGradeFactory(object):
try
:
method
=
CourseGradeFactory
()
.
update
if
force_update
else
CourseGradeFactory
()
.
create
course_grade
=
method
(
user
,
course
,
course_data
.
collected_structure
,
course_structure
,
course_key
)
yield
self
.
GradeResult
(
user
,
course_grade
,
""
)
yield
self
.
GradeResult
(
user
,
course_grade
,
None
)
except
Exception
as
exc
:
# pylint: disable=broad-except
# Keep marching on even if this student couldn't be graded for
...
...
@@ -119,7 +119,7 @@ class CourseGradeFactory(object):
course_data
.
course_key
,
exc
.
message
)
yield
self
.
GradeResult
(
user
,
None
,
exc
.
message
)
yield
self
.
GradeResult
(
user
,
None
,
exc
)
@staticmethod
def
_create_zero
(
user
,
course_data
):
...
...
lms/djangoapps/grades/tasks.py
View file @
65352c9d
...
...
@@ -96,7 +96,9 @@ def compute_grades_for_course(course_key, offset, batch_size, **kwargs): # pyli
course
=
courses
.
get_course_by_id
(
CourseKey
.
from_string
(
course_key
))
enrollments
=
CourseEnrollment
.
objects
.
filter
(
course_id
=
course
.
id
)
.
order_by
(
'created'
)
student_iter
=
(
enrollment
.
user
for
enrollment
in
enrollments
[
offset
:
offset
+
batch_size
])
list
(
CourseGradeFactory
()
.
iter
(
users
=
student_iter
,
course
=
course
,
force_update
=
True
))
for
result
in
CourseGradeFactory
()
.
iter
(
users
=
student_iter
,
course
=
course
,
force_update
=
True
):
if
result
.
error
is
not
None
:
raise
result
.
error
@task
(
bind
=
True
,
base
=
_BaseTask
,
default_retry_delay
=
30
,
routing_key
=
settings
.
RECALCULATE_GRADES_ROUTING_KEY
)
...
...
lms/djangoapps/grades/tests/test_grades.py
View file @
65352c9d
...
...
@@ -101,7 +101,7 @@ class TestGradeIteration(SharedModuleStoreTestCase):
with
self
.
assertNumQueries
(
4
):
all_course_grades
,
all_errors
=
self
.
_course_grades_and_errors_for
(
self
.
course
,
self
.
students
)
self
.
assertEqual
(
all_errors
,
{
student
:
all_errors
[
student
]
.
message
for
student
in
all_errors
}
,
{
student3
:
"Error for student3."
,
student4
:
"Error for student4."
,
...
...
@@ -130,10 +130,10 @@ class TestGradeIteration(SharedModuleStoreTestCase):
students_to_course_grades
=
{}
students_to_errors
=
{}
for
student
,
course_grade
,
err
_msg
in
CourseGradeFactory
()
.
iter
(
students
,
course
):
for
student
,
course_grade
,
err
or
in
CourseGradeFactory
()
.
iter
(
students
,
course
):
students_to_course_grades
[
student
]
=
course_grade
if
err
_msg
:
students_to_errors
[
student
]
=
err
_msg
if
err
or
:
students_to_errors
[
student
]
=
err
or
return
students_to_course_grades
,
students_to_errors
...
...
lms/djangoapps/instructor_task/tasks_helper/grades.py
View file @
65352c9d
...
...
@@ -322,10 +322,10 @@ class CourseGradeReport(object):
certificate_whitelist
=
CertificateWhitelist
.
objects
.
filter
(
course_id
=
context
.
course_id
,
whitelist
=
True
)
whitelisted_user_ids
=
[
entry
.
user_id
for
entry
in
certificate_whitelist
]
success_rows
,
error_rows
=
[],
[]
for
user
,
course_grade
,
err
_msg
in
CourseGradeFactory
()
.
iter
(
users
,
course_key
=
context
.
course_id
):
for
user
,
course_grade
,
err
or
in
CourseGradeFactory
()
.
iter
(
users
,
course_key
=
context
.
course_id
):
if
not
course_grade
:
# An empty gradeset means we failed to grade a student.
error_rows
.
append
([
user
.
id
,
user
.
username
,
err
_msg
])
error_rows
.
append
([
user
.
id
,
user
.
username
,
err
or
.
message
])
else
:
success_rows
.
append
(
[
user
.
id
,
user
.
email
,
user
.
username
]
+
...
...
@@ -365,11 +365,12 @@ class ProblemGradeReport(object):
current_step
=
{
'step'
:
'Calculating Grades'
}
course
=
get_course_by_id
(
course_id
)
for
student
,
course_grade
,
err
_msg
in
CourseGradeFactory
()
.
iter
(
enrolled_students
,
course
):
for
student
,
course_grade
,
err
or
in
CourseGradeFactory
()
.
iter
(
enrolled_students
,
course
):
student_fields
=
[
getattr
(
student
,
field_name
)
for
field_name
in
header_row
]
task_progress
.
attempted
+=
1
if
not
course_grade
:
err_msg
=
error
.
message
# There was an error grading this student.
if
not
err_msg
:
err_msg
=
u'Unknown error'
...
...
lms/djangoapps/instructor_task/tests/test_tasks_helper.py
View file @
65352c9d
...
...
@@ -132,7 +132,7 @@ class TestInstructorGradeReport(InstructorGradeReportTestCase):
progress dict and uploaded to the report store.
"""
mock_grades_iter
.
return_value
=
[
(
self
.
create_student
(
'username'
,
'student@example.com'
),
None
,
'Cannot grade student'
)
(
self
.
create_student
(
'username'
,
'student@example.com'
),
None
,
TypeError
(
'Cannot grade student'
)
)
]
result
=
CourseGradeReport
.
generate
(
None
,
None
,
self
.
course
.
id
,
None
,
'graded'
)
self
.
assertDictContainsSubset
({
'attempted'
:
1
,
'succeeded'
:
0
,
'failed'
:
1
},
result
)
...
...
@@ -315,7 +315,7 @@ class TestInstructorGradeReport(InstructorGradeReportTestCase):
(
self
.
create_student
(
'username'
,
'student@example.com'
),
mock_course_grade
,
''
,
None
,
)
]
result
=
CourseGradeReport
.
generate
(
None
,
None
,
self
.
course
.
id
,
None
,
'graded'
)
...
...
@@ -667,7 +667,7 @@ class TestProblemGradeReport(TestReportMixin, InstructorTaskModuleTestCase):
"""
student
=
self
.
create_student
(
u'username'
,
u'student@example.com'
)
mock_grades_iter
.
return_value
=
[
(
student
,
None
,
error_message
)
(
student
,
None
,
Exception
(
error_message
)
)
]
result
=
ProblemGradeReport
.
generate
(
None
,
None
,
self
.
course
.
id
,
None
,
'graded'
)
self
.
assertDictContainsSubset
({
'attempted'
:
1
,
'succeeded'
:
0
,
'failed'
:
1
},
result
)
...
...
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