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
02d970c3
Commit
02d970c3
authored
Aug 15, 2012
by
kimth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Map '/course/' urls to the course's root in the multicourse hierarchy
parent
f1f80cb1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletions
+16
-1
common/djangoapps/xmodule_modifiers.py
+11
-0
lms/djangoapps/courseware/module_render.py
+5
-1
No files found.
common/djangoapps/xmodule_modifiers.py
View file @
02d970c3
...
...
@@ -34,6 +34,17 @@ def wrap_xmodule(get_html, module, template):
return
_get_html
def
replace_course_urls
(
get_html
,
course_id
,
module
):
"""
Updates the supplied module with a new get_html function that wraps
the old get_html function and substitutes urls of the form /course/...
with urls that are /courses/<course_id>/...
"""
@wraps
(
get_html
)
def
_get_html
():
return
replace_urls
(
get_html
(),
staticfiles_prefix
=
'/courses/'
+
course_id
,
replace_prefix
=
'/course/'
)
return
_get_html
def
replace_static_urls
(
get_html
,
prefix
,
module
):
"""
Updates the supplied module with a new get_html function that wraps
...
...
lms/djangoapps/courseware/module_render.py
View file @
02d970c3
...
...
@@ -19,7 +19,7 @@ from xmodule.exceptions import NotFoundError
from
xmodule.modulestore
import
Location
from
xmodule.modulestore.django
import
modulestore
from
xmodule.x_module
import
ModuleSystem
from
xmodule_modifiers
import
replace_static_urls
,
add_histogram
,
wrap_xmodule
from
xmodule_modifiers
import
replace_
course_urls
,
replace_
static_urls
,
add_histogram
,
wrap_xmodule
log
=
logging
.
getLogger
(
"mitx.courseware"
)
...
...
@@ -233,6 +233,10 @@ def get_module(user, request, location, student_module_cache, position=None, cou
module
.
metadata
[
'data_dir'
],
module
)
# Allow URLs of the form '/course/' refer to the root of multicourse directory
# hierarchy of this course
module
.
get_html
=
replace_course_urls
(
module
.
get_html
,
course_id
,
module
)
if
settings
.
MITX_FEATURES
.
get
(
'DISPLAY_HISTOGRAMS_TO_STAFF'
):
if
has_access
(
user
,
module
,
'staff'
):
module
.
get_html
=
add_histogram
(
module
.
get_html
,
module
,
user
)
...
...
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