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
9cd38d11
Commit
9cd38d11
authored
Mar 20, 2013
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
import needs to enumerate through the fields for all content scopes. Also add unit test
parent
93eebdcd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
3 deletions
+34
-3
cms/djangoapps/contentstore/tests/test_contentstore.py
+14
-0
common/lib/xmodule/xmodule/modulestore/xml_importer.py
+15
-3
common/test/data/full/vertical/vertical_89.xml
+5
-0
No files found.
cms/djangoapps/contentstore/tests/test_contentstore.py
View file @
9cd38d11
...
@@ -101,6 +101,20 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
...
@@ -101,6 +101,20 @@ class ContentStoreToyCourseTest(ModuleStoreTestCase):
self
.
assertEqual
(
reverse_tabs
,
course_tabs
)
self
.
assertEqual
(
reverse_tabs
,
course_tabs
)
def
test_import_polls
(
self
):
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
'full'
])
module_store
=
modulestore
(
'direct'
)
found
=
False
item
=
None
items
=
module_store
.
get_items
([
'i4x'
,
'edX'
,
'full'
,
'poll_question'
,
None
,
None
])
found
=
len
(
items
)
>
0
self
.
assertTrue
(
found
)
# check that there's actually content in the 'question' field
self
.
assertGreater
(
len
(
items
[
0
]
.
question
),
0
)
def
test_delete
(
self
):
def
test_delete
(
self
):
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
'full'
])
import_from_xml
(
modulestore
(),
'common/test/data/'
,
[
'full'
])
...
...
common/lib/xmodule/xmodule/modulestore/xml_importer.py
View file @
9cd38d11
...
@@ -4,6 +4,8 @@ import mimetypes
...
@@ -4,6 +4,8 @@ import mimetypes
from
lxml.html
import
rewrite_links
as
lxml_rewrite_links
from
lxml.html
import
rewrite_links
as
lxml_rewrite_links
from
path
import
path
from
path
import
path
from
xblock.core
import
Scope
from
.xml
import
XMLModuleStore
from
.xml
import
XMLModuleStore
from
.exceptions
import
DuplicateItemError
from
.exceptions
import
DuplicateItemError
from
xmodule.modulestore
import
Location
from
xmodule.modulestore
import
Location
...
@@ -273,8 +275,18 @@ def import_from_xml(store, data_dir, course_dirs=None,
...
@@ -273,8 +275,18 @@ def import_from_xml(store, data_dir, course_dirs=None,
if
verbose
:
if
verbose
:
log
.
debug
(
'importing module location {0}'
.
format
(
module
.
location
))
log
.
debug
(
'importing module location {0}'
.
format
(
module
.
location
))
if
hasattr
(
module
,
'data'
):
content
=
{}
module_data
=
module
.
data
for
field
in
module
.
fields
:
if
field
.
scope
!=
Scope
.
content
:
continue
try
:
content
[
field
.
name
]
=
module
.
_model_data
[
field
.
name
]
except
KeyError
:
# Ignore any missing keys in _model_data
pass
if
'data'
in
content
:
module_data
=
content
[
'data'
]
# cdodge: now go through any link references to '/static/' and make sure we've imported
# cdodge: now go through any link references to '/static/' and make sure we've imported
# it as a StaticContent asset
# it as a StaticContent asset
...
@@ -298,7 +310,7 @@ def import_from_xml(store, data_dir, course_dirs=None,
...
@@ -298,7 +310,7 @@ def import_from_xml(store, data_dir, course_dirs=None,
except
Exception
,
e
:
except
Exception
,
e
:
logging
.
exception
(
"failed to rewrite links on {0}. Continuing..."
.
format
(
module
.
location
))
logging
.
exception
(
"failed to rewrite links on {0}. Continuing..."
.
format
(
module
.
location
))
store
.
update_item
(
module
.
location
,
module_data
)
store
.
update_item
(
module
.
location
,
content
)
if
hasattr
(
module
,
'children'
)
and
module
.
children
!=
[]:
if
hasattr
(
module
,
'children'
)
and
module
.
children
!=
[]:
store
.
update_children
(
module
.
location
,
module
.
children
)
store
.
update_children
(
module
.
location
,
module
.
children
)
...
...
common/test/data/full/vertical/vertical_89.xml
View file @
9cd38d11
...
@@ -7,4 +7,9 @@
...
@@ -7,4 +7,9 @@
<customtag
tag=
"S1"
slug=
"discuss_91"
impl=
"discuss"
/>
<customtag
tag=
"S1"
slug=
"discuss_91"
impl=
"discuss"
/>
<customtag
page=
"70"
slug=
"book_92"
impl=
"book"
/>
<customtag
page=
"70"
slug=
"book_92"
impl=
"book"
/>
<customtag
lecnum=
"1"
slug=
"slides_93"
impl=
"slides"
/>
<customtag
lecnum=
"1"
slug=
"slides_93"
impl=
"slides"
/>
<poll_question
name=
"T1_changemind_poll_foo"
display_name=
"Change your answer"
reset=
"false"
>
<p>
Have you changed your mind?
</p>
<answer
id=
"yes"
>
Yes
</answer>
<answer
id=
"no"
>
No
</answer>
</poll_question>
</sequential>
</sequential>
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