Commit 63d4ac8c by Vik Paruchuri

Working on some flagging coffeescript

parent 78f9f634
......@@ -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('<div class="action-taken">#{action_type} done for student.</div>')
gentle_alert: (msg) =>
if $('.message-container').length
......
......@@ -47,6 +47,9 @@
<td>
<a href="#ban" class="ban-button action-button" data-action-type="ban">Ban</a>
</td>
<td>
<div class="action-taken"></div>
</td>
<td style="display:none;">
${problem['submission_id']}
</td>
......
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