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
1a94e3ef
Commit
1a94e3ef
authored
Feb 18, 2015
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8 from mckinseyacademy/cleanup
Addressed nits and remaining work from max submissions task.
parents
2a4ff349
c3d895c4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
5 deletions
+46
-5
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
+8
-0
tests/integration/test_max_submissions.py
+17
-4
No files found.
poll/poll.py
View file @
1a94e3ef
...
...
@@ -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 @
1a94e3ef
...
...
@@ -207,3 +207,7 @@ th.survey-answer {
.poll-hidden
{
display
:
none
;
}
.poll-submissions-count
{
font-weight
:
bold
;
}
poll/public/html/poll.html
View file @
1a94e3ef
...
...
@@ -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 @
1a94e3ef
...
...
@@ -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 @
1a94e3ef
...
...
@@ -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
;
};
...
...
@@ -31,6 +34,7 @@ function PollUtil (runtime, element, pollType) {
var
choice
=
radio
.
val
();
var
thanks
=
$
(
'.poll-voting-thanks'
,
element
);
thanks
.
addClass
(
'poll-hidden'
);
// JQuery's fade functions set element-level styles. Clear these.
thanks
.
removeAttr
(
'style'
);
$
.
ajax
({
type
:
"POST"
,
...
...
@@ -111,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 @
1a94e3ef
...
...
@@ -50,12 +50,9 @@ class TestPrivateResults(PollBaseTest):
for
__
in
range
(
0
,
2
):
self
.
go_to_page
(
page
)
for
___
in
range
(
1
,
5
):
self
.
submission_run
(
names
)
self
.
do_submit
(
names
)
self
.
assertTrue
(
self
.
get_submit
()
.
is_enabled
())
def
submission_run
(
self
,
names
):
self
.
do_submit
(
names
)
@unpack
@data
(
*
scenarios_max
)
def
test_max_submissions_one_view
(
self
,
page
,
names
):
...
...
@@ -78,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