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
accdbdd6
Commit
accdbdd6
authored
Apr 26, 2012
by
David Ormsbee
Committed by
Calen Pennington
Jun 07, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check that blank answers are never marked correct (because of NaN issues)
parent
0a5e6ce6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
3 deletions
+21
-3
common/lib/capa/checker.py
+21
-3
No files found.
common/lib/capa/checker.py
View file @
accdbdd6
...
...
@@ -53,6 +53,7 @@ def command_test(problem):
sys
.
stderr
=
StringIO
()
check_that_suggested_answers_work
(
problem
)
check_that_blanks_fail
(
problem
)
log_captured_output
(
sys
.
stdout
,
"captured stdout from {0}"
.
format
(
problem
))
...
...
@@ -63,6 +64,21 @@ def command_test(problem):
finally
:
sys
.
stdout
,
sys
.
stderr
=
old_stdout
,
old_stderr
def
check_that_blanks_fail
(
problem
):
"""Leaving it blank should never work. Neither should a space."""
blank_answers
=
dict
((
answer_id
,
u""
)
for
answer_id
in
problem
.
get_question_answers
())
grading_results
=
problem
.
grade_answers
(
blank_answers
)
try
:
assert
(
all
(
result
==
'incorrect'
for
result
in
grading_results
.
values
()))
except
AssertionError
:
log
.
error
(
"Blank accepted as correct answer in {0} for {1}"
.
format
(
problem
,
[
answer_id
for
answer_id
,
result
in
sorted
(
grading_results
.
items
())
if
result
!=
'incorrect'
]))
def
check_that_suggested_answers_work
(
problem
):
"""Split this up so that we're only used for formula/numeric answers.
...
...
@@ -78,12 +94,12 @@ def check_that_suggested_answers_work(problem):
real_answers
=
problem
.
get_question_answers
()
# all_answers is real_answers + blanks for other answer_ids for which the
# responsetypes can't provide us pre-canned answers (customres
op
nse)
# responsetypes can't provide us pre-canned answers (customres
po
nse)
all_answer_ids
=
problem
.
get_answer_ids
()
all_answers
=
dict
((
answer_id
,
real_answers
.
get
(
answer_id
,
""
))
for
answer_id
in
all_answer_ids
)
log
.
debug
(
real_answers
)
log
.
debug
(
"Real answers: {0}"
.
format
(
real_answers
)
)
if
real_answers
:
try
:
real_results
=
dict
((
answer_id
,
result
)
for
answer_id
,
result
...
...
@@ -93,11 +109,13 @@ def check_that_suggested_answers_work(problem):
assert
(
all
(
result
==
'correct'
for
answer_id
,
result
in
real_results
.
items
()))
except
AssertionError
:
log
.
error
(
"The following generated answers were not accepted:"
)
log
.
error
(
"The following generated answers were not accepted for {0}:"
.
format
(
problem
))
for
question_id
,
result
in
sorted
(
real_results
.
items
()):
if
result
!=
'correct'
:
log
.
error
(
" {0} = {1}"
.
format
(
question_id
,
real_answers
[
question_id
]))
except
Exception
as
ex
:
log
.
error
(
"Uncaught error in {0}"
.
format
(
problem
))
log
.
exception
(
ex
)
def
log_captured_output
(
output_stream
,
stream_name
):
...
...
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