From 6fcf65ef62a50c76a8e6e8f3a6651cff6ab75671 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Tue, 13 May 2014 11:58:56 -0400 Subject: [PATCH] Fix staff debug view --- lms/djangoapps/instructor/views/api.py | 2 +- lms/static/js/staff_debug_actions.js | 27 ++++++++++++++------------ lms/templates/staff_problem_info.html | 12 ++++++------ 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/lms/djangoapps/instructor/views/api.py b/lms/djangoapps/instructor/views/api.py index 05f62f04a1..2a48d3091b 100644 --- a/lms/djangoapps/instructor/views/api.py +++ b/lms/djangoapps/instructor/views/api.py @@ -832,7 +832,7 @@ def rescore_problem(request, course_id): try: module_state_key = UsageKey.from_string(problem_to_reset) except InvalidKeyError: - return HttpResponseBadRequest() + return HttpResponseBadRequest("Unable to parse problem id") response_payload = {} response_payload['problem_to_reset'] = problem_to_reset diff --git a/lms/static/js/staff_debug_actions.js b/lms/static/js/staff_debug_actions.js index cf5bc85495..a37664a147 100644 --- a/lms/static/js/staff_debug_actions.js +++ b/lms/static/js/staff_debug_actions.js @@ -22,7 +22,7 @@ var StaffDebug = (function(){ do_idash_action = function(action){ var pdata = { 'problem_to_reset': action.location, - 'unique_student_identifier': get_user(action.location), + 'unique_student_identifier': get_user(action.locationName), 'delete_module': action.delete_module } $.ajax({ @@ -40,7 +40,7 @@ var StaffDebug = (function(){ {text: text}, {interpolate: /\{(.+?)\}/g} ) - $("#result_"+action.location).html(html); + $("#result_"+action.locationName).html(html); }, error: function(request, status, error) { var response_json; @@ -62,15 +62,16 @@ var StaffDebug = (function(){ {text: text}, {interpolate: /\{(.+?)\}/g} ) - $("#result_"+action.location).html(html); + $("#result_"+action.locationName).html(html); }, dataType: 'json' }); } - reset = function(locname){ + reset = function(locname, location){ this.do_idash_action({ - location: locname, + locationName: locname, + location: location, method: 'reset_student_attempts', success_msg: gettext('Successfully reset the attempts for user {user}'), error_msg: gettext('Failed to reset attempts.'), @@ -78,9 +79,10 @@ var StaffDebug = (function(){ }); } - sdelete = function(locname){ + sdelete = function(locname, location){ this.do_idash_action({ - location: locname, + locationName: locname, + location: location, method: 'reset_student_attempts', success_msg: gettext('Successfully deleted student state for user {user}'), error_msg: gettext('Failed to delete student state.'), @@ -88,9 +90,10 @@ var StaffDebug = (function(){ }); } - rescore = function(locname){ + rescore = function(locname, location){ this.do_idash_action({ - location: locname, + locationName: locname, + location: location, method: 'rescore_problem', success_msg: gettext('Successfully rescored problem for user {user}'), error_msg: gettext('Failed to rescore problem.'), @@ -112,15 +115,15 @@ var StaffDebug = (function(){ // Register click handlers $(document).ready(function() { $('#staff-debug-reset').click(function() { - StaffDebug.reset($(this).data('location')); + StaffDebug.reset($(this).parent().data('location-name'), $(this).parent().data('location')); return false; }); $('#staff-debug-sdelete').click(function() { - StaffDebug.sdelete($(this).data('location')); + StaffDebug.sdelete($(this).parent().data('location-name'), $(this).parent().data('location')); return false; }); $('#staff-debug-rescore').click(function() { - StaffDebug.rescore($(this).data('location')); + StaffDebug.rescore($(this).parent().data('location-name'), $(this).parent().data('location')); return false; }); }); diff --git a/lms/templates/staff_problem_info.html b/lms/templates/staff_problem_info.html index 4bdc157d95..3b17ceabc0 100644 --- a/lms/templates/staff_problem_info.html +++ b/lms/templates/staff_problem_info.html @@ -61,14 +61,14 @@ ${block_content} -
+
[ - ${_('Reset Student Attempts')} + ${_('Reset Student Attempts')} | - ${_('Delete Student State')} + ${_('Delete Student State')} | - ${_('Rescore Student Submission')} - + ${_('Rescore Student Submission')} + ]
@@ -128,7 +128,7 @@ $(function () { null, %endif { - 'location': '${location}', + 'location': '${location.to_deprecated_string()}', 'xqa_key': '${xqa_key}', 'category': '${category}', 'user': '${user}'