Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add scores table, which will hold the computed_current_score and computed_final_score which is currently stored on the enrollment object. in addition, grading period scores will be stored on the scores table. closes CNVS-33573 Test plan: * Create a course * Make sure should total for all grading periods is enabled * As a teacher, create an assignment that falls in a grading period * As a student, submit something for that assignment * As a teacher, grade that submission * As a student, view your grades * You should see the student's grade for both the grading period and all grading periods. * Repeat this process for another assignment and make sure the total grades get updated for the student. Basically, we want to smoke test test saving scores for an assignment and re-calculating course grades with new scores. Everything should behave the same as before. Change-Id: Ib7241d55c0fa52e01441671f17f65675f8e10564 Reviewed-on: https://gerrit.instructure.com/96825 Reviewed-by: Spencer Olson <solson@instructure.com> Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com> Tested-by: Keith T. Garner <kgarner@instructure.com> QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
- Loading branch information
Showing
25 changed files
with
561 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# | ||
# Copyright (C) 2016 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/>. | ||
# | ||
|
||
class Score < ActiveRecord::Base | ||
include Canvas::SoftDeletable | ||
|
||
attr_accessible :current_score, :final_score, :grading_period | ||
|
||
belongs_to :enrollment | ||
belongs_to :grading_period | ||
has_one :course, through: :enrollment | ||
|
||
validates :enrollment, presence: true | ||
validates :current_score, :final_score, numericality: true, allow_nil: true | ||
validates_uniqueness_of :enrollment_id, scope: :grading_period_id, conditions: -> { active } | ||
|
||
def current_grade | ||
score_to_grade(current_score) | ||
end | ||
|
||
def final_grade | ||
score_to_grade(final_score) | ||
end | ||
|
||
delegate :score_to_grade, to: :course | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class CreateScoresTable < ActiveRecord::Migration[4.2] | ||
tag :predeploy | ||
|
||
def up | ||
create_table :scores do |t| | ||
t.integer :enrollment_id, limit: 8, null: false | ||
t.integer :grading_period_id, limit: 8 | ||
t.string :workflow_state, default: :active, null: false, limit: 255 | ||
t.float :current_score | ||
t.float :final_score | ||
t.timestamps | ||
end | ||
|
||
add_foreign_key :scores, :enrollments | ||
add_foreign_key :scores, :grading_periods | ||
|
||
add_index :scores, [:enrollment_id, :grading_period_id], unique: true | ||
end | ||
|
||
def down | ||
drop_table :scores | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
db/migrate/20161212200216_drop_grading_period_grades_table.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class DropGradingPeriodGradesTable < ActiveRecord::Migration[4.2] | ||
tag :postdeploy | ||
|
||
def up | ||
drop_table :grading_period_grades | ||
end | ||
|
||
def down | ||
raise ActiveRecord::IrreversibleMigration | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.