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
66cb1bc2
Commit
66cb1bc2
authored
Jul 01, 2015
by
Jonathan Piacenti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to activate a child block via jump_to_id.
parent
0166729a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
7 deletions
+25
-7
common/lib/xmodule/xmodule/modulestore/search.py
+2
-1
lms/djangoapps/courseware/views.py
+23
-6
No files found.
common/lib/xmodule/xmodule/modulestore/search.py
View file @
66cb1bc2
...
@@ -81,6 +81,7 @@ def path_to_location(modulestore, usage_key):
...
@@ -81,6 +81,7 @@ def path_to_location(modulestore, usage_key):
# pull out the location names
# pull out the location names
chapter
=
path
[
1
]
.
name
if
n
>
1
else
None
chapter
=
path
[
1
]
.
name
if
n
>
1
else
None
section
=
path
[
2
]
.
name
if
n
>
2
else
None
section
=
path
[
2
]
.
name
if
n
>
2
else
None
vertical
=
path
[
3
]
.
name
if
n
>
3
else
None
# Figure out the position
# Figure out the position
position
=
None
position
=
None
...
@@ -104,4 +105,4 @@ def path_to_location(modulestore, usage_key):
...
@@ -104,4 +105,4 @@ def path_to_location(modulestore, usage_key):
position_list
.
append
(
str
(
child_locs
.
index
(
path
[
path_index
+
1
])
+
1
))
position_list
.
append
(
str
(
child_locs
.
index
(
path
[
path_index
+
1
])
+
1
))
position
=
"_"
.
join
(
position_list
)
position
=
"_"
.
join
(
position_list
)
return
(
course_id
,
chapter
,
section
,
position
)
return
(
course_id
,
chapter
,
section
,
vertical
,
position
,
path
[
-
1
]
)
lms/djangoapps/courseware/views.py
View file @
66cb1bc2
...
@@ -60,6 +60,7 @@ from util.milestones_helpers import get_prerequisite_courses_display
...
@@ -60,6 +60,7 @@ from util.milestones_helpers import get_prerequisite_courses_display
from
microsite_configuration
import
microsite
from
microsite_configuration
import
microsite
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
opaque_keys.edx.locations
import
BlockUsageLocator
from
instructor.enrollment
import
uses_shib
from
instructor.enrollment
import
uses_shib
from
util.db
import
commit_on_success_with_read_committed
from
util.db
import
commit_on_success_with_read_committed
...
@@ -492,7 +493,8 @@ def _index_bulk_op(request, course_key, chapter, section, position):
...
@@ -492,7 +493,8 @@ def _index_bulk_op(request, course_key, chapter, section, position):
# Save where we are in the chapter
# Save where we are in the chapter
save_child_position
(
chapter_module
,
section
)
save_child_position
(
chapter_module
,
section
)
context
[
'fragment'
]
=
section_module
.
render
(
STUDENT_VIEW
)
section_render_context
=
{
'activate_block_id'
:
request
.
GET
.
get
(
'activate_block_id'
)}
context
[
'fragment'
]
=
section_module
.
render
(
STUDENT_VIEW
,
section_render_context
)
context
[
'section_title'
]
=
section_descriptor
.
display_name_with_default
context
[
'section_title'
]
=
section_descriptor
.
display_name_with_default
else
:
else
:
# section is none, so display a message
# section is none, so display a message
...
@@ -600,7 +602,7 @@ def jump_to(request, course_id, location):
...
@@ -600,7 +602,7 @@ def jump_to(request, course_id, location):
except
InvalidKeyError
:
except
InvalidKeyError
:
raise
Http404
(
u"Invalid course_key or usage_key"
)
raise
Http404
(
u"Invalid course_key or usage_key"
)
try
:
try
:
(
course_key
,
chapter
,
section
,
position
)
=
path_to_location
(
modulestore
(),
usage_key
)
(
course_key
,
chapter
,
section
,
position
,
final_target_id
)
=
path_to_location
(
modulestore
(),
usage_key
)
except
ItemNotFoundError
:
except
ItemNotFoundError
:
raise
Http404
(
u"No data at this location: {0}"
.
format
(
usage_key
))
raise
Http404
(
u"No data at this location: {0}"
.
format
(
usage_key
))
except
NoPathToItem
:
except
NoPathToItem
:
...
@@ -609,14 +611,29 @@ def jump_to(request, course_id, location):
...
@@ -609,14 +611,29 @@ def jump_to(request, course_id, location):
# choose the appropriate view (and provide the necessary args) based on the
# choose the appropriate view (and provide the necessary args) based on the
# args provided by the redirect.
# args provided by the redirect.
# Rely on index to do all error handling and access control.
# Rely on index to do all error handling and access control.
if
chapter
is
None
:
if
chapter
is
None
:
re
turn
redirect
(
'courseware'
,
course_id
=
course_key
.
to_deprecated_string
(
))
re
direct_url
=
reverse
(
'courseware'
,
args
=
(
unicode
(
course_key
),
))
elif
section
is
None
:
elif
section
is
None
:
re
turn
redirect
(
'courseware_chapter'
,
course_id
=
course_key
.
to_deprecated_string
(),
chapter
=
chapter
)
re
direct_url
=
reverse
(
'courseware_chapter'
,
args
=
(
unicode
(
course_key
),
chapter
)
)
elif
position
is
None
:
elif
position
is
None
:
return
redirect
(
'courseware_section'
,
course_id
=
course_key
.
to_deprecated_string
(),
chapter
=
chapter
,
section
=
section
)
redirect_url
=
reverse
(
'courseware_section'
,
args
=
(
unicode
(
course_key
),
chapter
,
section
)
)
else
:
else
:
return
redirect
(
'courseware_position'
,
course_id
=
course_key
.
to_deprecated_string
(),
chapter
=
chapter
,
section
=
section
,
position
=
position
)
# Here we use the navigation_index from the position returned from
# path_to_location - we can only navigate to the topmost vertical at the
# moment
redirect_url
=
reverse
(
'courseware_position'
,
args
=
(
unicode
(
course_key
),
chapter
,
section
,
position
)
)
redirect_url
+=
"?{}"
.
format
(
urllib
.
urlencode
({
'activate_block_id'
:
unicode
(
final_target_id
)}))
return
redirect
(
redirect_url
)
@ensure_csrf_cookie
@ensure_csrf_cookie
...
...
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