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
2bfbd57e
Commit
2bfbd57e
authored
Apr 29, 2015
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test case for an XBlock that has no student state fields, but sets a score
parent
2e06e592
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
2 deletions
+49
-2
lms/djangoapps/courseware/tests/test_module_render.py
+49
-2
No files found.
lms/djangoapps/courseware/tests/test_module_render.py
View file @
2bfbd57e
...
...
@@ -78,6 +78,27 @@ class EmptyXModuleDescriptor(XModuleDescriptor): # pylint: disable=abstract-met
module_class
=
EmptyXModule
class
GradedStatelessXBlock
(
XBlock
):
"""
This XBlock exists to test grade storage for blocks that don't store
student state in a scoped field.
"""
@XBlock.json_handler
def
set_score
(
self
,
json_data
,
suffix
):
# pylint: disable=unused-argument
"""
Set the score for this testing XBlock.
"""
self
.
runtime
.
publish
(
self
,
'grade'
,
{
'value'
:
json_data
[
'grade'
],
'max_value'
:
1
}
)
@attr
(
'shard_1'
)
@ddt.ddt
class
ModuleRenderTestCase
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
...
...
@@ -335,8 +356,7 @@ class TestHandleXBlockCallback(ModuleStoreTestCase, LoginEnrollmentTestCase):
self
.
course_key
=
self
.
create_toy_course
()
self
.
location
=
self
.
course_key
.
make_usage_key
(
'chapter'
,
'Overview'
)
self
.
toy_course
=
modulestore
()
.
get_course
(
self
.
course_key
)
self
.
mock_user
=
UserFactory
()
self
.
mock_user
.
id
=
1
self
.
mock_user
=
UserFactory
.
create
()
self
.
request_factory
=
RequestFactory
()
# Construct a mock module for the modulestore to return
...
...
@@ -476,6 +496,33 @@ class TestHandleXBlockCallback(ModuleStoreTestCase, LoginEnrollmentTestCase):
'bad_dispatch'
,
)
@XBlock.register_temp_plugin
(
GradedStatelessXBlock
,
identifier
=
'stateless_scorer'
)
def
test_score_without_student_state
(
self
):
course
=
CourseFactory
.
create
()
block
=
ItemFactory
.
create
(
category
=
'stateless_scorer'
,
parent
=
course
)
request
=
self
.
request_factory
.
post
(
'dummy_url'
,
data
=
json
.
dumps
({
"grade"
:
0.75
}),
content_type
=
'application/json'
)
request
.
user
=
self
.
mock_user
response
=
render
.
handle_xblock_callback
(
request
,
unicode
(
course
.
id
),
quote_slashes
(
unicode
(
block
.
scope_ids
.
usage_id
)),
'set_score'
,
''
,
)
self
.
assertEquals
(
response
.
status_code
,
200
)
student_module
=
StudentModule
.
objects
.
get
(
student
=
self
.
mock_user
,
module_state_key
=
block
.
scope_ids
.
usage_id
,
)
self
.
assertEquals
(
student_module
.
grade
,
0.75
)
self
.
assertEquals
(
student_module
.
max_grade
,
1
)
@patch.dict
(
'django.conf.settings.FEATURES'
,
{
'ENABLE_XBLOCK_VIEW_ENDPOINT'
:
True
})
def
test_xblock_view_handler
(
self
):
args
=
[
...
...
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