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
d82da9e7
Commit
d82da9e7
authored
Jan 06, 2015
by
Jonathan Piacenti
Committed by
E. Kolpakov
Jan 12, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test filter for problems with multiple capa response types.
parent
7c11a83f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
22 deletions
+31
-22
common/lib/xmodule/xmodule/tests/test_library_content.py
+31
-22
No files found.
common/lib/xmodule/xmodule/tests/test_library_content.py
View file @
d82da9e7
...
...
@@ -80,28 +80,33 @@ class TestLibraries(MixedSplitTestCase):
module_system
.
get_module
=
get_module
module
.
xmodule_runtime
=
module_system
def
_get_capa_problem_type_xml
(
self
,
problem_type
):
def
_get_capa_problem_type_xml
(
self
,
*
args
):
""" Helper function to create empty CAPA problem definition """
return
"<problem><{problem_type}></{problem_type}></problem>"
.
format
(
problem_type
=
problem_type
)
problem
=
"<problem>"
for
problem_type
in
args
:
problem
+=
"<{problem_type}></{problem_type}>"
.
format
(
problem_type
=
problem_type
)
problem
+=
"</problem>"
return
problem
def
_create_capa_problems
(
self
):
""" Helper function to create two capa problems: multiplechoiceresponse and optionresponse """
ItemFactory
.
create
(
category
=
"problem"
,
parent_location
=
self
.
library
.
location
,
user_id
=
self
.
user_id
,
publish_item
=
False
,
data
=
self
.
_get_capa_problem_type_xml
(
"multiplechoiceresponse"
),
modulestore
=
self
.
store
,
)
ItemFactory
.
create
(
category
=
"problem"
,
parent_location
=
self
.
library
.
location
,
user_id
=
self
.
user_id
,
publish_item
=
False
,
data
=
self
.
_get_capa_problem_type_xml
(
"optionresponse"
),
modulestore
=
self
.
store
,
)
"""
Helper function to create a set of capa problems to test against.
Creates four blocks total.
"""
problem_types
=
[
[
"multiplechoiceresponse"
],
[
"optionresponse"
],
[
"optionresponse"
,
"coderesponse"
],
[
"coderesponse"
,
"optionresponse"
]
]
for
problem_type
in
problem_types
:
ItemFactory
.
create
(
category
=
"problem"
,
parent_location
=
self
.
library
.
location
,
user_id
=
self
.
user_id
,
publish_item
=
False
,
data
=
self
.
_get_capa_problem_type_xml
(
*
problem_type
),
modulestore
=
self
.
store
,
)
def
test_lib_content_block
(
self
):
"""
...
...
@@ -184,7 +189,7 @@ class TestLibraries(MixedSplitTestCase):
self
.
assertTrue
(
self
.
lc_block
.
validate
())
# ... unless requested more blocks than exists in library
self
.
lc_block
.
max_count
=
3
self
.
lc_block
.
max_count
=
10
self
.
lc_block
.
capa_type
=
'multiplechoiceresponse'
result
=
self
.
lc_block
.
validate
()
self
.
assertFalse
(
result
)
# Validation fails due to at least one warning/message
...
...
@@ -213,7 +218,11 @@ class TestLibraries(MixedSplitTestCase):
self
.
lc_block
.
capa_type
=
"optionresponse"
self
.
lc_block
.
refresh_children
(
None
,
None
)
self
.
assertEqual
(
len
(
self
.
lc_block
.
children
),
1
)
self
.
assertEqual
(
len
(
self
.
lc_block
.
children
),
3
)
self
.
lc_block
.
capa_type
=
"coderesponse"
self
.
lc_block
.
refresh_children
(
None
,
None
)
self
.
assertEqual
(
len
(
self
.
lc_block
.
children
),
2
)
self
.
lc_block
.
capa_type
=
"customresponse"
self
.
lc_block
.
refresh_children
(
None
,
None
)
...
...
@@ -221,4 +230,4 @@ class TestLibraries(MixedSplitTestCase):
self
.
lc_block
.
capa_type
=
ANY_CAPA_TYPE_VALUE
self
.
lc_block
.
refresh_children
(
None
,
None
)
self
.
assertEqual
(
len
(
self
.
lc_block
.
children
),
len
(
self
.
lib_blocks
)
+
2
)
self
.
assertEqual
(
len
(
self
.
lc_block
.
children
),
len
(
self
.
lib_blocks
)
+
4
)
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