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
ff1189c5
Commit
ff1189c5
authored
Apr 12, 2013
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pylint and Pep8 fixes
parent
06a54a8c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
39 deletions
+24
-39
common/lib/capa/capa/inputtypes.py
+10
-13
common/lib/capa/capa/tests/test_inputtypes.py
+14
-26
No files found.
common/lib/capa/capa/inputtypes.py
View file @
ff1189c5
...
...
@@ -150,8 +150,8 @@ class InputTypeBase(object):
## we can swap this around in the future if there's a more logical
## order.
self
.
id
=
state
.
get
(
'id'
,
xml
.
get
(
'id'
))
if
self
.
id
is
None
:
self
.
i
nput_i
d
=
state
.
get
(
'id'
,
xml
.
get
(
'id'
))
if
self
.
i
nput_i
d
is
None
:
raise
ValueError
(
"input id state is None. xml is {0}"
.
format
(
etree
.
tostring
(
xml
)))
...
...
@@ -249,7 +249,7 @@ class InputTypeBase(object):
and don't need to override this method.
"""
context
=
{
'id'
:
self
.
id
,
'id'
:
self
.
i
nput_i
d
,
'value'
:
self
.
value
,
'status'
:
self
.
status
,
'msg'
:
self
.
msg
,
...
...
@@ -623,7 +623,6 @@ class CodeInput(InputTypeBase):
self
.
queue_len
=
self
.
msg
self
.
msg
=
self
.
submitted_msg
def
setup
(
self
):
''' setup this input type '''
self
.
setup_code_response_rendering
()
...
...
@@ -676,7 +675,6 @@ class MatlabInput(CodeInput):
self
.
queue_len
=
1
self
.
msg
=
self
.
plot_submitted_msg
def
handle_ajax
(
self
,
dispatch
,
get
):
'''
Handle AJAX calls directed to this input
...
...
@@ -685,7 +683,8 @@ class MatlabInput(CodeInput):
- dispatch (str) - indicates how we want this ajax call to be handled
- get (dict) - dictionary of key-value pairs that contain useful data
Returns:
dict - 'success' - whether or not we successfully queued this submission
- 'message' - message to be rendered in case of error
'''
if
dispatch
==
'plot'
:
...
...
@@ -738,7 +737,6 @@ class MatlabInput(CodeInput):
msg
=
result
[
'msg'
]
return
msg
def
_plot_data
(
self
,
get
):
'''
AJAX handler for the plot button
...
...
@@ -762,17 +760,16 @@ class MatlabInput(CodeInput):
anonymous_student_id
=
self
.
system
.
anonymous_student_id
queuekey
=
xqueue_interface
.
make_hashkey
(
str
(
self
.
system
.
seed
)
+
qtime
+
anonymous_student_id
+
self
.
id
)
self
.
i
nput_i
d
)
xheader
=
xqueue_interface
.
make_xheader
(
lms_callback_url
=
callback_url
,
lms_key
=
queuekey
,
queue_name
=
self
.
queuename
)
lms_callback_url
=
callback_url
,
lms_key
=
queuekey
,
queue_name
=
self
.
queuename
)
# save the input state
self
.
input_state
[
'queuekey'
]
=
queuekey
self
.
input_state
[
'queuestate'
]
=
'queued'
# construct xqueue body
student_info
=
{
'anonymous_student_id'
:
anonymous_student_id
,
'submission_time'
:
qtime
}
...
...
@@ -781,7 +778,7 @@ class MatlabInput(CodeInput):
'student_response'
:
response
}
(
error
,
msg
)
=
qinterface
.
send_to_queue
(
header
=
xheader
,
body
=
json
.
dumps
(
contents
))
body
=
json
.
dumps
(
contents
))
return
{
'success'
:
error
==
0
,
'message'
:
msg
}
...
...
common/lib/capa/capa/tests/test_inputtypes.py
View file @
ff1189c5
...
...
@@ -60,6 +60,7 @@ class OptionInputTest(unittest.TestCase):
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
]
...
...
@@ -120,7 +121,6 @@ class ChoiceGroupTest(unittest.TestCase):
self
.
check_group
(
'checkboxgroup'
,
'checkbox'
,
'[]'
)
class
JavascriptInputTest
(
unittest
.
TestCase
):
'''
The javascript input is a pretty straightforward pass-thru, but test it anyway
...
...
@@ -186,7 +186,6 @@ class TextLineTest(unittest.TestCase):
'preprocessor'
:
None
}
self
.
assertEqual
(
context
,
expected
)
def
test_math_rendering
(
self
):
size
=
"42"
preprocessorClass
=
"preParty"
...
...
@@ -226,7 +225,7 @@ class TextLineTest(unittest.TestCase):
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'
))
trailing_text
.
append
((
'a < b'
,
'a < b'
))
for
xml_text
,
expected_text
in
trailing_text
:
xml_str
=
u"""<textline id="prob_1_2"
...
...
@@ -269,7 +268,6 @@ class FileSubmissionTest(unittest.TestCase):
/>"""
.
format
(
af
=
allowed_files
,
rf
=
required_files
,)
element
=
etree
.
fromstring
(
xml_str
)
state
=
{
'value'
:
'BumbleBee.py'
,
...
...
@@ -335,11 +333,11 @@ class CodeInputTest(unittest.TestCase):
'cols'
:
cols
,
'hidden'
:
''
,
'tabsize'
:
int
(
tabsize
),
'queue_len'
:
'3'
,
}
'queue_len'
:
'3'
}
self
.
assertEqual
(
context
,
expected
)
class
MatlabTest
(
unittest
.
TestCase
):
'''
Test Matlab input types
...
...
@@ -358,12 +356,12 @@ class MatlabTest(unittest.TestCase):
<plot_payload>
{payload}
</plot_payload>
</matlabinput>"""
.
format
(
r
=
self
.
rows
,
c
=
self
.
cols
,
tabsize
=
self
.
tabsize
,
m
=
self
.
mode
,
payload
=
self
.
payload
,
ln
=
self
.
linenumbers
)
</matlabinput>"""
.
format
(
r
=
self
.
rows
,
c
=
self
.
cols
,
tabsize
=
self
.
tabsize
,
m
=
self
.
mode
,
payload
=
self
.
payload
,
ln
=
self
.
linenumbers
)
elt
=
etree
.
fromstring
(
self
.
xml
)
state
=
{
'value'
:
'print "good evening"'
,
'status'
:
'incomplete'
,
...
...
@@ -372,7 +370,6 @@ class MatlabTest(unittest.TestCase):
self
.
input_class
=
lookup_tag
(
'matlabinput'
)
self
.
the_input
=
self
.
input_class
(
test_system
,
elt
,
state
)
def
test_rendering
(
self
):
context
=
self
.
the_input
.
_get_render_context
()
...
...
@@ -387,12 +384,10 @@ class MatlabTest(unittest.TestCase):
'linenumbers'
:
'true'
,
'hidden'
:
''
,
'tabsize'
:
int
(
self
.
tabsize
),
'queue_len'
:
'3'
,
}
'queue_len'
:
'3'
}
self
.
assertEqual
(
context
,
expected
)
def
test_rendering_with_state
(
self
):
state
=
{
'value'
:
'print "good evening"'
,
'status'
:
'incomplete'
,
...
...
@@ -414,8 +409,7 @@ class MatlabTest(unittest.TestCase):
'linenumbers'
:
'true'
,
'hidden'
:
''
,
'tabsize'
:
int
(
self
.
tabsize
),
'queue_len'
:
'3'
,
}
'queue_len'
:
'3'
}
self
.
assertEqual
(
context
,
expected
)
...
...
@@ -439,8 +433,7 @@ class MatlabTest(unittest.TestCase):
'linenumbers'
:
'true'
,
'hidden'
:
''
,
'tabsize'
:
int
(
self
.
tabsize
),
'queue_len'
:
'1'
,
}
'queue_len'
:
'1'
}
self
.
assertEqual
(
context
,
expected
)
...
...
@@ -491,9 +484,6 @@ class MatlabTest(unittest.TestCase):
self
.
assertFalse
(
'queue_msg'
in
input_state
)
class
SchematicTest
(
unittest
.
TestCase
):
'''
Check that schematic inputs work
...
...
@@ -507,7 +497,6 @@ class SchematicTest(unittest.TestCase):
initial_value
=
'two large batteries'
submit_analyses
=
'maybe'
xml_str
=
"""<schematic id="prob_1_2"
height="{h}"
width="{w}"
...
...
@@ -537,8 +526,7 @@ class SchematicTest(unittest.TestCase):
'height'
:
height
,
'parts'
:
parts
,
'analyses'
:
analyses
,
'submit_analyses'
:
submit_analyses
,
}
'submit_analyses'
:
submit_analyses
}
self
.
assertEqual
(
context
,
expected
)
...
...
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