Pass user_id and course_id to runtime in cms (dev) and tests.

This commit is contained in:
Alexander Kryklia
2013-09-05 16:44:09 +03:00
parent f6d9c077f0
commit e10577d6ad
3 changed files with 6 additions and 5 deletions

View File

@@ -81,7 +81,6 @@ def preview_component(request, location):
component,
'xmodule_edit.html'
)
return render_to_response('component.html', {
'preview': get_preview_html(request, component, 0),
'editor': component.runtime.render(component, None, 'studio_view').content,
@@ -104,7 +103,6 @@ def preview_module_system(request, preview_id, descriptor):
return lms_field_data(descriptor._field_data, student_data)
course_id = get_course_for_item(descriptor.location).location.course_id
return ModuleSystem(
ajax_url=reverse('preview_dispatch', args=[preview_id, descriptor.location.url(), '']).rstrip('/'),
# TODO (cpennington): Do we want to track how instructors are using the preview problems?
@@ -118,6 +116,8 @@ def preview_module_system(request, preview_id, descriptor):
xblock_field_data=preview_field_data,
can_execute_unsafe_code=(lambda: can_execute_unsafe_code(course_id)),
mixins=settings.XBLOCK_MIXINS,
course_id=course_id,
anonymous_student_id='student'
)

View File

@@ -40,7 +40,7 @@ open_ended_grading_interface = {
}
def get_test_system():
def get_test_system(course_id=''):
"""
Construct a test ModuleSystem instance.
@@ -66,7 +66,8 @@ def get_test_system():
node_path=os.environ.get("NODE_PATH", "/usr/local/lib/node_modules"),
xblock_field_data=lambda descriptor: descriptor._field_data,
anonymous_student_id='student',
open_ended_grading_interface=open_ended_grading_interface
open_ended_grading_interface= open_ended_grading_interface,
course_id=course_id
)

View File

@@ -86,7 +86,7 @@ class BaseTestXmodule(ModuleStoreTestCase):
data=self.DATA
)
self.runtime = get_test_system()
self.runtime = get_test_system(course_id='MITx/999/Robot_Super_Course')
# Allow us to assert that the template was called in the same way from
# different code paths while maintaining the type returned by render_template
self.runtime.render_template = lambda template, context: u'{!r}, {!r}'.format(template, sorted(context.items()))