Commit 50c1d944 by Jonathan Piacenti

Several appearance tweaks.

parent 1b9c44da
...@@ -375,6 +375,9 @@ class PollBlock(PollBase): ...@@ -375,6 +375,9 @@ class PollBlock(PollBase):
class SurveyBlock(PollBase): class SurveyBlock(PollBase):
display_name = String(default='Survey') display_name = String(default='Survey')
# The display name affects how the block is labeled in the studio,
# but either way we want it to say 'Poll' by default on the page.
block_name = String(default='Poll')
answers = List( answers = List(
default=( default=(
('Y', 'Yes'), ('N', 'No'), ('Y', 'Yes'), ('N', 'No'),
...@@ -424,7 +427,7 @@ class SurveyBlock(PollBase): ...@@ -424,7 +427,7 @@ class SurveyBlock(PollBase):
'feedback': markdown(self.feedback) or False, 'feedback': markdown(self.feedback) or False,
# The SDK doesn't set url_name. # The SDK doesn't set url_name.
'url_name': getattr(self, 'url_name', ''), 'url_name': getattr(self, 'url_name', ''),
"display_name": self.display_name, "block_name": self.block_name,
}) })
return self.create_fragment( return self.create_fragment(
...@@ -438,7 +441,7 @@ class SurveyBlock(PollBase): ...@@ -438,7 +441,7 @@ class SurveyBlock(PollBase):
js_template = self.resource_string('/public/handlebars/poll_studio.handlebars') js_template = self.resource_string('/public/handlebars/poll_studio.handlebars')
context.update({ context.update({
'feedback': self.feedback, 'feedback': self.feedback,
'display_name': self.display_name, 'display_name': self.block_name,
'js_template': js_template, 'js_template': js_template,
'multiquestion': True, 'multiquestion': True,
}) })
...@@ -567,7 +570,7 @@ class SurveyBlock(PollBase): ...@@ -567,7 +570,7 @@ class SurveyBlock(PollBase):
'answers': [ 'answers': [
value for value in OrderedDict(self.answers).values()], value for value in OrderedDict(self.answers).values()],
'tally': detail, 'total': total, 'feedback': markdown(self.feedback), 'tally': detail, 'total': total, 'feedback': markdown(self.feedback),
'plural': total > 1, 'display_name': self.display_name, 'plural': total > 1, 'block_name': self.block_name,
} }
@XBlock.json_handler @XBlock.json_handler
...@@ -639,7 +642,7 @@ class SurveyBlock(PollBase): ...@@ -639,7 +642,7 @@ class SurveyBlock(PollBase):
result = {'success': True, 'errors': []} result = {'success': True, 'errors': []}
feedback = data.get('feedback', '').strip() feedback = data.get('feedback', '').strip()
display_name = data.get('display_name', '').strip() block_name = data.get('display_name', '').strip()
answers = self.gather_items(data, result, 'Answer', 'answers', image=False) answers = self.gather_items(data, result, 'Answer', 'answers', image=False)
questions = self.gather_items(data, result, 'Question', 'questions') questions = self.gather_items(data, result, 'Question', 'questions')
...@@ -650,7 +653,7 @@ class SurveyBlock(PollBase): ...@@ -650,7 +653,7 @@ class SurveyBlock(PollBase):
self.answers = answers self.answers = answers
self.questions = questions self.questions = questions
self.feedback = feedback self.feedback = feedback
self.display_name = display_name self.block_name = block_name
# Tally will not be updated until the next attempt to use it, per # Tally will not be updated until the next attempt to use it, per
# scoping limitations. # scoping limitations.
......
...@@ -110,6 +110,7 @@ li.poll-result .poll-image { ...@@ -110,6 +110,7 @@ li.poll-result .poll-image {
margin-top: 1em; margin-top: 1em;
margin-bottom: 1em; margin-bottom: 1em;
font-size: smaller; font-size: smaller;
font-weight: bold;
} }
.survey-table { .survey-table {
...@@ -143,7 +144,7 @@ li.poll-result .poll-image { ...@@ -143,7 +144,7 @@ li.poll-result .poll-image {
} }
.survey-table thead tr th { .survey-table thead tr th {
font-weight: normal; font-weight: bold;
font-size: .8rem; font-size: .8rem;
} }
......
<script id="survey-results-template" type="text/html"> <script id="survey-results-template" type="text/html">
<h3 class="poll-header">{{display_name}}</h3> <h3 class="poll-header">{{block_name}}</h3>
<table class="survey-table"> <table class="survey-table">
<thead> <thead>
<tr> <tr>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="poll-block"> <div class="poll-block">
{# 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 %}
<h2 class="poll-header">{{display_name}}</h2> <h3 class="poll-header">{{display_name}}</h3>
<form> <form>
<div class="poll-question-container"> <div class="poll-question-container">
{{question|safe}} {{question|safe}}
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<li class="field comp-setting-entry is-set"> <li class="field comp-setting-entry is-set">
<div class="wrapper-comp-setting"> <div class="wrapper-comp-setting">
<label class="label setting-label poll-setting-label" for="display_name">Display Name</label> <label class="label setting-label poll-setting-label" for="display_name">Display Name</label>
<!-- In the case of surveys, this field will actually be used for block_name. -->
<input class="input setting-input" name="display_name" id="poll-display-name" value="{{ display_name }}" type="text" /> <input class="input setting-input" name="display_name" id="poll-display-name" value="{{ display_name }}" type="text" />
</div> </div>
</li> </li>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="poll-block"> <div class="poll-block">
{# 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 choices %} {% if not choices %}
<h3 class="poll-header">{{display_name}}</h3> <h3 class="poll-header">{{block_name}}</h3>
<form> <form>
<table class="survey-table"> <table class="survey-table">
<thead> <thead>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment