Skip to content

Commit 6873b0b

Browse files
Don't display submissions count and max submissions to anonymous users (#3)
* feat: unauthenticated users can now vote and see results of polls * refactor: Add function to check if current user is anonymous user * refactor: Change anonymous user vote to a service call * fix: render max_submissions correctly after user votes * refactor: add function to get anonymous user poll service * fix: don't display submissions_count to anonymous user
1 parent 1d40d2d commit 6873b0b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

poll/poll.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,7 @@ def student_view(self, context=None):
576576
'can_view_private_results': self.can_view_private_results(),
577577
# a11y: Transfer block ID to enable creating unique ids for questions and answers in the template
578578
'block_id': self._get_block_id(),
579+
'is_anonymous_user': self.is_anonymous_user(),
579580
})
580581

581582
if self.choice:
@@ -762,8 +763,6 @@ def is_anonymous_user(self):
762763
user_service = self.runtime.service(self, 'user')
763764
user = user_service.get_current_user()
764765
return not user.opt_attrs.get('edx-platform.is_authenticated')
765-
766-
767766

768767
@XBlock.json_handler
769768
def studio_submit(self, data, suffix=''):

poll/public/html/poll.html

+2
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ <h3 class="poll-header">{{ display_name }}</h3>
4040
<span>{% trans 'Thank you.' %}</span>
4141
</div>
4242

43+
{% if not is_anonymous_user %}
4344
<div class="poll-submissions-count poll-hidden">
4445
{% blocktrans with submissions_count_s='<span class="poll-current-count">{{ submissions_count }}</span>' max_submissions_s='<span class="poll-max-submissions">{{ max_submissions }}</span>' %}
4546
You have used {{ submissions_count_s }} out of {{ max_submissions_s }} submissions.
4647
{% endblocktrans %}
4748
</div>
49+
{% endif %}
4850

4951
{% if feedback %}
5052
<div class="poll-feedback-container{% if not choice %} poll-hidden{% endif %}">

0 commit comments

Comments
 (0)