Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
cc6f8be8
Commit
cc6f8be8
authored
7 years ago
by
Alex Dusenbery
Committed by
Alex Dusenbery
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
EDUCATOR-1029 | More defensive version of ZeroSubsectionGrade.problem_scores
parent
19a5aa7d
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/grades/new/subsection_grade.py
+3
-1
3 additions, 1 deletion
lms/djangoapps/grades/new/subsection_grade.py
lms/djangoapps/grades/tests/test_new.py
+26
-9
26 additions, 9 deletions
lms/djangoapps/grades/tests/test_new.py
with
29 additions
and
10 deletions
lms/djangoapps/grades/new/subsection_grade.py
+
3
−
1
View file @
cc6f8be8
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/grades/tests/test_new.py
+
26
−
9
View file @
cc6f8be8
...
...
@@ -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
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment