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
eb2be538
Commit
eb2be538
authored
Sep 18, 2015
by
Sarina Canelake
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9639 from jolyonb/feqtext
Adding trailing_text to formulaequationinput
parents
aacd239b
daa4c673
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
1 deletions
+50
-1
common/lib/capa/capa/inputtypes.py
+4
-1
common/lib/capa/capa/templates/formulaequationinput.html
+1
-0
common/lib/capa/capa/tests/test_input_templates.py
+1
-0
common/lib/capa/capa/tests/test_inputtypes.py
+44
-0
No files found.
common/lib/capa/capa/inputtypes.py
View file @
eb2be538
...
...
@@ -1214,9 +1214,11 @@ class FormulaEquationInput(InputTypeBase):
Example:
<formulaequationinput size="50" label="Enter the equation for motion"/>
<formulaequationinput size="50" label="Enter the equation for motion"
/>
options: size -- width of the textbox.
trailing_text -- text to show after the input textbox when
rendered, same as textline (useful for units)
"""
template
=
"formulaequationinput.html"
...
...
@@ -1231,6 +1233,7 @@ class FormulaEquationInput(InputTypeBase):
Attribute
(
'size'
,
'20'
),
Attribute
(
'inline'
,
False
),
Attribute
(
'label'
,
''
),
Attribute
(
'trailing_text'
,
''
),
]
def
_extra_context
(
self
):
...
...
common/lib/capa/capa/templates/formulaequationinput.html
View file @
eb2be538
...
...
@@ -9,6 +9,7 @@
size=
"${size}"
%
endif
/>
${trailing_text | h}
<span
class=
"status"
id=
"${id}_status"
data-tooltip=
"${status.display_tooltip}"
>
<span
class=
"sr"
>
...
...
common/lib/capa/capa/tests/test_input_templates.py
View file @
eb2be538
...
...
@@ -486,6 +486,7 @@ class FormulaEquationInputTemplateTest(TemplateTestCase):
'label'
:
'test'
,
'previewer'
:
'file.js'
,
'reported_status'
:
'REPORTED_STATUS'
,
'trailing_text'
:
None
,
}
super
(
FormulaEquationInputTemplateTest
,
self
)
.
setUp
()
...
...
common/lib/capa/capa/tests/test_inputtypes.py
View file @
eb2be538
...
...
@@ -1126,9 +1126,53 @@ class FormulaEquationTest(unittest.TestCase):
'size'
:
self
.
size
,
'previewer'
:
'/dummy-static/js/capa/src/formula_equation_preview.js'
,
'inline'
:
False
,
'trailing_text'
:
''
,
}
self
.
assertEqual
(
context
,
expected
)
def
test_trailing_text_rendering
(
self
):
"""
Verify that the render context matches the expected render context with trailing_text
"""
size
=
"42"
# store (xml_text, expected)
trailing_text
=
[]
# standard trailing text
trailing_text
.
append
((
'm/s'
,
'm/s'
))
# unicode trailing text
trailing_text
.
append
((
u'
\xc3
'
,
u'
\xc3
'
))
# html escaped trailing text
# this is the only one we expect to change
trailing_text
.
append
((
'a < b'
,
'a < b'
))
for
xml_text
,
expected_text
in
trailing_text
:
xml_str
=
u"""<formulaequationinput id="prob_1_2"
size="{size}"
trailing_text="{tt}"
/>"""
.
format
(
size
=
size
,
tt
=
xml_text
)
element
=
etree
.
fromstring
(
xml_str
)
state
=
{
'value'
:
'x^2+1/2'
,
}
the_input
=
lookup_tag
(
'formulaequationinput'
)(
test_capa_system
(),
element
,
state
)
context
=
the_input
.
_get_render_context
()
# pylint: disable=protected-access
expected
=
{
'STATIC_URL'
:
'/dummy-static/'
,
'id'
:
'prob_1_2'
,
'value'
:
'x^2+1/2'
,
'status'
:
inputtypes
.
Status
(
'unanswered'
),
'label'
:
''
,
'msg'
:
''
,
'size'
:
size
,
'previewer'
:
'/dummy-static/js/capa/src/formula_equation_preview.js'
,
'inline'
:
False
,
'trailing_text'
:
expected_text
,
}
self
.
assertEqual
(
context
,
expected
)
def
test_formcalc_ajax_sucess
(
self
):
"""
Verify that using the correct dispatch and valid data produces a valid response
...
...
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