From 32cb0897e9b95d3abdcd9419ad30859ee226c2f4 Mon Sep 17 00:00:00 2001 From: Arjun Singh Date: Fri, 31 Aug 2012 04:24:52 -0700 Subject: [PATCH] Fixing sequentials nested inside of verticals, provides a path to sequentials nested in sequentials. Changes jump_to to redirect to courseware index. --- common/lib/xmodule/xmodule/modulestore/search.py | 15 +++++++++------ lms/djangoapps/courseware/views.py | 7 +++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/search.py b/common/lib/xmodule/xmodule/modulestore/search.py index 87f1cbf825..1eb880c56a 100644 --- a/common/lib/xmodule/xmodule/modulestore/search.py +++ b/common/lib/xmodule/xmodule/modulestore/search.py @@ -93,11 +93,14 @@ def path_to_location(modulestore, course_id, location): # Figure out the position position = None if n > 3: - section_desc = modulestore.get_instance(course_id, path[2]) - child_locs = [c.location for c in section_desc.get_children()] - # positions are 1-indexed, and should be strings to be consistent with - # url parsing. - position = str(child_locs.index(path[3]) + 1) - + position_list = [] + for path_index in range(2, n-1): + if path[path_index].category == 'sequential': + section_desc = modulestore.get_instance(course_id, path[path_index]) + child_locs = [c.location for c in section_desc.get_children()] + # positions are 1-indexed, and should be strings to be consistent with + # url parsing. + position_list.append(str(child_locs.index(path[path_index+1]) + 1)) + position = "_".join(position_list) return (course_id, chapter, section, position) diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index 3f0f54147b..d1a52f06c1 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -218,8 +218,11 @@ def jump_to(request, course_id, location): raise Http404("This location is not in any class: {0}".format(location)) # Rely on index to do all error handling and access control. - return index(request, course_id, chapter, section, position) - + return redirect('courseware_position', + course_id=course_id, + chapter=chapter, + section=section, + position=position) @ensure_csrf_cookie def course_info(request, course_id): """