Commit 01e8fe8d by Vik Paruchuri

Pass S3 interface in module_render

parent 120c0e13
......@@ -870,8 +870,7 @@ class ModuleSystem(object):
node_path="",
anonymous_student_id='',
course_id=None,
peer_grading_interface=None,
staff_grading_interface=None,
open_ended_grading_interface=None,
s3_interface=None):
'''
Create a closure around the system environment.
......@@ -923,8 +922,7 @@ class ModuleSystem(object):
self.anonymous_student_id = anonymous_student_id
self.course_id = course_id
self.user_is_staff = user is not None and user.is_staff
self.peer_grading_interface = peer_grading_interface
self.staff_grading_interface = staff_grading_interface
self.open_ended_grading_interface = open_ended_grading_interface
self.s3_interface = s3_interface
def get(self, attr):
......
......@@ -226,6 +226,26 @@ def _get_module(user, request, descriptor, student_module_cache, course_id,
'waittime': settings.XQUEUE_WAITTIME_BETWEEN_REQUESTS
}
def get_or_default(key, default):
getattr(settings, key, default)
#This is a hacky way to pass settings to the combined open ended xmodule
#It needs an S3 interface to upload images to S3
#It needs the open ended grading interface in order to get peer grading to be done
#TODO: refactor these settings into module-specific settings when possible.
#this first checks to see if the descriptor is the correct one, and only sends settings if it is
is_descriptor_combined_open_ended = descriptor.__class__.__name__ == 'CombinedOpenEndedDescriptor'
open_ended_grading_interface = None
s3_interface = None
if is_descriptor_combined_open_ended:
open_ended_grading_interface = settings.OPEN_ENDED_GRADING_INTERFACE
s3_interface = {
'access_key' : get_or_default('AWS_ACCESS_KEY_ID',''),
'secret_access_key' : get_or_default('AWS_SECRET_ACCESS_KEY',''),
'storage_bucket_name' : get_or_default('AWS_STORAGE_BUCKET_NAME','')
}
def inner_get_module(descriptor):
"""
Delegate to get_module. It does an access check, so may return None
......@@ -255,6 +275,8 @@ def _get_module(user, request, descriptor, student_module_cache, course_id,
node_path=settings.NODE_PATH,
anonymous_student_id=unique_id_for_user(user),
course_id=course_id,
open_ended_grading_interface=open_ended_grading_interface,
s3_interface=s3_interface,
)
# pass position specified in URL to module through ModuleSystem
system.set('position', position)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment