Commit ff9cfa0f by Dhaval Adjodah

pre-handoff

parent e9bb8718
class @Survey class @Survey
constructor: (element) -> constructor: (element) ->
alert ("Im in ur coffee scripts!")
alert (@element_id)
@el = $(element).find('.surveys-wrapper') @el = $(element).find('.surveys-wrapper')
@id = @el.data('problem-id') @id = @el.data('problem-id')
@element_id = @el.attr('id') @element_id = @el.attr('id')
@url = @el.data('url') @url = @el.data('url')
alert ("Im in ur coffee scripts!")
alert (@element_id)
$: (selector) -> $: (selector) ->
$(selector, @el) $(selector, @el)
......
...@@ -7,22 +7,15 @@ from pkg_resources import resource_string ...@@ -7,22 +7,15 @@ 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
from django import forms
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class SurveyForm(forms.Form):
name_f=forms.CharField()
pass
class SurveyModule(XModule): class SurveyModule(XModule):
video_time = 0 video_time = 0
icon_class = 'video' icon_class = 'video'
js = {'coffee': [resource_string(__name__, 'js/src/survey/display.coffee')]} js = {'coffee': [resource_string(__name__, 'js/src/survey/display.coffee')]}
js_module_name = "Survey" 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):
...@@ -33,39 +26,31 @@ class SurveyModule(XModule): ...@@ -33,39 +26,31 @@ class SurveyModule(XModule):
self.question_list = [] self.question_list = []
for item in list(xmltree): for item in list(xmltree):
# self.question_list.append[{'type':item.get('type'),'question_name':item.get('question_name'),'label':item.get('label')}] # self.question_list.append[{'type':item.get('type'),'question_name':item.get('question_name'),'label':item.get('label')}]
if item.get('choices'):
else:
dic = {'type':item.get('type'),'question_name':item.get('question_name'),'label':item.get('label')} dic = {'type':item.get('type'),'question_name':item.get('question_name'),'label':item.get('label')}
self.question_list.append(dic) self.question_list.append(dic)
self.form_to_serve=SurveyForm()
# <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):
log.debug(u"GET {0}".format(get)) # log.debug(u"GET {0}".format(get))
log.debug(u"DISPATCH {0}".format(dispatch)) # log.debug(u"DISPATCH {0}".format(dispatch))
# if dispatch == 'goto_position':
handlers = { # self.position = int(float(get['position']))
'survey_save': self.save_survey # log.info(u"NEW POSITION {0}".format(self.position))
} # return json.dumps({'success':True})
# raise Http404()
if dispatch not in handlers:
print 'Error dispatch not in handlers'
return 'Error'
# return json.dumps(d, cls=ComplexEncoder)
print "handling dispatch"
print dispatch print dispatch
print get print get
...@@ -82,10 +67,6 @@ class SurveyModule(XModule): ...@@ -82,10 +67,6 @@ class SurveyModule(XModule):
# def get_instance_state(self): # def get_instance_state(self):
# return self.state # return self.state
def save_survey(self, request):
print "request recieved"
return None
def survey_question_list(self): def survey_question_list(self):
return self.question_list return self.question_list
#dirty test: #dirty test:
...@@ -99,11 +80,7 @@ class SurveyModule(XModule): ...@@ -99,11 +80,7 @@ class SurveyModule(XModule):
return self.context return self.context
def get_html(self): def get_html(self):
print "serving survey" return self.system.render_template('survey.html', self.survey_context())
return self.system.render_template('survey.html', {"form": self.form_to_serve,
"id": self.id,
"ajax_url": self.system.ajax_url,
"element_id": "some_element_id"})
class SurveyDescriptor(RawDescriptor): class SurveyDescriptor(RawDescriptor):
......
<%namespace name="survey_fields" file="survey_fields.html"/> <%namespace name="survey_fields" file="survey_fields.html"/>
<h2 class="survey-header"> <h2 class="survey-header">
Survey Form ${ survey_name }
</h2> </h2>
<section id="problem_${element_id}" class="surveys-wrapper" data-problem-id="${id}" data-url="${ajax_url}"> <section id="problem_${element_id}" class="surveys-wrapper" data-problem-id="${id}" data-url="${ajax_url}">
<section class="problem">
%if not took_survey:
${survey_fields.body(survey_list)}
%else:
<p>Thank you for your help! You can only take the survey once, and we already have your submission.</p>
%endif
<section class="action"> <section class="action">
<input type="hidden" name="problem_id" value="test_survey"> <input type="submit" id="" value="Submit Survey" />
${ form.as_p() }
<input class="save" type="button" value="Submit Survey">
</section>
</section> </section>
</section> </section>
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