Commit ff9cfa0f by Dhaval Adjodah

pre-handoff

parent e9bb8718
class @Survey
constructor: (element) ->
alert ("Im in ur coffee scripts!")
alert (@element_id)
@el = $(element).find('.surveys-wrapper')
@id = @el.data('problem-id')
@element_id = @el.attr('id')
@url = @el.data('url')
alert ("Im in ur coffee scripts!")
alert (@element_id)
$: (selector) ->
$(selector, @el)
......
......@@ -7,22 +7,15 @@ from pkg_resources import resource_string
from xmodule.x_module import XModule
from xmodule.raw_module import RawDescriptor
from django import forms
log = logging.getLogger(__name__)
class SurveyForm(forms.Form):
name_f=forms.CharField()
pass
class SurveyModule(XModule):
video_time = 0
icon_class = 'video'
js = {'coffee': [resource_string(__name__, 'js/src/survey/display.coffee')]}
js_module_name = "Survey"
css = {'scss': [resource_string(__name__, 'css/capa/display.scss')]}
def __init__(self, system, location, definition, instance_state=None, shared_state=None, **kwargs):
......@@ -33,39 +26,31 @@ class SurveyModule(XModule):
self.question_list = []
for item in list(xmltree):
# self.question_list.append[{'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.form_to_serve=SurveyForm()
if item.get('choices'):
else:
dic = {'type':item.get('type'),'question_name':item.get('question_name'),'label':item.get('label')}
self.question_list.append(dic)
# <section format="Video" name="Welcome">
# <video youtube="0.75:izygArpw-Qo,1.0:p2Q6BrNhdh8,1.25:1EeWXzPdhSA,1.50:rABDYkeK0x8"/>
# </section>
# def get_html(self):
# return self.system.render_template('problem_ajax.html', {
# 'element_id': self.location.html_id(),
# 'id': self.id,
# 'ajax_url': self.system.ajax_url,
# })
def get_html(self):
return self.system.render_template('problem_ajax.html', {
'element_id': self.location.html_id(),
'id': self.id,
'ajax_url': self.system.ajax_url,
})
def handle_ajax(self, dispatch, get):
log.debug(u"GET {0}".format(get))
log.debug(u"DISPATCH {0}".format(dispatch))
handlers = {
'survey_save': self.save_survey
}
if dispatch not in handlers:
print 'Error dispatch not in handlers'
return 'Error'
# return json.dumps(d, cls=ComplexEncoder)
print "handling dispatch"
# log.debug(u"GET {0}".format(get))
# log.debug(u"DISPATCH {0}".format(dispatch))
# if dispatch == 'goto_position':
# self.position = int(float(get['position']))
# log.info(u"NEW POSITION {0}".format(self.position))
# return json.dumps({'success':True})
# raise Http404()
print dispatch
print get
......@@ -82,10 +67,6 @@ class SurveyModule(XModule):
# def get_instance_state(self):
# return self.state
def save_survey(self, request):
print "request recieved"
return None
def survey_question_list(self):
return self.question_list
#dirty test:
......@@ -99,11 +80,7 @@ class SurveyModule(XModule):
return self.context
def get_html(self):
print "serving survey"
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"})
return self.system.render_template('survey.html', self.survey_context())
class SurveyDescriptor(RawDescriptor):
......
<%namespace name="survey_fields" file="survey_fields.html"/>
<h2 class="survey-header">
Survey Form
${ survey_name }
</h2>
<section id="problem_${element_id}" class="surveys-wrapper" data-problem-id="${id}" data-url="${ajax_url}">
<section class="problem">
<section class="action">
<input type="hidden" name="problem_id" value="test_survey">
${ form.as_p() }
<input class="save" type="button" value="Submit Survey">
</section>
</section>
</section>
<section id="problem_${element_id}" class="surveys-wrapper" data-problem-id="${id}" data-url="${ajax_url}">
%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">
<input type="submit" id="" value="Submit Survey" />
</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