Commit 0b0895e4 by Jonathan Piacenti

Improve event data and response display for surveys.

parent 1e409383
......@@ -49,9 +49,12 @@ class PollBase(XBlock, ResourceMixin, PublishEventMixin):
'max_value': 1,
}
)
# The SDK doesn't set url_name.
event_dict = {'url_name': getattr(self, 'url_name', '')}
event_dict.update(choice_data)
self.publish_event_from_dict(
self.event_namespace + '.submitted',
choice_data,
event_dict,
)
@staticmethod
......@@ -466,11 +469,12 @@ class SurveyBlock(PollBase):
answer_set = OrderedDict(default_answers)
answer_set.update(source_tally[key])
tally.append({
'text': value['label'],
'label': value['label'],
'img': value['img'],
'answers': [
{
'count': count, 'choice': False,
'key': answer_key, 'top': False
'key': answer_key, 'top': False,
}
for answer_key, count in answer_set.items()],
'key': key,
......@@ -625,7 +629,7 @@ class SurveyBlock(PollBase):
for key, value in self.choices.items():
self.tally[key][value] += 1
self.send_vote_event({'choices': choices})
self.send_vote_event({'choices': self.choices})
return result
......
......@@ -11,12 +11,14 @@
</thead>
{{#each tally}}
<tr class="survey-row">
{{#if img}}
<div class="poll-image-td">
<img src="{{img}}" />
</div>
{{/if}}
<td class="survey-question">{{{text}}}</td>
<td class="survey-question">
{{#if img}}
<div class="poll-image-td">
<img src="{{img}}" />
</div>
{{/if}}
{{{label}}}
</td>
{{#each answers}}
<td class="survey-percentage survey-option{{#if choice}} survey-choice{{/if}}{{#if top}} poll-top-choice{{/if}}">{{percent}}%</td>
{{/each}}
......
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