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
d51604c7
Commit
d51604c7
authored
Jun 10, 2012
by
ichuang
Committed by
Matthew Mongeau
Jun 21, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix xmodule/capa tests to use new CorrectMap
parent
c5d0610d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
19 deletions
+19
-19
common/lib/capa/capa_problem.py
+2
-2
common/lib/xmodule/tests.py
+17
-17
No files found.
common/lib/capa/capa_problem.py
View file @
d51604c7
...
@@ -200,12 +200,12 @@ class LoncapaProblem(object):
...
@@ -200,12 +200,12 @@ class LoncapaProblem(object):
self
.
student_answers
=
answers
self
.
student_answers
=
answers
oldcmap
=
self
.
correct_map
# old CorrectMap
oldcmap
=
self
.
correct_map
# old CorrectMap
newcmap
=
CorrectMap
()
# start new with empty CorrectMap
newcmap
=
CorrectMap
()
# start new with empty CorrectMap
log
.
debug
(
'Responders:
%
s'
%
self
.
responders
)
#
log.debug('Responders: %s' % self.responders)
for
responder
in
self
.
responders
.
values
():
for
responder
in
self
.
responders
.
values
():
results
=
responder
.
evaluate_answers
(
answers
,
oldcmap
)
# call the responsetype instance to do the actual grading
results
=
responder
.
evaluate_answers
(
answers
,
oldcmap
)
# call the responsetype instance to do the actual grading
newcmap
.
update
(
results
)
newcmap
.
update
(
results
)
self
.
correct_map
=
newcmap
self
.
correct_map
=
newcmap
log
.
debug
(
'
%
s: in grade_answers, answers=
%
s, cmap=
%
s'
%
(
self
,
answers
,
newcmap
))
#
log.debug('%s: in grade_answers, answers=%s, cmap=%s' % (self,answers,newcmap))
return
newcmap
return
newcmap
def
get_question_answers
(
self
):
def
get_question_answers
(
self
):
...
...
common/lib/xmodule/tests.py
View file @
d51604c7
#
#
# unittests for
courseware
# unittests for
xmodule (and capa)
#
#
# Note: run this using a like like this:
# Note: run this using a like like this:
#
#
# django-admin.py test --settings=
envs.test_ike --pythonpath=. coursewar
e
# django-admin.py test --settings=
lms.envs.test_ike --pythonpath=. common/lib/xmodul
e
import
unittest
import
unittest
import
os
import
os
...
@@ -96,31 +96,31 @@ class MultiChoiceTest(unittest.TestCase):
...
@@ -96,31 +96,31 @@ class MultiChoiceTest(unittest.TestCase):
multichoice_file
=
os
.
path
.
dirname
(
__file__
)
+
"/test_files/multichoice.xml"
multichoice_file
=
os
.
path
.
dirname
(
__file__
)
+
"/test_files/multichoice.xml"
test_lcp
=
lcp
.
LoncapaProblem
(
open
(
multichoice_file
),
'1'
,
system
=
i4xs
)
test_lcp
=
lcp
.
LoncapaProblem
(
open
(
multichoice_file
),
'1'
,
system
=
i4xs
)
correct_answers
=
{
'1_2_1'
:
'choice_foil3'
}
correct_answers
=
{
'1_2_1'
:
'choice_foil3'
}
self
.
assertEquals
(
test_lcp
.
grade_answers
(
correct_answers
)
[
'1_2_1'
]
,
'correct'
)
self
.
assertEquals
(
test_lcp
.
grade_answers
(
correct_answers
)
.
get_correctness
(
'1_2_1'
)
,
'correct'
)
false_answers
=
{
'1_2_1'
:
'choice_foil2'
}
false_answers
=
{
'1_2_1'
:
'choice_foil2'
}
self
.
assertEquals
(
test_lcp
.
grade_answers
(
false_answers
)
[
'1_2_1'
]
,
'incorrect'
)
self
.
assertEquals
(
test_lcp
.
grade_answers
(
false_answers
)
.
get_correctness
(
'1_2_1'
)
,
'incorrect'
)
def
test_MC_bare_grades
(
self
):
def
test_MC_bare_grades
(
self
):
multichoice_file
=
os
.
path
.
dirname
(
__file__
)
+
"/test_files/multi_bare.xml"
multichoice_file
=
os
.
path
.
dirname
(
__file__
)
+
"/test_files/multi_bare.xml"
test_lcp
=
lcp
.
LoncapaProblem
(
open
(
multichoice_file
),
'1'
,
system
=
i4xs
)
test_lcp
=
lcp
.
LoncapaProblem
(
open
(
multichoice_file
),
'1'
,
system
=
i4xs
)
correct_answers
=
{
'1_2_1'
:
'choice_2'
}
correct_answers
=
{
'1_2_1'
:
'choice_2'
}
self
.
assertEquals
(
test_lcp
.
grade_answers
(
correct_answers
)
[
'1_2_1'
]
,
'correct'
)
self
.
assertEquals
(
test_lcp
.
grade_answers
(
correct_answers
)
.
get_correctness
(
'1_2_1'
)
,
'correct'
)
false_answers
=
{
'1_2_1'
:
'choice_1'
}
false_answers
=
{
'1_2_1'
:
'choice_1'
}
self
.
assertEquals
(
test_lcp
.
grade_answers
(
false_answers
)
[
'1_2_1'
]
,
'incorrect'
)
self
.
assertEquals
(
test_lcp
.
grade_answers
(
false_answers
)
.
get_correctness
(
'1_2_1'
)
,
'incorrect'
)
def
test_TF_grade
(
self
):
def
test_TF_grade
(
self
):
truefalse_file
=
os
.
path
.
dirname
(
__file__
)
+
"/test_files/truefalse.xml"
truefalse_file
=
os
.
path
.
dirname
(
__file__
)
+
"/test_files/truefalse.xml"
test_lcp
=
lcp
.
LoncapaProblem
(
open
(
truefalse_file
),
'1'
,
system
=
i4xs
)
test_lcp
=
lcp
.
LoncapaProblem
(
open
(
truefalse_file
),
'1'
,
system
=
i4xs
)
correct_answers
=
{
'1_2_1'
:[
'choice_foil2'
,
'choice_foil1'
]}
correct_answers
=
{
'1_2_1'
:[
'choice_foil2'
,
'choice_foil1'
]}
self
.
assertEquals
(
test_lcp
.
grade_answers
(
correct_answers
)
[
'1_2_1'
]
,
'correct'
)
self
.
assertEquals
(
test_lcp
.
grade_answers
(
correct_answers
)
.
get_correctness
(
'1_2_1'
)
,
'correct'
)
false_answers
=
{
'1_2_1'
:[
'choice_foil1'
]}
false_answers
=
{
'1_2_1'
:[
'choice_foil1'
]}
self
.
assertEquals
(
test_lcp
.
grade_answers
(
false_answers
)
[
'1_2_1'
]
,
'incorrect'
)
self
.
assertEquals
(
test_lcp
.
grade_answers
(
false_answers
)
.
get_correctness
(
'1_2_1'
)
,
'incorrect'
)
false_answers
=
{
'1_2_1'
:[
'choice_foil1'
,
'choice_foil3'
]}
false_answers
=
{
'1_2_1'
:[
'choice_foil1'
,
'choice_foil3'
]}
self
.
assertEquals
(
test_lcp
.
grade_answers
(
false_answers
)
[
'1_2_1'
]
,
'incorrect'
)
self
.
assertEquals
(
test_lcp
.
grade_answers
(
false_answers
)
.
get_correctness
(
'1_2_1'
)
,
'incorrect'
)
false_answers
=
{
'1_2_1'
:[
'choice_foil3'
]}
false_answers
=
{
'1_2_1'
:[
'choice_foil3'
]}
self
.
assertEquals
(
test_lcp
.
grade_answers
(
false_answers
)
[
'1_2_1'
]
,
'incorrect'
)
self
.
assertEquals
(
test_lcp
.
grade_answers
(
false_answers
)
.
get_correctness
(
'1_2_1'
)
,
'incorrect'
)
false_answers
=
{
'1_2_1'
:[
'choice_foil1'
,
'choice_foil2'
,
'choice_foil3'
]}
false_answers
=
{
'1_2_1'
:[
'choice_foil1'
,
'choice_foil2'
,
'choice_foil3'
]}
self
.
assertEquals
(
test_lcp
.
grade_answers
(
false_answers
)
[
'1_2_1'
]
,
'incorrect'
)
self
.
assertEquals
(
test_lcp
.
grade_answers
(
false_answers
)
.
get_correctness
(
'1_2_1'
)
,
'incorrect'
)
class
ImageResponseTest
(
unittest
.
TestCase
):
class
ImageResponseTest
(
unittest
.
TestCase
):
def
test_ir_grade
(
self
):
def
test_ir_grade
(
self
):
...
@@ -131,8 +131,8 @@ class ImageResponseTest(unittest.TestCase):
...
@@ -131,8 +131,8 @@ class ImageResponseTest(unittest.TestCase):
test_answers
=
{
'1_2_1'
:
'[500,20]'
,
test_answers
=
{
'1_2_1'
:
'[500,20]'
,
'1_2_2'
:
'[250,300]'
,
'1_2_2'
:
'[250,300]'
,
}
}
self
.
assertEquals
(
test_lcp
.
grade_answers
(
test_answers
)
[
'1_2_1'
]
,
'correct'
)
self
.
assertEquals
(
test_lcp
.
grade_answers
(
test_answers
)
.
get_correctness
(
'1_2_1'
)
,
'correct'
)
self
.
assertEquals
(
test_lcp
.
grade_answers
(
test_answers
)
[
'1_2_2'
]
,
'incorrect'
)
self
.
assertEquals
(
test_lcp
.
grade_answers
(
test_answers
)
.
get_correctness
(
'1_2_2'
)
,
'incorrect'
)
class
SymbolicResponseTest
(
unittest
.
TestCase
):
class
SymbolicResponseTest
(
unittest
.
TestCase
):
def
test_sr_grade
(
self
):
def
test_sr_grade
(
self
):
...
@@ -220,8 +220,8 @@ class SymbolicResponseTest(unittest.TestCase):
...
@@ -220,8 +220,8 @@ class SymbolicResponseTest(unittest.TestCase):
</mstyle>
</mstyle>
</math>'''
,
</math>'''
,
}
}
self
.
assertEquals
(
test_lcp
.
grade_answers
(
correct_answers
)
[
'1_2_1'
]
,
'correct'
)
self
.
assertEquals
(
test_lcp
.
grade_answers
(
correct_answers
)
.
get_correctness
(
'1_2_1'
)
,
'correct'
)
self
.
assertEquals
(
test_lcp
.
grade_answers
(
wrong_answers
)
[
'1_2_1'
]
,
'incorrect'
)
self
.
assertEquals
(
test_lcp
.
grade_answers
(
wrong_answers
)
.
get_correctness
(
'1_2_1'
)
,
'incorrect'
)
class
OptionResponseTest
(
unittest
.
TestCase
):
class
OptionResponseTest
(
unittest
.
TestCase
):
'''
'''
...
@@ -237,8 +237,8 @@ class OptionResponseTest(unittest.TestCase):
...
@@ -237,8 +237,8 @@ class OptionResponseTest(unittest.TestCase):
test_answers
=
{
'1_2_1'
:
'True'
,
test_answers
=
{
'1_2_1'
:
'True'
,
'1_2_2'
:
'True'
,
'1_2_2'
:
'True'
,
}
}
self
.
assertEquals
(
test_lcp
.
grade_answers
(
test_answers
)
[
'1_2_1'
]
,
'correct'
)
self
.
assertEquals
(
test_lcp
.
grade_answers
(
test_answers
)
.
get_correctness
(
'1_2_1'
)
,
'correct'
)
self
.
assertEquals
(
test_lcp
.
grade_answers
(
test_answers
)
[
'1_2_2'
]
,
'incorrect'
)
self
.
assertEquals
(
test_lcp
.
grade_answers
(
test_answers
)
.
get_correctness
(
'1_2_2'
)
,
'incorrect'
)
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Grading tests
# Grading tests
...
...
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