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
99ce254b
Commit
99ce254b
authored
Oct 04, 2016
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix import required by downstream commit.
parent
62042188
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
30 deletions
+32
-30
lms/djangoapps/grades/tests/test_grades.py
+2
-30
lms/djangoapps/grades/tests/utils.py
+30
-0
No files found.
lms/djangoapps/grades/tests/test_grades.py
View file @
99ce254b
...
...
@@ -10,8 +10,7 @@ from nose.plugins.attrib import attr
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
capa.tests.response_xml_factory
import
MultipleChoiceResponseXMLFactory
from
courseware.module_render
import
get_module
from
courseware.model_data
import
FieldDataCache
,
set_score
from
courseware.model_data
import
set_score
from
courseware.tests.helpers
import
(
LoginEnrollmentTestCase
,
get_request_for_user
...
...
@@ -25,6 +24,7 @@ from xmodule.modulestore import ModuleStoreEnum
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.django_utils
import
SharedModuleStoreTestCase
from
.utils
import
answer_problem
from
..
import
course_grades
from
..course_grades
import
summary
as
grades_summary
from
..module_grades
import
get_module_score
...
...
@@ -533,31 +533,3 @@ class TestGetModuleScore(LoginEnrollmentTestCase, SharedModuleStoreTestCase):
score
=
get_module_score
(
self
.
request
.
user
,
self
.
course
,
self
.
seq3
)
self
.
assertEqual
(
score
,
1.0
)
def
answer_problem
(
course
,
request
,
problem
,
score
=
1
,
max_value
=
1
):
"""
Records a correct answer for the given problem.
Arguments:
course (Course): Course object, the course the required problem is in
request (Request): request Object
problem (xblock): xblock object, the problem to be answered
"""
user
=
request
.
user
grade_dict
=
{
'value'
:
score
,
'max_value'
:
max_value
,
'user_id'
:
user
.
id
}
field_data_cache
=
FieldDataCache
.
cache_for_descriptor_descendents
(
course
.
id
,
user
,
course
,
depth
=
2
)
# pylint: disable=protected-access
module
=
get_module
(
user
,
request
,
problem
.
scope_ids
.
usage_id
,
field_data_cache
,
)
.
_xmodule
module
.
system
.
publish
(
problem
,
'grade'
,
grade_dict
)
lms/djangoapps/grades/tests/utils.py
View file @
99ce254b
...
...
@@ -3,6 +3,8 @@ Utilities for grades related tests
"""
from
contextlib
import
contextmanager
from
mock
import
patch
from
courseware.module_render
import
get_module
from
courseware.model_data
import
FieldDataCache
from
xmodule.graders
import
ProblemScore
...
...
@@ -24,3 +26,31 @@ def mock_get_score(earned=0, possible=1):
with
patch
(
'lms.djangoapps.grades.new.subsection_grade.get_score'
)
as
mock_score
:
mock_score
.
return_value
=
ProblemScore
(
earned
,
possible
,
earned
,
possible
,
1
,
True
,
None
,
None
)
yield
mock_score
def
answer_problem
(
course
,
request
,
problem
,
score
=
1
,
max_value
=
1
):
"""
Records a correct answer for the given problem.
Arguments:
course (Course): Course object, the course the required problem is in
request (Request): request Object
problem (xblock): xblock object, the problem to be answered
"""
user
=
request
.
user
grade_dict
=
{
'value'
:
score
,
'max_value'
:
max_value
,
'user_id'
:
user
.
id
}
field_data_cache
=
FieldDataCache
.
cache_for_descriptor_descendents
(
course
.
id
,
user
,
course
,
depth
=
2
)
# pylint: disable=protected-access
module
=
get_module
(
user
,
request
,
problem
.
scope_ids
.
usage_id
,
field_data_cache
,
)
.
_xmodule
module
.
system
.
publish
(
problem
,
'grade'
,
grade_dict
)
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