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
ea73feda
Commit
ea73feda
authored
Jul 19, 2012
by
Arjun Singh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for ChoiceResponses.
parent
a54f5902
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
127 additions
and
1 deletions
+127
-1
common/lib/capa/capa/responsetypes.py
+1
-1
common/lib/xmodule/tests/__init__.py
+27
-0
common/lib/xmodule/tests/test_files/choiceresponse_checkbox.xml
+59
-0
common/lib/xmodule/tests/test_files/choiceresponse_radio.xml
+40
-0
No files found.
common/lib/capa/capa/responsetypes.py
View file @
ea73feda
...
...
@@ -325,7 +325,7 @@ class ChoiceResponse(LoncapaResponse):
def
assign_choice_names
(
self
):
'''
Initialize name attributes in <choice> tags for his response.
Initialize name attributes in <choice> tags for
t
his response.
'''
for
index
,
choice
in
enumerate
(
self
.
xml
.
xpath
(
'//*[@id=$id]//choice'
,
...
...
common/lib/xmodule/tests/__init__.py
View file @
ea73feda
...
...
@@ -325,6 +325,33 @@ class CodeResponseTest(unittest.TestCase):
else
:
self
.
assertTrue
(
test_lcp
.
correct_map
.
is_queued
(
answer_ids
[
j
]))
# Should be queued, message undelivered
class
ChoiceResponseTest
(
unittest
.
TestCase
):
def
test_cr_rb_grade
(
self
):
problem_file
=
os
.
path
.
dirname
(
__file__
)
+
"/test_files/choiceresponse_radio.xml"
test_lcp
=
lcp
.
LoncapaProblem
(
open
(
problem_file
)
.
read
(),
'1'
,
system
=
i4xs
)
correct_answers
=
{
'1_2_1'
:
'choice_2'
,
'1_3_1'
:[
'choice_2'
,
'choice_3'
]}
test_answers
=
{
'1_2_1'
:
'choice_2'
,
'1_3_1'
:
'choice_2'
,
}
self
.
assertEquals
(
test_lcp
.
grade_answers
(
test_answers
)
.
get_correctness
(
'1_2_1'
),
'correct'
)
self
.
assertEquals
(
test_lcp
.
grade_answers
(
test_answers
)
.
get_correctness
(
'1_3_1'
),
'incorrect'
)
def
test_cr_cb_grade
(
self
):
problem_file
=
os
.
path
.
dirname
(
__file__
)
+
"/test_files/choiceresponse_checkbox.xml"
test_lcp
=
lcp
.
LoncapaProblem
(
open
(
problem_file
)
.
read
(),
'1'
,
system
=
i4xs
)
correct_answers
=
{
'1_2_1'
:
'choice_2'
,
'1_3_1'
:[
'choice_2'
,
'choice_3'
],
'1_4_1'
:[
'choice_2'
,
'choice_3'
]}
test_answers
=
{
'1_2_1'
:
'choice_2'
,
'1_3_1'
:
'choice_2'
,
'1_4_1'
:[
'choice_2'
,
'choice_3'
],
}
self
.
assertEquals
(
test_lcp
.
grade_answers
(
test_answers
)
.
get_correctness
(
'1_2_1'
),
'correct'
)
self
.
assertEquals
(
test_lcp
.
grade_answers
(
test_answers
)
.
get_correctness
(
'1_3_1'
),
'incorrect'
)
self
.
assertEquals
(
test_lcp
.
grade_answers
(
test_answers
)
.
get_correctness
(
'1_4_1'
),
'correct'
)
#-----------------------------------------------------------------------------
# Grading tests
...
...
common/lib/xmodule/tests/test_files/choiceresponse_checkbox.xml
0 → 100644
View file @
ea73feda
<problem>
<choiceresponse>
<checkboxgroup>
<choice
correct=
"false"
>
<startouttext
/>
This is foil One.
<endouttext
/>
</choice>
<choice
correct=
"false"
>
<startouttext
/>
This is foil Two.
<endouttext
/>
</choice>
<choice
correct=
"true"
>
<startouttext
/>
This is foil Three.
<endouttext
/>
</choice>
<choice
correct=
"false"
>
<startouttext
/>
This is foil Four.
<endouttext
/>
</choice>
<choice
correct=
"false"
>
<startouttext
/>
This is foil Five.
<endouttext
/>
</choice>
</checkboxgroup>
</choiceresponse>
<choiceresponse>
<checkboxgroup>
<choice
correct=
"false"
>
<startouttext
/>
This is foil One.
<endouttext
/>
</choice>
<choice
correct=
"false"
>
<startouttext
/>
This is foil Two.
<endouttext
/>
</choice>
<choice
correct=
"true"
>
<startouttext
/>
This is foil Three.
<endouttext
/>
</choice>
<choice
correct=
"true"
>
<startouttext
/>
This is foil Four.
<endouttext
/>
</choice>
<choice
correct=
"false"
>
<startouttext
/>
This is foil Five.
<endouttext
/>
</choice>
</checkboxgroup>
</choiceresponse>
<choiceresponse>
<checkboxgroup>
<choice
correct=
"false"
>
<startouttext
/>
This is foil One.
<endouttext
/>
</choice>
<choice
correct=
"false"
>
<startouttext
/>
This is foil Two.
<endouttext
/>
</choice>
<choice
correct=
"true"
>
<startouttext
/>
This is foil Three.
<endouttext
/>
</choice>
<choice
correct=
"true"
>
<startouttext
/>
This is foil Four.
<endouttext
/>
</choice>
<choice
correct=
"false"
>
<startouttext
/>
This is foil Five.
<endouttext
/>
</choice>
</checkboxgroup>
</choiceresponse>
</problem>
common/lib/xmodule/tests/test_files/choiceresponse_radio.xml
0 → 100644
View file @
ea73feda
<problem>
<choiceresponse>
<radiogroup>
<choice
correct=
"false"
>
<startouttext
/>
This is foil One.
<endouttext
/>
</choice>
<choice
correct=
"false"
>
<startouttext
/>
This is foil Two.
<endouttext
/>
</choice>
<choice
correct=
"true"
>
<startouttext
/>
This is foil Three.
<endouttext
/>
</choice>
<choice
correct=
"false"
>
<startouttext
/>
This is foil Four.
<endouttext
/>
</choice>
<choice
correct=
"false"
>
<startouttext
/>
This is foil Five.
<endouttext
/>
</choice>
</radiogroup>
</choiceresponse>
<choiceresponse>
<radiogroup>
<choice
correct=
"false"
>
<startouttext
/>
This is foil One.
<endouttext
/>
</choice>
<choice
correct=
"false"
>
<startouttext
/>
This is foil Two.
<endouttext
/>
</choice>
<choice
correct=
"true"
>
<startouttext
/>
This is foil Three.
<endouttext
/>
</choice>
<choice
correct=
"true"
>
<startouttext
/>
This is foil Four.
<endouttext
/>
</choice>
<choice
correct=
"false"
>
<startouttext
/>
This is foil Five.
<endouttext
/>
</choice>
</radiogroup>
</choiceresponse>
</problem>
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