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
74ed4630
Commit
74ed4630
authored
May 20, 2015
by
E. Kolpakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Addressing python review notes
parent
8caf30a5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
18 deletions
+20
-18
poll/poll.py
+20
-18
No files found.
poll/poll.py
View file @
74ed4630
...
...
@@ -109,7 +109,7 @@ class PollBase(XBlock, ResourceMixin, PublishEventMixin):
"""
Find out if any answer has an image, since it affects layout.
"""
return
any
(
value
[
'img'
]
for
value
in
dict
(
field
)
.
values
()
)
return
any
(
value
[
'img'
]
for
key
,
value
in
field
)
@staticmethod
def
markdown_items
(
items
):
...
...
@@ -190,20 +190,23 @@ class PollBase(XBlock, ResourceMixin, PublishEventMixin):
Checks to see if the user has permissions to view private results.
This only works inside the LMS.
"""
if
HAS_EDX_ACCESS
and
hasattr
(
self
.
runtime
,
'user'
)
and
hasattr
(
self
.
runtime
,
'course_id'
):
# Course staff users have permission to view results.
if
has_access
(
self
.
runtime
.
user
,
'staff'
,
self
,
self
.
runtime
.
course_id
):
return
True
else
:
# Check if user is member of a group that is explicitly granted
# permission to view the results through django configuration.
group_names
=
getattr
(
settings
,
'XBLOCK_POLL_EXTRA_VIEW_GROUPS'
,
[])
if
group_names
:
group_ids
=
self
.
runtime
.
user
.
groups
.
values_list
(
'id'
,
flat
=
True
)
return
GroupProfile
.
objects
.
filter
(
group_id__in
=
group_ids
,
name__in
=
group_names
)
.
exists
()
else
:
if
not
(
HAS_EDX_ACCESS
and
hasattr
(
self
.
runtime
,
'user'
)
and
hasattr
(
self
.
runtime
,
'course_id'
)
):
return
False
# Course staff users have permission to view results.
if
has_access
(
self
.
runtime
.
user
,
'staff'
,
self
,
self
.
runtime
.
course_id
)
:
return
True
# Check if user is member of a group that is explicitly granted
# permission to view the results through django configuration.
group_names
=
getattr
(
settings
,
'XBLOCK_POLL_EXTRA_VIEW_GROUPS'
,
[]
)
if
not
group_names
:
return
False
group_ids
=
self
.
runtime
.
user
.
groups
.
values_list
(
'id'
,
flat
=
True
)
return
GroupProfile
.
objects
.
filter
(
group_id__in
=
group_ids
,
name__in
=
group_names
)
.
exists
()
@staticmethod
def
get_max_submissions
(
data
,
result
,
private_results
):
"""
...
...
@@ -254,7 +257,7 @@ class PollBlock(PollBase):
we just clean it up on first access within the LMS, in case the studio
has made changes to the answers.
"""
answers
=
OrderedD
ict
(
self
.
answers
)
answers
=
d
ict
(
self
.
answers
)
for
key
in
answers
.
keys
():
if
key
not
in
self
.
tally
:
self
.
tally
[
key
]
=
0
...
...
@@ -331,7 +334,6 @@ class PollBlock(PollBase):
context
.
update
({
'choice'
:
choice
,
# Offset so choices will always be True.
'answers'
:
self
.
markdown_items
(
self
.
answers
),
'question'
:
markdown
(
self
.
question
),
'private_results'
:
self
.
private_results
,
...
...
@@ -531,7 +533,7 @@ class SurveyBlock(PollBase):
def
student_view
(
self
,
context
=
None
):
"""
The primary view of the
Poll
Block, shown to students
The primary view of the
Survey
Block, shown to students
when viewing courses.
"""
if
not
context
:
...
...
@@ -654,8 +656,8 @@ class SurveyBlock(PollBase):
we just clean it up on first access within the LMS, in case the studio
has made changes to the answers.
"""
questions
=
OrderedD
ict
(
self
.
questions
)
answers
=
OrderedD
ict
(
self
.
answers
)
questions
=
d
ict
(
self
.
questions
)
answers
=
d
ict
(
self
.
answers
)
default_answers
=
{
answer
:
0
for
answer
in
answers
.
keys
()}
for
key
in
questions
.
keys
():
if
key
not
in
self
.
tally
:
...
...
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