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
205c5164
Commit
205c5164
authored
Jun 29, 2015
by
Sven Marnach
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add configuration option to decide whether image alt attrs should be mandatory.
parent
b42291da
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
5 deletions
+19
-5
poll/poll.py
+16
-2
poll/public/handlebars/poll_studio.handlebars
+3
-3
No files found.
poll/poll.py
View file @
205c5164
...
@@ -121,8 +121,17 @@ class PollBase(XBlock, ResourceMixin, PublishEventMixin):
...
@@ -121,8 +121,17 @@ class PollBase(XBlock, ResourceMixin, PublishEventMixin):
return
[(
key
,
{
'label'
:
markdown
(
value
[
'label'
]),
'img'
:
value
[
'img'
],
'img_alt'
:
value
.
get
(
'img_alt'
)})
return
[(
key
,
{
'label'
:
markdown
(
value
[
'label'
]),
'img'
:
value
[
'img'
],
'img_alt'
:
value
.
get
(
'img_alt'
)})
for
key
,
value
in
items
]
for
key
,
value
in
items
]
@staticmethod
def
img_alt_mandatory
(
self
):
def
gather_items
(
data
,
result
,
noun
,
field
,
image
=
True
):
"""
Determine whether alt attributes for images are configured to be mandatory. Defaults to True.
"""
settings_service
=
self
.
runtime
.
service
(
self
,
"settings"
)
if
not
settings_service
:
return
True
xblock_settings
=
settings_service
.
get_settings_bucket
(
self
)
return
xblock_settings
.
get
(
'IMG_ALT_MANDATORY'
,
True
)
def
gather_items
(
self
,
data
,
result
,
noun
,
field
,
image
=
True
):
"""
"""
Gathers a set of label-img pairs from a data dict and puts them in order.
Gathers a set of label-img pairs from a data dict and puts them in order.
"""
"""
...
@@ -165,6 +174,11 @@ class PollBase(XBlock, ResourceMixin, PublishEventMixin):
...
@@ -165,6 +174,11 @@ class PollBase(XBlock, ResourceMixin, PublishEventMixin):
"All {1}s must have labels. Please check the form. "
"All {1}s must have labels. Please check the form. "
"Check the form and explicitly delete {1}s "
"Check the form and explicitly delete {1}s "
"if not needed."
.
format
(
noun
,
noun
.
lower
()))
"if not needed."
.
format
(
noun
,
noun
.
lower
()))
if
image_link
and
not
image_alt
and
self
.
img_alt_mandatory
():
result
[
'success'
]
=
False
result
[
'errors'
]
.
append
(
"All images must have an alternative text describing the image in a way that "
"would allow someone to answer the poll if the image did not load."
)
if
image
:
if
image
:
items
.
append
((
key
,
{
'label'
:
label
,
'img'
:
image_link
,
'img_alt'
:
image_alt
}))
items
.
append
((
key
,
{
'label'
:
label
,
'img'
:
image_link
,
'img_alt'
:
image_alt
}))
else
:
else
:
...
...
poll/public/handlebars/poll_studio.handlebars
View file @
205c5164
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
{{#if
image
}}
{{#if
image
}}
<
label
class
=
"label setting-label"
for
=
"
{{
noun
}}
-img-
{{
key
}}
"
>
Image
URL
<
/label
>
<
label
class
=
"label setting-label"
for
=
"
{{
noun
}}
-img-
{{
key
}}
"
>
Image
URL
<
/label
>
<
input
class
=
"input setting-input"
name
=
"
{{
noun
}}
-img-
{{
key
}}
"
id
=
"
{{
noun
}}
-img-
{{
key
}}
"
value
=
"
{{
img
}}
"
type
=
"text"
/><
br
/>
<
input
class
=
"input setting-input"
name
=
"
{{
noun
}}
-img-
{{
key
}}
"
id
=
"
{{
noun
}}
-img-
{{
key
}}
"
value
=
"
{{
img
}}
"
type
=
"text"
/><
br
/>
<
label
class
=
"label setting-label"
for
=
"
{{
noun
}}
-img_alt-
{{
key
}}
"
>
Image
alternate
text
<
/label
>
<
label
class
=
"label setting-label"
for
=
"
{{
noun
}}
-img_alt-
{{
key
}}
"
>
Image
alternat
iv
e
text
<
/label
>
<
input
class
=
"input setting-input"
name
=
"
{{
noun
}}
-img_alt-
{{
key
}}
"
id
=
"
{{
noun
}}
-img_alt-
{{
key
}}
"
value
=
"
{{
img_alt
}}
"
type
=
"text"
/><
br
/>
<
input
class
=
"input setting-input"
name
=
"
{{
noun
}}
-img_alt-
{{
key
}}
"
id
=
"
{{
noun
}}
-img_alt-
{{
key
}}
"
value
=
"
{{
img_alt
}}
"
type
=
"text"
/><
br
/>
{{/if}}
{{/if}}
<
/div
>
<
/div
>
...
@@ -21,8 +21,8 @@
...
@@ -21,8 +21,8 @@
<
/span
>
<
/span
>
<
span
class
=
"tip setting-help"
>
<
span
class
=
"tip setting-help"
>
{{#if
image
}}
{{#if
image
}}
This
must
have
an
image
URL
or
text
,
and
can
have
both
.
If
you
add
an
image
,
an
alternate
text
that
describes
This
must
have
an
image
URL
or
text
,
and
can
have
both
.
If
you
add
an
image
,
you
must
also
provide
an
alternative
text
th
e
image
in
a
way
that
would
allow
someone
to
answer
the
poll
if
the
image
did
not
load
is
strongly
encourage
d
.
th
at
describes
the
image
in
a
way
that
would
allow
someone
to
answer
the
poll
if
the
image
did
not
loa
d
.
{{/if}}
{{/if}}
<
/span
>
<
/span
>
<
/li
>
<
/li
>
...
...
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