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
13af6fc1
Commit
13af6fc1
authored
Apr 09, 2014
by
Carson Gee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored terminology and added loop break for optimization
parent
4844a504
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
12 deletions
+14
-12
cms/djangoapps/contentstore/management/commands/tests/test_import.py
+8
-7
common/lib/xmodule/xmodule/modulestore/xml_importer.py
+6
-5
No files found.
cms/djangoapps/contentstore/management/commands/tests/test_import.py
View file @
13af6fc1
...
...
@@ -23,7 +23,7 @@ class TestImport(ModuleStoreTestCase):
"""
COURSE_ID
=
[
'EDx'
,
'0.00x'
,
'2013_Spring'
,
]
DIFF_
TERM
=
[
'EDx'
,
'0.00x'
,
'2014_Spring'
,
]
DIFF_
RUN
=
[
'EDx'
,
'0.00x'
,
'2014_Spring'
,
]
def
setUp
(
self
):
"""
...
...
@@ -43,14 +43,14 @@ class TestImport(ModuleStoreTestCase):
with
open
(
os
.
path
.
join
(
self
.
good_dir
,
"course"
,
"{0[2]}.xml"
.
format
(
self
.
COURSE_ID
)),
"w+"
)
as
f
:
f
.
write
(
'<course></course>'
)
# Create
term
changed course xml
# Create
run
changed course xml
self
.
dupe_dir
=
tempfile
.
mkdtemp
(
dir
=
self
.
content_dir
)
os
.
makedirs
(
os
.
path
.
join
(
self
.
dupe_dir
,
"course"
))
with
open
(
os
.
path
.
join
(
self
.
dupe_dir
,
"course.xml"
),
"w+"
)
as
f
:
f
.
write
(
'<course url_name="{0[2]}" org="{0[0]}" '
'course="{0[1]}"/>'
.
format
(
self
.
DIFF_
TERM
))
'course="{0[1]}"/>'
.
format
(
self
.
DIFF_
RUN
))
with
open
(
os
.
path
.
join
(
self
.
dupe_dir
,
"course"
,
"{0[2]}.xml"
.
format
(
self
.
DIFF_
TERM
)),
"w+"
)
as
f
:
with
open
(
os
.
path
.
join
(
self
.
dupe_dir
,
"course"
,
"{0[2]}.xml"
.
format
(
self
.
DIFF_
RUN
)),
"w+"
)
as
f
:
f
.
write
(
'<course></course>'
)
def
test_forum_seed
(
self
):
...
...
@@ -63,8 +63,9 @@ class TestImport(ModuleStoreTestCase):
def
test_duplicate_with_url
(
self
):
"""
Check to make sure an import doesn't import courses that will
create find one duplicates
Check to make sure an import doesn't import courses that have the
same org and course, but they have different runs in order to
prevent modulestore "findone" exceptions on deletion
"""
# Load up base course and verify it is available
call_command
(
'import'
,
self
.
content_dir
,
self
.
good_dir
)
...
...
@@ -73,4 +74,4 @@ class TestImport(ModuleStoreTestCase):
# Now load up duped course and verify it doesn't load
call_command
(
'import'
,
self
.
content_dir
,
self
.
dupe_dir
)
self
.
assertIsNone
(
store
.
get_course
(
'/'
.
join
(
self
.
DIFF_
TERM
)))
self
.
assertIsNone
(
store
.
get_course
(
'/'
.
join
(
self
.
DIFF_
RUN
)))
common/lib/xmodule/xmodule/modulestore/xml_importer.py
View file @
13af6fc1
...
...
@@ -179,15 +179,15 @@ def import_from_xml(
course_prefix
=
u'{0.org}/{0.course}'
.
format
(
course_location
)
# Check to see if a course with the same
# pseudo_course_id, but different
term
exists in
# pseudo_course_id, but different
run
exists in
# the passed store to avoid broken courses
courses
=
store
.
get_courses
()
bad_
term
=
False
bad_
run
=
False
for
course
in
courses
:
if
course
.
location
.
course_id
.
startswith
(
course_prefix
):
log
.
debug
(
'Import is overwriting existing course'
)
# Importing over existing course, check
# that
term
s match or fail
# that
run
s match or fail
if
course
.
location
.
name
!=
module
.
location
.
name
:
log
.
error
(
'A course with ID
%
s exists, and this '
...
...
@@ -197,8 +197,9 @@ def import_from_xml(
course
.
location
.
course_id
,
module
.
location
.
course_id
)
bad_term
=
True
if
bad_term
:
bad_run
=
True
break
if
bad_run
:
# Skip this course, but keep trying to import courses
continue
...
...
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