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
edx
xblock-poll
Commits
c3d895c4
Commit
c3d895c4
authored
Feb 17, 2015
by
Jonathan Piacenti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added counter display for polls with maximum submissions greater than 1.
parent
00e634e3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
1 deletions
+44
-1
poll/poll.py
+9
-1
poll/public/css/poll.css
+4
-0
poll/public/html/poll.html
+4
-0
poll/public/html/survey.html
+4
-0
poll/public/js/poll.js
+7
-0
tests/integration/test_max_submissions.py
+16
-0
No files found.
poll/poll.py
View file @
c3d895c4
...
...
@@ -303,6 +303,8 @@ class PollBlock(PollBase):
'url_name'
:
getattr
(
self
,
'url_name'
,
''
),
'display_name'
:
self
.
display_name
,
'can_vote'
:
self
.
can_vote
(),
'max_submissions'
:
self
.
max_submissions
,
'submissions_count'
:
self
.
submissions_count
,
})
if
self
.
choice
:
...
...
@@ -393,6 +395,8 @@ class PollBlock(PollBase):
result
[
'success'
]
=
True
result
[
'can_vote'
]
=
self
.
can_vote
()
result
[
'submissions_count'
]
=
self
.
submissions_count
result
[
'max_submissions'
]
=
self
.
max_submissions
self
.
send_vote_event
({
'choice'
:
self
.
choice
})
...
...
@@ -504,7 +508,9 @@ class SurveyBlock(PollBase):
# The SDK doesn't set url_name.
'url_name'
:
getattr
(
self
,
'url_name'
,
''
),
'block_name'
:
self
.
block_name
,
'can_vote'
:
self
.
can_vote
()
'can_vote'
:
self
.
can_vote
(),
'submissions_count'
:
self
.
submissions_count
,
'max_submissions'
:
self
.
max_submissions
,
})
return
self
.
create_fragment
(
...
...
@@ -739,6 +745,8 @@ class SurveyBlock(PollBase):
self
.
send_vote_event
({
'choices'
:
self
.
choices
})
result
[
'can_vote'
]
=
self
.
can_vote
()
result
[
'submissions_count'
]
=
self
.
submissions_count
result
[
'max_submissions'
]
=
self
.
max_submissions
return
result
...
...
poll/public/css/poll.css
View file @
c3d895c4
...
...
@@ -207,3 +207,7 @@ th.survey-answer {
.poll-hidden
{
display
:
none
;
}
.poll-submissions-count
{
font-weight
:
bold
;
}
poll/public/html/poll.html
View file @
c3d895c4
...
...
@@ -27,6 +27,10 @@
<input
class=
"input-main"
type=
"button"
name=
"poll-submit"
value=
"{% if choice %}Resubmit{% else %}Submit{% endif %}"
disabled
/>
</form>
<div
class=
"poll-voting-thanks{% if not choice or can_vote %} poll-hidden{% endif %}"
><span>
Thank you for your submission!
</span></div>
<div
class=
"poll-submissions-count poll-hidden"
>
You have used
<span
class=
"poll-current-count"
>
{{ submissions_count }}
</span>
out of
<span
class=
"poll-max-submissions"
>
{{ max_submissions }}
</span>
submissions.
</div>
{% if feedback %}
<div
class=
"poll-feedback-container{% if not choice %} poll-hidden{% endif %}"
>
<hr
/>
...
...
poll/public/html/survey.html
View file @
c3d895c4
...
...
@@ -34,6 +34,10 @@
<input
class=
"input-main"
type=
"button"
name=
"poll-submit"
value=
"{% if choices and can_vote %}Resubmit{% else %}Submit{% endif %}"
disabled
/>
</form>
<div
class=
"poll-voting-thanks{% if not choices or can_vote %} poll-hidden{% endif %}"
><span>
Thank you for your submission!
</span></div>
<div
class=
"poll-submissions-count poll-hidden"
>
You have used
<span
class=
"poll-current-count"
>
{{ submissions_count }}
</span>
out of
<span
class=
"poll-max-submissions"
>
{{ max_submissions }}
</span>
submissions.
</div>
{% if feedback %}
<div
class=
"poll-feedback-container{% if not choices %} poll-hidden{% endif %}"
>
<hr
/>
...
...
poll/public/js/poll.js
View file @
c3d895c4
...
...
@@ -16,6 +16,9 @@ function PollUtil (runtime, element, pollType) {
self
.
getResults
({
'success'
:
true
});
return
false
;
}
if
(
parseInt
(
$
(
'.poll-max-submissions'
).
text
())
>
1
&&
parseInt
(
$
(
'.poll-current-count'
).
text
())
>
0
)
{
$
(
'.poll-submissions-count'
,
element
).
show
();
}
return
true
;
};
...
...
@@ -112,6 +115,10 @@ function PollUtil (runtime, element, pollType) {
alert
(
data
[
'errors'
].
join
(
'
\
n'
));
}
var
can_vote
=
data
[
'can_vote'
];
$
(
'.poll-current-count'
,
element
).
text
(
data
[
'submissions_count'
]);
if
(
data
[
'max_submissions'
]
>
1
)
{
$
(
'.poll-submissions-count'
).
show
();
}
if
(
$
(
'div.poll-block'
,
element
).
data
(
'private'
))
{
// User may be changing their vote. Give visual feedback that it was accepted.
var
thanks
=
$
(
'.poll-voting-thanks'
,
element
);
...
...
tests/integration/test_max_submissions.py
View file @
c3d895c4
...
...
@@ -75,3 +75,19 @@ class TestPrivateResults(PollBaseTest):
self
.
go_to_page
(
page
)
self
.
do_submit
(
names
)
self
.
assertFalse
(
self
.
get_submit
()
.
is_enabled
())
@unpack
@data
(
*
scenarios_max
)
def
test_max_submissions_counter
(
self
,
page
,
names
):
"""
Verify a counter is displayed stating how many submissions have been used.
Our XML allows two submissions, and we must mind the off-by-one for range.
"""
self
.
go_to_page
(
page
)
counter_div
=
self
.
browser
.
find_element_by_css_selector
(
'.poll-submissions-count'
)
counter
=
self
.
browser
.
find_element_by_css_selector
(
'.poll-current-count'
)
self
.
assertFalse
(
counter_div
.
is_displayed
())
for
i
in
range
(
1
,
3
):
self
.
do_submit
(
names
)
self
.
assertTrue
(
counter_div
.
is_displayed
())
self
.
assertEqual
(
counter
.
text
.
strip
(),
str
(
i
))
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