Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
ff9cfa0f
Commit
ff9cfa0f
authored
Aug 03, 2012
by
Dhaval Adjodah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pre-handoff
parent
e9bb8718
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
50 deletions
+27
-50
common/lib/xmodule/xmodule/js/src/survey/display.coffee
+2
-2
common/lib/xmodule/xmodule/survey_module.py
+17
-40
lms/templates/survey.html
+8
-8
No files found.
common/lib/xmodule/xmodule/js/src/survey/display.coffee
View file @
ff9cfa0f
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
)
...
...
common/lib/xmodule/xmodule/survey_module.py
View file @
ff9cfa0f
...
...
@@ -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')}]
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
)
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"/>
# </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
):
...
...
lms/templates/survey.html
View file @
ff9cfa0f
<
%
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"
>
%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=
"hidden"
name=
"problem_id"
value=
"test_survey"
>
${ form.as_p() }
<input
class=
"save"
type=
"button"
value=
"Submit Survey"
>
</section>
<input
type=
"submit"
id=
""
value=
"Submit Survey"
/>
</section>
</section>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment