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
f3c3436f
Commit
f3c3436f
authored
Jul 30, 2013
by
Felix Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Addressing more PR comments. Fixed a test that broke when new code came in.
parent
d6715749
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
10 deletions
+17
-10
common/lib/capa/capa/responsetypes.py
+11
-9
common/lib/xmodule/xmodule/crowdsource_hinter.py
+6
-1
No files found.
common/lib/capa/capa/responsetypes.py
View file @
f3c3436f
...
@@ -1799,7 +1799,7 @@ class FormulaResponse(LoncapaResponse):
...
@@ -1799,7 +1799,7 @@ class FormulaResponse(LoncapaResponse):
self
.
correct_answer
,
given
,
self
.
samples
)
self
.
correct_answer
,
given
,
self
.
samples
)
return
CorrectMap
(
self
.
answer_id
,
correctness
)
return
CorrectMap
(
self
.
answer_id
,
correctness
)
def
hash
_answers
(
self
,
answer
,
var_dict_list
):
def
tupleize
_answers
(
self
,
answer
,
var_dict_list
):
"""
"""
Takes in an answer and a list of dictionaries mapping variables to values.
Takes in an answer and a list of dictionaries mapping variables to values.
Each dictionary represents a test case for the answer.
Each dictionary represents a test case for the answer.
...
@@ -1850,7 +1850,7 @@ class FormulaResponse(LoncapaResponse):
...
@@ -1850,7 +1850,7 @@ class FormulaResponse(LoncapaResponse):
def
randomize_variables
(
self
,
samples
):
def
randomize_variables
(
self
,
samples
):
"""
"""
Returns a list of dictionaries mapping variables to random values in range,
Returns a list of dictionaries mapping variables to random values in range,
as expected by
hash
_answers.
as expected by
tupleize
_answers.
"""
"""
variables
=
samples
.
split
(
'@'
)[
0
]
.
split
(
','
)
variables
=
samples
.
split
(
'@'
)[
0
]
.
split
(
','
)
numsamples
=
int
(
samples
.
split
(
'@'
)[
1
]
.
split
(
'#'
)[
1
])
numsamples
=
int
(
samples
.
split
(
'@'
)[
1
]
.
split
(
'#'
)[
1
])
...
@@ -1876,13 +1876,15 @@ class FormulaResponse(LoncapaResponse):
...
@@ -1876,13 +1876,15 @@ class FormulaResponse(LoncapaResponse):
"correct" or "incorrect".
"correct" or "incorrect".
"""
"""
var_dict_list
=
self
.
randomize_variables
(
samples
)
var_dict_list
=
self
.
randomize_variables
(
samples
)
student_result
=
self
.
hash
_answers
(
given
,
var_dict_list
)
student_result
=
self
.
tupleize
_answers
(
given
,
var_dict_list
)
instructor_result
=
self
.
hash
_answers
(
expected
,
var_dict_list
)
instructor_result
=
self
.
tupleize
_answers
(
expected
,
var_dict_list
)
for
i
in
xrange
(
len
(
instructor_result
)):
correct
=
all
(
compare_with_tolerance
(
student
,
instructor
,
self
.
tolerance
)
if
not
compare_with_tolerance
(
student_result
[
i
],
instructor_result
[
i
],
self
.
tolerance
):
for
student
,
instructor
in
zip
(
student_result
,
instructor_result
))
return
"incorrect"
if
correct
:
return
"correct"
return
"correct"
else
:
return
"incorrect"
def
compare_answer
(
self
,
a
,
b
):
def
compare_answer
(
self
,
a
,
b
):
"""
"""
...
@@ -1897,7 +1899,7 @@ class FormulaResponse(LoncapaResponse):
...
@@ -1897,7 +1899,7 @@ class FormulaResponse(LoncapaResponse):
"""
"""
var_dict_list
=
self
.
randomize_variables
(
self
.
samples
)
var_dict_list
=
self
.
randomize_variables
(
self
.
samples
)
try
:
try
:
self
.
hash
_answers
(
answer
,
var_dict_list
)
self
.
tupleize
_answers
(
answer
,
var_dict_list
)
return
True
return
True
except
StudentInputError
:
except
StudentInputError
:
return
False
return
False
...
...
common/lib/xmodule/xmodule/crowdsource_hinter.py
View file @
f3c3436f
...
@@ -76,7 +76,12 @@ class CrowdsourceHinterModule(CrowdsourceHinterFields, XModule):
...
@@ -76,7 +76,12 @@ class CrowdsourceHinterModule(CrowdsourceHinterFields, XModule):
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
XModule
.
__init__
(
self
,
*
args
,
**
kwargs
)
XModule
.
__init__
(
self
,
*
args
,
**
kwargs
)
# We need to know whether we are working with a FormulaResponse problem.
# We need to know whether we are working with a FormulaResponse problem.
responder
=
self
.
get_display_items
()[
0
]
.
lcp
.
responders
.
values
()[
0
]
try
:
responder
=
self
.
get_display_items
()[
0
]
.
lcp
.
responders
.
values
()[
0
]
except
(
IndexError
,
AttributeError
):
log
.
exception
(
'Unable to find a capa problem child.'
)
return
self
.
is_formula
=
(
type
(
responder
)
==
FormulaResponse
)
self
.
is_formula
=
(
type
(
responder
)
==
FormulaResponse
)
if
self
.
is_formula
:
if
self
.
is_formula
:
self
.
answer_to_str
=
self
.
formula_answer_to_str
self
.
answer_to_str
=
self
.
formula_answer_to_str
...
...
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