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
1628c176
Commit
1628c176
authored
Sep 29, 2016
by
Nimisha Asthagiri
Committed by
GitHub
Sep 29, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #13603 from edx/beryl/grades_reset_capa
Update grade when CAPA problem state is reset
parents
c67c6409
d3d77638
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
7 deletions
+58
-7
common/lib/xmodule/xmodule/capa_base.py
+3
-0
lms/djangoapps/courseware/tests/test_submitting_problems.py
+55
-7
No files found.
common/lib/xmodule/xmodule/capa_base.py
View file @
1628c176
...
...
@@ -1476,6 +1476,9 @@ class CapaMixin(CapaFields):
# Pull in the new problem seed
self
.
set_state_from_lcp
()
# Grade may have changed, so publish new value
self
.
publish_grade
()
event_info
[
'new_state'
]
=
self
.
lcp
.
get_state
()
self
.
track_function_unmask
(
'reset_problem'
,
event_info
)
...
...
lms/djangoapps/courseware/tests/test_submitting_problems.py
View file @
1628c176
...
...
@@ -108,6 +108,15 @@ class ProblemSubmissionTestMixin(TestCase):
resp
=
self
.
client
.
post
(
modx_url
)
return
resp
def
rescore_question
(
self
,
problem_url_name
):
"""
Reset specified problem for current user.
"""
problem_location
=
self
.
problem_location
(
problem_url_name
)
modx_url
=
self
.
modx_url
(
problem_location
,
'problem_reset'
)
resp
=
self
.
client
.
post
(
modx_url
)
return
resp
def
show_question_answer
(
self
,
problem_url_name
):
"""
Shows the answer to the current student.
...
...
@@ -301,6 +310,18 @@ class TestSubmittingProblems(ModuleStoreTestCase, LoginEnrollmentTestCase, Probl
"""
return
[
s
.
earned
for
s
in
self
.
get_grade_summary
()[
'totaled_scores'
][
'Homework'
]]
def
hw_grade
(
self
,
hw_url_name
):
"""
Returns SubsectionGrade for given url.
"""
# list of grade summaries for each section
sections_list
=
[]
for
chapter
in
self
.
get_progress_summary
():
sections_list
.
extend
(
chapter
[
'sections'
])
# get the first section that matches the url (there should only be one)
return
next
(
section
for
section
in
sections_list
if
section
.
url_name
==
hw_url_name
)
def
score_for_hw
(
self
,
hw_url_name
):
"""
Returns list of scores for a given url.
...
...
@@ -308,15 +329,42 @@ class TestSubmittingProblems(ModuleStoreTestCase, LoginEnrollmentTestCase, Probl
Returns list of scores for the given homework:
[<points on problem_1>, <points on problem_2>, ..., <points on problem_n>]
"""
return
[
s
.
earned
for
s
in
self
.
hw_grade
(
hw_url_name
)
.
scores
]
# list of grade summaries for each section
sections_list
=
[]
for
chapter
in
self
.
get_progress_summary
():
sections_list
.
extend
(
chapter
[
'sections'
])
# get the first section that matches the url (there should only be one)
hw_section
=
next
(
section
for
section
in
sections_list
if
section
.
url_name
==
hw_url_name
)
return
[
s
.
earned
for
s
in
hw_section
.
scores
]
class
TestCourseGrades
(
TestSubmittingProblems
):
"""
Tests grades are updated correctly when manipulating problems.
"""
def
setUp
(
self
):
super
(
TestCourseGrades
,
self
)
.
setUp
()
self
.
homework
=
self
.
add_graded_section_to_course
(
'homework'
)
self
.
problem
=
self
.
add_dropdown_to_section
(
self
.
homework
.
location
,
'p1'
,
1
)
def
_submit_correct_answer
(
self
):
"""
Submits correct answer to the problem.
"""
resp
=
self
.
submit_question_answer
(
'p1'
,
{
'2_1'
:
'Correct'
})
self
.
assertEqual
(
resp
.
status_code
,
200
)
def
_verify_grade
(
self
,
expected_problem_score
,
expected_hw_grade
):
"""
Verifies the problem score and the homework grade are as expected.
"""
hw_grade
=
self
.
hw_grade
(
'homework'
)
problem_score
=
hw_grade
.
scores
[
0
]
self
.
assertEquals
((
problem_score
.
earned
,
problem_score
.
possible
),
expected_problem_score
)
self
.
assertEquals
((
hw_grade
.
graded_total
.
earned
,
hw_grade
.
graded_total
.
possible
),
expected_hw_grade
)
def
test_basic
(
self
):
self
.
_submit_correct_answer
()
self
.
_verify_grade
(
expected_problem_score
=
(
1.0
,
1.0
),
expected_hw_grade
=
(
1.0
,
1.0
))
def
test_problem_reset
(
self
):
self
.
_submit_correct_answer
()
self
.
reset_question_answer
(
'p1'
)
self
.
_verify_grade
(
expected_problem_score
=
(
0.0
,
1.0
),
expected_hw_grade
=
(
0.0
,
1.0
))
@attr
(
shard
=
3
)
...
...
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