Commit 236c3dc5 by kimth

modx_dispatch handles new/old problem_check ajax

parent 51fc69da
...@@ -14,6 +14,7 @@ class @Problem ...@@ -14,6 +14,7 @@ class @Problem
window.update_schematics() window.update_schematics()
@$('section.action input:button').click @refreshAnswers @$('section.action input:button').click @refreshAnswers
@$('section.action input.check').click @check_fd @$('section.action input.check').click @check_fd
#@$('section.action input.check').click @check
@$('section.action input.reset').click @reset @$('section.action input.reset').click @reset
@$('section.action input.show').click @show @$('section.action input.show').click @show
@$('section.action input.save').click @save @$('section.action input.save').click @save
......
import json import json
import logging import logging
from urlparse import parse_qs
from django.conf import settings from django.conf import settings
from django.http import Http404 from django.http import Http404
...@@ -14,6 +15,7 @@ from static_replace import replace_urls ...@@ -14,6 +15,7 @@ from static_replace import replace_urls
from xmodule.exceptions import NotFoundError from xmodule.exceptions import NotFoundError
from xmodule.x_module import ModuleSystem from xmodule.x_module import ModuleSystem
from xmodule_modifiers import replace_static_urls, add_histogram, wrap_xmodule from xmodule_modifiers import replace_static_urls, add_histogram, wrap_xmodule
import xqueue_interface
log = logging.getLogger("mitx.courseware") log = logging.getLogger("mitx.courseware")
...@@ -270,16 +272,16 @@ def modx_dispatch(request, dispatch=None, id=None): ...@@ -270,16 +272,16 @@ def modx_dispatch(request, dispatch=None, id=None):
- id -- the module id. Used to look up the XModule instance - id -- the module id. Used to look up the XModule instance
''' '''
# ''' (fix emacs broken parsing) # ''' (fix emacs broken parsing)
print ' THK: module_render.modx_dispatch' post = request.POST.copy()
print dispatch
print request.POST.keys() # Catch the use of FormData in xmodule frontend. After this block, the 'post' dict
print request.FILES.keys() # is functionally equivalent before- and after- the use of FormData
if request.POST.has_key('answers'): # TODO: A more elegant solution?
print request.POST['answers'] if request.POST.has_key('_answers_querystring'):
for filename in request.FILES.keys(): post = parse_qs(request.POST.get('_answers_querystring'))
uploadedFile = request.FILES.get(filename) for key in post.keys():
print uploadedFile.read() post[key] = post[key][0] # parse_qs returns { key: list }
student_module_cache = StudentModuleCache(request.user, modulestore().get_item(id)) student_module_cache = StudentModuleCache(request.user, modulestore().get_item(id))
instance, instance_module, shared_module, module_type = get_module(request.user, request, id, student_module_cache) instance, instance_module, shared_module, module_type = get_module(request.user, request, id, student_module_cache)
...@@ -292,7 +294,7 @@ def modx_dispatch(request, dispatch=None, id=None): ...@@ -292,7 +294,7 @@ def modx_dispatch(request, dispatch=None, id=None):
# Let the module handle the AJAX # Let the module handle the AJAX
try: try:
ajax_return = instance.handle_ajax(dispatch, request.POST) ajax_return = instance.handle_ajax(dispatch, post)
except NotFoundError: except NotFoundError:
log.exception("Module indicating to user that request doesn't exist") log.exception("Module indicating to user that request doesn't exist")
raise Http404 raise Http404
......
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