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
2b9d78df
Commit
2b9d78df
authored
May 13, 2013
by
Peter Baratta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pep8 fixes and changes to NaN tests
parent
a1db394b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
7 deletions
+16
-7
common/lib/capa/capa/responsetypes.py
+2
-1
common/lib/capa/capa/tests/test_responsetypes.py
+9
-4
common/lib/capa/capa/util.py
+5
-2
No files found.
common/lib/capa/capa/responsetypes.py
View file @
2b9d78df
...
...
@@ -2,7 +2,8 @@
# File: courseware/capa/responsetypes.py
#
'''
Problem response evaluation. Handles checking of student responses, of a variety of types.
Problem response evaluation. Handles checking of student responses,
of a variety of types.
Used by capa_problem.py
'''
...
...
common/lib/capa/capa/tests/test_responsetypes.py
View file @
2b9d78df
...
...
@@ -442,7 +442,7 @@ class FormulaResponseTest(ResponseTest):
# This resolves a bug where a problem with relative tolerance would
# pass with any arbitrarily large student answer.
sample_dict
=
{
'x'
:
(
1
,
2
)}
sample_dict
=
{
'x'
:
(
1
,
2
)}
# Test problem
problem
=
self
.
build_problem
(
sample_dict
=
sample_dict
,
...
...
@@ -457,7 +457,7 @@ class FormulaResponseTest(ResponseTest):
# 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
)}
sample_dict
=
{
'x'
:
(
1
,
2
)}
# Test problem
problem
=
self
.
build_problem
(
sample_dict
=
sample_dict
,
...
...
@@ -465,7 +465,11 @@ class FormulaResponseTest(ResponseTest):
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
# right now this evaluates to 'nan' for a given x (Python implementation-dependent)
input_formula
=
"10*x + 0*1e999"
self
.
assert_grade
(
problem
,
input_formula
,
"incorrect"
)
# Expect an correct answer (+ nan) to be marked incorrect
input_formula
=
"x + 0*1e999"
self
.
assert_grade
(
problem
,
input_formula
,
"incorrect"
)
...
...
@@ -763,7 +767,8 @@ class NumericalResponseTest(ResponseTest):
answer
=
4
,
tolerance
=
"10
%
"
)
correct_responses
=
[]
incorrect_responses
=
[
"0*1e999"
]
# right now this evaluates to 'nan' for a given x
# right now these evaluate to 'nan'
incorrect_responses
=
[
"0*1e999"
,
"4 + 0*1e999"
]
self
.
assert_multiple_grade
(
problem
,
correct_responses
,
incorrect_responses
)
def
test_grade_with_script
(
self
):
...
...
common/lib/capa/capa/util.py
View file @
2b9d78df
...
...
@@ -23,10 +23,12 @@ def compare_with_tolerance(v1, v2, tol):
tolerance
=
evaluator
(
dict
(),
dict
(),
tol
)
if
isinf
(
v1
)
or
isinf
(
v2
):
return
v1
==
v2
# because the other numerical comparison does not work with infinities
# because the other numerical comparison does not work with infinities
return
v1
==
v2
else
:
return
abs
(
v1
-
v2
)
<=
tolerance
def
contextualize_text
(
text
,
context
):
# private
''' Takes a string with variables. E.g. $a+$b.
Does a substitution of those variables from the context '''
...
...
@@ -55,7 +57,8 @@ def convert_files_to_filenames(answers):
new_answers
=
dict
()
for
answer_id
in
answers
.
keys
():
answer
=
answers
[
answer_id
]
if
is_list_of_files
(
answer
):
# Files are stored as a list, even if one file
# Files are stored as a list, even if one file
if
is_list_of_files
(
answer
):
new_answers
[
answer_id
]
=
[
f
.
name
for
f
in
answer
]
else
:
new_answers
[
answer_id
]
=
answers
[
answer_id
]
...
...
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