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
7ff03124
Commit
7ff03124
authored
Aug 23, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pep8, pylint, and more tests
parent
734843c3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
12 deletions
+58
-12
common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_modulev1.py
+5
-5
common/lib/xmodule/xmodule/tests/test_combined_open_ended.py
+53
-7
common/lib/xmodule/xmodule/tests/test_util_open_ended.py
+0
-0
No files found.
common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_modulev1.py
View file @
7ff03124
...
@@ -35,8 +35,8 @@ TRUE_DICT = ["True", True, "TRUE", "true"]
...
@@ -35,8 +35,8 @@ TRUE_DICT = ["True", True, "TRUE", "true"]
HUMAN_TASK_TYPE
=
{
HUMAN_TASK_TYPE
=
{
'selfassessment'
:
"Self"
,
'selfassessment'
:
"Self"
,
'openended'
:
"edX"
,
'openended'
:
"edX"
,
'ml_grading.conf'
:
"AI"
,
'ml_grading.conf'
:
"AI"
,
'peer_grading.conf'
:
"Peer"
,
'peer_grading.conf'
:
"Peer"
,
}
}
HUMAN_STATES
=
{
HUMAN_STATES
=
{
...
@@ -379,7 +379,7 @@ class CombinedOpenEndedV1Module():
...
@@ -379,7 +379,7 @@ class CombinedOpenEndedV1Module():
'accept_file_upload'
:
self
.
accept_file_upload
,
'accept_file_upload'
:
self
.
accept_file_upload
,
'location'
:
self
.
location
,
'location'
:
self
.
location
,
'legend_list'
:
LEGEND_LIST
,
'legend_list'
:
LEGEND_LIST
,
'human_state'
:
HUMAN_STATES
.
get
(
self
.
state
,
"Not started."
)
'human_state'
:
HUMAN_STATES
.
get
(
self
.
state
,
"Not started."
)
}
}
return
context
return
context
...
@@ -535,14 +535,14 @@ class CombinedOpenEndedV1Module():
...
@@ -535,14 +535,14 @@ class CombinedOpenEndedV1Module():
'feedback_dicts'
:
feedback_dicts
,
'feedback_dicts'
:
feedback_dicts
,
'grader_ids'
:
grader_ids
,
'grader_ids'
:
grader_ids
,
'submission_ids'
:
submission_ids
,
'submission_ids'
:
submission_ids
,
'success'
:
True
'success'
:
True
}
}
return
last_response_dict
return
last_response_dict
def
extract_human_name_from_task
(
self
,
task_xml
):
def
extract_human_name_from_task
(
self
,
task_xml
):
tree
=
etree
.
fromstring
(
task_xml
)
tree
=
etree
.
fromstring
(
task_xml
)
payload
=
tree
.
xpath
(
"/openended/openendedparam/grader_payload"
)
payload
=
tree
.
xpath
(
"/openended/openendedparam/grader_payload"
)
if
len
(
payload
)
==
0
:
if
len
(
payload
)
==
0
:
task_name
=
"selfassessment"
task_name
=
"selfassessment"
else
:
else
:
inner_payload
=
json
.
loads
(
payload
[
0
]
.
text
)
inner_payload
=
json
.
loads
(
payload
[
0
]
.
text
)
...
...
common/lib/xmodule/xmodule/tests/test_combined_open_ended.py
View file @
7ff03124
...
@@ -23,7 +23,8 @@ from xmodule.combined_open_ended_module import CombinedOpenEndedModule
...
@@ -23,7 +23,8 @@ from xmodule.combined_open_ended_module import CombinedOpenEndedModule
from
xmodule.modulestore
import
Location
from
xmodule.modulestore
import
Location
from
xmodule.tests
import
get_test_system
,
test_util_open_ended
from
xmodule.tests
import
get_test_system
,
test_util_open_ended
from
xmodule.tests.test_util_open_ended
import
(
MockQueryDict
,
DummyModulestore
,
TEST_STATE_SA_IN
,
from
xmodule.tests.test_util_open_ended
import
(
MockQueryDict
,
DummyModulestore
,
TEST_STATE_SA_IN
,
MOCK_INSTANCE_STATE
,
TEST_STATE_SA
,
TEST_STATE_AI
,
TEST_STATE_AI2
,
TEST_STATE_AI2_INVALID
)
MOCK_INSTANCE_STATE
,
TEST_STATE_SA
,
TEST_STATE_AI
,
TEST_STATE_AI2
,
TEST_STATE_AI2_INVALID
,
TEST_STATE_SINGLE
,
TEST_STATE_PE_SINGLE
)
import
capa.xqueue_interface
as
xqueue_interface
import
capa.xqueue_interface
as
xqueue_interface
...
@@ -424,8 +425,6 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
...
@@ -424,8 +425,6 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
)
)
def
setUp
(
self
):
def
setUp
(
self
):
# TODO: this constructor call is definitely wrong, but neither branch
# of the merge matches the module constructor. Someone (Vik?) should fix this.
self
.
combinedoe
=
CombinedOpenEndedV1Module
(
self
.
test_system
,
self
.
combinedoe
=
CombinedOpenEndedV1Module
(
self
.
test_system
,
self
.
location
,
self
.
location
,
self
.
definition
,
self
.
definition
,
...
@@ -435,16 +434,25 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
...
@@ -435,16 +434,25 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
instance_state
=
self
.
static_data
)
instance_state
=
self
.
static_data
)
def
test_get_tag_name
(
self
):
def
test_get_tag_name
(
self
):
"""
Test to see if the xml tag name is correct
"""
name
=
self
.
combinedoe
.
get_tag_name
(
"<t>Tag</t>"
)
name
=
self
.
combinedoe
.
get_tag_name
(
"<t>Tag</t>"
)
self
.
assertEqual
(
name
,
"t"
)
self
.
assertEqual
(
name
,
"t"
)
def
test_get_last_response
(
self
):
def
test_get_last_response
(
self
):
"""
See if we can parse the last response
"""
response_dict
=
self
.
combinedoe
.
get_last_response
(
0
)
response_dict
=
self
.
combinedoe
.
get_last_response
(
0
)
self
.
assertEqual
(
response_dict
[
'type'
],
"selfassessment"
)
self
.
assertEqual
(
response_dict
[
'type'
],
"selfassessment"
)
self
.
assertEqual
(
response_dict
[
'max_score'
],
self
.
max_score
)
self
.
assertEqual
(
response_dict
[
'max_score'
],
self
.
max_score
)
self
.
assertEqual
(
response_dict
[
'state'
],
CombinedOpenEndedV1Module
.
INITIAL
)
self
.
assertEqual
(
response_dict
[
'state'
],
CombinedOpenEndedV1Module
.
INITIAL
)
def
test_update_task_states
(
self
):
def
test_update_task_states
(
self
):
"""
See if we can update the task states properly
"""
changed
=
self
.
combinedoe
.
update_task_states
()
changed
=
self
.
combinedoe
.
update_task_states
()
self
.
assertFalse
(
changed
)
self
.
assertFalse
(
changed
)
...
@@ -455,6 +463,9 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
...
@@ -455,6 +463,9 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
self
.
assertTrue
(
changed
)
self
.
assertTrue
(
changed
)
def
test_get_max_score
(
self
):
def
test_get_max_score
(
self
):
"""
Try to get the max score of the problem
"""
self
.
combinedoe
.
update_task_states
()
self
.
combinedoe
.
update_task_states
()
self
.
combinedoe
.
state
=
"done"
self
.
combinedoe
.
state
=
"done"
self
.
combinedoe
.
is_scored
=
True
self
.
combinedoe
.
is_scored
=
True
...
@@ -462,24 +473,39 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
...
@@ -462,24 +473,39 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
self
.
assertEqual
(
max_score
,
1
)
self
.
assertEqual
(
max_score
,
1
)
def
test_container_get_max_score
(
self
):
def
test_container_get_max_score
(
self
):
"""
See if we can get the max score from the actual xmodule
"""
#The progress view requires that this function be exposed
#The progress view requires that this function be exposed
max_score
=
self
.
combinedoe_container
.
max_score
()
max_score
=
self
.
combinedoe_container
.
max_score
()
self
.
assertEqual
(
max_score
,
None
)
self
.
assertEqual
(
max_score
,
None
)
def
test_container_weight
(
self
):
def
test_container_weight
(
self
):
"""
Check the problem weight in the container
"""
weight
=
self
.
combinedoe_container
.
weight
weight
=
self
.
combinedoe_container
.
weight
self
.
assertEqual
(
weight
,
1
)
self
.
assertEqual
(
weight
,
1
)
def
test_container_child_weight
(
self
):
def
test_container_child_weight
(
self
):
"""
Test the class to see if it picks up the right weight
"""
weight
=
self
.
combinedoe_container
.
child_module
.
weight
weight
=
self
.
combinedoe_container
.
child_module
.
weight
self
.
assertEqual
(
weight
,
1
)
self
.
assertEqual
(
weight
,
1
)
def
test_get_score
(
self
):
def
test_get_score
(
self
):
"""
See if scoring works
"""
score_dict
=
self
.
combinedoe
.
get_score
()
score_dict
=
self
.
combinedoe
.
get_score
()
self
.
assertEqual
(
score_dict
[
'score'
],
0
)
self
.
assertEqual
(
score_dict
[
'score'
],
0
)
self
.
assertEqual
(
score_dict
[
'total'
],
1
)
self
.
assertEqual
(
score_dict
[
'total'
],
1
)
def
test_alternate_orderings
(
self
):
def
test_alternate_orderings
(
self
):
"""
Try multiple ordering of definitions to see if the problem renders different steps correctly.
"""
t1
=
self
.
task_xml1
t1
=
self
.
task_xml1
t2
=
self
.
task_xml2
t2
=
self
.
task_xml2
xml_to_test
=
[[
t1
],
[
t2
],
[
t1
,
t1
],
[
t1
,
t2
],
[
t2
,
t2
],
[
t2
,
t1
],
[
t1
,
t2
,
t1
]]
xml_to_test
=
[[
t1
],
[
t2
],
[
t1
,
t1
],
[
t1
,
t2
],
[
t2
,
t2
],
[
t2
,
t1
],
[
t1
,
t2
,
t1
]]
...
@@ -515,6 +541,9 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
...
@@ -515,6 +541,9 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
def
test_get_score_realistic
(
self
):
def
test_get_score_realistic
(
self
):
"""
Try to parse the correct score from a json instance state
"""
instance_state
=
json
.
loads
(
MOCK_INSTANCE_STATE
)
instance_state
=
json
.
loads
(
MOCK_INSTANCE_STATE
)
rubric
=
"""
rubric
=
"""
<rubric>
<rubric>
...
@@ -544,10 +573,13 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
...
@@ -544,10 +573,13 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
self
.
assertEqual
(
score_dict
[
'total'
],
15.0
)
self
.
assertEqual
(
score_dict
[
'total'
],
15.0
)
def
ai_state
(
self
,
task_state
,
task_number
,
task_xml
):
def
ai_state
(
self
,
task_state
,
task_number
,
task_xml
):
"""
See if state is properly reset or left unchanged
"""
definition
=
{
'prompt'
:
etree
.
XML
(
self
.
prompt
),
'rubric'
:
etree
.
XML
(
self
.
rubric
),
definition
=
{
'prompt'
:
etree
.
XML
(
self
.
prompt
),
'rubric'
:
etree
.
XML
(
self
.
rubric
),
'task_xml'
:
task_xml
}
'task_xml'
:
task_xml
}
descriptor
=
Mock
(
data
=
definition
)
descriptor
=
Mock
(
data
=
definition
)
instance_state
=
{
'task_states'
:
task_state
,
'graded'
:
True
}
instance_state
=
{
'task_states'
:
task_state
,
'graded'
:
True
}
if
task_number
is
not
None
:
if
task_number
is
not
None
:
instance_state
.
update
({
'current_task_number'
:
task_number
})
instance_state
.
update
({
'current_task_number'
:
task_number
})
combinedoe
=
CombinedOpenEndedV1Module
(
self
.
test_system
,
combinedoe
=
CombinedOpenEndedV1Module
(
self
.
test_system
,
...
@@ -560,16 +592,24 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
...
@@ -560,16 +592,24 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
return
combinedoe
return
combinedoe
def
ai_state_reset
(
self
,
task_state
,
task_number
=
None
):
def
ai_state_reset
(
self
,
task_state
,
task_number
=
None
):
"""
See if state is properly reset
"""
combinedoe
=
self
.
ai_state
(
task_state
,
task_number
,
[
self
.
task_xml2
])
combinedoe
=
self
.
ai_state
(
task_state
,
task_number
,
[
self
.
task_xml2
])
html
=
combinedoe
.
get_html
()
html
=
combinedoe
.
get_html
()
self
.
assertIsInstance
(
html
,
basestring
)
self
.
assertIsInstance
(
html
,
basestring
)
def
ai_state_success
(
self
,
task_state
,
task_number
=
None
):
def
ai_state_success
(
self
,
task_state
,
task_number
=
None
,
iscore
=
2
,
tasks
=
None
):
combinedoe
=
self
.
ai_state
(
task_state
,
task_number
,
[
self
.
task_xml1
,
self
.
task_xml2
])
"""
See if state stays the same
"""
if
tasks
is
None
:
tasks
=
[
self
.
task_xml1
,
self
.
task_xml2
]
combinedoe
=
self
.
ai_state
(
task_state
,
task_number
,
tasks
)
html
=
combinedoe
.
get_html
()
html
=
combinedoe
.
get_html
()
self
.
assertIsInstance
(
html
,
basestring
)
self
.
assertIsInstance
(
html
,
basestring
)
score
=
combinedoe
.
get_score
()
score
=
combinedoe
.
get_score
()
self
.
assertEqual
(
int
(
score
[
'score'
]),
2
)
self
.
assertEqual
(
int
(
score
[
'score'
]),
iscore
)
def
test_ai_state_reset
(
self
):
def
test_ai_state_reset
(
self
):
self
.
ai_state_reset
(
TEST_STATE_AI
)
self
.
ai_state_reset
(
TEST_STATE_AI
)
...
@@ -589,6 +629,12 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
...
@@ -589,6 +629,12 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
def
test_ai_state_success
(
self
):
def
test_ai_state_success
(
self
):
self
.
ai_state_success
(
TEST_STATE_AI
)
self
.
ai_state_success
(
TEST_STATE_AI
)
def
test_state_single
(
self
):
self
.
ai_state_success
(
TEST_STATE_SINGLE
,
iscore
=
12
)
def
test_state_pe_single
(
self
):
self
.
ai_state_success
(
TEST_STATE_PE_SINGLE
,
iscore
=
0
,
tasks
=
[
self
.
task_xml2
])
class
OpenEndedModuleXmlTest
(
unittest
.
TestCase
,
DummyModulestore
):
class
OpenEndedModuleXmlTest
(
unittest
.
TestCase
,
DummyModulestore
):
"""
"""
Test the student flow in the combined open ended xmodule
Test the student flow in the combined open ended xmodule
...
...
common/lib/xmodule/xmodule/tests/test_util_open_ended.py
View file @
7ff03124
This diff is collapsed.
Click to expand it.
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