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
8d9d6ce0
Commit
8d9d6ce0
authored
Apr 24, 2015
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clarify the interface used by xqueue_callback to load an XBlock
parent
917ea90d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
10 deletions
+8
-10
lms/djangoapps/courseware/module_render.py
+6
-6
lms/djangoapps/courseware/tests/test_module_render.py
+2
-4
No files found.
lms/djangoapps/courseware/module_render.py
View file @
8d9d6ce0
...
...
@@ -52,7 +52,7 @@ from xblock.exceptions import NoSuchHandlerError, NoSuchViewError
from
xblock.django.request
import
django_to_webob_request
,
webob_to_django_response
from
xmodule.error_module
import
ErrorDescriptor
,
NonStaffErrorDescriptor
from
xmodule.exceptions
import
NotFoundError
,
ProcessingError
from
opaque_keys.edx.keys
import
UsageKey
from
opaque_keys.edx.keys
import
UsageKey
,
CourseKey
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
xmodule.contentstore.django
import
contentstore
from
xmodule.modulestore.django
import
modulestore
,
ModuleI18nService
...
...
@@ -724,12 +724,12 @@ def get_module_for_descriptor_internal(user, descriptor, field_data_cache, cours
return
descriptor
def
find_target_student_module
(
request
,
user_id
,
course_id
,
mod_id
):
def
load_single_xblock
(
request
,
user_id
,
course_id
,
usage_key_string
):
"""
Retrieve target StudentModule
Load a single XBlock identified by usage_key_string.
"""
course_id
=
SlashSeparatedCourseKey
.
from_deprecated_string
(
course_id
)
usage_key
=
course_id
.
make_usage_key_from_deprecated_string
(
mod_id
)
usage_key
=
course_id
.
make_usage_key_from_deprecated_string
(
usage_key_string
)
user
=
User
.
objects
.
get
(
id
=
user_id
)
field_data_cache
=
FieldDataCache
.
cache_for_descriptor_descendents
(
course_id
,
...
...
@@ -740,7 +740,7 @@ def find_target_student_module(request, user_id, course_id, mod_id):
)
instance
=
get_module
(
user
,
request
,
usage_key
,
field_data_cache
,
grade_bucket_type
=
'xqueue'
)
if
instance
is
None
:
msg
=
"No module {0} for user {1}--access denied?"
.
format
(
mod_id
,
user
)
msg
=
"No module {0} for user {1}--access denied?"
.
format
(
usage_key_string
,
user
)
log
.
debug
(
msg
)
raise
Http404
return
instance
...
...
@@ -764,7 +764,7 @@ def xqueue_callback(request, course_id, userid, mod_id, dispatch):
if
not
isinstance
(
header
,
dict
)
or
'lms_key'
not
in
header
:
raise
Http404
instance
=
find_target_student_module
(
request
,
userid
,
course_id
,
mod_id
)
instance
=
load_single_xblock
(
request
,
userid
,
course_id
,
mod_id
)
# Transfer 'queuekey' from xqueue response header to the data.
# This is required to use the interface defined by 'handle_ajax'
...
...
lms/djangoapps/courseware/tests/test_module_render.py
View file @
8d9d6ce0
...
...
@@ -160,8 +160,7 @@ class ModuleRenderTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
}
# Patch getmodule to return our mock module
with
patch
(
'courseware.module_render.find_target_student_module'
)
as
get_fake_module
:
get_fake_module
.
return_value
=
self
.
mock_module
with
patch
(
'courseware.module_render.load_single_xblock'
,
return_value
=
self
.
mock_module
):
# call xqueue_callback with our mocked information
request
=
self
.
request_factory
.
post
(
self
.
callback_url
,
data
)
render
.
xqueue_callback
(
request
,
self
.
course_key
,
self
.
mock_user
.
id
,
self
.
mock_module
.
id
,
self
.
dispatch
)
...
...
@@ -176,8 +175,7 @@ class ModuleRenderTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
'xqueue_body'
:
'hello world'
,
}
with
patch
(
'courseware.module_render.find_target_student_module'
)
as
get_fake_module
:
get_fake_module
.
return_value
=
self
.
mock_module
with
patch
(
'courseware.module_render.load_single_xblock'
,
return_value
=
self
.
mock_module
):
# Test with missing xqueue data
with
self
.
assertRaises
(
Http404
):
request
=
self
.
request_factory
.
post
(
self
.
callback_url
,
{})
...
...
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