Commit 459c1dab by Piotr Mitros

Using Ajax URL

parent b6808c39
...@@ -43,6 +43,7 @@ class LoncapaModule(XModule): ...@@ -43,6 +43,7 @@ class LoncapaModule(XModule):
{'problem':content, {'problem':content,
'id':self.filename, 'id':self.filename,
'check_button':check_button, 'check_button':check_button,
'ajax_url':self.ajax_url,
}) })
if encapsulate: if encapsulate:
html = '<div id="main_{id}">'.format(id=self.item_id)+html+"</div>" html = '<div id="main_{id}">'.format(id=self.item_id)+html+"</div>"
......
...@@ -173,8 +173,10 @@ def render_x_module(request, xml_module): ...@@ -173,8 +173,10 @@ def render_x_module(request, xml_module):
state = smod.state state = smod.state
# Create a new instance # Create a new instance
ajax_url = '/modx/'+module_type+'/'+module_id+'/'
instance=module_class(xml_module.toxml(), instance=module_class(xml_module.toxml(),
module_id, module_id,
ajax_url=ajax_url,
state=state) state=state)
# If instance wasn't already in the database, create it # If instance wasn't already in the database, create it
...@@ -201,7 +203,10 @@ def modx_dispatch(request, module=None, dispatch=None, id=None): ...@@ -201,7 +203,10 @@ def modx_dispatch(request, module=None, dispatch=None, id=None):
s=s[0] s=s[0]
dispatch=dispatch.split('?')[0] dispatch=dispatch.split('?')[0]
instance=modx_modules[module](s.xml, s.module_id, state=s.state)
ajax_url = '/modx/'+module+'/'+id+'/'
instance=modx_modules[module](s.xml, s.module_id, ajax_url=ajax_url, state=s.state)
html=instance.handle_ajax(dispatch, request.GET) html=instance.handle_ajax(dispatch, request.GET)
s.state=instance.get_state() s.state=instance.get_state()
s.grade=instance.get_score()['score'] s.grade=instance.get_score()['score']
......
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