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):
...
@@ -109,7 +109,7 @@ class PollBase(XBlock, ResourceMixin, PublishEventMixin):
"""
"""
Find out if any answer has an image, since it affects layout.
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
@staticmethod
def
markdown_items
(
items
):
def
markdown_items
(
items
):
...
@@ -190,20 +190,23 @@ class PollBase(XBlock, ResourceMixin, PublishEventMixin):
...
@@ -190,20 +190,23 @@ class PollBase(XBlock, ResourceMixin, PublishEventMixin):
Checks to see if the user has permissions to view private results.
Checks to see if the user has permissions to view private results.
This only works inside the LMS.
This only works inside the LMS.
"""
"""
if
HAS_EDX_ACCESS
and
hasattr
(
self
.
runtime
,
'user'
)
and
hasattr
(
self
.
runtime
,
'course_id'
):
if
not
(
HAS_EDX_ACCESS
and
hasattr
(
self
.
runtime
,
'user'
)
and
hasattr
(
self
.
runtime
,
'course_id'
)
):
# Course staff users have permission to view results.
return
False
if
has_access
(
self
.
runtime
.
user
,
'staff'
,
self
,
self
.
runtime
.
course_id
):
return
True
# Course staff users have permission to view results.
else
:
if
has_access
(
self
.
runtime
.
user
,
'staff'
,
self
,
self
.
runtime
.
course_id
)
:
# Check if user is member of a group that is explicitly granted
return
True
# permission to view the results through django configuration.
group_names
=
getattr
(
settings
,
'XBLOCK_POLL_EXTRA_VIEW_GROUPS'
,
[])
# Check if user is member of a group that is explicitly granted
if
group_names
:
# permission to view the results through django configuration.
group_ids
=
self
.
runtime
.
user
.
groups
.
values_list
(
'id'
,
flat
=
True
)
group_names
=
getattr
(
settings
,
'XBLOCK_POLL_EXTRA_VIEW_GROUPS'
,
[]
)
return
GroupProfile
.
objects
.
filter
(
group_id__in
=
group_ids
,
name__in
=
group_names
)
.
exists
()
else
:
if
not
group_names
:
return
False
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
@staticmethod
def
get_max_submissions
(
data
,
result
,
private_results
):
def
get_max_submissions
(
data
,
result
,
private_results
):
"""
"""
...
@@ -254,7 +257,7 @@ class PollBlock(PollBase):
...
@@ -254,7 +257,7 @@ class PollBlock(PollBase):
we just clean it up on first access within the LMS, in case the studio
we just clean it up on first access within the LMS, in case the studio
has made changes to the answers.
has made changes to the answers.
"""
"""
answers
=
OrderedD
ict
(
self
.
answers
)
answers
=
d
ict
(
self
.
answers
)
for
key
in
answers
.
keys
():
for
key
in
answers
.
keys
():
if
key
not
in
self
.
tally
:
if
key
not
in
self
.
tally
:
self
.
tally
[
key
]
=
0
self
.
tally
[
key
]
=
0
...
@@ -331,7 +334,6 @@ class PollBlock(PollBase):
...
@@ -331,7 +334,6 @@ class PollBlock(PollBase):
context
.
update
({
context
.
update
({
'choice'
:
choice
,
'choice'
:
choice
,
# Offset so choices will always be True.
'answers'
:
self
.
markdown_items
(
self
.
answers
),
'answers'
:
self
.
markdown_items
(
self
.
answers
),
'question'
:
markdown
(
self
.
question
),
'question'
:
markdown
(
self
.
question
),
'private_results'
:
self
.
private_results
,
'private_results'
:
self
.
private_results
,
...
@@ -531,7 +533,7 @@ class SurveyBlock(PollBase):
...
@@ -531,7 +533,7 @@ class SurveyBlock(PollBase):
def
student_view
(
self
,
context
=
None
):
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.
when viewing courses.
"""
"""
if
not
context
:
if
not
context
:
...
@@ -654,8 +656,8 @@ class SurveyBlock(PollBase):
...
@@ -654,8 +656,8 @@ class SurveyBlock(PollBase):
we just clean it up on first access within the LMS, in case the studio
we just clean it up on first access within the LMS, in case the studio
has made changes to the answers.
has made changes to the answers.
"""
"""
questions
=
OrderedD
ict
(
self
.
questions
)
questions
=
d
ict
(
self
.
questions
)
answers
=
OrderedD
ict
(
self
.
answers
)
answers
=
d
ict
(
self
.
answers
)
default_answers
=
{
answer
:
0
for
answer
in
answers
.
keys
()}
default_answers
=
{
answer
:
0
for
answer
in
answers
.
keys
()}
for
key
in
questions
.
keys
():
for
key
in
questions
.
keys
():
if
key
not
in
self
.
tally
:
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