Commit 6fcf65ef by Calen Pennington

Fix staff debug view

parent 484c529d
...@@ -832,7 +832,7 @@ def rescore_problem(request, course_id): ...@@ -832,7 +832,7 @@ def rescore_problem(request, course_id):
try: try:
module_state_key = UsageKey.from_string(problem_to_reset) module_state_key = UsageKey.from_string(problem_to_reset)
except InvalidKeyError: except InvalidKeyError:
return HttpResponseBadRequest() return HttpResponseBadRequest("Unable to parse problem id")
response_payload = {} response_payload = {}
response_payload['problem_to_reset'] = problem_to_reset response_payload['problem_to_reset'] = problem_to_reset
......
...@@ -22,7 +22,7 @@ var StaffDebug = (function(){ ...@@ -22,7 +22,7 @@ var StaffDebug = (function(){
do_idash_action = function(action){ do_idash_action = function(action){
var pdata = { var pdata = {
'problem_to_reset': action.location, 'problem_to_reset': action.location,
'unique_student_identifier': get_user(action.location), 'unique_student_identifier': get_user(action.locationName),
'delete_module': action.delete_module 'delete_module': action.delete_module
} }
$.ajax({ $.ajax({
...@@ -40,7 +40,7 @@ var StaffDebug = (function(){ ...@@ -40,7 +40,7 @@ var StaffDebug = (function(){
{text: text}, {text: text},
{interpolate: /\{(.+?)\}/g} {interpolate: /\{(.+?)\}/g}
) )
$("#result_"+action.location).html(html); $("#result_"+action.locationName).html(html);
}, },
error: function(request, status, error) { error: function(request, status, error) {
var response_json; var response_json;
...@@ -62,15 +62,16 @@ var StaffDebug = (function(){ ...@@ -62,15 +62,16 @@ var StaffDebug = (function(){
{text: text}, {text: text},
{interpolate: /\{(.+?)\}/g} {interpolate: /\{(.+?)\}/g}
) )
$("#result_"+action.location).html(html); $("#result_"+action.locationName).html(html);
}, },
dataType: 'json' dataType: 'json'
}); });
} }
reset = function(locname){ reset = function(locname, location){
this.do_idash_action({ this.do_idash_action({
location: locname, locationName: locname,
location: location,
method: 'reset_student_attempts', method: 'reset_student_attempts',
success_msg: gettext('Successfully reset the attempts for user {user}'), success_msg: gettext('Successfully reset the attempts for user {user}'),
error_msg: gettext('Failed to reset attempts.'), error_msg: gettext('Failed to reset attempts.'),
...@@ -78,9 +79,10 @@ var StaffDebug = (function(){ ...@@ -78,9 +79,10 @@ var StaffDebug = (function(){
}); });
} }
sdelete = function(locname){ sdelete = function(locname, location){
this.do_idash_action({ this.do_idash_action({
location: locname, locationName: locname,
location: location,
method: 'reset_student_attempts', method: 'reset_student_attempts',
success_msg: gettext('Successfully deleted student state for user {user}'), success_msg: gettext('Successfully deleted student state for user {user}'),
error_msg: gettext('Failed to delete student state.'), error_msg: gettext('Failed to delete student state.'),
...@@ -88,9 +90,10 @@ var StaffDebug = (function(){ ...@@ -88,9 +90,10 @@ var StaffDebug = (function(){
}); });
} }
rescore = function(locname){ rescore = function(locname, location){
this.do_idash_action({ this.do_idash_action({
location: locname, locationName: locname,
location: location,
method: 'rescore_problem', method: 'rescore_problem',
success_msg: gettext('Successfully rescored problem for user {user}'), success_msg: gettext('Successfully rescored problem for user {user}'),
error_msg: gettext('Failed to rescore problem.'), error_msg: gettext('Failed to rescore problem.'),
...@@ -112,15 +115,15 @@ var StaffDebug = (function(){ ...@@ -112,15 +115,15 @@ var StaffDebug = (function(){
// Register click handlers // Register click handlers
$(document).ready(function() { $(document).ready(function() {
$('#staff-debug-reset').click(function() { $('#staff-debug-reset').click(function() {
StaffDebug.reset($(this).data('location')); StaffDebug.reset($(this).parent().data('location-name'), $(this).parent().data('location'));
return false; return false;
}); });
$('#staff-debug-sdelete').click(function() { $('#staff-debug-sdelete').click(function() {
StaffDebug.sdelete($(this).data('location')); StaffDebug.sdelete($(this).parent().data('location-name'), $(this).parent().data('location'));
return false; return false;
}); });
$('#staff-debug-rescore').click(function() { $('#staff-debug-rescore').click(function() {
StaffDebug.rescore($(this).data('location')); StaffDebug.rescore($(this).parent().data('location-name'), $(this).parent().data('location'));
return false; return false;
}); });
}); });
...@@ -61,13 +61,13 @@ ${block_content} ...@@ -61,13 +61,13 @@ ${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> <div data-location="${unicode(location)}" data-location-name="${location.name}">
[ [
<a href="#" id="staff-debug-reset" data-location="${location.name}">${_('Reset Student Attempts')}</a> <a href="#" id="staff-debug-reset">${_('Reset Student Attempts')}</a>
| |
<a href="#" id="staff-debug-sdelete" data-location="${location.name}">${_('Delete Student State')}</a> <a href="#" id="staff-debug-sdelete">${_('Delete Student State')}</a>
| |
<a href="#" id="staff-debug-rescore" data-location="${location.name}">${_('Rescore Student Submission')}</a> <a href="#" id="staff-debug-rescore">${_('Rescore Student Submission')}</a>
] ]
</div> </div>
...@@ -128,7 +128,7 @@ $(function () { ...@@ -128,7 +128,7 @@ $(function () {
null, null,
%endif %endif
{ {
'location': '${location}', 'location': '${location.to_deprecated_string()}',
'xqa_key': '${xqa_key}', 'xqa_key': '${xqa_key}',
'category': '${category}', 'category': '${category}',
'user': '${user}' 'user': '${user}'
......
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