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
9db977fe
Commit
9db977fe
authored
Nov 02, 2012
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1002 from MITx/feature/victor/inputtypes-refactor
More inputtype refactor …
parents
d05f6c8a
79174259
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
40 additions
and
16 deletions
+40
-16
common/lib/capa/capa/inputtypes.py
+0
-0
common/lib/capa/capa/templates/crystallography.html
+1
-1
common/lib/capa/capa/templates/filesubmission.html
+1
-1
common/lib/capa/capa/templates/javascriptinput.html
+1
-1
common/lib/capa/capa/templates/textline.html
+1
-1
common/lib/capa/capa/templates/vsepr_input.html
+1
-1
common/lib/capa/capa/tests/test_inputtypes.py
+35
-11
No files found.
common/lib/capa/capa/inputtypes.py
View file @
9db977fe
This diff is collapsed.
Click to expand it.
common/lib/capa/capa/templates/crystallography.html
View file @
9db977fe
...
...
@@ -19,7 +19,7 @@
<div
style=
"display:none;"
name=
"${hidden}"
inputid=
"input_${id}"
/>
% endif
<input
type=
"text"
name=
"input_${id}"
id=
"input_${id}"
value=
"${value}"
<input
type=
"text"
name=
"input_${id}"
id=
"input_${id}"
value=
"${value
|h
}"
%
if
size:
size=
"${size}"
%
endif
...
...
common/lib/capa/capa/templates/filesubmission.html
View file @
9db977fe
...
...
@@ -12,7 +12,7 @@
% endif
<p
class=
"debug"
>
${status}
</p>
<input
type=
"file"
name=
"input_${id}"
id=
"input_${id}"
value=
"${value}"
multiple=
"multiple"
data-required_files=
"${required_files
}"
data-allowed_files=
"${allowed_files
}"
/>
<input
type=
"file"
name=
"input_${id}"
id=
"input_${id}"
value=
"${value}"
multiple=
"multiple"
data-required_files=
"${required_files
|h}"
data-allowed_files=
"${allowed_files|h
}"
/>
</div>
<div
class=
"message"
>
${msg|n}
</div>
</section>
common/lib/capa/capa/templates/javascriptinput.html
View file @
9db977fe
...
...
@@ -2,7 +2,7 @@
<input
type=
"hidden"
name=
"input_${id}"
id=
"input_${id}"
class=
"javascriptinput_input"
/>
<div
class=
"javascriptinput_data"
data-display_class=
"${display_class}"
data-problem_state=
"${problem_state}"
data-params=
"${params}"
data-submission=
"${value
}"
data-evaluation=
"${evaluation
}"
>
data-submission=
"${value
|h}"
data-evaluation=
"${msg|h
}"
>
</div>
<div
class=
"script_placeholder"
data-src=
"/static/js/${display_file}"
></div>
<div
class=
"javascriptinput_container"
></div>
...
...
common/lib/capa/capa/templates/textline.html
View file @
9db977fe
...
...
@@ -20,7 +20,7 @@
<div
style=
"display:none;"
name=
"${hidden}"
inputid=
"input_${id}"
/>
% endif
<input
type=
"text"
name=
"input_${id}"
id=
"input_${id}"
value=
"${value}"
<input
type=
"text"
name=
"input_${id}"
id=
"input_${id}"
value=
"${value
|h
}"
%
if
do_math:
class=
"math"
%
endif
...
...
common/lib/capa/capa/templates/vsepr_input.html
View file @
9db977fe
...
...
@@ -21,7 +21,7 @@
<div
class=
"incorrect"
id=
"status_${id}"
>
% endif
<input
type=
"text"
name=
"input_${id}"
id=
"input_${id}"
value=
"${value}"
<input
type=
"text"
name=
"input_${id}"
id=
"input_${id}"
value=
"${value
|h
}"
style=
"display:none;"
/>
...
...
common/lib/capa/capa/tests/test_inputtypes.py
View file @
9db977fe
...
...
@@ -2,9 +2,18 @@
Tests of input types.
TODO:
- refactor: so much repetive code (have factory methods that build xml elements directly, etc)
- test error cases
- check rendering -- e.g. msg should appear in the rendered output. If possible, test that
templates are escaping things properly.
- test unicode in values, parameters, etc.
- test various html escapes
- test funny xml chars -- should never get xml parse error if things are escaped properly.
"""
from
lxml
import
etree
...
...
@@ -46,6 +55,19 @@ class OptionInputTest(unittest.TestCase):
self
.
assertEqual
(
context
,
expected
)
def
test_option_parsing
(
self
):
f
=
inputtypes
.
OptionInput
.
parse_options
def
check
(
input
,
options
):
"""Take list of options, confirm that output is in the silly doubled format"""
expected
=
[(
o
,
o
)
for
o
in
options
]
self
.
assertEqual
(
f
(
input
),
expected
)
check
(
"('a','b')"
,
[
'a'
,
'b'
])
check
(
"('a', 'b')"
,
[
'a'
,
'b'
])
check
(
"('a b','b')"
,
[
'a b'
,
'b'
])
check
(
"('My
\"
quoted
\"
place','b')"
,
[
'My
\"
quoted
\"
place'
,
'b'
])
class
ChoiceGroupTest
(
unittest
.
TestCase
):
'''
Test choice groups, radio groups, and checkbox groups
...
...
@@ -73,6 +95,7 @@ class ChoiceGroupTest(unittest.TestCase):
expected
=
{
'id'
:
'sky_input'
,
'value'
:
'foil3'
,
'status'
:
'answered'
,
'msg'
:
''
,
'input_type'
:
expected_input_type
,
'choices'
:
[(
'foil1'
,
'<text>This is foil One.</text>'
),
(
'foil2'
,
'<text>This is foil Two.</text>'
),
...
...
@@ -119,12 +142,13 @@ class JavascriptInputTest(unittest.TestCase):
context
=
the_input
.
_get_render_context
()
expected
=
{
'id'
:
'prob_1_2'
,
'status'
:
'unanswered'
,
'msg'
:
''
,
'value'
:
'3'
,
'params'
:
params
,
'display_file'
:
display_file
,
'display_class'
:
display_class
,
'problem_state'
:
problem_state
,
'value'
:
'3'
,
'evaluation'
:
''
,}
'problem_state'
:
problem_state
,}
self
.
assertEqual
(
context
,
expected
)
...
...
@@ -204,9 +228,6 @@ class FileSubmissionTest(unittest.TestCase):
element
=
etree
.
fromstring
(
xml_str
)
escapedict
=
{
'"'
:
'"'
}
esc
=
lambda
s
:
saxutils
.
escape
(
s
,
escapedict
)
state
=
{
'value'
:
'BumbleBee.py'
,
'status'
:
'incomplete'
,
'feedback'
:
{
'message'
:
'3'
},
}
...
...
@@ -220,8 +241,8 @@ class FileSubmissionTest(unittest.TestCase):
'msg'
:
input_class
.
submitted_msg
,
'value'
:
'BumbleBee.py'
,
'queue_len'
:
'3'
,
'allowed_files'
:
esc
(
'["runme.py", "nooooo.rb", "ohai.java"]'
)
,
'required_files'
:
esc
(
'["cookies.py"]'
)
}
'allowed_files'
:
'["runme.py", "nooooo.rb", "ohai.java"]'
,
'required_files'
:
'["cookies.py"]'
}
self
.
assertEqual
(
context
,
expected
)
...
...
@@ -255,14 +276,15 @@ class CodeInputTest(unittest.TestCase):
'status'
:
'incomplete'
,
'feedback'
:
{
'message'
:
'3'
},
}
the_input
=
lookup_tag
(
'codeinput'
)(
test_system
,
element
,
state
)
input_class
=
lookup_tag
(
'codeinput'
)
the_input
=
input_class
(
test_system
,
element
,
state
)
context
=
the_input
.
_get_render_context
()
expected
=
{
'id'
:
'prob_1_2'
,
'value'
:
'print "good evening"'
,
'status'
:
'queued'
,
'msg'
:
'Submitted to grader.'
,
'msg'
:
input_class
.
submitted_msg
,
'mode'
:
mode
,
'linenumbers'
:
linenumbers
,
'rows'
:
rows
,
...
...
@@ -311,8 +333,9 @@ class SchematicTest(unittest.TestCase):
expected
=
{
'id'
:
'prob_1_2'
,
'value'
:
value
,
'initial_value'
:
initial_value
,
'status'
:
'unsubmitted'
,
'msg'
:
''
,
'initial_value'
:
initial_value
,
'width'
:
width
,
'height'
:
height
,
'parts'
:
parts
,
...
...
@@ -476,6 +499,7 @@ class ChemicalEquationTest(unittest.TestCase):
expected
=
{
'id'
:
'prob_1_2'
,
'value'
:
'H2OYeah'
,
'status'
:
'unanswered'
,
'msg'
:
''
,
'size'
:
size
,
'previewer'
:
'/static/js/capa/chemical_equation_preview.js'
,
}
...
...
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