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
89f38252
Commit
89f38252
authored
6 years ago
by
Alex Dusenbery
Committed by
Alex Dusenbery
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Gradebook: check if subsection grade has an override when including earned/possible scores.
parent
36689eb2
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/grades/api/v1/gradebook_views.py
+5
-3
5 additions, 3 deletions
lms/djangoapps/grades/api/v1/gradebook_views.py
lms/djangoapps/grades/api/v1/tests/test_gradebook_views.py
+80
-0
80 additions, 0 deletions
lms/djangoapps/grades/api/v1/tests/test_gradebook_views.py
with
85 additions
and
3 deletions
lms/djangoapps/grades/api/v1/gradebook_views.py
+
5
−
3
View file @
89f38252
...
...
@@ -431,12 +431,14 @@ class GradebookView(GradeViewMixin, PaginatedAPIView):
# For ZeroSubsectionGrades, we don't want to crawl the subsection's
# subtree to find the problem scores specific to this user
# (ZeroSubsectionGrade.attempted_graded is always False).
# We've already fetched the whole course structure in a non-specific way
# We've already fetched the whole course structure in a non-
user-
specific way
# when creating `graded_subsections`. Looking at the problem scores
# specific to this user (the user in `course_grade.user`) would require
# us to re-fetch the user-specific course structure from the modulestore,
# which is a costly operation.
if
subsection_grade
.
attempted_graded
:
# which is a costly operation. So we only drill into the `graded_total`
# attribute if the user has attempted this graded subsection, or if there
# has been a grade override applied.
if
subsection_grade
.
attempted_graded
or
subsection_grade
.
override
:
graded_description
=
'
({earned:.2f}/{possible:.2f})
'
.
format
(
earned
=
subsection_grade
.
graded_total
.
earned
,
possible
=
subsection_grade
.
graded_total
.
possible
,
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/grades/api/v1/tests/test_gradebook_views.py
+
80
−
0
View file @
89f38252
...
...
@@ -647,6 +647,86 @@ class GradebookViewTest(GradebookViewTestBase):
actual_data
=
dict
(
resp
.
data
)
self
.
assertEqual
(
expected_results
,
actual_data
)
@ddt.data
(
'
login_staff
'
,
'
login_course_admin
'
,
'
login_course_staff
'
,
)
def
test_gradebook_data_for_single_learner_override
(
self
,
login_method
):
"""
Tests that, when a subsection grade that was created from an override, and thus
does not have a truthy `first_attempted` attribute, is the only grade for a
user
'
s subsection, we still get data including a non-zero possible score.
"""
with
patch
(
'
lms.djangoapps.grades.course_grade_factory.CourseGradeFactory.read
'
)
as
mock_grade
:
course_grade
=
self
.
mock_course_grade
(
self
.
student
,
passed
=
True
,
letter_grade
=
'
A
'
,
percent
=
0.85
)
mock_subsection_grades
=
{
self
.
subsections
[
self
.
chapter_1
.
location
][
0
].
location
:
self
.
mock_subsection_grade
(
self
.
subsections
[
self
.
chapter_1
.
location
][
0
],
earned_all
=
1.0
,
possible_all
=
2.0
,
earned_graded
=
1.0
,
possible_graded
=
2.0
,
first_attempted
=
None
,
override
=
MagicMock
(),
),
self
.
subsections
[
self
.
chapter_1
.
location
][
1
].
location
:
self
.
mock_subsection_grade
(
self
.
subsections
[
self
.
chapter_1
.
location
][
1
],
earned_all
=
1.0
,
possible_all
=
2.0
,
earned_graded
=
1.0
,
possible_graded
=
2.0
,
first_attempted
=
None
,
override
=
MagicMock
(),
),
self
.
subsections
[
self
.
chapter_2
.
location
][
0
].
location
:
self
.
mock_subsection_grade
(
self
.
subsections
[
self
.
chapter_2
.
location
][
0
],
earned_all
=
1.0
,
possible_all
=
2.0
,
earned_graded
=
1.0
,
possible_graded
=
2.0
,
first_attempted
=
None
,
override
=
MagicMock
(),
),
self
.
subsections
[
self
.
chapter_2
.
location
][
1
].
location
:
self
.
mock_subsection_grade
(
self
.
subsections
[
self
.
chapter_2
.
location
][
1
],
earned_all
=
1.0
,
possible_all
=
2.0
,
earned_graded
=
1.0
,
possible_graded
=
2.0
,
first_attempted
=
None
,
override
=
MagicMock
(),
),
}
course_grade
.
subsection_grade
=
lambda
key
:
mock_subsection_grades
[
key
]
mock_grade
.
return_value
=
course_grade
with
override_waffle_flag
(
self
.
waffle_flag
,
active
=
True
):
getattr
(
self
,
login_method
)()
resp
=
self
.
client
.
get
(
self
.
get_url
(
course_key
=
self
.
course
.
id
,
username
=
self
.
student
.
username
)
)
expected_results
=
OrderedDict
([
(
'
course_id
'
,
text_type
(
self
.
course
.
id
)),
(
'
email
'
,
self
.
student
.
email
),
(
'
user_id
'
,
self
.
student
.
id
),
(
'
username
'
,
self
.
student
.
username
),
(
'
full_name
'
,
self
.
student
.
get_full_name
()),
(
'
passed
'
,
True
),
(
'
percent
'
,
0.85
),
(
'
letter_grade
'
,
'
A
'
),
(
'
progress_page_url
'
,
reverse
(
'
student_progress
'
,
kwargs
=
dict
(
course_id
=
text_type
(
self
.
course
.
id
),
student_id
=
self
.
student
.
id
)
)),
(
'
section_breakdown
'
,
self
.
expected_subsection_grades
(
letter_grade
=
'
A
'
)),
])
self
.
assertEqual
(
status
.
HTTP_200_OK
,
resp
.
status_code
)
actual_data
=
dict
(
resp
.
data
)
self
.
assertEqual
(
expected_results
,
actual_data
)
@ddt.data
(
'
login_staff
'
,
'
login_course_admin
'
,
...
...
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