2021-03-30 06:09:22 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-14 23:16:20 +08:00
|
|
|
#
|
|
|
|
# Copyright (C) 2017 - present Instructure, Inc.
|
|
|
|
#
|
|
|
|
# This file is part of Canvas.
|
|
|
|
#
|
|
|
|
# Canvas is free software: you can redistribute it and/or modify it under
|
|
|
|
# the terms of the GNU Affero General Public License as published by the Free
|
|
|
|
# Software Foundation, version 3 of the License.
|
|
|
|
#
|
|
|
|
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
|
|
# details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License along
|
|
|
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
add late_policy_status, accepted_at, points_deducted to submission
closes: CNVS-32365
Test Plan:
1. As a student, submit to an assignment late.
2. In rails console, observe that the submission created in step 1
returns `minutes_late` that accurately represents the number of
minutes late the submission was. This value should be 0 for
not-late submissions.
3. As the student, resubmit to the assignment. In a rails console,
verify the minutes_late has been updated.
4. Repeat steps 1-3 with a quiz instead of an assignment. To get the
submission for a quiz, it will look like:
quiz = Quizzes::Quiz.find_by(title: "My Quiz")
s = quiz.quiz_submissions.find_by(user_id: 173).submission
For quiz submissions, the student should be given one minute of
leeway, meaning if you submit a minute or less after the quiz is
due, minutes_late should be 0. A way you can test it via rails
console:
# make the student's submitted at exactly 1 minute after it was due
irb(main):103:0> s.submitted_at = 1.minute.from_now(s.cached_due_date)
=> Thu, 04 May 2017 06:00:59 UTC +00:00
# verify minutes_late is 0, since quiz submissions get 1 minute of leeway
irb(main):105:0> s.minutes_late
=> 0.0
# make the student's submitted at exactly 2 minutes after it was due
irb(main):106:0> s.submitted_at = 2.minutes.from_now(s.cached_due_date)
=> Thu, 04 May 2017 06:01:59 UTC +00:00
# verify minutes late is 1, since quiz submissions get 1 minute of leeway
irb(main):108:0> s.minutes_late
=> 1.0
Change-Id: I170f798a38d827a0699682cb557c1aa81c73201e
Reviewed-on: https://gerrit.instructure.com/107955
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com>
QA-Review: Matt Taylor <mtaylor@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-05-02 22:47:31 +08:00
|
|
|
class AddLateColumnsToSubmissions < ActiveRecord::Migration[4.2]
|
|
|
|
tag :predeploy
|
|
|
|
|
|
|
|
def up
|
|
|
|
add_column :submissions, :late_policy_status, :string, limit: 16
|
|
|
|
add_column :submissions, :accepted_at, :timestamp
|
|
|
|
add_column :submissions, :points_deducted, :decimal, precision: 6, scale: 2
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
remove_column :submissions, :points_deducted
|
|
|
|
remove_column :submissions, :accepted_at
|
|
|
|
remove_column :submissions, :late_policy_status
|
|
|
|
end
|
|
|
|
end
|