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
c305fc38
Commit
c305fc38
authored
Jan 24, 2014
by
Adam Palay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix regression for stringresponse problems with unspecified case sensitivity (BLD-710)
write failing tests
parent
ac3cd92b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
5 deletions
+29
-5
common/lib/capa/capa/responsetypes.py
+3
-0
common/lib/capa/capa/tests/response_xml_factory.py
+6
-3
common/lib/capa/capa/tests/test_responsetypes.py
+20
-2
No files found.
common/lib/capa/capa/responsetypes.py
View file @
c305fc38
...
@@ -1054,6 +1054,9 @@ class StringResponse(LoncapaResponse):
...
@@ -1054,6 +1054,9 @@ class StringResponse(LoncapaResponse):
def
setup_response
(
self
):
def
setup_response
(
self
):
self
.
backward
=
'_or_'
in
self
.
xml
.
get
(
'answer'
)
.
lower
()
self
.
backward
=
'_or_'
in
self
.
xml
.
get
(
'answer'
)
.
lower
()
self
.
regexp
=
False
self
.
case_insensitive
=
False
if
self
.
xml
.
get
(
'type'
)
is
not
None
:
self
.
regexp
=
'regexp'
in
self
.
xml
.
get
(
'type'
)
.
lower
()
.
split
(
' '
)
self
.
regexp
=
'regexp'
in
self
.
xml
.
get
(
'type'
)
.
lower
()
.
split
(
' '
)
self
.
case_insensitive
=
'ci'
in
self
.
xml
.
get
(
'type'
)
.
lower
()
.
split
(
' '
)
self
.
case_insensitive
=
'ci'
in
self
.
xml
.
get
(
'type'
)
.
lower
()
.
split
(
' '
)
...
...
common/lib/capa/capa/tests/response_xml_factory.py
View file @
c305fc38
...
@@ -700,7 +700,7 @@ class StringResponseXMLFactory(ResponseXMLFactory):
...
@@ -700,7 +700,7 @@ class StringResponseXMLFactory(ResponseXMLFactory):
"""
"""
# Retrieve the **kwargs
# Retrieve the **kwargs
answer
=
kwargs
.
get
(
"answer"
,
None
)
answer
=
kwargs
.
get
(
"answer"
,
None
)
case_sensitive
=
kwargs
.
get
(
"case_sensitive"
,
Tru
e
)
case_sensitive
=
kwargs
.
get
(
"case_sensitive"
,
Non
e
)
hint_list
=
kwargs
.
get
(
'hints'
,
None
)
hint_list
=
kwargs
.
get
(
'hints'
,
None
)
hint_fn
=
kwargs
.
get
(
'hintfn'
,
None
)
hint_fn
=
kwargs
.
get
(
'hintfn'
,
None
)
regexp
=
kwargs
.
get
(
'regexp'
,
None
)
regexp
=
kwargs
.
get
(
'regexp'
,
None
)
...
@@ -714,9 +714,12 @@ class StringResponseXMLFactory(ResponseXMLFactory):
...
@@ -714,9 +714,12 @@ class StringResponseXMLFactory(ResponseXMLFactory):
response_element
.
set
(
"answer"
,
unicode
(
answer
))
response_element
.
set
(
"answer"
,
unicode
(
answer
))
# Set the case sensitivity and regexp:
# Set the case sensitivity and regexp:
type_value
=
"cs"
if
case_sensitive
else
"ci"
type_value
=
''
if
case_sensitive
is
not
None
:
type_value
+=
"cs"
if
case_sensitive
else
"ci"
type_value
+=
' regexp'
if
regexp
else
''
type_value
+=
' regexp'
if
regexp
else
''
response_element
.
set
(
"type"
,
type_value
)
if
type_value
:
response_element
.
set
(
"type"
,
type_value
.
strip
())
# Add the hints if specified
# Add the hints if specified
if
hint_list
or
hint_fn
:
if
hint_list
or
hint_fn
:
...
...
common/lib/capa/capa/tests/test_responsetypes.py
View file @
c305fc38
...
@@ -564,6 +564,10 @@ class StringResponseTest(ResponseTest):
...
@@ -564,6 +564,10 @@ class StringResponseTest(ResponseTest):
problem
=
self
.
build_problem
(
answer
=
".*tre+"
,
case_sensitive
=
False
,
regexp
=
True
)
problem
=
self
.
build_problem
(
answer
=
".*tre+"
,
case_sensitive
=
False
,
regexp
=
True
)
self
.
assert_grade
(
problem
,
"There is a tree"
,
"correct"
)
self
.
assert_grade
(
problem
,
"There is a tree"
,
"correct"
)
# test with case_sensitive not specified
problem
=
self
.
build_problem
(
answer
=
".*tre+"
,
regexp
=
True
)
self
.
assert_grade
(
problem
,
"There is a tree"
,
"correct"
)
answers
=
[
answers
=
[
"Martin Luther King Junior"
,
"Martin Luther King Junior"
,
"Doctor Martin Luther King Junior"
,
"Doctor Martin Luther King Junior"
,
...
@@ -611,6 +615,7 @@ class StringResponseTest(ResponseTest):
...
@@ -611,6 +615,7 @@ class StringResponseTest(ResponseTest):
self
.
assert_grade
(
problem
,
u"î"
,
"incorrect"
)
self
.
assert_grade
(
problem
,
u"î"
,
"incorrect"
)
self
.
assert_grade
(
problem
,
u"o"
,
"incorrect"
)
self
.
assert_grade
(
problem
,
u"o"
,
"incorrect"
)
def
test_backslash_and_unicode_regexps
(
self
):
def
test_backslash_and_unicode_regexps
(
self
):
"""
"""
Test some special cases of [unicode] regexps.
Test some special cases of [unicode] regexps.
...
@@ -643,8 +648,13 @@ class StringResponseTest(ResponseTest):
...
@@ -643,8 +648,13 @@ class StringResponseTest(ResponseTest):
def
test_case_sensitive
(
self
):
def
test_case_sensitive
(
self
):
# Test single answer
# Test single answer
problem
=
self
.
build_problem
(
answer
=
"Second"
,
case_sensitive
=
True
)
problem
_specified
=
self
.
build_problem
(
answer
=
"Second"
,
case_sensitive
=
True
)
# should also be case_sensitive if case sensitivity is not specified
problem_not_specified
=
self
.
build_problem
(
answer
=
"Second"
)
problems
=
[
problem_specified
,
problem_not_specified
]
for
problem
in
problems
:
# Exact string should be correct
# Exact string should be correct
self
.
assert_grade
(
problem
,
"Second"
,
"correct"
)
self
.
assert_grade
(
problem
,
"Second"
,
"correct"
)
...
@@ -654,8 +664,16 @@ class StringResponseTest(ResponseTest):
...
@@ -654,8 +664,16 @@ class StringResponseTest(ResponseTest):
# Test multiple answers
# Test multiple answers
answers
=
[
"Second"
,
"Third"
,
"Fourth"
]
answers
=
[
"Second"
,
"Third"
,
"Fourth"
]
problem
=
self
.
build_problem
(
answer
=
"sample_answer"
,
case_sensitive
=
True
,
additional_answers
=
answers
)
# set up problems
problem_specified
=
self
.
build_problem
(
answer
=
"sample_answer"
,
case_sensitive
=
True
,
additional_answers
=
answers
)
problem_not_specified
=
self
.
build_problem
(
answer
=
"sample_answer"
,
additional_answers
=
answers
)
problems
=
[
problem_specified
,
problem_not_specified
]
for
problem
in
problems
:
for
answer
in
answers
:
for
answer
in
answers
:
# Exact string should be correct
# Exact string should be correct
self
.
assert_grade
(
problem
,
answer
,
"correct"
)
self
.
assert_grade
(
problem
,
answer
,
"correct"
)
...
...
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