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
1c2958e3
Commit
1c2958e3
authored
Aug 09, 2013
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
address PR feedback
parent
c6f27742
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
22 deletions
+18
-22
common/lib/xmodule/xmodule/modulestore/store_utilities.py
+13
-16
common/lib/xmodule/xmodule/modulestore/xml_importer.py
+3
-4
common/test/data/toy/html/nonportable_link.html
+1
-0
common/test/data/toy/html/nonportable_link.xml
+1
-2
No files found.
common/lib/xmodule/xmodule/modulestore/store_utilities.py
View file @
1c2958e3
...
@@ -20,7 +20,7 @@ def _prefix_only_url_replace_regex(prefix):
...
@@ -20,7 +20,7 @@ def _prefix_only_url_replace_regex(prefix):
(?P<prefix>{prefix}) # the prefix
(?P<prefix>{prefix}) # the prefix
(?P<rest>.*?) # everything else in the url
(?P<rest>.*?) # everything else in the url
(?P=quote) # the first matching closing quote
(?P=quote) # the first matching closing quote
"""
.
format
(
prefix
=
prefix
)
"""
.
format
(
prefix
=
re
.
escape
(
prefix
)
)
def
_prefix_and_category_url_replace_regex
(
prefix
):
def
_prefix_and_category_url_replace_regex
(
prefix
):
...
@@ -37,7 +37,7 @@ def _prefix_and_category_url_replace_regex(prefix):
...
@@ -37,7 +37,7 @@ def _prefix_and_category_url_replace_regex(prefix):
(?P<category>[^/]+)/
(?P<category>[^/]+)/
(?P<rest>.*?) # everything else in the url
(?P<rest>.*?) # everything else in the url
(?P=quote) # the first matching closing quote
(?P=quote) # the first matching closing quote
"""
.
format
(
prefix
=
prefix
)
"""
.
format
(
prefix
=
re
.
escape
(
prefix
)
)
def
rewrite_nonportable_content_links
(
source_course_id
,
dest_course_id
,
text
):
def
rewrite_nonportable_content_links
(
source_course_id
,
dest_course_id
,
text
):
...
@@ -54,18 +54,19 @@ def rewrite_nonportable_content_links(source_course_id, dest_course_id, text):
...
@@ -54,18 +54,19 @@ def rewrite_nonportable_content_links(source_course_id, dest_course_id, text):
def
portable_asset_link_subtitution
(
match
):
def
portable_asset_link_subtitution
(
match
):
quote
=
match
.
group
(
'quote'
)
quote
=
match
.
group
(
'quote'
)
rest
=
match
.
group
(
'rest'
)
rest
=
match
.
group
(
'rest'
)
return
""
.
join
([
quote
,
'/static/'
+
rest
,
quote
])
return
quote
+
'/static/'
+
rest
+
quote
def
portable_jump_to_link_substitution
(
match
):
def
portable_jump_to_link_substitution
(
match
):
quote
=
match
.
group
(
'quote'
)
quote
=
match
.
group
(
'quote'
)
rest
=
match
.
group
(
'rest'
)
rest
=
match
.
group
(
'rest'
)
return
""
.
join
([
quote
,
'/jump_to_id/'
+
rest
,
quote
])
return
quote
+
'/jump_to_id/'
+
rest
+
quote
def
generic_courseware_link_substitution
(
match
):
def
generic_courseware_link_substitution
(
match
):
quote
=
match
.
group
(
'quote'
)
quote
=
match
.
group
(
'quote'
)
rest
=
match
.
group
(
'rest'
)
rest
=
match
.
group
(
'rest'
)
dest_generic_courseware_lik_base
=
'/courses/{org}/{course}/{run}/'
.
format
(
dest_generic_courseware_lik_base
=
'/courses/{org}/{course}/{run}/'
.
format
(
org
=
dest_org
,
course
=
dest_course
,
run
=
dest_run
)
org
=
dest_org
,
course
=
dest_course
,
run
=
dest_run
)
return
""
.
join
([
quote
,
dest_generic_courseware_lik_base
+
rest
,
quote
])
return
""
.
join
([
quote
,
dest_generic_courseware_lik_base
+
rest
,
quote
])
...
@@ -77,18 +78,15 @@ def rewrite_nonportable_content_links(source_course_id, dest_course_id, text):
...
@@ -77,18 +78,15 @@ def rewrite_nonportable_content_links(source_course_id, dest_course_id, text):
c4x_link_base
=
'{0}/'
.
format
(
StaticContent
.
get_base_url_path_for_course_assets
(
course_location
))
c4x_link_base
=
'{0}/'
.
format
(
StaticContent
.
get_base_url_path_for_course_assets
(
course_location
))
text
=
re
.
sub
(
_prefix_only_url_replace_regex
(
c4x_link_base
),
portable_asset_link_subtitution
,
text
)
text
=
re
.
sub
(
_prefix_only_url_replace_regex
(
c4x_link_base
),
portable_asset_link_subtitution
,
text
)
except
Exception
,
e
:
except
Exception
,
e
:
logging
.
warning
(
"Error going regex subtituion (0) on text = {1}.
\n\n
Error msg = {2}"
.
format
(
logging
.
warning
(
"Error going regex subtituion
%
r on text =
%
r.
\n\n
Error msg =
%
s"
,
c4x_link_base
,
text
,
str
(
e
))
c4x_link_base
,
text
,
str
(
e
)))
pass
try
:
try
:
jump_to_link_base
=
'/courses/{org}/{course}/{run}/jump_to/i4x://{org}/{course}/'
.
format
(
jump_to_link_base
=
'/courses/{org}/{course}/{run}/jump_to/i4x://{org}/{course}/'
.
format
(
org
=
org
,
course
=
course
,
run
=
run
)
org
=
org
,
course
=
course
,
run
=
run
)
text
=
re
.
sub
(
_prefix_and_category_url_replace_regex
(
jump_to_link_base
),
portable_jump_to_link_substitution
,
text
)
text
=
re
.
sub
(
_prefix_and_category_url_replace_regex
(
jump_to_link_base
),
portable_jump_to_link_substitution
,
text
)
except
Exception
,
e
:
except
Exception
,
e
:
logging
.
warning
(
"Error going regex subtituion (0) on text = {1}.
\n\n
Error msg = {2}"
.
format
(
logging
.
warning
(
"Error going regex subtituion
%
r on text =
%
r.
\n\n
Error msg =
%
s"
,
jump_to_link_base
,
text
,
str
(
e
))
jump_to_link_base
,
text
,
str
(
e
)))
pass
# Also, there commonly is a set of link URL's used in the format:
# Also, there commonly is a set of link URL's used in the format:
# /courses/<org>/<course>/<run> which will be broken if migrated to a different course_id
# /courses/<org>/<course>/<run> which will be broken if migrated to a different course_id
...
@@ -99,12 +97,11 @@ def rewrite_nonportable_content_links(source_course_id, dest_course_id, text):
...
@@ -99,12 +97,11 @@ def rewrite_nonportable_content_links(source_course_id, dest_course_id, text):
if
source_course_id
!=
dest_course_id
:
if
source_course_id
!=
dest_course_id
:
try
:
try
:
generic_courseware_link_base
=
'/courses/{org}/{course}/{run}/'
.
format
(
generic_courseware_link_base
=
'/courses/{org}/{course}/{run}/'
.
format
(
org
=
org
,
course
=
course
,
run
=
run
)
org
=
org
,
course
=
course
,
run
=
run
)
text
=
re
.
sub
(
_prefix_only_url_replace_regex
(
generic_courseware_link_base
),
portable_asset_link_subtitution
,
text
)
text
=
re
.
sub
(
_prefix_only_url_replace_regex
(
generic_courseware_link_base
),
portable_asset_link_subtitution
,
text
)
except
Exception
,
e
:
except
Exception
,
e
:
logging
.
warning
(
"Error going regex subtituion (0) on text = {1}.
\n\n
Error msg = {2}"
.
format
(
logging
.
warning
(
"Error going regex subtituion
%
r on text =
%
r.
\n\n
Error msg =
%
s"
,
generic_courseware_link_base
,
text
,
str
(
e
))
generic_courseware_link_base
,
text
,
str
(
e
)))
pass
return
text
return
text
...
...
common/lib/xmodule/xmodule/modulestore/xml_importer.py
View file @
1c2958e3
...
@@ -128,8 +128,8 @@ def import_from_xml(store, data_dir, course_dirs=None,
...
@@ -128,8 +128,8 @@ def import_from_xml(store, data_dir, course_dirs=None,
{
"type"
:
"discussion"
,
"name"
:
"Discussion"
},
{
"type"
:
"discussion"
,
"name"
:
"Discussion"
},
{
"type"
:
"wiki"
,
"name"
:
"Wiki"
}]
# note, add 'progress' when we can support it on Edge
{
"type"
:
"wiki"
,
"name"
:
"Wiki"
}]
# note, add 'progress' when we can support it on Edge
import_module
(
module
,
store
,
course_data_path
,
static_content_store
,
course_location
,
import_module
(
module
,
store
,
course_data_path
,
static_content_store
,
course_location
,
target_location_namespace
if
target_location_namespace
else
course_location
)
target_location_namespace
or
course_location
)
course_items
.
append
(
module
)
course_items
.
append
(
module
)
...
@@ -161,7 +161,7 @@ def import_from_xml(store, data_dir, course_dirs=None,
...
@@ -161,7 +161,7 @@ def import_from_xml(store, data_dir, course_dirs=None,
# now import any 'draft' items
# now import any 'draft' items
if
draft_store
is
not
None
:
if
draft_store
is
not
None
:
import_course_draft
(
xml_module_store
,
store
,
draft_store
,
course_data_path
,
import_course_draft
(
xml_module_store
,
store
,
draft_store
,
course_data_path
,
static_content_store
,
course_location
,
target_location_namespace
if
target_location_namespace
is
not
None
static_content_store
,
course_location
,
target_location_namespace
if
target_location_namespace
else
course_location
)
else
course_location
)
finally
:
finally
:
...
@@ -543,4 +543,3 @@ def import_course_from_xml(modulestore, static_content_store, course_data_path,
...
@@ -543,4 +543,3 @@ def import_course_from_xml(modulestore, static_content_store, course_data_path,
{
"type"
:
"wiki"
,
"name"
:
"Wiki"
}]
# note, add 'progress' when we can support it on Edge
{
"type"
:
"wiki"
,
"name"
:
"Wiki"
}]
# note, add 'progress' when we can support it on Edge
import_module_from_xml
(
modulestore
,
static_content_store
,
course_data_path
,
module
,
target_location_namespace
,
verbose
=
verbose
)
import_module_from_xml
(
modulestore
,
static_content_store
,
course_data_path
,
module
,
target_location_namespace
,
verbose
=
verbose
)
common/test/data/toy/html/nonportable_link.html
View file @
1c2958e3
<a
href=
"/courses/edX/toy/2012_Fall/jump_to/i4x://edX/toy/html/nonportable_link"
>
link
</a>
<a
href=
"/courses/edX/toy/2012_Fall/jump_to/i4x://edX/toy/html/nonportable_link"
>
link
</a>
common/test/data/toy/html/nonportable_link.xml
View file @
1c2958e3
<html
filename=
"nonportable_link.html"
/>
<html
filename=
"nonportable_link.html"
/>
\ No newline at end of file
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