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
f62dad2f
Commit
f62dad2f
authored
Mar 05, 2013
by
Will Daly
Committed by
Ned Batchelder
May 06, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added symbolic response tests
parent
e61a6fe7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
6 deletions
+53
-6
common/lib/capa/capa/inputtypes.py
+1
-1
common/lib/capa/capa/responsetypes.py
+16
-4
common/lib/capa/capa/tests/response_xml_factory.py
+35
-0
common/lib/capa/capa/tests/test_responsetypes.py
+0
-0
common/lib/capa/capa/util.py
+1
-1
No files found.
common/lib/capa/capa/inputtypes.py
View file @
f62dad2f
...
...
@@ -46,7 +46,7 @@ import sys
import
pyparsing
from
.registry
import
TagRegistry
from
c
apa.c
hem
import
chemcalc
from
chem
import
chemcalc
import
xqueue_interface
from
datetime
import
datetime
...
...
common/lib/capa/capa/responsetypes.py
View file @
f62dad2f
...
...
@@ -29,7 +29,7 @@ from collections import namedtuple
from
shapely.geometry
import
Point
,
MultiPoint
# specific library imports
from
.
calc
import
evaluator
,
UndefinedVariable
from
calc
import
evaluator
,
UndefinedVariable
from
.correctmap
import
CorrectMap
from
datetime
import
datetime
from
.util
import
*
...
...
@@ -1043,7 +1043,7 @@ class CustomResponse(LoncapaResponse):
messages
=
self
.
context
[
'messages'
]
correct_map
=
CorrectMap
()
overall_message
=
self
.
clean_message_html
(
self
.
context
[
'overall_message'
])
)
overall_message
=
self
.
clean_message_html
(
self
.
context
[
'overall_message'
])
correct_map
.
set_overall_message
(
overall_message
)
for
k
in
range
(
len
(
idset
)):
...
...
@@ -1195,12 +1195,24 @@ class SymbolicResponse(CustomResponse):
"""
response_tag
=
'symbolicresponse'
max_inputfields
=
1
def
setup_response
(
self
):
# Symbolic response always uses symmath_check()
# If the XML did not specify this, then set it now
# Otherwise, we get an error from the superclass
self
.
xml
.
set
(
'cfn'
,
'symmath_check'
)
# Let CustomResponse do its setup
super
(
SymbolicResponse
,
self
)
.
setup_response
()
def
execute_check_function
(
self
,
idset
,
submission
):
from
symmath
import
symmath_check
fn
=
self
.
code
try
:
answer_given
=
submission
[
0
]
if
(
len
(
idset
)
==
1
)
else
submission
# Since we have limited max_inputfields to 1,
# we can assume that there is only one submission
answer_given
=
submission
[
0
]
ret
=
symmath_check
(
self
.
expect
,
answer_given
,
dynamath
=
self
.
context
.
get
(
'dynamath'
),
...
...
common/lib/capa/capa/tests/response_xml_factory.py
View file @
f62dad2f
...
...
@@ -734,3 +734,38 @@ class AnnotationResponseXMLFactory(ResponseXMLFactory):
option_element
.
text
=
description
return
input_element
class
SymbolicResponseXMLFactory
(
ResponseXMLFactory
):
""" Factory for producing <symbolicresponse> xml """
def
create_response_element
(
self
,
**
kwargs
):
""" Build the <symbolicresponse> XML element.
Uses **kwargs:
*expect*: The correct answer (a sympy string)
*options*: list of option strings to pass to symmath_check
(e.g. 'matrix', 'qbit', 'imaginary', 'numerical')"""
# Retrieve **kwargs
expect
=
kwargs
.
get
(
'expect'
,
''
)
options
=
kwargs
.
get
(
'options'
,
[])
# Symmath check expects a string of options
options_str
=
","
.
join
(
options
)
# Construct the <symbolicresponse> element
response_element
=
etree
.
Element
(
'symbolicresponse'
)
if
expect
:
response_element
.
set
(
'expect'
,
str
(
expect
))
if
options_str
:
response_element
.
set
(
'options'
,
str
(
options_str
))
return
response_element
def
create_input_element
(
self
,
**
kwargs
):
return
ResponseXMLFactory
.
textline_input_xml
(
**
kwargs
)
common/lib/capa/capa/tests/test_responsetypes.py
View file @
f62dad2f
This diff is collapsed.
Click to expand it.
common/lib/capa/capa/util.py
View file @
f62dad2f
from
.calc
import
evaluator
,
UndefinedVariable
from
calc
import
evaluator
#-----------------------------------------------------------------------------
#
...
...
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