Commit 5d403493 by Dhaval Adjodah

trying to figure out handle ajax/coffeescript

parent f8d3a024
...@@ -3,6 +3,7 @@ import logging ...@@ -3,6 +3,7 @@ import logging
from lxml import etree from lxml import etree
from pkg_resources import resource_string
from xmodule.x_module import XModule from xmodule.x_module import XModule
from xmodule.raw_module import RawDescriptor from xmodule.raw_module import RawDescriptor
...@@ -13,11 +14,11 @@ class SurveyModule(XModule): ...@@ -13,11 +14,11 @@ class SurveyModule(XModule):
video_time = 0 video_time = 0
icon_class = 'video' icon_class = 'video'
# js = {'coffee': [resource_string(__name__, 'js/src/capa/display.coffee')], js = {'coffee': [resource_string(__name__, 'js/src/survey/display.coffee')],
# 'js': [resource_string(__name__, 'js/src/capa/imageinput.js'), 'js': [resource_string(__name__, 'js/src/capa/imageinput.js'),
# resource_string(__name__, 'js/src/capa/schematic.js')]} resource_string(__name__, 'js/src/capa/schematic.js')]}
# js_module_name = "Problem" js_module_name = "Survey"
# css = {'scss': [resource_string(__name__, 'css/capa/display.scss')]} css = {'scss': [resource_string(__name__, 'css/capa/display.scss')]}
def __init__(self, system, location, definition, instance_state=None, shared_state=None, **kwargs): def __init__(self, system, location, definition, instance_state=None, shared_state=None, **kwargs):
XModule.__init__(self, system, location, definition, instance_state, shared_state, **kwargs) XModule.__init__(self, system, location, definition, instance_state, shared_state, **kwargs)
...@@ -33,12 +34,12 @@ class SurveyModule(XModule): ...@@ -33,12 +34,12 @@ class SurveyModule(XModule):
# <section format="Video" name="Welcome"> # <section format="Video" name="Welcome">
# <video youtube="0.75:izygArpw-Qo,1.0:p2Q6BrNhdh8,1.25:1EeWXzPdhSA,1.50:rABDYkeK0x8"/> # <video youtube="0.75:izygArpw-Qo,1.0:p2Q6BrNhdh8,1.25:1EeWXzPdhSA,1.50:rABDYkeK0x8"/>
# </section> # </section>
def get_html(self): # def get_html(self):
return self.system.render_template('problem_ajax.html', { # return self.system.render_template('problem_ajax.html', {
'element_id': self.location.html_id(), # 'element_id': self.location.html_id(),
'id': self.id, # 'id': self.id,
'ajax_url': self.system.ajax_url, # 'ajax_url': self.system.ajax_url,
}) # })
def handle_ajax(self, dispatch, get): def handle_ajax(self, dispatch, get):
...@@ -49,6 +50,18 @@ class SurveyModule(XModule): ...@@ -49,6 +50,18 @@ class SurveyModule(XModule):
# log.info(u"NEW POSITION {0}".format(self.position)) # log.info(u"NEW POSITION {0}".format(self.position))
# return json.dumps({'success':True}) # return json.dumps({'success':True})
# raise Http404() # raise Http404()
handlers = {
'problem_show': self.get_answer
}
if dispatch not in handlers:
print 'Error poop'
return 'Error'
# return json.dumps(d, cls=ComplexEncoder)
print "poop" print "poop"
print dispatch print dispatch
print get print get
...@@ -70,7 +83,10 @@ class SurveyModule(XModule): ...@@ -70,7 +83,10 @@ class SurveyModule(XModule):
return self.question_list return self.question_list
#dirty test: #dirty test:
def survey_context(self): def survey_context(self):
self.context = {'took_survey' : False, self.context = {'element_id': self.location.html_id(),
'id': self.id,
'ajax_url': self.system.ajax_url,
'took_survey' : False,
'survey_list' : self.survey_question_list(), 'survey_list' : self.survey_question_list(),
'survey_name' : self.name} 'survey_name' : self.name}
return self.context return self.context
......
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