Commit e9bb8718 by John Hess

Transitioned to Django form. Made required tweaks in html. Still working on coffeescript

parent 39243a1b
class @Problem
class @Survey
constructor: (element) ->
@el = $(element).find('.problems-wrapper')
@el = $(element).find('.surveys-wrapper')
@id = @el.data('problem-id')
@element_id = @el.attr('id')
@url = @el.data('url')
@render()
alert ("Im in ur coffee scripts!")
alert (@element_id)
$: (selector) ->
$(selector, @el)
......@@ -24,16 +25,6 @@ class @Problem
@el.attr progress: response.progress_status
@el.trigger('progressChanged')
render: (content) ->
if content
@el.html(content)
@bind()
else
$.postWithPrefix "#{@url}/problem_get", (response) =>
@el.html(response.html)
@executeProblemScripts()
@bind()
executeProblemScripts: ->
@el.find(".script_placeholder").each (index, placeholder) ->
s = $("<script>")
......
......@@ -7,17 +7,22 @@ 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': [resource_string(__name__, 'js/src/capa/imageinput.js'),
resource_string(__name__, 'js/src/capa/schematic.js')]}
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):
......@@ -29,7 +34,9 @@ class SurveyModule(XModule):
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.question_list.append(dic)
self.form_to_serve=SurveyForm()
# <section format="Video" name="Welcome">
# <video youtube="0.75:izygArpw-Qo,1.0:p2Q6BrNhdh8,1.25:1EeWXzPdhSA,1.50:rABDYkeK0x8"/>
......@@ -43,26 +50,22 @@ class SurveyModule(XModule):
def handle_ajax(self, dispatch, get):
# 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()
log.debug(u"GET {0}".format(get))
log.debug(u"DISPATCH {0}".format(dispatch))
handlers = {
'problem_show': self.get_answer
'survey_save': self.save_survey
}
if dispatch not in handlers:
print 'Error poop'
print 'Error dispatch not in handlers'
return 'Error'
# return json.dumps(d, cls=ComplexEncoder)
print "poop"
print "handling dispatch"
print dispatch
print get
......@@ -79,6 +82,10 @@ 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:
......@@ -92,7 +99,11 @@ class SurveyModule(XModule):
return self.context
def get_html(self):
return self.system.render_template('survey.html', self.survey_context())
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"})
class SurveyDescriptor(RawDescriptor):
......
<%namespace name="survey_fields" file="survey_fields.html"/>
<h2 class="survey-header">
${ survey_name }
Survey Form
</h2>
<section class="survey" class="main-content">
<form id="survey_form">
%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
<input type="submit" id="" value="Submit Survey" />
</form>
<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>
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