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
d597ac4c
Commit
d597ac4c
authored
Jan 25, 2013
by
Alexander Kryklia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
logic of polls rendering now in template
parent
38a1f40b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
25 deletions
+17
-25
common/lib/xmodule/xmodule/poll_module.py
+6
-23
lms/templates/poll.html
+11
-2
No files found.
common/lib/xmodule/xmodule/poll_module.py
View file @
d597ac4c
...
@@ -90,7 +90,7 @@ class PollModule(XModule):
...
@@ -90,7 +90,7 @@ class PollModule(XModule):
'element_id'
:
self
.
html_id
,
'element_id'
:
self
.
html_id
,
'element_class'
:
self
.
html_class
,
'element_class'
:
self
.
html_class
,
'ajax_url'
:
self
.
system
.
ajax_url
,
'ajax_url'
:
self
.
system
.
ajax_url
,
'poll_
units
'
:
self
.
parse_sequence
(
self
.
sequence
),
'poll_
chain
'
:
self
.
parse_sequence
(
self
.
sequence
),
'configuration_json'
:
json
.
dumps
({}),
'configuration_json'
:
json
.
dumps
({}),
'poll_units'
:
self
.
poll_units_list
'poll_units'
:
self
.
poll_units_list
}
}
...
@@ -101,31 +101,14 @@ class PollModule(XModule):
...
@@ -101,31 +101,14 @@ class PollModule(XModule):
def
get_poll_unit_html
(
self
,
i
,
question
,
css_class
):
def
get_poll_unit_html
(
self
,
i
,
question
,
css_class
):
""" """
""" """
return
"""
return
"""
<div id="poll_unit_{poll_number}" class="{css_class} polls">
"""
.
format
(
poll_number
=
i
,
question
=
question
,
css_class
=
css_class
)
{question}
<div class="vote_and_submit">
<div id="vote_block-{poll_number}" class="vote">
<a class="upvote">Yes</a>
<a class="downvote">No</a>
</div>
</div>
<div class="graph_answer"></div>
</div>"""
.
format
(
poll_number
=
i
,
question
=
question
,
css_class
=
css_class
)
def
parse_sequence
(
self
,
html_string
):
def
parse_sequence
(
self
,
html_string
):
""" substitute sequence """
""" substitute sequence """
poll_units
=
html
.
fromstring
(
html_string
)
.
xpath
(
'//unit'
)
return
[(
stringify_children
(
pu
.
xpath
(
'//question'
)[
0
]),
for
i
,
pu
in
enumerate
(
poll_units
):
(
pu
.
get
(
'plot'
,
"no"
),
pu
.
get
(
'next_yes'
,
"end"
),
if
i
==
0
:
pu
.
get
(
'next_no'
,
"end"
),
pu
.
get
(
'id'
)))
css_class
=
''
for
pu
in
html
.
fromstring
(
html_string
)
.
xpath
(
'//unit'
)]
else
:
css_class
=
'hidden'
pu_question
=
stringify_children
(
pu
.
xpath
(
'//question'
)[
0
])
pu_html
=
self
.
get_poll_unit_html
(
i
,
pu_question
,
css_class
)
pu_controls
=
(
pu
.
get
(
'plot'
,
"no"
),
pu
.
get
(
'next_yes'
,
"end"
),
pu
.
get
(
'next_no'
,
"end"
))
self
.
poll_units_list
.
append
((
pu_html
,
pu_controls
))
# import ipdb; ipdb.set_trace()
class
PollDescriptor
(
MakoModuleDescriptor
,
XmlDescriptor
):
class
PollDescriptor
(
MakoModuleDescriptor
,
XmlDescriptor
):
...
...
lms/templates/poll.html
View file @
d597ac4c
...
@@ -13,7 +13,16 @@
...
@@ -13,7 +13,16 @@
<!-- Main HTML. -->
<!-- Main HTML. -->
${element_html}
${element_html}
% for poll_unit, poll_unit_controls in poll_units:
% for question, controls in poll_chain:
${poll_unit}
<div
id=
"poll_unit_${loop.index}"
class=
"${'' if loop.index == 0 else 'hidden'} polls"
>
${question}
<div
class=
"vote_and_submit"
>
<div
id=
"vote_block-${loop.index}"
class=
"vote"
>
<a
class=
"upvote"
>
Yes
</a>
<a
class=
"downvote"
>
No
</a>
</div>
</div>
<div
class=
"graph_answer"
></div>
</div>
% endfor
% endfor
</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