Commit fb65aad1 by Calen Pennington

Merge pull request #3826 from cpennington/ok-use-deprecated-for-instructor-api

Use old deprecated form for instructor api calls, and in staff debug info
parents c7bf96f0 8699a13b
...@@ -258,7 +258,7 @@ class ViewsTestCase(TestCase): ...@@ -258,7 +258,7 @@ class ViewsTestCase(TestCase):
url = reverse('submission_history', kwargs={ url = reverse('submission_history', kwargs={
'course_id': self.course_key.to_deprecated_string(), 'course_id': self.course_key.to_deprecated_string(),
'student_username': 'dummy', 'student_username': 'dummy',
'location': unicode(self.component.location) 'location': self.component.location.to_deprecated_string(),
}) })
response = self.client.get(url) response = self.client.get(url)
# Tests that we do not get an "Invalid x" response when passing correct arguments to view # Tests that we do not get an "Invalid x" response when passing correct arguments to view
......
...@@ -740,7 +740,7 @@ def submission_history(request, course_id, student_username, location): ...@@ -740,7 +740,7 @@ def submission_history(request, course_id, student_username, location):
return HttpResponse(escape(_(u'Invalid course id.'))) return HttpResponse(escape(_(u'Invalid course id.')))
try: try:
usage_key = UsageKey.from_string(location) usage_key = course_key.make_usage_key_from_deprecated_string(location)
except (InvalidKeyError, AssertionError): except (InvalidKeyError, AssertionError):
return HttpResponse(escape(_(u'Invalid location.'))) return HttpResponse(escape(_(u'Invalid location.')))
......
...@@ -118,7 +118,7 @@ class TestInstructorAPIDenyLevels(ModuleStoreTestCase, LoginEnrollmentTestCase): ...@@ -118,7 +118,7 @@ class TestInstructorAPIDenyLevels(ModuleStoreTestCase, LoginEnrollmentTestCase):
self.course.id, self.course.id,
'robot-some-problem-urlname' 'robot-some-problem-urlname'
) )
self.problem_urlname = str(self.problem_location) self.problem_urlname = self.problem_location.to_deprecated_string()
_module = StudentModule.objects.create( _module = StudentModule.objects.create(
student=self.user, student=self.user,
course_id=self.course.id, course_id=self.course.id,
...@@ -1489,7 +1489,7 @@ class TestInstructorAPIRegradeTask(ModuleStoreTestCase, LoginEnrollmentTestCase) ...@@ -1489,7 +1489,7 @@ class TestInstructorAPIRegradeTask(ModuleStoreTestCase, LoginEnrollmentTestCase)
self.course.id, self.course.id,
'robot-some-problem-urlname' '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( self.module_to_reset = StudentModule.objects.create(
student=self.student, student=self.student,
...@@ -1749,7 +1749,7 @@ class TestInstructorAPITaskLists(ModuleStoreTestCase, LoginEnrollmentTestCase): ...@@ -1749,7 +1749,7 @@ class TestInstructorAPITaskLists(ModuleStoreTestCase, LoginEnrollmentTestCase):
self.course.id, self.course.id,
'robot-some-problem-urlname' '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( self.module = StudentModule.objects.create(
student=self.student, student=self.student,
......
...@@ -61,7 +61,7 @@ class InstructorResetStudentStateTest(ModuleStoreTestCase, LoginEnrollmentTestCa ...@@ -61,7 +61,7 @@ class InstructorResetStudentStateTest(ModuleStoreTestCase, LoginEnrollmentTestCa
response = self.client.post(url, { response = self.client.post(url, {
'action': 'Delete student state for module', 'action': 'Delete student state for module',
'unique_student_identifier': self.student.email, '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) self.assertEqual(response.status_code, 200)
......
...@@ -70,7 +70,6 @@ from .tools import ( ...@@ -70,7 +70,6 @@ from .tools import (
) )
from xmodule.modulestore import Location from xmodule.modulestore import Location
from xmodule.modulestore.locations import SlashSeparatedCourseKey from xmodule.modulestore.locations import SlashSeparatedCourseKey
from xmodule.modulestore.keys import UsageKey
from opaque_keys import InvalidKeyError from opaque_keys import InvalidKeyError
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -768,7 +767,7 @@ def reset_student_attempts(request, course_id): ...@@ -768,7 +767,7 @@ def reset_student_attempts(request, course_id):
return HttpResponseForbidden("Requires instructor access.") return HttpResponseForbidden("Requires instructor access.")
try: 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: except InvalidKeyError:
return HttpResponseBadRequest() return HttpResponseBadRequest()
...@@ -830,7 +829,7 @@ def rescore_problem(request, course_id): ...@@ -830,7 +829,7 @@ def rescore_problem(request, course_id):
) )
try: 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: except InvalidKeyError:
return HttpResponseBadRequest("Unable to parse problem id") return HttpResponseBadRequest("Unable to parse problem id")
...@@ -933,7 +932,7 @@ def list_instructor_tasks(request, course_id): ...@@ -933,7 +932,7 @@ def list_instructor_tasks(request, course_id):
if problem_location_str: if problem_location_str:
try: 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: except InvalidKeyError:
return HttpResponseBadRequest() return HttpResponseBadRequest()
if student: if student:
......
...@@ -33,7 +33,6 @@ from xmodule.modulestore.django import modulestore ...@@ -33,7 +33,6 @@ from xmodule.modulestore.django import modulestore
from xmodule.modulestore.locations import SlashSeparatedCourseKey from xmodule.modulestore.locations import SlashSeparatedCourseKey
from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.modulestore.exceptions import ItemNotFoundError
from xmodule.html_module import HtmlDescriptor from xmodule.html_module import HtmlDescriptor
from xmodule.modulestore.keys import UsageKey
from opaque_keys import InvalidKeyError from opaque_keys import InvalidKeyError
from lms.lib.xblock.runtime import quote_slashes from lms.lib.xblock.runtime import quote_slashes
...@@ -265,7 +264,7 @@ def instructor_dashboard(request, course_id): ...@@ -265,7 +264,7 @@ def instructor_dashboard(request, course_id):
elif "Rescore ALL students' problem submissions" in action: elif "Rescore ALL students' problem submissions" in action:
problem_location_str = strip_if_string(request.POST.get('problem_for_all_students', '')) problem_location_str = strip_if_string(request.POST.get('problem_for_all_students', ''))
try: 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) instructor_task = submit_rescore_problem_for_all_students(request, problem_location)
if instructor_task is None: if instructor_task is None:
msg += '<font color="red">{text}</font>'.format( msg += '<font color="red">{text}</font>'.format(
...@@ -301,7 +300,7 @@ def instructor_dashboard(request, course_id): ...@@ -301,7 +300,7 @@ def instructor_dashboard(request, course_id):
elif "Reset ALL students' attempts" in action: elif "Reset ALL students' attempts" in action:
problem_location_str = strip_if_string(request.POST.get('problem_for_all_students', '')) problem_location_str = strip_if_string(request.POST.get('problem_for_all_students', ''))
try: 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) instructor_task = submit_reset_problem_attempts_for_all_students(request, problem_location)
if instructor_task is None: if instructor_task is None:
msg += '<font color="red">{text}</font>'.format( msg += '<font color="red">{text}</font>'.format(
...@@ -341,7 +340,7 @@ def instructor_dashboard(request, course_id): ...@@ -341,7 +340,7 @@ def instructor_dashboard(request, course_id):
else: else:
problem_location_str = strip_if_string(request.POST.get('problem_for_student', '')) problem_location_str = strip_if_string(request.POST.get('problem_for_student', ''))
try: try:
problem_location = UsageKey.from_string(problem_location_str) problem_location = course_key.make_usage_key_from_deprecated_string(problem_location_str)
except InvalidKeyError: except InvalidKeyError:
msg += '<font color="red">{text}</font>'.format( msg += '<font color="red">{text}</font>'.format(
text=_('Could not find problem location "{url}".').format( text=_('Could not find problem location "{url}".').format(
...@@ -355,7 +354,7 @@ def instructor_dashboard(request, course_id): ...@@ -355,7 +354,7 @@ def instructor_dashboard(request, course_id):
elif "Show Background Task History" in action: elif "Show Background Task History" in action:
problem_location = strip_if_string(request.POST.get('problem_for_all_students', '')) problem_location = strip_if_string(request.POST.get('problem_for_all_students', ''))
try: try:
problem_location = UsageKey.from_string(problem_location_str) problem_location = course_key.make_usage_key_from_deprecated_string(problem_location_str)
except InvalidKeyError: except InvalidKeyError:
msg += '<font color="red">{text}</font>'.format( msg += '<font color="red">{text}</font>'.format(
text=_('Could not find problem location "{url}".').format( text=_('Could not find problem location "{url}".').format(
...@@ -375,7 +374,7 @@ def instructor_dashboard(request, course_id): ...@@ -375,7 +374,7 @@ def instructor_dashboard(request, course_id):
) )
problem_location_str = strip_if_string(request.POST.get('problem_for_student', '')) problem_location_str = strip_if_string(request.POST.get('problem_for_student', ''))
try: 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: except InvalidKeyError:
msg += '<font color="red">{text}</font>'.format( msg += '<font color="red">{text}</font>'.format(
text=_('Could not find problem location "{url}".').format( text=_('Could not find problem location "{url}".').format(
......
...@@ -275,7 +275,7 @@ function goto( mode) ...@@ -275,7 +275,7 @@ function goto( mode)
</p> </p>
<p> <p>
${_("You should provide the full location of a problem. A location will look like this: {location}").format( ${_("You should provide the full location of a problem. A location will look like this: {location}").format(
location="<tt>location:edX+Open_DemoX+problem+78c98390884243b89f6023745231c525</tt>") location="<tt>i4x://edX/Open_DemoX/problem/78c98390884243b89f6023745231c525</tt>")
} }
</p> </p>
<p> <p>
...@@ -308,7 +308,7 @@ function goto( mode) ...@@ -308,7 +308,7 @@ function goto( mode)
</p> </p>
<p> <p>
${_("You should provide the full location of a problem. A location will look like this: {location}").format( ${_("You should provide the full location of a problem. A location will look like this: {location}").format(
location="<tt>location:edX+Open_DemoX+problem+78c98390884243b89f6023745231c525</tt>") location="<tt>i4x://edX/Open_DemoX/problem/78c98390884243b89f6023745231c525</tt>")
} }
</p> </p>
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
<p> <p>
${_("You should provide the full location of a problem. A location will look like this: {location}").format( ${_("You should provide the full location of a problem. A location will look like this: {location}").format(
location="<tt>location:edX+Open_DemoX+problem+78c98390884243b89f6023745231c525</tt>") location="<tt>i4x://edX/Open_DemoX/problem/78c98390884243b89f6023745231c525</tt>")
} }
</p> </p>
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
</p> </p>
<p> <p>
${_("You should provide the full location of a problem. A location will look like this: {location}").format( ${_("You should provide the full location of a problem. A location will look like this: {location}").format(
location="<tt>location:edX+Open_DemoX+problem+78c98390884243b89f6023745231c525</tt>") location="<tt>i4x://edX/Open_DemoX/problem/78c98390884243b89f6023745231c525</tt>")
} }
</p> </p>
<p> <p>
......
...@@ -61,7 +61,7 @@ ${block_content} ...@@ -61,7 +61,7 @@ ${block_content}
<label for="sd_fu_${location.name}">${_('Username')}:</label> <label for="sd_fu_${location.name}">${_('Username')}:</label>
<input type="text" id="sd_fu_${location.name}" placeholder="${user.username}"/> <input type="text" id="sd_fu_${location.name}" placeholder="${user.username}"/>
</div> </div>
<div data-location="${unicode(location)}" data-location-name="${location.name}"> <div data-location="${location.to_deprecated_string()}" data-location-name="${location.name}">
[ [
<a href="#" id="staff-debug-reset" class="staff-debug-reset">${_('Reset Student Attempts')}</a> <a href="#" id="staff-debug-reset" class="staff-debug-reset">${_('Reset Student Attempts')}</a>
| |
...@@ -75,7 +75,7 @@ ${block_content} ...@@ -75,7 +75,7 @@ ${block_content}
<div class="staff_info" style="display:block"> <div class="staff_info" style="display:block">
is_released = ${is_released} is_released = ${is_released}
location = ${location | h} location = ${location.to_deprecated_string() | h}
<table summary="${_('Module Fields')}"> <table summary="${_('Module Fields')}">
<tr><th>${_('Module Fields')}</th></tr> <tr><th>${_('Module Fields')}</th></tr>
%for name, field in fields: %for name, field in fields:
...@@ -104,7 +104,7 @@ category = ${category | h} ...@@ -104,7 +104,7 @@ category = ${category | h}
<form id="${element_id}_history_form"> <form id="${element_id}_history_form">
<label for="${element_id}_history_student_username">${_("User:")}</label> <label for="${element_id}_history_student_username">${_("User:")}</label>
<input id="${element_id}_history_student_username" type="text" placeholder=""/> <input id="${element_id}_history_student_username" type="text" placeholder=""/>
<input type="hidden" id="${element_id}_history_location" value="${location}"/> <input type="hidden" id="${element_id}_history_location" value="${location.to_deprecated_string()}"/>
<div class="submit"> <div class="submit">
<button name="submit" type="submit">${_("View History")}</button> <button name="submit" type="submit">${_("View History")}</button>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment