update cached turnitin data when redirecting to originality report

Turnitin has no way to register callbacks when a submission's
originality score changes.  However, teachers are able to
modify originality scores for submissions by marking certain
sources as being ignored when checking for originality.  If a
teacher does this then the data we've cached will get out of
date.

We don't really want to have to regularly poll for updated
info, so this will just schedule a background job to check
for updates whenever someone goes to view the full
originality report.  There will still be plenty of time
when the data it out of sync, but it at least gives a
way in the UI to update the data.

Change-Id: Ia8cc814a2e9cf5ec140d3fd22acedfbb00da1b8a
Reviewed-on: https://gerrit.instructure.com/2163
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
This commit is contained in:
Brian Whitmer 2011-02-04 14:12:36 -07:00
parent a5eeb2b784
commit c54670da94
1 changed files with 1 additions and 0 deletions

View File

@ -180,6 +180,7 @@ class Submission < ActiveRecord::Base
def turnitin_report_url(asset_string, user)
if self.turnitin_data && self.turnitin_data[asset_string] && self.turnitin_data[asset_string][:similarity_score]
turnitin = Turnitin::Client.new(*self.context.turnitin_settings)
self.send_later(:check_turnitin_status, asset_string)
if self.grants_right?(user, nil, :grade)
turnitin.submissionReportUrl(self, asset_string)
elsif self.current_submission_graded?