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
e9bb8718
Commit
e9bb8718
authored
Aug 03, 2012
by
John Hess
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Transitioned to Django form. Made required tweaks in html. Still working on coffeescript
parent
39243a1b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
40 deletions
+42
-40
common/lib/xmodule/xmodule/js/src/survey/display.coffee
+4
-13
common/lib/xmodule/xmodule/survey_module.py
+27
-16
lms/templates/survey.html
+11
-11
No files found.
common/lib/xmodule/xmodule/js/src/survey/display.coffee
View file @
e9bb8718
class
@
Problem
class
@
Survey
constructor
:
(
element
)
->
@
el
=
$
(
element
).
find
(
'.
problem
s-wrapper'
)
@
el
=
$
(
element
).
find
(
'.
survey
s-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>"
)
...
...
common/lib/xmodule/xmodule/survey_module.py
View file @
e9bb8718
...
...
@@ -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
):
...
...
lms/templates/survey.html
View file @
e9bb8718
<
%
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>
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