diff --git a/lms/djangoapps/courseware/tests/test_views.py b/lms/djangoapps/courseware/tests/test_views.py index 7e3af1dd88..213c3d1b31 100644 --- a/lms/djangoapps/courseware/tests/test_views.py +++ b/lms/djangoapps/courseware/tests/test_views.py @@ -258,7 +258,7 @@ class ViewsTestCase(TestCase): url = reverse('submission_history', kwargs={ 'course_id': self.course_key.to_deprecated_string(), 'student_username': 'dummy', - 'location': unicode(self.component.location) + 'location': self.component.location.to_deprecated_string(), }) response = self.client.get(url) # Tests that we do not get an "Invalid x" response when passing correct arguments to view diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index 7392b21136..5fc16f7bb7 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -740,7 +740,7 @@ def submission_history(request, course_id, student_username, location): return HttpResponse(escape(_(u'Invalid course id.'))) try: - usage_key = UsageKey.from_string(location) + usage_key = course_key.make_usage_key_from_deprecated_string(location) except (InvalidKeyError, AssertionError): return HttpResponse(escape(_(u'Invalid location.'))) diff --git a/lms/djangoapps/instructor/tests/test_api.py b/lms/djangoapps/instructor/tests/test_api.py index e052ea13ed..1a3ea1e377 100644 --- a/lms/djangoapps/instructor/tests/test_api.py +++ b/lms/djangoapps/instructor/tests/test_api.py @@ -118,7 +118,7 @@ class TestInstructorAPIDenyLevels(ModuleStoreTestCase, LoginEnrollmentTestCase): self.course.id, 'robot-some-problem-urlname' ) - self.problem_urlname = str(self.problem_location) + self.problem_urlname = self.problem_location.to_deprecated_string() _module = StudentModule.objects.create( student=self.user, course_id=self.course.id, @@ -1489,7 +1489,7 @@ class TestInstructorAPIRegradeTask(ModuleStoreTestCase, LoginEnrollmentTestCase) self.course.id, 'robot-some-problem-urlname' ) - self.problem_urlname = str(self.problem_location) + self.problem_urlname = self.problem_location.to_deprecated_string() self.module_to_reset = StudentModule.objects.create( student=self.student, @@ -1749,7 +1749,7 @@ class TestInstructorAPITaskLists(ModuleStoreTestCase, LoginEnrollmentTestCase): self.course.id, 'robot-some-problem-urlname' ) - self.problem_urlname = str(self.problem_location) + self.problem_urlname = self.problem_location.to_deprecated_string() self.module = StudentModule.objects.create( student=self.student, diff --git a/lms/djangoapps/instructor/tests/test_legacy_reset.py b/lms/djangoapps/instructor/tests/test_legacy_reset.py index 9e207306e1..9a7112ed0f 100644 --- a/lms/djangoapps/instructor/tests/test_legacy_reset.py +++ b/lms/djangoapps/instructor/tests/test_legacy_reset.py @@ -61,7 +61,7 @@ class InstructorResetStudentStateTest(ModuleStoreTestCase, LoginEnrollmentTestCa response = self.client.post(url, { 'action': 'Delete student state for module', 'unique_student_identifier': self.student.email, - 'problem_for_student': str(problem_location), + 'problem_for_student': problem_location.to_deprecated_string(), }) self.assertEqual(response.status_code, 200) diff --git a/lms/djangoapps/instructor/views/api.py b/lms/djangoapps/instructor/views/api.py index 88c2d734ee..0d67a6a1bd 100644 --- a/lms/djangoapps/instructor/views/api.py +++ b/lms/djangoapps/instructor/views/api.py @@ -70,7 +70,6 @@ from .tools import ( ) from xmodule.modulestore import Location from xmodule.modulestore.locations import SlashSeparatedCourseKey -from xmodule.modulestore.keys import UsageKey from opaque_keys import InvalidKeyError log = logging.getLogger(__name__) @@ -768,7 +767,7 @@ def reset_student_attempts(request, course_id): return HttpResponseForbidden("Requires instructor access.") try: - module_state_key = UsageKey.from_string(problem_to_reset) + module_state_key = course_id.make_usage_key_from_deprecated_string(problem_to_reset) except InvalidKeyError: return HttpResponseBadRequest() @@ -830,7 +829,7 @@ def rescore_problem(request, course_id): ) try: - module_state_key = UsageKey.from_string(problem_to_reset) + module_state_key = course_id.make_usage_key_from_deprecated_string(problem_to_reset) except InvalidKeyError: return HttpResponseBadRequest("Unable to parse problem id") @@ -933,7 +932,7 @@ def list_instructor_tasks(request, course_id): if problem_location_str: try: - module_state_key = UsageKey.from_string(problem_location_str) + module_state_key = course_id.make_usage_key_from_deprecated_string(problem_location_str) except InvalidKeyError: return HttpResponseBadRequest() if student: diff --git a/lms/djangoapps/instructor/views/legacy.py b/lms/djangoapps/instructor/views/legacy.py index 87016d8442..933f3e4d67 100644 --- a/lms/djangoapps/instructor/views/legacy.py +++ b/lms/djangoapps/instructor/views/legacy.py @@ -33,7 +33,6 @@ from xmodule.modulestore.django import modulestore from xmodule.modulestore.locations import SlashSeparatedCourseKey from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.html_module import HtmlDescriptor -from xmodule.modulestore.keys import UsageKey from opaque_keys import InvalidKeyError from lms.lib.xblock.runtime import quote_slashes @@ -265,7 +264,7 @@ def instructor_dashboard(request, course_id): elif "Rescore ALL students' problem submissions" in action: problem_location_str = strip_if_string(request.POST.get('problem_for_all_students', '')) try: - problem_location = UsageKey.from_string(problem_location_str) + problem_location = course_key.make_usage_key_from_deprecated_string(problem_location_str) instructor_task = submit_rescore_problem_for_all_students(request, problem_location) if instructor_task is None: msg += '{text}'.format( @@ -301,7 +300,7 @@ def instructor_dashboard(request, course_id): elif "Reset ALL students' attempts" in action: problem_location_str = strip_if_string(request.POST.get('problem_for_all_students', '')) try: - problem_location = UsageKey.from_string(problem_location_str) + problem_location = course_key.make_usage_key_from_deprecated_string(problem_location_str) instructor_task = submit_reset_problem_attempts_for_all_students(request, problem_location) if instructor_task is None: msg += '{text}'.format( @@ -341,7 +340,7 @@ def instructor_dashboard(request, course_id): else: problem_location_str = strip_if_string(request.POST.get('problem_for_student', '')) try: - problem_location = UsageKey.from_string(problem_location_str) + problem_location = course_key.make_usage_key_from_deprecated_string(problem_location_str) except InvalidKeyError: msg += '{text}'.format( text=_('Could not find problem location "{url}".').format( @@ -355,7 +354,7 @@ def instructor_dashboard(request, course_id): elif "Show Background Task History" in action: problem_location = strip_if_string(request.POST.get('problem_for_all_students', '')) try: - problem_location = UsageKey.from_string(problem_location_str) + problem_location = course_key.make_usage_key_from_deprecated_string(problem_location_str) except InvalidKeyError: msg += '{text}'.format( text=_('Could not find problem location "{url}".').format( @@ -375,7 +374,7 @@ def instructor_dashboard(request, course_id): ) problem_location_str = strip_if_string(request.POST.get('problem_for_student', '')) try: - module_state_key = UsageKey.from_string(problem_location_str) + module_state_key = course_key.make_usage_key_from_deprecated_string(problem_location_str) except InvalidKeyError: msg += '{text}'.format( text=_('Could not find problem location "{url}".').format( diff --git a/lms/templates/courseware/instructor_dashboard.html b/lms/templates/courseware/instructor_dashboard.html index d3d7fca026..1d4f39feba 100644 --- a/lms/templates/courseware/instructor_dashboard.html +++ b/lms/templates/courseware/instructor_dashboard.html @@ -275,7 +275,7 @@ function goto( mode)

