From cd14156ad75532d2c81bedcaa83df7ef4ec8cd95 Mon Sep 17 00:00:00 2001 From: Duane Johnson Date: Thu, 18 Jul 2013 14:12:51 -0600 Subject: [PATCH] override cached_due_date with latest for versioned submissions fixes CNVS-6869 reverts g/22303 and g/22305 Test Plan: - make a submission - change the due date on the submission's assignment - the speedgrader should incorporate the change and be able to tell if the submission is overdue based on the new due date Change-Id: I2604e0bde43a1f5970ee3a38813295be410f2212 Reviewed-on: https://gerrit.instructure.com/22480 Reviewed-by: Jacob Fugal Tested-by: Jenkins QA-Review: Clare Strong Reviewed-by: Brian Palmer Product-Review: Duane Johnson --- app/models/assignment.rb | 1 - app/models/submission.rb | 3 ++- lib/api/v1/gradebook_history.rb | 4 +--- lib/api/v1/submission.rb | 1 - 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/models/assignment.rb b/app/models/assignment.rb index 3a6f7113ac9..c835cae01bf 100644 --- a/app/models/assignment.rb +++ b/app/models/assignment.rb @@ -1124,7 +1124,6 @@ class Assignment < ActiveRecord::Base ) if json['submission_history'] json['submission_history'].map! do |version| - version.cached_due_date = sub.cached_due_date version.as_json( :include => { :submission_comments => { :only => comment_fields } diff --git a/app/models/submission.rb b/app/models/submission.rb index d5c722fd8be..b3d0a16e9d5 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -141,7 +141,8 @@ class Submission < ActiveRecord::Base simply_versioned :explicit => true, :when => lambda{ |model| model.new_version_needed? }, - :on_create => lambda{ |model,version| SubmissionVersion.index_version(version) } + :on_create => lambda{ |model,version| SubmissionVersion.index_version(version) }, + :on_load => lambda{ |model,version| model.cached_due_date = version.versionable.cached_due_date } def new_version_needed? turnitin_data_changed? || (changes.keys - [ diff --git a/lib/api/v1/gradebook_history.rb b/lib/api/v1/gradebook_history.rb index 298a3548c3a..a60f3bf99ce 100644 --- a/lib/api/v1/gradebook_history.rb +++ b/lib/api/v1/gradebook_history.rb @@ -30,9 +30,7 @@ module Api::V1 student = opts[:student] || submission.user current_grader = submission.grader || default_grader - model = version.model - model.cached_due_date = submission.cached_due_date - json = submission_attempt_json(model, assignment, api_context.user, api_context.session, nil, course).with_indifferent_access + json = submission_attempt_json(version.model, assignment, api_context.user, api_context.session, nil, course).with_indifferent_access grader = (json[:grader_id] && json[:grader_id] > 0 && user_cache[json[:grader_id]]) || default_grader json = json.merge( diff --git a/lib/api/v1/submission.rb b/lib/api/v1/submission.rb index d8ee9853021..8eeade12b16 100644 --- a/lib/api/v1/submission.rb +++ b/lib/api/v1/submission.rb @@ -31,7 +31,6 @@ module Api::V1::Submission if includes.include?("submission_history") hash['submission_history'] = [] submission.submission_history.each_with_index do |ver, idx| - ver.cached_due_date = submission.cached_due_date hash['submission_history'] << submission_attempt_json(ver, assignment, user, session, idx, context) end end