Allow resubmitting to plagiarism platform for anonymous grading
Closes PLAT-3647 Test Plan: - Enable the 'Anonymous Grading' FF in your root account - Create an assignment with a plagiarism detection tool. Be sure to select the 'Graders cannot view student names' option when creating the assignment. - As a student submit to the assignment. - Create a pending originality report for the submission. - In speedgrader click the "resubmit to <tool name>" button. - Verify the page refreshes and a `plagiarism_resubmit` live event was emitted. Change-Id: Ib633b0d2b9807d2c963ecdba00048d4cfb0392a7 Reviewed-on: https://gerrit.instructure.com/160767 Tested-by: Jenkins Reviewed-by: Nathan Mills <nathanm@instructure.com> Reviewed-by: Han Ngo <hngo@instructure.com> QA-Review: August Thornton <august@instructure.com> Product-Review: Weston Dransfield <wdransfield@instructure.com>
This commit is contained in:
parent
b214d7f4ad
commit
03fa56b270
|
@ -541,11 +541,11 @@ class SubmissionsController < SubmissionsBaseController
|
|||
private :plagiarism_report
|
||||
|
||||
def resubmit_to_plagiarism(type)
|
||||
return head 400 unless params_are_integers?(:assignment_id, :submission_id)
|
||||
return head 400 unless params_are_integers?(:assignment_id)
|
||||
|
||||
if authorized_action(@context, @current_user, [:manage_grades, :view_all_grades])
|
||||
@assignment = @context.assignments.active.find(params[:assignment_id])
|
||||
@submission = @assignment.submissions.where(user_id: params[:submission_id]).first
|
||||
@submission = plagiarism_resubmit_submission(@assignment)
|
||||
Canvas::LiveEvents.plagiarism_resubmit(@submission)
|
||||
|
||||
if type == 'vericite'
|
||||
|
@ -574,6 +574,12 @@ class SubmissionsController < SubmissionsBaseController
|
|||
end
|
||||
private :always_permitted_create_params
|
||||
|
||||
def plagiarism_resubmit_submission(assignment)
|
||||
return assignment.submissions.find_by(user_id: params[:submission_id]) unless params[:anonymous]
|
||||
assignment.submissions.find_by(anonymous_id: params[:submission_id])
|
||||
end
|
||||
private :plagiarism_resubmit_submission
|
||||
|
||||
protected
|
||||
|
||||
def generate_submission_zip(assignment, context)
|
||||
|
|
|
@ -1651,7 +1651,7 @@ EG = {
|
|||
$('#plagiarism_platform_info_container').hide();
|
||||
} else {
|
||||
const resubmitUrl = SpeedgraderHelpers.plagiarismResubmitUrl(submission, anonymizableUserId)
|
||||
$('#plagiarism_resubmit_button').on('click', (e) => { SpeedgraderHelpers.plagiarismResubmitHandler(e, resubmitUrl) })
|
||||
$('#plagiarism_resubmit_button').on('click', (e) => { SpeedgraderHelpers.plagiarismResubmitHandler(e, resubmitUrl, anonymizableUserId) })
|
||||
}
|
||||
|
||||
if(vericiteEnabled){
|
||||
|
|
|
@ -155,11 +155,12 @@ export function setupAnonymizableAuthorId (isAnonymous) {
|
|||
return "not_submitted";
|
||||
}
|
||||
},
|
||||
plagiarismResubmitHandler: (event, resubmitUrl) => {
|
||||
plagiarismResubmitHandler: (event, resubmitUrl, anonymizableUserId = "") => {
|
||||
event.preventDefault();
|
||||
$(event.target).attr('disabled', true).text(I18n.t('turnitin.resubmitting', 'Resubmitting...'));
|
||||
const params = anonymizableUserId === 'anonymous_id' ? { anonymous: true } : {}
|
||||
|
||||
$.ajaxJSON(resubmitUrl, "POST", {}, () => {
|
||||
$(event.target).attr('disabled', true).text(I18n.t('turnitin.resubmitting', 'Resubmitting...'));
|
||||
$.ajaxJSON(resubmitUrl, "POST", params, () => {
|
||||
speedgraderHelpers.reloadPage();
|
||||
});
|
||||
},
|
||||
|
|
|
@ -402,6 +402,24 @@ test("prevents the button's default action", () => {
|
|||
$.ajaxJSON = previousAjaxJson
|
||||
})
|
||||
|
||||
test("sets the 'anonymous' param to true if anonymizableUserId is 'anonymous_id'", () => {
|
||||
$('#fixtures').append('<button id="resubmit-button">Click Here</button>')
|
||||
const ajaxStub = sinon.stub()
|
||||
ajaxStub.returns({
|
||||
status: 200,
|
||||
data: {}
|
||||
})
|
||||
const previousAjaxJson = $.ajaxJSON
|
||||
$.ajaxJSON = ajaxStub
|
||||
const event = {
|
||||
preventDefault: sinon.spy(),
|
||||
target: document.getElementById('resubmit-button')
|
||||
}
|
||||
SpeedgraderHelpers.plagiarismResubmitHandler(event, 'http://www.test.com', 'anonymous_id')
|
||||
deepEqual(ajaxStub.args[0][2], {anonymous: true})
|
||||
$.ajaxJSON = previousAjaxJson
|
||||
})
|
||||
|
||||
test("changes the button's text to 'Resubmitting...'", () => {
|
||||
$('#fixtures').append('<button id="resubmit-button">Click Here</button>')
|
||||
const ajaxStub = sinon.stub()
|
||||
|
|
|
@ -673,9 +673,9 @@ describe SubmissionsController do
|
|||
end
|
||||
|
||||
describe 'POST resubmit_to_turnitin' do
|
||||
it 'returns 400 if submission_id is not integer' do
|
||||
it 'returns 400 if assignment_id is not integer' do
|
||||
assignment = assignment_model
|
||||
post 'resubmit_to_turnitin', params: {:course_id => assignment.context_id, :assignment_id => assignment.id, :submission_id => '{ user_id }'}
|
||||
post 'resubmit_to_turnitin', params: {course_id: assignment.context_id, assignment_id: 'assignment-id', submission_id: test_student.id}
|
||||
expect(response.response_code).to eq 400
|
||||
end
|
||||
|
||||
|
@ -691,6 +691,17 @@ describe SubmissionsController do
|
|||
end
|
||||
end
|
||||
|
||||
it "redirects to speed grader when an anonymous submission id is used" do
|
||||
params = {
|
||||
course_id: assignment.context_id,
|
||||
assignment_id: assignment.id,
|
||||
submission_id: assignment.submission_for_student(test_student).anonymous_id,
|
||||
anonymous: true
|
||||
}
|
||||
post 'resubmit_to_turnitin', params: params
|
||||
expect(response).to be_redirect
|
||||
end
|
||||
|
||||
describe 'POST resubmit_to_vericite' do
|
||||
it "emits a 'plagiarism_resubmit' live event" do
|
||||
expect(Canvas::LiveEvents).to receive(:plagiarism_resubmit)
|
||||
|
|
Loading…
Reference in New Issue