Pass S3 interface in module_render

This commit is contained in:
Vik Paruchuri
2013-02-11 17:54:37 -05:00
parent 120c0e139e
commit 01e8fe8d08
2 changed files with 24 additions and 4 deletions

View File

@@ -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)