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
b210346f
Commit
b210346f
authored
Aug 23, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add in more tests
parent
4e8b839d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
2 deletions
+51
-2
common/lib/xmodule/xmodule/open_ended_grading_classes/combined_open_ended_modulev1.py
+4
-1
common/lib/xmodule/xmodule/tests/test_combined_open_ended.py
+47
-1
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 @
b210346f
...
@@ -178,7 +178,7 @@ class CombinedOpenEndedV1Module():
...
@@ -178,7 +178,7 @@ class CombinedOpenEndedV1Module():
if
self
.
current_task_number
>
len
(
self
.
task_states
)
or
self
.
current_task_number
>
len
(
self
.
task_xml
):
if
self
.
current_task_number
>
len
(
self
.
task_states
)
or
self
.
current_task_number
>
len
(
self
.
task_xml
):
self
.
current_task_number
=
min
([
len
(
self
.
task_states
),
len
(
self
.
task_xml
)])
-
1
self
.
current_task_number
=
min
([
len
(
self
.
task_states
),
len
(
self
.
task_xml
)])
-
1
#If the length of the task xml is less than the length of the task states, state is invalid
#If the length of the task xml is less than the length of the task states, state is invalid
el
if
len
(
self
.
task_xml
)
<
len
(
self
.
task_states
):
if
len
(
self
.
task_xml
)
<
len
(
self
.
task_states
):
self
.
current_task_number
=
0
self
.
current_task_number
=
0
self
.
task_states
=
self
.
task_states
[:
len
(
self
.
task_xml
)]
self
.
task_states
=
self
.
task_states
[:
len
(
self
.
task_xml
)]
#Loop through each task state and make sure it matches the xml definition
#Loop through each task state and make sure it matches the xml definition
...
@@ -197,6 +197,7 @@ class CombinedOpenEndedV1Module():
...
@@ -197,6 +197,7 @@ class CombinedOpenEndedV1Module():
self
.
static_data
,
self
.
static_data
,
instance_state
=
t
,
instance_state
=
t
,
)
)
#Loop through each attempt of the task and see if it is valid.
for
att
in
task
.
child_history
:
for
att
in
task
.
child_history
:
if
"post_assessment"
not
in
att
:
if
"post_assessment"
not
in
att
:
continue
continue
...
@@ -212,6 +213,8 @@ class CombinedOpenEndedV1Module():
...
@@ -212,6 +213,8 @@ class CombinedOpenEndedV1Module():
elif
tag_name
==
"selfassessment"
and
not
isinstance
(
pa
,
list
):
elif
tag_name
==
"selfassessment"
and
not
isinstance
(
pa
,
list
):
self
.
reset_task_state
(
"Type is self assessment and post assessment is not a list."
)
self
.
reset_task_state
(
"Type is self assessment and post assessment is not a list."
)
break
break
#See if we can properly render the task. Will go into the exception clause below if not.
task
.
get_html
(
self
.
system
)
except
Exception
as
err
:
except
Exception
as
err
:
#If one task doesn't match, the state is invalid.
#If one task doesn't match, the state is invalid.
self
.
reset_task_state
(
"Could not parse task. {0}"
.
format
(
err
))
self
.
reset_task_state
(
"Could not parse task. {0}"
.
format
(
err
))
...
...
common/lib/xmodule/xmodule/tests/test_combined_open_ended.py
View file @
b210346f
...
@@ -22,7 +22,8 @@ from xmodule.open_ended_grading_classes.grading_service_module import GradingSer
...
@@ -22,7 +22,8 @@ from xmodule.open_ended_grading_classes.grading_service_module import GradingSer
from
xmodule.combined_open_ended_module
import
CombinedOpenEndedModule
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
,
MOCK_INSTANCE_STATE
,
TEST_STATE_SA
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
)
import
capa.xqueue_interface
as
xqueue_interface
import
capa.xqueue_interface
as
xqueue_interface
...
@@ -542,6 +543,51 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
...
@@ -542,6 +543,51 @@ class CombinedOpenEndedModuleTest(unittest.TestCase):
self
.
assertEqual
(
score_dict
[
'score'
],
15.0
)
self
.
assertEqual
(
score_dict
[
'score'
],
15.0
)
self
.
assertEqual
(
score_dict
[
'total'
],
15.0
)
self
.
assertEqual
(
score_dict
[
'total'
],
15.0
)
def
ai_state
(
self
,
task_state
,
task_number
,
task_xml
):
definition
=
{
'prompt'
:
etree
.
XML
(
self
.
prompt
),
'rubric'
:
etree
.
XML
(
self
.
rubric
),
'task_xml'
:
task_xml
}
descriptor
=
Mock
(
data
=
definition
)
instance_state
=
{
'task_states'
:
task_state
,
'graded'
:
True
}
if
task_number
is
not
None
:
instance_state
.
update
({
'current_task_number'
:
task_number
})
combinedoe
=
CombinedOpenEndedV1Module
(
self
.
test_system
,
self
.
location
,
definition
,
descriptor
,
static_data
=
self
.
static_data
,
metadata
=
self
.
metadata
,
instance_state
=
instance_state
)
return
combinedoe
def
ai_state_reset
(
self
,
task_state
,
task_number
=
None
):
combinedoe
=
self
.
ai_state
(
task_state
,
task_number
,
[
self
.
task_xml2
])
html
=
combinedoe
.
get_html
()
self
.
assertIsInstance
(
html
,
basestring
)
def
ai_state_success
(
self
,
task_state
,
task_number
=
None
):
combinedoe
=
self
.
ai_state
(
task_state
,
task_number
,
[
self
.
task_xml1
,
self
.
task_xml2
])
html
=
combinedoe
.
get_html
()
self
.
assertIsInstance
(
html
,
basestring
)
score
=
combinedoe
.
get_score
()
self
.
assertEqual
(
int
(
score
[
'score'
]),
2
)
def
test_ai_state_reset
(
self
):
self
.
ai_state_reset
(
TEST_STATE_AI
)
def
test_ai_state2_reset
(
self
):
self
.
ai_state_reset
(
TEST_STATE_AI2
)
def
test_ai_invalid_state
(
self
):
self
.
ai_state_reset
(
TEST_STATE_AI2_INVALID
)
def
test_ai_state_rest_task_number
(
self
):
self
.
ai_state_reset
(
TEST_STATE_AI
,
task_number
=
2
)
self
.
ai_state_reset
(
TEST_STATE_AI
,
task_number
=
5
)
self
.
ai_state_reset
(
TEST_STATE_AI
,
task_number
=
1
)
self
.
ai_state_reset
(
TEST_STATE_AI
,
task_number
=
0
)
def
test_ai_state_success
(
self
):
self
.
ai_state_success
(
TEST_STATE_AI
)
class
OpenEndedModuleXmlTest
(
unittest
.
TestCase
,
DummyModulestore
):
class
OpenEndedModuleXmlTest
(
unittest
.
TestCase
,
DummyModulestore
):
"""
"""
...
...
common/lib/xmodule/xmodule/tests/test_util_open_ended.py
View file @
b210346f
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