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
f970bbd1
Commit
f970bbd1
authored
May 10, 2013
by
Peter Baratta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests on the problem level that show the infinite answer bug
parent
ee527268
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
common/lib/capa/capa/tests/test_responsetypes.py
+52
-0
No files found.
common/lib/capa/capa/tests/test_responsetypes.py
View file @
f970bbd1
...
...
@@ -438,6 +438,36 @@ class FormulaResponseTest(ResponseTest):
self
.
assert_grade
(
problem
,
incorrect
,
'incorrect'
,
msg
=
"Failed on function {0}; the given, incorrect answer was {1} but graded 'correct'"
.
format
(
func
,
incorrect
))
def
test_grade_infinity
(
self
):
# This resolves a bug where a problem with relative tolerance would
# pass with any arbitrarily large student answer.
sample_dict
=
{
'x'
:
(
1
,
2
)}
# Test problem
problem
=
self
.
build_problem
(
sample_dict
=
sample_dict
,
num_samples
=
10
,
tolerance
=
"1
%
"
,
answer
=
"x"
)
# Expect such a large answer to be marked incorrect
input_formula
=
"x*1e999"
self
.
assert_grade
(
problem
,
input_formula
,
"incorrect"
)
def
test_grade_nan
(
self
):
# attempt to produce a value which causes the student's answer to be
# evaluated to nan. See if this is resolved correctly.
sample_dict
=
{
'x'
:
(
1
,
2
)}
# Test problem
problem
=
self
.
build_problem
(
sample_dict
=
sample_dict
,
num_samples
=
10
,
tolerance
=
"1
%
"
,
answer
=
"x"
)
# Expect an incorrect answer (+ nan) to be marked incorrect
input_formula
=
"10*x + 0*1e999"
# right now this evaluates to 'nan' for a given x
self
.
assert_grade
(
problem
,
input_formula
,
"incorrect"
)
class
StringResponseTest
(
ResponseTest
):
from
response_xml_factory
import
StringResponseXMLFactory
...
...
@@ -714,6 +744,28 @@ class NumericalResponseTest(ResponseTest):
incorrect_responses
=
[
""
,
"4.5"
,
"3.5"
,
"0"
]
self
.
assert_multiple_grade
(
problem
,
correct_responses
,
incorrect_responses
)
def
test_grade_infinity
(
self
):
# This resolves a bug where a problem with relative tolerance would
# pass with any arbitrarily large student answer.
problem
=
self
.
build_problem
(
question_text
=
"What is 2 + 2 approximately?"
,
explanation
=
"The answer is 4"
,
answer
=
4
,
tolerance
=
"10
%
"
)
correct_responses
=
[]
incorrect_responses
=
[
"1e999"
]
self
.
assert_multiple_grade
(
problem
,
correct_responses
,
incorrect_responses
)
def
test_grade_nan
(
self
):
# attempt to produce a value which causes the student's answer to be
# evaluated to nan. See if this is resolved correctly.
problem
=
self
.
build_problem
(
question_text
=
"What is 2 + 2 approximately?"
,
explanation
=
"The answer is 4"
,
answer
=
4
,
tolerance
=
"10
%
"
)
correct_responses
=
[]
incorrect_responses
=
[
"0*1e999"
]
# right now this evaluates to 'nan' for a given x
self
.
assert_multiple_grade
(
problem
,
correct_responses
,
incorrect_responses
)
def
test_grade_with_script
(
self
):
script_text
=
"computed_response = math.sqrt(4)"
problem
=
self
.
build_problem
(
question_text
=
"What is sqrt(4)?"
,
...
...
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