diff --git a/lms/static/coffee/src/open_ended/open_ended.coffee b/lms/static/coffee/src/open_ended/open_ended.coffee index 45de3a4fcc..558d712c46 100644 --- a/lms/static/coffee/src/open_ended/open_ended.coffee +++ b/lms/static/coffee/src/open_ended/open_ended.coffee @@ -23,26 +23,34 @@ class OpenEnded parent_tr = $(event.target).parent().parent() tr_children = parent_tr.children() action_type = "unflag" - submission_id = tr_children[4].innerText - student_id = tr_children[5].innerText - @post('take_action_on_flags', {'submission_id' : submission_id, 'student_id' : student_id, 'action_type' : action_type}, @handle_after_action) + submission_id = tr_children[5].innerText + student_id = tr_children[6].innerText + callback_func = @after_action_wrapper($(event.target), action_type) + @post('take_action_on_flags', {'submission_id' : submission_id, 'student_id' : student_id, 'action_type' : action_type}, callback_func) ban: (event) => event.preventDefault() parent_tr = $(event.target).parent().parent() tr_children = parent_tr.children() action_type = "ban" - submission_id = tr_children[4].innerText - student_id = tr_children[5].innerText - @post('take_action_on_flags', {'submission_id' : submission_id, 'student_id' : student_id, 'action_type' : action_type}, @handle_after_action) + submission_id = tr_children[5].innerText + student_id = tr_children[6].innerText + callback_func = @after_action_wrapper($(event.target), action_type) + @post('take_action_on_flags', {'submission_id' : submission_id, 'student_id' : student_id, 'action_type' : action_type}, callback_func) post: (cmd, data, callback) -> # if this post request fails, the error callback will catch it $.post(@ajax_url + cmd, data, callback) .error => callback({success: false, error: "Error occured while performing this operation"}) + after_action_wrapper: (target, action_type) -> + return @handle_after_action + handle_after_action: (data) -> - @gentle_alert data.data + tr_parent = target.parent().parent() + tr_children = tr_parent.children() + action_taken = tr_children[4].children()[0] + action_taken.replaceWith('