${_("You should provide the full location of a problem. A location will look like this: {location}").format( - location="location:edX+Open_DemoX+problem+78c98390884243b89f6023745231c525") + location="i4x://edX/Open_DemoX/problem/78c98390884243b89f6023745231c525") }

@@ -308,7 +308,7 @@ function goto( mode)

${_("You should provide the full location of a problem. A location will look like this: {location}").format( - location="location:edX+Open_DemoX+problem+78c98390884243b89f6023745231c525") + location="i4x://edX/Open_DemoX/problem/78c98390884243b89f6023745231c525") }

diff --git a/lms/templates/instructor/instructor_dashboard_2/student_admin.html b/lms/templates/instructor/instructor_dashboard_2/student_admin.html index 7376634cf1..728ea543d2 100644 --- a/lms/templates/instructor/instructor_dashboard_2/student_admin.html +++ b/lms/templates/instructor/instructor_dashboard_2/student_admin.html @@ -51,7 +51,7 @@

${_("You should provide the full location of a problem. A location will look like this: {location}").format( - location="location:edX+Open_DemoX+problem+78c98390884243b89f6023745231c525") + location="i4x://edX/Open_DemoX/problem/78c98390884243b89f6023745231c525") }

@@ -98,7 +98,7 @@

${_("You should provide the full location of a problem. A location will look like this: {location}").format( - location="location:edX+Open_DemoX+problem+78c98390884243b89f6023745231c525") + location="i4x://edX/Open_DemoX/problem/78c98390884243b89f6023745231c525") }

diff --git a/lms/templates/staff_problem_info.html b/lms/templates/staff_problem_info.html index da286ced90..d9a170089c 100644 --- a/lms/templates/staff_problem_info.html +++ b/lms/templates/staff_problem_info.html @@ -61,7 +61,7 @@ ${block_content} -

+
[ ${_('Reset Student Attempts')} | @@ -75,7 +75,7 @@ ${block_content}
is_released = ${is_released} -location = ${location | h} +location = ${location.to_deprecated_string() | h} %for name, field in fields: @@ -104,7 +104,7 @@ category = ${category | h} - +
${_('Module Fields')}