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
c1d4d730
Commit
c1d4d730
authored
Sep 10, 2016
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix submissions API test - now that calculated grades are saved
parent
d244715e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
15 deletions
+31
-15
lms/djangoapps/courseware/tests/test_submitting_problems.py
+31
-11
lms/djangoapps/grades/signals/handlers.py
+0
-4
No files found.
lms/djangoapps/courseware/tests/test_submitting_problems.py
View file @
c1d4d730
...
...
@@ -25,6 +25,7 @@ from courseware.models import StudentModule, BaseStudentModuleHistory
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
lms.djangoapps.lms_xblock.runtime
import
quote_slashes
from
student.models
import
anonymous_id_for_user
,
CourseEnrollment
from
submissions
import
api
as
submissions_api
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.partitions.partitions
import
Group
,
UserPartition
...
...
@@ -143,9 +144,22 @@ class TestSubmittingProblems(ModuleStoreTestCase, LoginEnrollmentTestCase, Probl
self
.
student_user
=
User
.
objects
.
get
(
email
=
self
.
student
)
self
.
factory
=
RequestFactory
()
# Disable the score change signal to prevent other components from being pulled into tests.
signal_patch
=
patch
(
'courseware.module_render.SCORE_CHANGED.send'
)
signal_patch
.
start
()
self
.
addCleanup
(
signal_patch
.
stop
)
self
.
score_changed_signal_patch
=
patch
(
'courseware.module_render.SCORE_CHANGED.send'
)
self
.
score_changed_signal_patch
.
start
()
def
tearDown
(
self
):
super
(
TestSubmittingProblems
,
self
)
.
tearDown
()
self
.
_stop_signal_patch
()
def
_stop_signal_patch
(
self
):
"""
Stops the signal patch for the SCORE_CHANGED event.
In case a test wants to test with the event actually
firing.
"""
if
self
.
score_changed_signal_patch
:
self
.
score_changed_signal_patch
.
stop
()
self
.
score_changed_signal_patch
=
None
def
add_dropdown_to_section
(
self
,
section_location
,
name
,
num_inputs
=
2
):
"""
...
...
@@ -540,14 +554,20 @@ class TestCourseGrader(TestSubmittingProblems):
self
.
check_grade_percent
(
0.67
)
self
.
assertEqual
(
self
.
get_grade_summary
()[
'grade'
],
'B'
)
# But now we mock out a get_scores call, and watch as it overrides the
# score read from StudentModule and our student gets an A instead.
with
patch
(
'submissions.api.get_scores'
)
as
mock_get_scores
:
mock_get_scores
.
return_value
=
{
self
.
problem_location
(
'p3'
)
.
to_deprecated_string
():
(
1
,
1
)
}
self
.
check_grade_percent
(
1.0
)
self
.
assertEqual
(
self
.
get_grade_summary
()[
'grade'
],
'A'
)
# But now, set the score with the submissions API and watch
# as it overrides the score read from StudentModule and our
# student gets an A instead.
self
.
_stop_signal_patch
()
student_item
=
{
'student_id'
:
anonymous_id_for_user
(
self
.
student_user
,
self
.
course
.
id
),
'course_id'
:
unicode
(
self
.
course
.
id
),
'item_id'
:
unicode
(
self
.
problem_location
(
'p3'
)),
'item_type'
:
'problem'
}
submission
=
submissions_api
.
create_submission
(
student_item
,
'any answer'
)
submissions_api
.
set_score
(
submission
[
'uuid'
],
1
,
1
)
self
.
check_grade_percent
(
1.0
)
self
.
assertEqual
(
self
.
get_grade_summary
()[
'grade'
],
'A'
)
def
test_submissions_api_anonymous_student_id
(
self
):
"""
...
...
lms/djangoapps/grades/signals/handlers.py
View file @
c1d4d730
...
...
@@ -43,8 +43,6 @@ def submissions_score_set_handler(sender, **kwargs): # pylint: disable=unused-a
usage_id
=
kwargs
[
'item_id'
]
user
=
user_by_anonymous_id
(
kwargs
[
'anonymous_user_id'
])
# If any of the kwargs were missing, at least one of the following values
# will be None.
SCORE_CHANGED
.
send
(
sender
=
None
,
points_possible
=
points_possible
,
...
...
@@ -73,8 +71,6 @@ def submissions_score_reset_handler(sender, **kwargs): # pylint: disable=unused
usage_id
=
kwargs
[
'item_id'
]
user
=
user_by_anonymous_id
(
kwargs
[
'anonymous_user_id'
])
# If any of the kwargs were missing, at least one of the following values
# will be None.
SCORE_CHANGED
.
send
(
sender
=
None
,
points_possible
=
0
,
...
...
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