Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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
edx-platform
Commits
0e2bf223
Commit
0e2bf223
authored
Jun 11, 2014
by
polesye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BLD-726: ChoiceTextGroup i18n.
parent
04c94265
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
7 deletions
+17
-7
common/lib/capa/capa/inputtypes.py
+17
-7
No files found.
common/lib/capa/capa/inputtypes.py
View file @
0e2bf223
...
...
@@ -1661,23 +1661,28 @@ class ChoiceTextGroup(InputTypeBase):
elif
self
.
tag
==
'checkboxtextgroup'
:
self
.
html_input_type
=
"checkbox"
else
:
raise
Exception
(
"ChoiceGroup: unexpected tag {0}"
.
format
(
self
.
tag
))
_
=
self
.
capa_system
.
i18n
.
ugettext
msg
=
_
(
"{input_type}: unexpected tag {tag_name}"
)
.
format
(
input_type
=
"ChoiceTextGroup"
,
tag_name
=
self
.
tag
)
raise
Exception
(
msg
)
if
self
.
value
==
''
:
# Make `value` an empty dictionary, if it currently has an empty
# value. This is necessary because the template expects a
# dictionary.
self
.
value
=
{}
self
.
choices
=
self
.
extract_choices
(
self
.
xml
)
self
.
choices
=
self
.
extract_choices
(
self
.
xml
,
self
.
capa_system
.
i18n
)
@classmethod
def
get_attributes
(
cls
):
"""
Returns a list of `Attribute` for this problem type
"""
_
=
lambda
text
:
text
return
[
Attribute
(
"show_correctness"
,
"always"
),
Attribute
(
"submitted_message"
,
"Answer received."
),
Attribute
(
"submitted_message"
,
_
(
"Answer received."
)
),
Attribute
(
"label"
,
""
),
]
...
...
@@ -1694,7 +1699,7 @@ class ChoiceTextGroup(InputTypeBase):
}
@staticmethod
def
extract_choices
(
element
):
def
extract_choices
(
element
,
i18n
):
"""
Extracts choices from the xml for this problem type.
If we have xml that is as follows(choice names will have been assigned
...
...
@@ -1734,14 +1739,19 @@ class ChoiceTextGroup(InputTypeBase):
]
"""
_
=
i18n
.
ugettext
choices
=
[]
for
choice
in
element
:
if
choice
.
tag
!=
'choice'
:
raise
Exception
(
"[capa.inputtypes.extract_choices] Expected a <choice>"
+
"tag; got {0} instead"
.
format
(
choice
.
tag
)
msg
=
"[capa.inputtypes.extract_choices] {0}"
.
format
(
# Translators: a "tag" is an XML element, such as "<b>" in HTML
_
(
"Expected a {expected_tag} tag; got {given_tag} instead"
)
.
format
(
expected_tag
=
u"<choice>"
,
given_tag
=
choice
.
tag
,
)
)
raise
Exception
(
msg
)
components
=
[]
choice_text
=
''
...
...
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