From 405b266fa7491c4677de9c241df8cc308626d086 Mon Sep 17 00:00:00 2001 From: Jonathan Piacenti Date: Fri, 3 Jul 2015 20:52:45 +0000 Subject: [PATCH] Addressed notes. --- common/lib/xmodule/xmodule/modulestore/search.py | 4 ++-- lms/djangoapps/courseware/tests/test_views.py | 3 ++- lms/djangoapps/courseware/url_helpers.py | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/search.py b/common/lib/xmodule/xmodule/modulestore/search.py index c57059c7b8..0ee4e37d41 100644 --- a/common/lib/xmodule/xmodule/modulestore/search.py +++ b/common/lib/xmodule/xmodule/modulestore/search.py @@ -44,8 +44,8 @@ def path_to_location(modulestore, usage_key): If no path exists, return None. - If a path exists, return it as a list with target location first, and - the starting location last. + If a path exists, return it as a tuple with root location first, and + the target location last. ''' # Standard DFS diff --git a/lms/djangoapps/courseware/tests/test_views.py b/lms/djangoapps/courseware/tests/test_views.py index abb0ee2465..693061f031 100644 --- a/lms/djangoapps/courseware/tests/test_views.py +++ b/lms/djangoapps/courseware/tests/test_views.py @@ -1138,7 +1138,7 @@ class TestIndexView(ModuleStoreTestCase): @XBlock.register_temp_plugin(ViewCheckerBlock, 'view_checker') @ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split) - def test_student_state(self, default_store, ): + def test_student_state(self, default_store): """ Verify that saved student state is loaded for xblocks rendered in the index view. """ @@ -1206,6 +1206,7 @@ class TestIndexView(ModuleStoreTestCase): response = views.index(request, unicode(course.id), chapter=chapter.url_name, section=section.url_name) self.assertIn("Activate Block ID: test_block_id", response.content) + class TestRenderXBlock(RenderXBlockTestMixin, ModuleStoreTestCase): """ Tests for the courseware.render_xblock endpoint. diff --git a/lms/djangoapps/courseware/url_helpers.py b/lms/djangoapps/courseware/url_helpers.py index 17723da088..62ba41e42e 100644 --- a/lms/djangoapps/courseware/url_helpers.py +++ b/lms/djangoapps/courseware/url_helpers.py @@ -1,6 +1,7 @@ """ Module to define url helpers functions """ +from urllib import urlencode from xmodule.modulestore.search import path_to_location, navigation_index from xmodule.modulestore.django import modulestore from django.core.urlresolvers import reverse @@ -47,7 +48,6 @@ def get_redirect_url(course_key, usage_key): args=(unicode(course_key), chapter, section, navigation_index(position)) ) - if final_target_id: - redirect_url += "?activate_block_id={final_target_id}".format(final_target_id=final_target_id) + redirect_url += "?{}".format(urlencode({'activate_block_id': unicode(final_target_id)})) return redirect_url