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
d17bc753
Commit
d17bc753
authored
Jul 31, 2017
by
Alex Dusenbery
Committed by
Ned Batchelder
Aug 01, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EDUCATOR-1029 | More defensive version of ZeroSubsectionGrade.problem_scores
(cherry picked from commit
cc6f8be8
)
parent
c93df9b0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
10 deletions
+29
-10
lms/djangoapps/grades/new/subsection_grade.py
+3
-1
lms/djangoapps/grades/tests/test_new.py
+26
-9
No files found.
lms/djangoapps/grades/new/subsection_grade.py
View file @
d17bc753
...
...
@@ -81,9 +81,11 @@ class ZeroSubsectionGrade(SubsectionGradeBase):
):
block
=
self
.
course_data
.
structure
[
block_key
]
if
getattr
(
block
,
'has_score'
,
False
):
locations
[
block_key
]
=
get_score
(
problem_score
=
get_score
(
submissions_scores
=
{},
csm_scores
=
{},
persisted_block
=
None
,
block
=
block
,
)
if
problem_score
is
not
None
:
locations
[
block_key
]
=
problem_score
return
locations
...
...
lms/djangoapps/grades/tests/test_new.py
View file @
d17bc753
...
...
@@ -367,23 +367,40 @@ class TestSubsectionGradeFactory(ProblemSubmissionTestMixin, GradeTestBase):
self
.
assertEqual
(
mock_read_saved_grade
.
called
,
feature_flag
and
course_setting
)
@ddt.ddt
class
ZeroGradeTest
(
GradeTestBase
):
"""
Tests ZeroCourseGrade (and, implicitly, ZeroSubsectionGrade)
functionality.
"""
def
test_zero
(
self
):
@ddt.data
(
True
,
False
)
def
test_zero
(
self
,
assume_zero_enabled
):
"""
Creates a ZeroCourseGrade and ensures it's empty.
"""
course_data
=
CourseData
(
self
.
request
.
user
,
structure
=
self
.
course_structure
)
chapter_grades
=
ZeroCourseGrade
(
self
.
request
.
user
,
course_data
)
.
chapter_grades
for
chapter
in
chapter_grades
:
for
section
in
chapter_grades
[
chapter
][
'sections'
]:
for
score
in
section
.
problem_scores
.
itervalues
():
self
.
assertEqual
(
score
.
earned
,
0
)
self
.
assertEqual
(
score
.
first_attempted
,
None
)
self
.
assertEqual
(
section
.
all_total
.
earned
,
0
)
with
waffle
()
.
override
(
ASSUME_ZERO_GRADE_IF_ABSENT
,
active
=
assume_zero_enabled
):
course_data
=
CourseData
(
self
.
request
.
user
,
structure
=
self
.
course_structure
)
chapter_grades
=
ZeroCourseGrade
(
self
.
request
.
user
,
course_data
)
.
chapter_grades
for
chapter
in
chapter_grades
:
for
section
in
chapter_grades
[
chapter
][
'sections'
]:
for
score
in
section
.
problem_scores
.
itervalues
():
self
.
assertEqual
(
score
.
earned
,
0
)
self
.
assertEqual
(
score
.
first_attempted
,
None
)
self
.
assertEqual
(
section
.
all_total
.
earned
,
0
)
@ddt.data
(
True
,
False
)
def
test_zero_null_scores
(
self
,
assume_zero_enabled
):
"""
Creates a zero course grade and ensures that null scores aren't included in the section problem scores.
"""
with
waffle
()
.
override
(
ASSUME_ZERO_GRADE_IF_ABSENT
,
active
=
assume_zero_enabled
):
with
patch
(
'lms.djangoapps.grades.new.subsection_grade.get_score'
,
return_value
=
None
):
course_data
=
CourseData
(
self
.
request
.
user
,
structure
=
self
.
course_structure
)
chapter_grades
=
ZeroCourseGrade
(
self
.
request
.
user
,
course_data
)
.
chapter_grades
for
chapter
in
chapter_grades
:
self
.
assertNotEqual
({},
chapter_grades
[
chapter
][
'sections'
])
for
section
in
chapter_grades
[
chapter
][
'sections'
]:
self
.
assertEqual
({},
section
.
problem_scores
)
class
SubsectionGradeTest
(
GradeTestBase
):
...
...
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