Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xblock-poll
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
OpenEdx
xblock-poll
Commits
13de8d1b
Commit
13de8d1b
authored
Nov 18, 2014
by
Jonathan Piacenti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CSS for results should match specification.
parent
26b4895d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
9 deletions
+34
-9
poll/poll.py
+10
-1
poll/public/css/poll.css
+10
-2
poll/public/html/poll.html
+3
-3
poll/public/html/poll_edit.html
+7
-0
poll/public/js/poll_edit.js
+4
-3
No files found.
poll/poll.py
View file @
13de8d1b
...
@@ -8,7 +8,7 @@ from markdown import markdown
...
@@ -8,7 +8,7 @@ from markdown import markdown
import
pkg_resources
import
pkg_resources
from
xblock.core
import
XBlock
from
xblock.core
import
XBlock
from
xblock.fields
import
Scope
,
List
,
String
,
Dict
,
UserScope
,
BlockScope
from
xblock.fields
import
Scope
,
List
,
String
,
Dict
from
xblock.fragment
import
Fragment
from
xblock.fragment
import
Fragment
...
@@ -17,6 +17,7 @@ class PollBlock(XBlock):
...
@@ -17,6 +17,7 @@ class PollBlock(XBlock):
Poll XBlock. Allows a teacher to poll users, and presents the results so
Poll XBlock. Allows a teacher to poll users, and presents the results so
far of the poll to the user when finished.
far of the poll to the user when finished.
"""
"""
title
=
String
(
default
=
'Poll'
)
question
=
String
(
default
=
'What is your favorite color?'
)
question
=
String
(
default
=
'What is your favorite color?'
)
answers
=
List
(
answers
=
List
(
default
=
((
'Red'
,
'Red'
),
(
'Blue'
,
'Blue'
),
(
'Green'
,
'Green'
),
default
=
((
'Red'
,
'Red'
),
(
'Blue'
,
'Blue'
),
(
'Green'
,
'Green'
),
...
@@ -102,6 +103,7 @@ class PollBlock(XBlock):
...
@@ -102,6 +103,7 @@ class PollBlock(XBlock):
# Offset so choices will always be True.
# Offset so choices will always be True.
'answers'
:
self
.
answers
,
'answers'
:
self
.
answers
,
'question'
:
markdown
(
clean
(
self
.
question
)),
'question'
:
markdown
(
clean
(
self
.
question
)),
'title'
:
self
.
title
,
'js_template'
:
js_template
,
'js_template'
:
js_template
,
})
})
...
@@ -133,6 +135,7 @@ class PollBlock(XBlock):
...
@@ -133,6 +135,7 @@ class PollBlock(XBlock):
js_template
=
self
.
resource_string
(
'/public/handlebars/studio.handlebars'
)
js_template
=
self
.
resource_string
(
'/public/handlebars/studio.handlebars'
)
context
.
update
({
context
.
update
({
'question'
:
clean
(
self
.
question
),
'question'
:
clean
(
self
.
question
),
'title'
:
self
.
title
,
'js_template'
:
js_template
'js_template'
:
js_template
})
})
context
=
Context
(
context
)
context
=
Context
(
context
)
...
@@ -152,6 +155,11 @@ class PollBlock(XBlock):
...
@@ -152,6 +155,11 @@ class PollBlock(XBlock):
def
studio_submit
(
self
,
data
,
suffix
=
''
):
def
studio_submit
(
self
,
data
,
suffix
=
''
):
# I wonder if there's something for live validation feedback already.
# I wonder if there's something for live validation feedback already.
result
=
{
'success'
:
True
,
'errors'
:
[]}
result
=
{
'success'
:
True
,
'errors'
:
[]}
if
'title'
not
in
data
or
not
data
[
'title'
]:
# This can be blank, if it needs to be.
title
=
''
else
:
title
=
data
[
'title'
][:
200
]
if
'question'
not
in
data
or
not
data
[
'question'
]:
if
'question'
not
in
data
or
not
data
[
'question'
]:
result
[
'errors'
]
.
append
(
"You must specify a question."
)
result
[
'errors'
]
.
append
(
"You must specify a question."
)
result
[
'success'
]
=
False
result
[
'success'
]
=
False
...
@@ -174,6 +182,7 @@ class PollBlock(XBlock):
...
@@ -174,6 +182,7 @@ class PollBlock(XBlock):
continue
continue
if
key
in
poll_order
:
if
key
in
poll_order
:
answers
.
append
((
key
,
value
))
answers
.
append
((
key
,
value
))
self
.
title
=
title
if
not
len
(
answers
)
>
1
:
if
not
len
(
answers
)
>
1
:
result
[
'errors'
]
.
append
(
result
[
'errors'
]
.
append
(
...
...
poll/public/css/poll.css
View file @
13de8d1b
.poll-answer
{
.poll-answer
{
margin-left
:
1em
;
margin-left
:
1em
;
font-weight
:
bold
;
font-weight
:
bold
;
display
:
inline-block
;
}
}
.percentage-gauge
{
.percentage-gauge
{
display
:
inline-block
;
display
:
inline-block
;
...
@@ -21,11 +22,18 @@
...
@@ -21,11 +22,18 @@
}
}
ul
.poll-answers
,
ul
.poll-answers-results
{
ul
.poll-answers
,
ul
.poll-answers-results
{
list-style-type
:
none
;
list-style-type
:
none
!important
;
display
:
table
;
max-width
:
80%
;
max-width
:
80%
;
}
}
li
.poll-answer
{
display
:
block
;
}
ul
.poll-answers-results
{
display
:
table
;
}
li
.poll-result
{
li
.poll-result
{
width
:
100%
;
width
:
100%
;
display
:
table-row
;
display
:
table-row
;
...
...
poll/public/html/poll.html
View file @
13de8d1b
...
@@ -3,13 +3,13 @@
...
@@ -3,13 +3,13 @@
{# If no form is present, the Javascript will load the results instead. #}
{# If no form is present, the Javascript will load the results instead. #}
{% if not choice %}
{% if not choice %}
<form>
<form>
<h2>
Poll
</h2>
<h2>
{{ title }}
</h2>
{{question|safe}}
{{question|safe}}
<ul
class=
"poll-answers"
>
<ul
class=
"poll-answers"
>
{% for key, answer in answers %}
{% for key, answer in answers %}
<li
class=
"poll-answer"
>
<li
class=
"poll-answer"
>
<input
type=
"radio"
name=
"choice"
id=
"answer-{{
number
}}"
value=
"{{key}}"
>
<input
type=
"radio"
name=
"choice"
id=
"answer-{{
key
}}"
value=
"{{key}}"
>
<label
class=
"poll-answer"
for=
"answer-{{
number
}}"
>
{{answer}}
</label>
<label
class=
"poll-answer"
for=
"answer-{{
key
}}"
>
{{answer}}
</label>
</li>
</li>
{% endfor %}
{% endfor %}
</ul>
</ul>
...
...
poll/public/html/poll_edit.html
View file @
13de8d1b
...
@@ -3,6 +3,13 @@
...
@@ -3,6 +3,13 @@
<form
id=
"poll-form"
>
<form
id=
"poll-form"
>
<ul
class=
"list-input settings-list"
id=
"poll-line-items"
>
<ul
class=
"list-input settings-list"
id=
"poll-line-items"
>
<li
class=
"field comp-setting-entry is-set"
>
<li
class=
"field comp-setting-entry is-set"
>
<div
class=
"wrapper-comp-setting"
>
<label
class=
"label setting-label"
for=
"poll-title"
>
Title
</label>
<input
class=
"input setting-input"
name=
"title"
id=
"poll-title"
value=
"{{title}}"
type=
"text"
/>
</div>
<span
class=
"tip setting-help"
>
Enter a title to act as the header for this Poll.
</span>
</li>
<li
class=
"field comp-setting-entry is-set"
>
<h2><label
for=
"question-editor"
>
Question/Prompt
</label></h2>
<h2><label
for=
"question-editor"
>
Question/Prompt
</label></h2>
<a
href=
"//daringfireball.net/projects/markdown/syntax"
target=
"_blank"
>
Markdown Syntax
</a>
is supported.
<a
href=
"//daringfireball.net/projects/markdown/syntax"
target=
"_blank"
>
Markdown Syntax
</a>
is supported.
<div
id=
"question-editor-container"
>
<div
id=
"question-editor-container"
>
...
...
poll/public/js/poll_edit.js
View file @
13de8d1b
...
@@ -32,11 +32,11 @@ function PollEditBlock(runtime, element) {
...
@@ -32,11 +32,11 @@ function PollEditBlock(runtime, element) {
pollLineItems
.
last
().
scrollTop
();
pollLineItems
.
last
().
scrollTop
();
});
});
$
(
element
).
find
(
'.cancel-button'
).
bind
(
'click'
,
function
()
{
$
(
element
).
find
(
'.cancel-button'
,
element
).
bind
(
'click'
,
function
()
{
runtime
.
notify
(
'cancel'
,
{});
runtime
.
notify
(
'cancel'
,
{});
});
});
$
(
element
).
find
(
'.save-button'
).
bind
(
'click'
,
function
()
{
$
(
element
).
find
(
'.save-button'
,
element
).
bind
(
'click'
,
function
()
{
var
handlerUrl
=
runtime
.
handlerUrl
(
element
,
'studio_submit'
);
var
handlerUrl
=
runtime
.
handlerUrl
(
element
,
'studio_submit'
);
var
data
=
{};
var
data
=
{};
var
poll_order
=
[];
var
poll_order
=
[];
...
@@ -46,7 +46,8 @@ function PollEditBlock(runtime, element) {
...
@@ -46,7 +46,8 @@ function PollEditBlock(runtime, element) {
poll_order
.
push
(
this
.
name
);
poll_order
.
push
(
this
.
name
);
}
}
});
});
data
[
'question'
]
=
$
(
'#question-editor'
).
val
();
data
[
'title'
]
=
$
(
'#poll-title'
,
element
).
val
();
data
[
'question'
]
=
$
(
'#question-editor'
,
element
).
val
();
data
[
'poll_order'
]
=
poll_order
;
data
[
'poll_order'
]
=
poll_order
;
function
check_return
(
data
)
{
function
check_return
(
data
)
{
if
(
data
[
'success'
])
{
if
(
data
[
'success'
])
{
...
...
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