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
42e711e7
Commit
42e711e7
authored
Mar 06, 2013
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update tests and documentation.
parent
1aa3580d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
9 deletions
+27
-9
common/lib/capa/capa/inputtypes.py
+1
-1
common/lib/capa/capa/tests/test_inputtypes.py
+23
-7
common/static/js/capa/chemical_equation_preview.js
+3
-1
No files found.
common/lib/capa/capa/inputtypes.py
View file @
42e711e7
...
...
@@ -756,7 +756,7 @@ class ChemicalEquationInput(InputTypeBase):
def
handle_ajax
(
self
,
dispatch
,
get
):
'''
Since we only have
one ajax handler for
this input, check to see if it
Since we only have
chemcalc preview
this input, check to see if it
matches the corresponding dispatch and send it through if it does
'''
if
dispatch
==
'preview_chemcalc'
:
...
...
common/lib/capa/capa/tests/test_inputtypes.py
View file @
42e711e7
...
...
@@ -482,27 +482,43 @@ class ChemicalEquationTest(unittest.TestCase):
'''
Check that chemical equation inputs work.
'''
def
test_rendering
(
self
):
size
=
"42"
xml_str
=
"""<chemicalequationinput id="prob_1_2" size="{size}"/>"""
.
format
(
size
=
size
)
def
setUp
(
self
):
self
.
size
=
"42"
xml_str
=
"""<chemicalequationinput id="prob_1_2" size="{size}"/>"""
.
format
(
size
=
self
.
size
)
element
=
etree
.
fromstring
(
xml_str
)
state
=
{
'value'
:
'H2OYeah'
,
}
the_input
=
lookup_tag
(
'chemicalequationinput'
)(
test_system
,
element
,
state
)
self
.
the_input
=
lookup_tag
(
'chemicalequationinput'
)(
test_system
,
element
,
state
)
context
=
the_input
.
_get_render_context
()
def
test_rendering
(
self
):
''' Verify that the render context matches the expected render context'''
context
=
self
.
the_input
.
_get_render_context
()
expected
=
{
'id'
:
'prob_1_2'
,
'value'
:
'H2OYeah'
,
'status'
:
'unanswered'
,
'msg'
:
''
,
'size'
:
size
,
'size'
:
s
elf
.
s
ize
,
'previewer'
:
'/static/js/capa/chemical_equation_preview.js'
,
}
self
.
assertEqual
(
context
,
expected
)
def
test_chemcalc_ajax_sucess
(
self
):
''' Verify that using the correct dispatch and valid data produces a valid response'''
data
=
{
'formula'
:
"H"
}
response
=
self
.
the_input
.
handle_ajax
(
"preview_chemcalc"
,
data
)
self
.
assertTrue
(
'preview'
in
response
)
self
.
assertNotEqual
(
response
[
'preview'
],
''
)
self
.
assertEqual
(
response
[
'error'
],
""
)
class
DragAndDropTest
(
unittest
.
TestCase
):
'''
...
...
common/static/js/capa/chemical_equation_preview.js
View file @
42e711e7
...
...
@@ -13,7 +13,9 @@
prev_id
=
"#"
+
this
.
id
+
"_preview"
;
preview_div
=
$
(
prev_id
);
url
=
$
(
this
).
parents
(
'.problems-wrapper'
).
data
(
'url'
);
// find the closest parent problems-wrapper and use that url
url
=
$
(
this
).
closest
(
'.problems-wrapper'
).
data
(
'url'
);
// grab the input id from the input
input_id
=
$
(
this
).
data
(
'input-id'
)
Problem
.
inputAjax
(
url
,
input_id
,
'preview_chemcalc'
,
{
"formula"
:
this
.
value
},
create_handler
(
preview_div
));
...
...
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