Difficulty selectbox in Studio (based on new XBlockAside functionality). Include:
- adaptation asides to be imported from the XML - updating SplitMongo to handle XBlockAsides (CRUD operations) - updating Studio to handle XBlockAsides handler calls - updating xblock/core.js to properly init XBlockAsides JavaScript
This commit is contained in:
@@ -9,7 +9,8 @@ from django.http import Http404, HttpResponseBadRequest
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from edxmako.shortcuts import render_to_string
|
||||
|
||||
from openedx.core.lib.xblock_utils import replace_static_urls, wrap_xblock, wrap_fragment, request_token
|
||||
from openedx.core.lib.xblock_utils import replace_static_urls, wrap_xblock, wrap_fragment, wrap_xblock_aside,\
|
||||
request_token
|
||||
from xmodule.x_module import PREVIEW_VIEWS, STUDENT_VIEW, AUTHOR_VIEW
|
||||
from xmodule.contentstore.django import contentstore
|
||||
from xmodule.error_module import ErrorDescriptor
|
||||
@@ -19,6 +20,7 @@ from xmodule.services import SettingsService
|
||||
from xmodule.modulestore.django import modulestore, ModuleI18nService
|
||||
from xmodule.mixin import wrap_with_license
|
||||
from opaque_keys.edx.keys import UsageKey
|
||||
from opaque_keys.edx.asides import AsideUsageKeyV1
|
||||
from xmodule.x_module import ModuleSystem
|
||||
from xblock.runtime import KvsFieldData
|
||||
from xblock.django.request import webob_to_django_response, django_to_webob_request
|
||||
@@ -56,8 +58,18 @@ def preview_handler(request, usage_key_string, handler, suffix=''):
|
||||
"""
|
||||
usage_key = UsageKey.from_string(usage_key_string)
|
||||
|
||||
descriptor = modulestore().get_item(usage_key)
|
||||
instance = _load_preview_module(request, descriptor)
|
||||
if isinstance(usage_key, AsideUsageKeyV1):
|
||||
descriptor = modulestore().get_item(usage_key.usage_key)
|
||||
for aside in descriptor.runtime.get_asides(descriptor):
|
||||
if aside.scope_ids.block_type == usage_key.aside_type:
|
||||
asides = [aside]
|
||||
instance = aside
|
||||
break
|
||||
else:
|
||||
descriptor = modulestore().get_item(usage_key)
|
||||
instance = _load_preview_module(request, descriptor)
|
||||
asides = []
|
||||
|
||||
# Let the module handle the AJAX
|
||||
req = django_to_webob_request(request)
|
||||
try:
|
||||
@@ -80,6 +92,7 @@ def preview_handler(request, usage_key_string, handler, suffix=''):
|
||||
log.exception("error processing ajax call")
|
||||
raise
|
||||
|
||||
modulestore().update_item(descriptor, request.user.id, asides=asides)
|
||||
return webob_to_django_response(resp)
|
||||
|
||||
|
||||
@@ -184,6 +197,15 @@ def _preview_module_system(request, descriptor, field_data):
|
||||
_studio_wrap_xblock,
|
||||
]
|
||||
|
||||
wrappers_asides = [
|
||||
partial(
|
||||
wrap_xblock_aside,
|
||||
'PreviewRuntime',
|
||||
usage_id_serializer=unicode,
|
||||
request_token=request_token(request)
|
||||
)
|
||||
]
|
||||
|
||||
if settings.FEATURES.get("LICENSING", False):
|
||||
# stick the license wrapper in front
|
||||
wrappers.insert(0, wrap_with_license)
|
||||
@@ -208,6 +230,7 @@ def _preview_module_system(request, descriptor, field_data):
|
||||
|
||||
# Set up functions to modify the fragment produced by student_view
|
||||
wrappers=wrappers,
|
||||
wrappers_asides=wrappers_asides,
|
||||
error_descriptor_class=ErrorDescriptor,
|
||||
get_user_role=lambda: get_user_role(request.user, course_id),
|
||||
# Get the raw DescriptorSystem, not the CombinedSystem
|
||||
|
||||
Reference in New Issue
Block a user