2020-10-27 00:50:13 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
#
|
2017-04-28 04:03:36 +08:00
|
|
|
# Copyright (C) 2011 - present Instructure, Inc.
|
2011-02-01 09:57:29 +08:00
|
|
|
#
|
|
|
|
# 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 GradeCalculator
|
2020-12-03 03:02:43 +08:00
|
|
|
attr_reader :gradable_assignments
|
2017-09-27 06:06:09 +08:00
|
|
|
attr_accessor :assignments, :groups
|
2014-01-15 08:29:38 +08:00
|
|
|
|
2020-10-13 05:32:34 +08:00
|
|
|
def initialize(user_ids, course, **opts)
|
2018-03-06 02:24:06 +08:00
|
|
|
Rails.logger.debug "GRADE CALCULATOR STARTS (initialize): #{Time.zone.now.to_i}"
|
|
|
|
Rails.logger.debug "GRADE CALCULATOR - caller: #{caller(1..1).first}"
|
update grading period scores when student is graded
When a student is graded, the score for their grading period will now
be updated in addition to their total course score. Previously, when a
student was graded, their grading period score was not updated.
closes CNVS-26709
test plan:
1) In a course with multiple grading periods enabled and grading
periods set up, grade students for assignments that fall in grading
periods and make sure the scores get updated for the grading period
and for the course total.
* To make sure the scores get updated for the grading period, open a
rails console and find the grading period scores (we'll assume the
student's enrollment ID is 5, and the ID of the grading period
that the assignment falls in is 8).
$ Enrollment.find(5).scores.where(grading_period_id: 8)
Then, give a different grade to the student for the assignment
that falls in the grading period and run the command above again.
You should see that the current_score and final_score have
changed.
* To make sure the scores get updated for the course total, open a
rails console and find the course total scores (we'll assume the
student's enrollment ID is 5).
$ Enrollment.find(5).scores.where(grading_period_id: nil)
Then, give a different grade to the student for the assignment
that falls in the grading period and run the command above again.
You should see that the current_score and final_score have
changed.
Edge case: make sure that grading period scores continue to get updated
even if MGP is turned off. To verify this, turn off MGP in a course
that originally had MGP turned on. Then, grade students in assignments
that fell in a grading period when MGP was enabled. After grading, the
grading period scores should be updated.
Change-Id: I29e4e22a0b73d1062a93c6ad420d876c2f5d040a
Reviewed-on: https://gerrit.instructure.com/98603
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2016-12-30 05:05:07 +08:00
|
|
|
opts = opts.reverse_merge(
|
2019-11-27 07:31:32 +08:00
|
|
|
emit_live_event: true,
|
update grading period scores when student is graded
When a student is graded, the score for their grading period will now
be updated in addition to their total course score. Previously, when a
student was graded, their grading period score was not updated.
closes CNVS-26709
test plan:
1) In a course with multiple grading periods enabled and grading
periods set up, grade students for assignments that fall in grading
periods and make sure the scores get updated for the grading period
and for the course total.
* To make sure the scores get updated for the grading period, open a
rails console and find the grading period scores (we'll assume the
student's enrollment ID is 5, and the ID of the grading period
that the assignment falls in is 8).
$ Enrollment.find(5).scores.where(grading_period_id: 8)
Then, give a different grade to the student for the assignment
that falls in the grading period and run the command above again.
You should see that the current_score and final_score have
changed.
* To make sure the scores get updated for the course total, open a
rails console and find the course total scores (we'll assume the
student's enrollment ID is 5).
$ Enrollment.find(5).scores.where(grading_period_id: nil)
Then, give a different grade to the student for the assignment
that falls in the grading period and run the command above again.
You should see that the current_score and final_score have
changed.
Edge case: make sure that grading period scores continue to get updated
even if MGP is turned off. To verify this, turn off MGP in a course
that originally had MGP turned on. Then, grade students in assignments
that fell in a grading period when MGP was enabled. After grading, the
grading period scores should be updated.
Change-Id: I29e4e22a0b73d1062a93c6ad420d876c2f5d040a
Reviewed-on: https://gerrit.instructure.com/98603
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2016-12-30 05:05:07 +08:00
|
|
|
ignore_muted: true,
|
|
|
|
update_all_grading_period_scores: true,
|
2017-12-12 06:29:35 +08:00
|
|
|
update_course_score: true,
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
only_update_course_gp_metadata: false,
|
|
|
|
only_update_points: false
|
update grading period scores when student is graded
When a student is graded, the score for their grading period will now
be updated in addition to their total course score. Previously, when a
student was graded, their grading period score was not updated.
closes CNVS-26709
test plan:
1) In a course with multiple grading periods enabled and grading
periods set up, grade students for assignments that fall in grading
periods and make sure the scores get updated for the grading period
and for the course total.
* To make sure the scores get updated for the grading period, open a
rails console and find the grading period scores (we'll assume the
student's enrollment ID is 5, and the ID of the grading period
that the assignment falls in is 8).
$ Enrollment.find(5).scores.where(grading_period_id: 8)
Then, give a different grade to the student for the assignment
that falls in the grading period and run the command above again.
You should see that the current_score and final_score have
changed.
* To make sure the scores get updated for the course total, open a
rails console and find the course total scores (we'll assume the
student's enrollment ID is 5).
$ Enrollment.find(5).scores.where(grading_period_id: nil)
Then, give a different grade to the student for the assignment
that falls in the grading period and run the command above again.
You should see that the current_score and final_score have
changed.
Edge case: make sure that grading period scores continue to get updated
even if MGP is turned off. To verify this, turn off MGP in a course
that originally had MGP turned on. Then, grade students in assignments
that fell in a grading period when MGP was enabled. After grading, the
grading period scores should be updated.
Change-Id: I29e4e22a0b73d1062a93c6ad420d876c2f5d040a
Reviewed-on: https://gerrit.instructure.com/98603
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2016-12-30 05:05:07 +08:00
|
|
|
)
|
2012-12-22 07:02:45 +08:00
|
|
|
|
2018-03-06 02:24:06 +08:00
|
|
|
Rails.logger.debug("GRADES: calc args: user_ids=#{user_ids.inspect}")
|
|
|
|
Rails.logger.debug("GRADES: calc args: course=#{course.inspect}")
|
|
|
|
Rails.logger.debug("GRADES: calc args: opts=#{opts.inspect}")
|
2015-02-13 11:08:45 +08:00
|
|
|
|
2014-12-06 05:49:27 +08:00
|
|
|
@course = course.is_a?(Course) ? course : Course.find(course)
|
2017-03-28 01:25:37 +08:00
|
|
|
|
2017-09-27 06:06:09 +08:00
|
|
|
@groups = opts[:groups] || @course.assignment_groups.active.to_a
|
2014-12-06 05:49:27 +08:00
|
|
|
@grading_period = opts[:grading_period]
|
update grading period scores when student is graded
When a student is graded, the score for their grading period will now
be updated in addition to their total course score. Previously, when a
student was graded, their grading period score was not updated.
closes CNVS-26709
test plan:
1) In a course with multiple grading periods enabled and grading
periods set up, grade students for assignments that fall in grading
periods and make sure the scores get updated for the grading period
and for the course total.
* To make sure the scores get updated for the grading period, open a
rails console and find the grading period scores (we'll assume the
student's enrollment ID is 5, and the ID of the grading period
that the assignment falls in is 8).
$ Enrollment.find(5).scores.where(grading_period_id: 8)
Then, give a different grade to the student for the assignment
that falls in the grading period and run the command above again.
You should see that the current_score and final_score have
changed.
* To make sure the scores get updated for the course total, open a
rails console and find the course total scores (we'll assume the
student's enrollment ID is 5).
$ Enrollment.find(5).scores.where(grading_period_id: nil)
Then, give a different grade to the student for the assignment
that falls in the grading period and run the command above again.
You should see that the current_score and final_score have
changed.
Edge case: make sure that grading period scores continue to get updated
even if MGP is turned off. To verify this, turn off MGP in a course
that originally had MGP turned on. Then, grade students in assignments
that fell in a grading period when MGP was enabled. After grading, the
grading period scores should be updated.
Change-Id: I29e4e22a0b73d1062a93c6ad420d876c2f5d040a
Reviewed-on: https://gerrit.instructure.com/98603
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2016-12-30 05:05:07 +08:00
|
|
|
# if we're updating an overall course score (no grading period specified), we
|
|
|
|
# want to first update all grading period scores for the users
|
|
|
|
@update_all_grading_period_scores = @grading_period.nil? && opts[:update_all_grading_period_scores]
|
|
|
|
# if we're updating a grading period score, we also need to update the
|
|
|
|
# overall course score
|
|
|
|
@update_course_score = @grading_period.present? && opts[:update_course_score]
|
2020-11-04 03:43:24 +08:00
|
|
|
@ignore_unposted_anonymous = opts.fetch(
|
|
|
|
:ignore_unposted_anonymous,
|
|
|
|
@course.root_account.feature_enabled?(:grade_calc_ignore_unposted_anonymous)
|
|
|
|
)
|
2020-12-03 03:02:43 +08:00
|
|
|
@gradable_assignments = (opts[:assignments] || @course.assignments.published.gradeable).to_a
|
2020-11-04 03:43:24 +08:00
|
|
|
|
2020-12-03 03:02:43 +08:00
|
|
|
@assignments = if @ignore_unposted_anonymous
|
|
|
|
Assignment.preload_unposted_anonymous_submissions(@gradable_assignments)
|
2020-11-04 03:43:24 +08:00
|
|
|
|
|
|
|
# Ignore anonymous assignments with unposted submissions in the grade calculation
|
|
|
|
# so that we don't break anonymity prior to the assignment being posted
|
|
|
|
# (which is when identities are revealed)
|
2020-12-03 03:02:43 +08:00
|
|
|
@gradable_assignments.reject(&:unposted_anonymous_submissions?)
|
|
|
|
else
|
|
|
|
@gradable_assignments
|
2020-11-04 03:43:24 +08:00
|
|
|
end
|
2017-03-28 01:25:37 +08:00
|
|
|
|
2016-07-20 01:31:02 +08:00
|
|
|
@user_ids = Array(user_ids).map { |id| Shard.relative_id_for(id, Shard.current, @course.shard) }
|
2014-03-17 23:52:51 +08:00
|
|
|
@current_updates = {}
|
|
|
|
@final_updates = {}
|
2017-10-05 02:34:31 +08:00
|
|
|
@dropped_updates = {}
|
2017-08-17 21:47:36 +08:00
|
|
|
@current_groups = {}
|
|
|
|
@final_groups = {}
|
2017-12-12 06:29:35 +08:00
|
|
|
# The developers of the future, I leave you this gift:
|
|
|
|
# If you add a new options here, make sure you also update the
|
|
|
|
# opts in the compute_branch method
|
2019-11-27 07:31:32 +08:00
|
|
|
@emit_live_event = opts[:emit_live_event]
|
2012-12-22 07:02:45 +08:00
|
|
|
@ignore_muted = opts[:ignore_muted]
|
2017-04-19 12:03:23 +08:00
|
|
|
@effective_due_dates = opts[:effective_due_dates]
|
2017-09-27 06:06:09 +08:00
|
|
|
@enrollments = opts[:enrollments]
|
|
|
|
@periods = opts[:periods]
|
|
|
|
@submissions = opts[:submissions]
|
2017-12-12 06:29:35 +08:00
|
|
|
@only_update_course_gp_metadata = opts[:only_update_course_gp_metadata]
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
@only_update_points = opts[:only_update_points]
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
2013-04-30 08:29:45 +08:00
|
|
|
|
2014-01-15 08:29:38 +08:00
|
|
|
# recomputes the scores and saves them to each user's Enrollment
|
2020-10-13 05:32:34 +08:00
|
|
|
def self.recompute_final_score(user_ids, course_id, **compute_score_opts)
|
2018-03-06 02:24:06 +08:00
|
|
|
Rails.logger.debug "GRADE CALCULATOR STARTS (recompute_final_score): #{Time.zone.now.to_i}"
|
|
|
|
Rails.logger.debug "GRADE CALCULATOR - caller: #{caller(1..1).first}"
|
2014-03-17 23:52:51 +08:00
|
|
|
user_ids = Array(user_ids).uniq.map(&:to_i)
|
|
|
|
return if user_ids.empty?
|
2021-09-23 00:25:11 +08:00
|
|
|
|
2017-09-27 06:06:09 +08:00
|
|
|
course = course_id.is_a?(Course) ? course_id : Course.active.where(id: course_id).take
|
2017-08-23 09:31:01 +08:00
|
|
|
return unless course
|
2017-09-27 06:06:09 +08:00
|
|
|
|
|
|
|
assignments = compute_score_opts[:assignments] || course.assignments.published.gradeable.to_a
|
|
|
|
groups = compute_score_opts[:groups] || course.assignment_groups.active.to_a
|
|
|
|
periods = compute_score_opts[:periods] || GradingPeriod.for(course)
|
|
|
|
grading_period_id = compute_score_opts.delete(:grading_period_id)
|
|
|
|
grading_period = periods.find_by(id: grading_period_id) if grading_period_id
|
|
|
|
opts = compute_score_opts.reverse_merge(
|
|
|
|
grading_period: grading_period,
|
|
|
|
assignments: assignments,
|
|
|
|
groups: groups,
|
|
|
|
periods: periods
|
update grading period scores when student is graded
When a student is graded, the score for their grading period will now
be updated in addition to their total course score. Previously, when a
student was graded, their grading period score was not updated.
closes CNVS-26709
test plan:
1) In a course with multiple grading periods enabled and grading
periods set up, grade students for assignments that fall in grading
periods and make sure the scores get updated for the grading period
and for the course total.
* To make sure the scores get updated for the grading period, open a
rails console and find the grading period scores (we'll assume the
student's enrollment ID is 5, and the ID of the grading period
that the assignment falls in is 8).
$ Enrollment.find(5).scores.where(grading_period_id: 8)
Then, give a different grade to the student for the assignment
that falls in the grading period and run the command above again.
You should see that the current_score and final_score have
changed.
* To make sure the scores get updated for the course total, open a
rails console and find the course total scores (we'll assume the
student's enrollment ID is 5).
$ Enrollment.find(5).scores.where(grading_period_id: nil)
Then, give a different grade to the student for the assignment
that falls in the grading period and run the command above again.
You should see that the current_score and final_score have
changed.
Edge case: make sure that grading period scores continue to get updated
even if MGP is turned off. To verify this, turn off MGP in a course
that originally had MGP turned on. Then, grade students in assignments
that fell in a grading period when MGP was enabled. After grading, the
grading period scores should be updated.
Change-Id: I29e4e22a0b73d1062a93c6ad420d876c2f5d040a
Reviewed-on: https://gerrit.instructure.com/98603
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2016-12-30 05:05:07 +08:00
|
|
|
)
|
2019-01-23 23:11:00 +08:00
|
|
|
user_ids.sort.in_groups_of(100, false) do |user_ids_group|
|
2020-10-13 05:32:34 +08:00
|
|
|
GradeCalculator.new(user_ids_group, course, **opts).compute_and_save_scores
|
2014-03-17 23:52:51 +08:00
|
|
|
end
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
2012-12-22 07:02:45 +08:00
|
|
|
|
2017-09-27 06:06:09 +08:00
|
|
|
def submissions
|
2018-02-15 23:28:07 +08:00
|
|
|
@submissions ||= begin
|
|
|
|
submissions = @course.submissions
|
|
|
|
.except(:order, :select)
|
|
|
|
.for_user(@user_ids)
|
|
|
|
.where(assignment_id: @assignments)
|
2019-05-31 04:49:30 +08:00
|
|
|
.select("submissions.id, user_id, assignment_id, score, excused, submissions.workflow_state, submissions.posted_at")
|
|
|
|
.preload(:assignment)
|
2018-02-15 23:28:07 +08:00
|
|
|
|
2018-03-06 02:24:06 +08:00
|
|
|
Rails.logger.debug "GRADE CALCULATOR - submissions: #{submissions.size} - #{Time.zone.now.to_i}"
|
2018-02-15 23:28:07 +08:00
|
|
|
submissions
|
|
|
|
end
|
2017-09-27 06:06:09 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def compute_scores
|
back-end grade calculator supports grading period weighting
closes CNVS-34105
test plan:
- Setup -
1. At the account-level, create a new grading period set that uses
weighted grading periods. Attach the default enrollment term to this
set.
2. Create a grading period (GP1) that runs from January 1, 2017 to June
30, 2017. Give it a weight of 75%.
3. Create a grading period (GP2) that runs from July 1, 2017 to
December 31, 2017. Give it a weight of 25%.
4. Create a course that belongs to the default enrollment term from
step 1. Enroll one student in the course. Make sure that student is
enrolled in at least one other course.
5. In the course settings, enable Multiple Grading Periods and enable
Display ‘All Grading Period’ Totals.
6. In the course, create an assignment (Assignment in GP1) that is
worth 10 points and due for everyone on March 15, 2017.
7. In the course, create an assignment (Assignment in GP2) that is
worth 10 points and due for everyone on September 15, 2017.
8. Go to the gradebook and give the student 5/10 on Assignment in GP1
and 10/10 on Assignment in GP2. Ignore the totals that show up in
the gradebook.
- Grade Verification -
1. Sign in as the student and go to the /grades page.
2. Verify the grade for GP1 is 50%.
3. Verify the grade for GP2 is 100%.
4. Verify the grade for ‘All Grading Periods’ is 62.5%.
5. Sign in as the account admin. Change the weight for GP1 to 20% and
change the weight for GP2 to 40%.
6. Sign in as the student and go to the /grades page.
7. Verify the grade for GP1 is 50%.
8. Verify the grade for GP2 is 100%.
9. Verify the grade for ‘All Grading Periods’ is 83.33%.
10. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 100%.
11. Sign in as the student and go to the /grades page.
12. Verify the grade for GP1 is 50%.
13. Verify the grade for GP2 is 100%.
14. Verify the grade for ‘All Grading Periods’ is 150%.
15. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 0%.
16. Sign in as the student and go to the /grades page.
17. Verify the grade for GP1 is 50%.
18. Verify the grade for GP2 is 100%.
19. Verify the grade for ‘All Grading Periods’ is 50%.
20. Sign in as the account admin. Change the weight for GP1 to 0% and
change the weight for GP2 to 0%.
21. Sign in as the student and go to the /grades page.
22. Verify the grade for GP1 is 50%.
23. Verify the grade for GP2 is 100%.
24. Verify the grade for ‘All Grading Periods’ is 0%.
25. Sign in as the account admin. Uncheck the box on the grading period
set for ‘weighting’.
26. Sign in as the student and go to the /grades page.
27. Verify the grade for GP1 is 50%.
28. Verify the grade for GP2 is 100%.
29. Verify the grade for ‘All Grading Periods’ is 75%.
Change-Id: Iac23e92986f371b13de2d5e0524d6bed8a277bc4
Reviewed-on: https://gerrit.instructure.com/99040
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-04 03:59:14 +08:00
|
|
|
scores_and_group_sums = []
|
2014-10-28 02:19:36 +08:00
|
|
|
@user_ids.each_slice(100) do |batched_ids|
|
back-end grade calculator supports grading period weighting
closes CNVS-34105
test plan:
- Setup -
1. At the account-level, create a new grading period set that uses
weighted grading periods. Attach the default enrollment term to this
set.
2. Create a grading period (GP1) that runs from January 1, 2017 to June
30, 2017. Give it a weight of 75%.
3. Create a grading period (GP2) that runs from July 1, 2017 to
December 31, 2017. Give it a weight of 25%.
4. Create a course that belongs to the default enrollment term from
step 1. Enroll one student in the course. Make sure that student is
enrolled in at least one other course.
5. In the course settings, enable Multiple Grading Periods and enable
Display ‘All Grading Period’ Totals.
6. In the course, create an assignment (Assignment in GP1) that is
worth 10 points and due for everyone on March 15, 2017.
7. In the course, create an assignment (Assignment in GP2) that is
worth 10 points and due for everyone on September 15, 2017.
8. Go to the gradebook and give the student 5/10 on Assignment in GP1
and 10/10 on Assignment in GP2. Ignore the totals that show up in
the gradebook.
- Grade Verification -
1. Sign in as the student and go to the /grades page.
2. Verify the grade for GP1 is 50%.
3. Verify the grade for GP2 is 100%.
4. Verify the grade for ‘All Grading Periods’ is 62.5%.
5. Sign in as the account admin. Change the weight for GP1 to 20% and
change the weight for GP2 to 40%.
6. Sign in as the student and go to the /grades page.
7. Verify the grade for GP1 is 50%.
8. Verify the grade for GP2 is 100%.
9. Verify the grade for ‘All Grading Periods’ is 83.33%.
10. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 100%.
11. Sign in as the student and go to the /grades page.
12. Verify the grade for GP1 is 50%.
13. Verify the grade for GP2 is 100%.
14. Verify the grade for ‘All Grading Periods’ is 150%.
15. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 0%.
16. Sign in as the student and go to the /grades page.
17. Verify the grade for GP1 is 50%.
18. Verify the grade for GP2 is 100%.
19. Verify the grade for ‘All Grading Periods’ is 50%.
20. Sign in as the account admin. Change the weight for GP1 to 0% and
change the weight for GP2 to 0%.
21. Sign in as the student and go to the /grades page.
22. Verify the grade for GP1 is 50%.
23. Verify the grade for GP2 is 100%.
24. Verify the grade for ‘All Grading Periods’ is 0%.
25. Sign in as the account admin. Uncheck the box on the grading period
set for ‘weighting’.
26. Sign in as the student and go to the /grades page.
27. Verify the grade for GP1 is 50%.
28. Verify the grade for GP2 is 100%.
29. Verify the grade for ‘All Grading Periods’ is 75%.
Change-Id: Iac23e92986f371b13de2d5e0524d6bed8a277bc4
Reviewed-on: https://gerrit.instructure.com/99040
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-04 03:59:14 +08:00
|
|
|
scores_and_group_sums_batch = compute_scores_and_group_sums_for_batch(batched_ids)
|
|
|
|
scores_and_group_sums.concat(scores_and_group_sums_batch)
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
back-end grade calculator supports grading period weighting
closes CNVS-34105
test plan:
- Setup -
1. At the account-level, create a new grading period set that uses
weighted grading periods. Attach the default enrollment term to this
set.
2. Create a grading period (GP1) that runs from January 1, 2017 to June
30, 2017. Give it a weight of 75%.
3. Create a grading period (GP2) that runs from July 1, 2017 to
December 31, 2017. Give it a weight of 25%.
4. Create a course that belongs to the default enrollment term from
step 1. Enroll one student in the course. Make sure that student is
enrolled in at least one other course.
5. In the course settings, enable Multiple Grading Periods and enable
Display ‘All Grading Period’ Totals.
6. In the course, create an assignment (Assignment in GP1) that is
worth 10 points and due for everyone on March 15, 2017.
7. In the course, create an assignment (Assignment in GP2) that is
worth 10 points and due for everyone on September 15, 2017.
8. Go to the gradebook and give the student 5/10 on Assignment in GP1
and 10/10 on Assignment in GP2. Ignore the totals that show up in
the gradebook.
- Grade Verification -
1. Sign in as the student and go to the /grades page.
2. Verify the grade for GP1 is 50%.
3. Verify the grade for GP2 is 100%.
4. Verify the grade for ‘All Grading Periods’ is 62.5%.
5. Sign in as the account admin. Change the weight for GP1 to 20% and
change the weight for GP2 to 40%.
6. Sign in as the student and go to the /grades page.
7. Verify the grade for GP1 is 50%.
8. Verify the grade for GP2 is 100%.
9. Verify the grade for ‘All Grading Periods’ is 83.33%.
10. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 100%.
11. Sign in as the student and go to the /grades page.
12. Verify the grade for GP1 is 50%.
13. Verify the grade for GP2 is 100%.
14. Verify the grade for ‘All Grading Periods’ is 150%.
15. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 0%.
16. Sign in as the student and go to the /grades page.
17. Verify the grade for GP1 is 50%.
18. Verify the grade for GP2 is 100%.
19. Verify the grade for ‘All Grading Periods’ is 50%.
20. Sign in as the account admin. Change the weight for GP1 to 0% and
change the weight for GP2 to 0%.
21. Sign in as the student and go to the /grades page.
22. Verify the grade for GP1 is 50%.
23. Verify the grade for GP2 is 100%.
24. Verify the grade for ‘All Grading Periods’ is 0%.
25. Sign in as the account admin. Uncheck the box on the grading period
set for ‘weighting’.
26. Sign in as the student and go to the /grades page.
27. Verify the grade for GP1 is 50%.
28. Verify the grade for GP2 is 100%.
29. Verify the grade for ‘All Grading Periods’ is 75%.
Change-Id: Iac23e92986f371b13de2d5e0524d6bed8a277bc4
Reviewed-on: https://gerrit.instructure.com/99040
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-04 03:59:14 +08:00
|
|
|
scores_and_group_sums
|
2012-12-22 07:02:45 +08:00
|
|
|
end
|
|
|
|
|
2014-03-17 23:52:51 +08:00
|
|
|
def compute_and_save_scores
|
2017-05-01 22:30:33 +08:00
|
|
|
calculate_grading_period_scores if @update_all_grading_period_scores
|
|
|
|
compute_scores
|
2018-05-16 04:48:18 +08:00
|
|
|
scores_prior_to_compute = Score.where(enrollment: @enrollments.map(&:id), assignment_group_id: nil, course_score: true).to_a
|
2014-03-17 23:52:51 +08:00
|
|
|
save_scores
|
2018-03-26 23:38:27 +08:00
|
|
|
update_score_statistics
|
2017-12-12 06:29:35 +08:00
|
|
|
# The next line looks weird, but it is intended behaviour. Its
|
2019-05-04 02:29:33 +08:00
|
|
|
# saying "if we're on the branch not calculating hidden scores, run
|
2017-12-12 06:29:35 +08:00
|
|
|
# the branch that does."
|
2019-05-04 02:29:33 +08:00
|
|
|
calculate_hidden_scores if @ignore_muted
|
2019-11-27 07:31:32 +08:00
|
|
|
|
|
|
|
# Since we @emit_live_event only in the outer call when @ignore_muted is true, this has to be
|
|
|
|
# done after calculate_hidden_scores -- so changes in that inner call are also captured. But
|
|
|
|
# it must be done before calculate_course_score so if @update_course_score is true (we are
|
|
|
|
# scoring a grading period, not a course) we don't trigger an additional alert/live event here.
|
2020-11-05 01:22:39 +08:00
|
|
|
create_course_grade_alerts_and_live_events(scores_prior_to_compute)
|
2019-11-27 07:31:32 +08:00
|
|
|
|
update grading period scores when student is graded
When a student is graded, the score for their grading period will now
be updated in addition to their total course score. Previously, when a
student was graded, their grading period score was not updated.
closes CNVS-26709
test plan:
1) In a course with multiple grading periods enabled and grading
periods set up, grade students for assignments that fall in grading
periods and make sure the scores get updated for the grading period
and for the course total.
* To make sure the scores get updated for the grading period, open a
rails console and find the grading period scores (we'll assume the
student's enrollment ID is 5, and the ID of the grading period
that the assignment falls in is 8).
$ Enrollment.find(5).scores.where(grading_period_id: 8)
Then, give a different grade to the student for the assignment
that falls in the grading period and run the command above again.
You should see that the current_score and final_score have
changed.
* To make sure the scores get updated for the course total, open a
rails console and find the course total scores (we'll assume the
student's enrollment ID is 5).
$ Enrollment.find(5).scores.where(grading_period_id: nil)
Then, give a different grade to the student for the assignment
that falls in the grading period and run the command above again.
You should see that the current_score and final_score have
changed.
Edge case: make sure that grading period scores continue to get updated
even if MGP is turned off. To verify this, turn off MGP in a course
that originally had MGP turned on. Then, grade students in assignments
that fell in a grading period when MGP was enabled. After grading, the
grading period scores should be updated.
Change-Id: I29e4e22a0b73d1062a93c6ad420d876c2f5d040a
Reviewed-on: https://gerrit.instructure.com/98603
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2016-12-30 05:05:07 +08:00
|
|
|
calculate_course_score if @update_course_score
|
2014-03-17 23:52:51 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2017-04-19 12:03:23 +08:00
|
|
|
def effective_due_dates
|
2017-05-24 03:20:50 +08:00
|
|
|
@effective_due_dates ||= EffectiveDueDates.for_course(@course, @assignments).filter_students_to(@user_ids)
|
2017-04-19 12:03:23 +08:00
|
|
|
end
|
|
|
|
|
2020-03-31 04:49:18 +08:00
|
|
|
def observer_ids
|
|
|
|
@observer_ids ||= ObserverEnrollment.where.not(workflow_state: [:rejected, :deleted])
|
|
|
|
.where(course: @course)
|
|
|
|
.pluck(:user_id)
|
|
|
|
.uniq
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_course_grade_alerts_and_live_events(scores)
|
|
|
|
@course.shard.activate do
|
2022-06-03 04:14:04 +08:00
|
|
|
ActiveRecord::Associations.preload(scores, :enrollment)
|
2020-03-31 04:49:18 +08:00
|
|
|
# Make only one alert per user even if they have multiple enrollments (sections in same course)
|
|
|
|
scores = scores.uniq { |s| s.enrollment.user_id }
|
|
|
|
|
|
|
|
scores.each_slice(100) do |scores_batch|
|
|
|
|
scores_info = scores_batch.each_with_object({ student_ids: [], ids: [] }) do |score, memo|
|
|
|
|
memo[:student_ids] << score.enrollment.user_id
|
|
|
|
memo[:ids] << score.id
|
|
|
|
end
|
|
|
|
|
|
|
|
preloaded_thresholds = ObserverAlertThreshold.active
|
|
|
|
.where(user_id: scores_info[:student_ids], alert_type: ["course_grade_high", "course_grade_low"])
|
|
|
|
.group_by(&:user_id)
|
|
|
|
|
|
|
|
reloaded_scores = Score.where(id: scores_info[:ids]).index_by(&:id)
|
|
|
|
scores_batch.each do |score|
|
|
|
|
reloaded_score = reloaded_scores[score.id]
|
|
|
|
# NOTE: only the old score has enrollment pre-loaded
|
|
|
|
create_course_grade_live_event(score, reloaded_score) if @emit_live_event
|
|
|
|
|
|
|
|
thresholds = preloaded_thresholds.fetch(score.enrollment.user_id, [])
|
|
|
|
create_course_grade_alert(score, reloaded_score, thresholds)
|
|
|
|
end
|
2018-05-16 04:48:18 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-11-27 07:31:32 +08:00
|
|
|
LIVE_EVENT_FIELDS = %i[current_score final_score unposted_current_score unposted_final_score].freeze
|
|
|
|
|
|
|
|
def create_course_grade_live_event(old_score, score)
|
|
|
|
return if LIVE_EVENT_FIELDS.all? { |f| old_score.send(f) == score.send(f) }
|
2021-09-23 00:25:11 +08:00
|
|
|
|
2021-11-17 06:27:33 +08:00
|
|
|
old_score_values = LIVE_EVENT_FIELDS.index_with { |f| old_score.send(f) }
|
2019-11-27 07:31:32 +08:00
|
|
|
Canvas::LiveEvents.course_grade_change(score, old_score_values, old_score.enrollment)
|
|
|
|
end
|
|
|
|
|
2020-03-31 04:49:18 +08:00
|
|
|
def create_course_grade_alert(old_score, score, thresholds)
|
|
|
|
thresholds.each do |threshold|
|
|
|
|
next unless threshold.did_pass_threshold(old_score.current_score, score.current_score)
|
|
|
|
next unless observer_ids.include?(threshold.observer_id)
|
|
|
|
|
|
|
|
ObserverAlert.create(observer_id: threshold.observer_id, user_id: threshold.user_id,
|
|
|
|
observer_alert_threshold: threshold,
|
|
|
|
context: @course, action_date: score.updated_at, alert_type: threshold.alert_type,
|
|
|
|
title: I18n.t("Course grade: %{grade}% in %{course_code}", {
|
|
|
|
grade: score.current_score,
|
|
|
|
course_code: @course.course_code
|
|
|
|
}))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
back-end grade calculator supports grading period weighting
closes CNVS-34105
test plan:
- Setup -
1. At the account-level, create a new grading period set that uses
weighted grading periods. Attach the default enrollment term to this
set.
2. Create a grading period (GP1) that runs from January 1, 2017 to June
30, 2017. Give it a weight of 75%.
3. Create a grading period (GP2) that runs from July 1, 2017 to
December 31, 2017. Give it a weight of 25%.
4. Create a course that belongs to the default enrollment term from
step 1. Enroll one student in the course. Make sure that student is
enrolled in at least one other course.
5. In the course settings, enable Multiple Grading Periods and enable
Display ‘All Grading Period’ Totals.
6. In the course, create an assignment (Assignment in GP1) that is
worth 10 points and due for everyone on March 15, 2017.
7. In the course, create an assignment (Assignment in GP2) that is
worth 10 points and due for everyone on September 15, 2017.
8. Go to the gradebook and give the student 5/10 on Assignment in GP1
and 10/10 on Assignment in GP2. Ignore the totals that show up in
the gradebook.
- Grade Verification -
1. Sign in as the student and go to the /grades page.
2. Verify the grade for GP1 is 50%.
3. Verify the grade for GP2 is 100%.
4. Verify the grade for ‘All Grading Periods’ is 62.5%.
5. Sign in as the account admin. Change the weight for GP1 to 20% and
change the weight for GP2 to 40%.
6. Sign in as the student and go to the /grades page.
7. Verify the grade for GP1 is 50%.
8. Verify the grade for GP2 is 100%.
9. Verify the grade for ‘All Grading Periods’ is 83.33%.
10. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 100%.
11. Sign in as the student and go to the /grades page.
12. Verify the grade for GP1 is 50%.
13. Verify the grade for GP2 is 100%.
14. Verify the grade for ‘All Grading Periods’ is 150%.
15. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 0%.
16. Sign in as the student and go to the /grades page.
17. Verify the grade for GP1 is 50%.
18. Verify the grade for GP2 is 100%.
19. Verify the grade for ‘All Grading Periods’ is 50%.
20. Sign in as the account admin. Change the weight for GP1 to 0% and
change the weight for GP2 to 0%.
21. Sign in as the student and go to the /grades page.
22. Verify the grade for GP1 is 50%.
23. Verify the grade for GP2 is 100%.
24. Verify the grade for ‘All Grading Periods’ is 0%.
25. Sign in as the account admin. Uncheck the box on the grading period
set for ‘weighting’.
26. Sign in as the student and go to the /grades page.
27. Verify the grade for GP1 is 50%.
28. Verify the grade for GP2 is 100%.
29. Verify the grade for ‘All Grading Periods’ is 75%.
Change-Id: Iac23e92986f371b13de2d5e0524d6bed8a277bc4
Reviewed-on: https://gerrit.instructure.com/99040
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-04 03:59:14 +08:00
|
|
|
def compute_scores_and_group_sums_for_batch(user_ids)
|
2021-11-15 23:09:24 +08:00
|
|
|
user_ids.filter_map do |user_id|
|
2017-09-05 01:57:09 +08:00
|
|
|
next unless enrollments_by_user[user_id].first
|
2021-09-23 00:25:11 +08:00
|
|
|
|
back-end grade calculator supports grading period weighting
closes CNVS-34105
test plan:
- Setup -
1. At the account-level, create a new grading period set that uses
weighted grading periods. Attach the default enrollment term to this
set.
2. Create a grading period (GP1) that runs from January 1, 2017 to June
30, 2017. Give it a weight of 75%.
3. Create a grading period (GP2) that runs from July 1, 2017 to
December 31, 2017. Give it a weight of 25%.
4. Create a course that belongs to the default enrollment term from
step 1. Enroll one student in the course. Make sure that student is
enrolled in at least one other course.
5. In the course settings, enable Multiple Grading Periods and enable
Display ‘All Grading Period’ Totals.
6. In the course, create an assignment (Assignment in GP1) that is
worth 10 points and due for everyone on March 15, 2017.
7. In the course, create an assignment (Assignment in GP2) that is
worth 10 points and due for everyone on September 15, 2017.
8. Go to the gradebook and give the student 5/10 on Assignment in GP1
and 10/10 on Assignment in GP2. Ignore the totals that show up in
the gradebook.
- Grade Verification -
1. Sign in as the student and go to the /grades page.
2. Verify the grade for GP1 is 50%.
3. Verify the grade for GP2 is 100%.
4. Verify the grade for ‘All Grading Periods’ is 62.5%.
5. Sign in as the account admin. Change the weight for GP1 to 20% and
change the weight for GP2 to 40%.
6. Sign in as the student and go to the /grades page.
7. Verify the grade for GP1 is 50%.
8. Verify the grade for GP2 is 100%.
9. Verify the grade for ‘All Grading Periods’ is 83.33%.
10. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 100%.
11. Sign in as the student and go to the /grades page.
12. Verify the grade for GP1 is 50%.
13. Verify the grade for GP2 is 100%.
14. Verify the grade for ‘All Grading Periods’ is 150%.
15. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 0%.
16. Sign in as the student and go to the /grades page.
17. Verify the grade for GP1 is 50%.
18. Verify the grade for GP2 is 100%.
19. Verify the grade for ‘All Grading Periods’ is 50%.
20. Sign in as the account admin. Change the weight for GP1 to 0% and
change the weight for GP2 to 0%.
21. Sign in as the student and go to the /grades page.
22. Verify the grade for GP1 is 50%.
23. Verify the grade for GP2 is 100%.
24. Verify the grade for ‘All Grading Periods’ is 0%.
25. Sign in as the account admin. Uncheck the box on the grading period
set for ‘weighting’.
26. Sign in as the student and go to the /grades page.
27. Verify the grade for GP1 is 50%.
28. Verify the grade for GP2 is 100%.
29. Verify the grade for ‘All Grading Periods’ is 75%.
Change-Id: Iac23e92986f371b13de2d5e0524d6bed8a277bc4
Reviewed-on: https://gerrit.instructure.com/99040
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-04 03:59:14 +08:00
|
|
|
group_sums = compute_group_sums_for_user(user_id)
|
|
|
|
scores = compute_scores_for_user(user_id, group_sums)
|
2017-08-17 21:47:36 +08:00
|
|
|
update_changes_hash_for_user(user_id, scores, group_sums)
|
back-end grade calculator supports grading period weighting
closes CNVS-34105
test plan:
- Setup -
1. At the account-level, create a new grading period set that uses
weighted grading periods. Attach the default enrollment term to this
set.
2. Create a grading period (GP1) that runs from January 1, 2017 to June
30, 2017. Give it a weight of 75%.
3. Create a grading period (GP2) that runs from July 1, 2017 to
December 31, 2017. Give it a weight of 25%.
4. Create a course that belongs to the default enrollment term from
step 1. Enroll one student in the course. Make sure that student is
enrolled in at least one other course.
5. In the course settings, enable Multiple Grading Periods and enable
Display ‘All Grading Period’ Totals.
6. In the course, create an assignment (Assignment in GP1) that is
worth 10 points and due for everyone on March 15, 2017.
7. In the course, create an assignment (Assignment in GP2) that is
worth 10 points and due for everyone on September 15, 2017.
8. Go to the gradebook and give the student 5/10 on Assignment in GP1
and 10/10 on Assignment in GP2. Ignore the totals that show up in
the gradebook.
- Grade Verification -
1. Sign in as the student and go to the /grades page.
2. Verify the grade for GP1 is 50%.
3. Verify the grade for GP2 is 100%.
4. Verify the grade for ‘All Grading Periods’ is 62.5%.
5. Sign in as the account admin. Change the weight for GP1 to 20% and
change the weight for GP2 to 40%.
6. Sign in as the student and go to the /grades page.
7. Verify the grade for GP1 is 50%.
8. Verify the grade for GP2 is 100%.
9. Verify the grade for ‘All Grading Periods’ is 83.33%.
10. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 100%.
11. Sign in as the student and go to the /grades page.
12. Verify the grade for GP1 is 50%.
13. Verify the grade for GP2 is 100%.
14. Verify the grade for ‘All Grading Periods’ is 150%.
15. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 0%.
16. Sign in as the student and go to the /grades page.
17. Verify the grade for GP1 is 50%.
18. Verify the grade for GP2 is 100%.
19. Verify the grade for ‘All Grading Periods’ is 50%.
20. Sign in as the account admin. Change the weight for GP1 to 0% and
change the weight for GP2 to 0%.
21. Sign in as the student and go to the /grades page.
22. Verify the grade for GP1 is 50%.
23. Verify the grade for GP2 is 100%.
24. Verify the grade for ‘All Grading Periods’ is 0%.
25. Sign in as the account admin. Uncheck the box on the grading period
set for ‘weighting’.
26. Sign in as the student and go to the /grades page.
27. Verify the grade for GP1 is 50%.
28. Verify the grade for GP2 is 100%.
29. Verify the grade for ‘All Grading Periods’ is 75%.
Change-Id: Iac23e92986f371b13de2d5e0524d6bed8a277bc4
Reviewed-on: https://gerrit.instructure.com/99040
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-04 03:59:14 +08:00
|
|
|
{
|
|
|
|
current: scores[:current],
|
|
|
|
current_groups: group_sums[:current].index_by { |group| group[:id] },
|
|
|
|
final: scores[:final],
|
|
|
|
final_groups: group_sums[:final].index_by { |group| group[:id] }
|
|
|
|
}
|
2021-11-15 23:09:24 +08:00
|
|
|
end
|
back-end grade calculator supports grading period weighting
closes CNVS-34105
test plan:
- Setup -
1. At the account-level, create a new grading period set that uses
weighted grading periods. Attach the default enrollment term to this
set.
2. Create a grading period (GP1) that runs from January 1, 2017 to June
30, 2017. Give it a weight of 75%.
3. Create a grading period (GP2) that runs from July 1, 2017 to
December 31, 2017. Give it a weight of 25%.
4. Create a course that belongs to the default enrollment term from
step 1. Enroll one student in the course. Make sure that student is
enrolled in at least one other course.
5. In the course settings, enable Multiple Grading Periods and enable
Display ‘All Grading Period’ Totals.
6. In the course, create an assignment (Assignment in GP1) that is
worth 10 points and due for everyone on March 15, 2017.
7. In the course, create an assignment (Assignment in GP2) that is
worth 10 points and due for everyone on September 15, 2017.
8. Go to the gradebook and give the student 5/10 on Assignment in GP1
and 10/10 on Assignment in GP2. Ignore the totals that show up in
the gradebook.
- Grade Verification -
1. Sign in as the student and go to the /grades page.
2. Verify the grade for GP1 is 50%.
3. Verify the grade for GP2 is 100%.
4. Verify the grade for ‘All Grading Periods’ is 62.5%.
5. Sign in as the account admin. Change the weight for GP1 to 20% and
change the weight for GP2 to 40%.
6. Sign in as the student and go to the /grades page.
7. Verify the grade for GP1 is 50%.
8. Verify the grade for GP2 is 100%.
9. Verify the grade for ‘All Grading Periods’ is 83.33%.
10. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 100%.
11. Sign in as the student and go to the /grades page.
12. Verify the grade for GP1 is 50%.
13. Verify the grade for GP2 is 100%.
14. Verify the grade for ‘All Grading Periods’ is 150%.
15. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 0%.
16. Sign in as the student and go to the /grades page.
17. Verify the grade for GP1 is 50%.
18. Verify the grade for GP2 is 100%.
19. Verify the grade for ‘All Grading Periods’ is 50%.
20. Sign in as the account admin. Change the weight for GP1 to 0% and
change the weight for GP2 to 0%.
21. Sign in as the student and go to the /grades page.
22. Verify the grade for GP1 is 50%.
23. Verify the grade for GP2 is 100%.
24. Verify the grade for ‘All Grading Periods’ is 0%.
25. Sign in as the account admin. Uncheck the box on the grading period
set for ‘weighting’.
26. Sign in as the student and go to the /grades page.
27. Verify the grade for GP1 is 50%.
28. Verify the grade for GP2 is 100%.
29. Verify the grade for ‘All Grading Periods’ is 75%.
Change-Id: Iac23e92986f371b13de2d5e0524d6bed8a277bc4
Reviewed-on: https://gerrit.instructure.com/99040
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-04 03:59:14 +08:00
|
|
|
end
|
|
|
|
|
2017-04-19 12:03:23 +08:00
|
|
|
def assignment_visible_to_student?(assignment_id, user_id)
|
|
|
|
effective_due_dates.find_effective_due_date(user_id, assignment_id).key?(:due_at)
|
|
|
|
end
|
|
|
|
|
back-end grade calculator supports grading period weighting
closes CNVS-34105
test plan:
- Setup -
1. At the account-level, create a new grading period set that uses
weighted grading periods. Attach the default enrollment term to this
set.
2. Create a grading period (GP1) that runs from January 1, 2017 to June
30, 2017. Give it a weight of 75%.
3. Create a grading period (GP2) that runs from July 1, 2017 to
December 31, 2017. Give it a weight of 25%.
4. Create a course that belongs to the default enrollment term from
step 1. Enroll one student in the course. Make sure that student is
enrolled in at least one other course.
5. In the course settings, enable Multiple Grading Periods and enable
Display ‘All Grading Period’ Totals.
6. In the course, create an assignment (Assignment in GP1) that is
worth 10 points and due for everyone on March 15, 2017.
7. In the course, create an assignment (Assignment in GP2) that is
worth 10 points and due for everyone on September 15, 2017.
8. Go to the gradebook and give the student 5/10 on Assignment in GP1
and 10/10 on Assignment in GP2. Ignore the totals that show up in
the gradebook.
- Grade Verification -
1. Sign in as the student and go to the /grades page.
2. Verify the grade for GP1 is 50%.
3. Verify the grade for GP2 is 100%.
4. Verify the grade for ‘All Grading Periods’ is 62.5%.
5. Sign in as the account admin. Change the weight for GP1 to 20% and
change the weight for GP2 to 40%.
6. Sign in as the student and go to the /grades page.
7. Verify the grade for GP1 is 50%.
8. Verify the grade for GP2 is 100%.
9. Verify the grade for ‘All Grading Periods’ is 83.33%.
10. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 100%.
11. Sign in as the student and go to the /grades page.
12. Verify the grade for GP1 is 50%.
13. Verify the grade for GP2 is 100%.
14. Verify the grade for ‘All Grading Periods’ is 150%.
15. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 0%.
16. Sign in as the student and go to the /grades page.
17. Verify the grade for GP1 is 50%.
18. Verify the grade for GP2 is 100%.
19. Verify the grade for ‘All Grading Periods’ is 50%.
20. Sign in as the account admin. Change the weight for GP1 to 0% and
change the weight for GP2 to 0%.
21. Sign in as the student and go to the /grades page.
22. Verify the grade for GP1 is 50%.
23. Verify the grade for GP2 is 100%.
24. Verify the grade for ‘All Grading Periods’ is 0%.
25. Sign in as the account admin. Uncheck the box on the grading period
set for ‘weighting’.
26. Sign in as the student and go to the /grades page.
27. Verify the grade for GP1 is 50%.
28. Verify the grade for GP2 is 100%.
29. Verify the grade for ‘All Grading Periods’ is 75%.
Change-Id: Iac23e92986f371b13de2d5e0524d6bed8a277bc4
Reviewed-on: https://gerrit.instructure.com/99040
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-04 03:59:14 +08:00
|
|
|
def compute_group_sums_for_user(user_id)
|
|
|
|
user_submissions = submissions_by_user.fetch(user_id, []).select do |submission|
|
2017-04-19 12:03:23 +08:00
|
|
|
assignment_visible_to_student?(submission.assignment_id, user_id)
|
back-end grade calculator supports grading period weighting
closes CNVS-34105
test plan:
- Setup -
1. At the account-level, create a new grading period set that uses
weighted grading periods. Attach the default enrollment term to this
set.
2. Create a grading period (GP1) that runs from January 1, 2017 to June
30, 2017. Give it a weight of 75%.
3. Create a grading period (GP2) that runs from July 1, 2017 to
December 31, 2017. Give it a weight of 25%.
4. Create a course that belongs to the default enrollment term from
step 1. Enroll one student in the course. Make sure that student is
enrolled in at least one other course.
5. In the course settings, enable Multiple Grading Periods and enable
Display ‘All Grading Period’ Totals.
6. In the course, create an assignment (Assignment in GP1) that is
worth 10 points and due for everyone on March 15, 2017.
7. In the course, create an assignment (Assignment in GP2) that is
worth 10 points and due for everyone on September 15, 2017.
8. Go to the gradebook and give the student 5/10 on Assignment in GP1
and 10/10 on Assignment in GP2. Ignore the totals that show up in
the gradebook.
- Grade Verification -
1. Sign in as the student and go to the /grades page.
2. Verify the grade for GP1 is 50%.
3. Verify the grade for GP2 is 100%.
4. Verify the grade for ‘All Grading Periods’ is 62.5%.
5. Sign in as the account admin. Change the weight for GP1 to 20% and
change the weight for GP2 to 40%.
6. Sign in as the student and go to the /grades page.
7. Verify the grade for GP1 is 50%.
8. Verify the grade for GP2 is 100%.
9. Verify the grade for ‘All Grading Periods’ is 83.33%.
10. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 100%.
11. Sign in as the student and go to the /grades page.
12. Verify the grade for GP1 is 50%.
13. Verify the grade for GP2 is 100%.
14. Verify the grade for ‘All Grading Periods’ is 150%.
15. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 0%.
16. Sign in as the student and go to the /grades page.
17. Verify the grade for GP1 is 50%.
18. Verify the grade for GP2 is 100%.
19. Verify the grade for ‘All Grading Periods’ is 50%.
20. Sign in as the account admin. Change the weight for GP1 to 0% and
change the weight for GP2 to 0%.
21. Sign in as the student and go to the /grades page.
22. Verify the grade for GP1 is 50%.
23. Verify the grade for GP2 is 100%.
24. Verify the grade for ‘All Grading Periods’ is 0%.
25. Sign in as the account admin. Uncheck the box on the grading period
set for ‘weighting’.
26. Sign in as the student and go to the /grades page.
27. Verify the grade for GP1 is 50%.
28. Verify the grade for GP2 is 100%.
29. Verify the grade for ‘All Grading Periods’ is 75%.
Change-Id: Iac23e92986f371b13de2d5e0524d6bed8a277bc4
Reviewed-on: https://gerrit.instructure.com/99040
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-04 03:59:14 +08:00
|
|
|
end
|
2017-04-19 12:03:23 +08:00
|
|
|
|
back-end grade calculator supports grading period weighting
closes CNVS-34105
test plan:
- Setup -
1. At the account-level, create a new grading period set that uses
weighted grading periods. Attach the default enrollment term to this
set.
2. Create a grading period (GP1) that runs from January 1, 2017 to June
30, 2017. Give it a weight of 75%.
3. Create a grading period (GP2) that runs from July 1, 2017 to
December 31, 2017. Give it a weight of 25%.
4. Create a course that belongs to the default enrollment term from
step 1. Enroll one student in the course. Make sure that student is
enrolled in at least one other course.
5. In the course settings, enable Multiple Grading Periods and enable
Display ‘All Grading Period’ Totals.
6. In the course, create an assignment (Assignment in GP1) that is
worth 10 points and due for everyone on March 15, 2017.
7. In the course, create an assignment (Assignment in GP2) that is
worth 10 points and due for everyone on September 15, 2017.
8. Go to the gradebook and give the student 5/10 on Assignment in GP1
and 10/10 on Assignment in GP2. Ignore the totals that show up in
the gradebook.
- Grade Verification -
1. Sign in as the student and go to the /grades page.
2. Verify the grade for GP1 is 50%.
3. Verify the grade for GP2 is 100%.
4. Verify the grade for ‘All Grading Periods’ is 62.5%.
5. Sign in as the account admin. Change the weight for GP1 to 20% and
change the weight for GP2 to 40%.
6. Sign in as the student and go to the /grades page.
7. Verify the grade for GP1 is 50%.
8. Verify the grade for GP2 is 100%.
9. Verify the grade for ‘All Grading Periods’ is 83.33%.
10. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 100%.
11. Sign in as the student and go to the /grades page.
12. Verify the grade for GP1 is 50%.
13. Verify the grade for GP2 is 100%.
14. Verify the grade for ‘All Grading Periods’ is 150%.
15. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 0%.
16. Sign in as the student and go to the /grades page.
17. Verify the grade for GP1 is 50%.
18. Verify the grade for GP2 is 100%.
19. Verify the grade for ‘All Grading Periods’ is 50%.
20. Sign in as the account admin. Change the weight for GP1 to 0% and
change the weight for GP2 to 0%.
21. Sign in as the student and go to the /grades page.
22. Verify the grade for GP1 is 50%.
23. Verify the grade for GP2 is 100%.
24. Verify the grade for ‘All Grading Periods’ is 0%.
25. Sign in as the account admin. Uncheck the box on the grading period
set for ‘weighting’.
26. Sign in as the student and go to the /grades page.
27. Verify the grade for GP1 is 50%.
28. Verify the grade for GP2 is 100%.
29. Verify the grade for ‘All Grading Periods’ is 75%.
Change-Id: Iac23e92986f371b13de2d5e0524d6bed8a277bc4
Reviewed-on: https://gerrit.instructure.com/99040
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-04 03:59:14 +08:00
|
|
|
{
|
|
|
|
current: create_group_sums(user_submissions, user_id, ignore_ungraded: true),
|
|
|
|
final: create_group_sums(user_submissions, user_id, ignore_ungraded: false)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def compute_scores_for_user(user_id, group_sums)
|
|
|
|
scores = if compute_course_scores_from_weighted_grading_periods?
|
|
|
|
calculate_total_from_weighted_grading_periods(user_id)
|
|
|
|
else
|
|
|
|
{
|
|
|
|
current: calculate_total_from_group_scores(group_sums[:current]),
|
|
|
|
final: calculate_total_from_group_scores(group_sums[:final])
|
|
|
|
}
|
|
|
|
end
|
2018-03-06 02:24:06 +08:00
|
|
|
Rails.logger.debug "GRADES: calculated: #{scores.inspect}"
|
back-end grade calculator supports grading period weighting
closes CNVS-34105
test plan:
- Setup -
1. At the account-level, create a new grading period set that uses
weighted grading periods. Attach the default enrollment term to this
set.
2. Create a grading period (GP1) that runs from January 1, 2017 to June
30, 2017. Give it a weight of 75%.
3. Create a grading period (GP2) that runs from July 1, 2017 to
December 31, 2017. Give it a weight of 25%.
4. Create a course that belongs to the default enrollment term from
step 1. Enroll one student in the course. Make sure that student is
enrolled in at least one other course.
5. In the course settings, enable Multiple Grading Periods and enable
Display ‘All Grading Period’ Totals.
6. In the course, create an assignment (Assignment in GP1) that is
worth 10 points and due for everyone on March 15, 2017.
7. In the course, create an assignment (Assignment in GP2) that is
worth 10 points and due for everyone on September 15, 2017.
8. Go to the gradebook and give the student 5/10 on Assignment in GP1
and 10/10 on Assignment in GP2. Ignore the totals that show up in
the gradebook.
- Grade Verification -
1. Sign in as the student and go to the /grades page.
2. Verify the grade for GP1 is 50%.
3. Verify the grade for GP2 is 100%.
4. Verify the grade for ‘All Grading Periods’ is 62.5%.
5. Sign in as the account admin. Change the weight for GP1 to 20% and
change the weight for GP2 to 40%.
6. Sign in as the student and go to the /grades page.
7. Verify the grade for GP1 is 50%.
8. Verify the grade for GP2 is 100%.
9. Verify the grade for ‘All Grading Periods’ is 83.33%.
10. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 100%.
11. Sign in as the student and go to the /grades page.
12. Verify the grade for GP1 is 50%.
13. Verify the grade for GP2 is 100%.
14. Verify the grade for ‘All Grading Periods’ is 150%.
15. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 0%.
16. Sign in as the student and go to the /grades page.
17. Verify the grade for GP1 is 50%.
18. Verify the grade for GP2 is 100%.
19. Verify the grade for ‘All Grading Periods’ is 50%.
20. Sign in as the account admin. Change the weight for GP1 to 0% and
change the weight for GP2 to 0%.
21. Sign in as the student and go to the /grades page.
22. Verify the grade for GP1 is 50%.
23. Verify the grade for GP2 is 100%.
24. Verify the grade for ‘All Grading Periods’ is 0%.
25. Sign in as the account admin. Uncheck the box on the grading period
set for ‘weighting’.
26. Sign in as the student and go to the /grades page.
27. Verify the grade for GP1 is 50%.
28. Verify the grade for GP2 is 100%.
29. Verify the grade for ‘All Grading Periods’ is 75%.
Change-Id: Iac23e92986f371b13de2d5e0524d6bed8a277bc4
Reviewed-on: https://gerrit.instructure.com/99040
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-04 03:59:14 +08:00
|
|
|
scores
|
|
|
|
end
|
|
|
|
|
2017-08-17 21:47:36 +08:00
|
|
|
def update_changes_hash_for_user(user_id, scores, group_sums)
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
@current_updates[user_id] = scores[:current]
|
|
|
|
@final_updates[user_id] = scores[:final]
|
2017-08-17 21:47:36 +08:00
|
|
|
@current_groups[user_id] = group_sums[:current]
|
|
|
|
@final_groups[user_id] = group_sums[:final]
|
2017-11-15 07:47:01 +08:00
|
|
|
@dropped_updates[user_id] = {
|
|
|
|
current: { dropped: scores[:current][:dropped] },
|
|
|
|
final: { dropped: scores[:final][:dropped] }
|
|
|
|
}
|
back-end grade calculator supports grading period weighting
closes CNVS-34105
test plan:
- Setup -
1. At the account-level, create a new grading period set that uses
weighted grading periods. Attach the default enrollment term to this
set.
2. Create a grading period (GP1) that runs from January 1, 2017 to June
30, 2017. Give it a weight of 75%.
3. Create a grading period (GP2) that runs from July 1, 2017 to
December 31, 2017. Give it a weight of 25%.
4. Create a course that belongs to the default enrollment term from
step 1. Enroll one student in the course. Make sure that student is
enrolled in at least one other course.
5. In the course settings, enable Multiple Grading Periods and enable
Display ‘All Grading Period’ Totals.
6. In the course, create an assignment (Assignment in GP1) that is
worth 10 points and due for everyone on March 15, 2017.
7. In the course, create an assignment (Assignment in GP2) that is
worth 10 points and due for everyone on September 15, 2017.
8. Go to the gradebook and give the student 5/10 on Assignment in GP1
and 10/10 on Assignment in GP2. Ignore the totals that show up in
the gradebook.
- Grade Verification -
1. Sign in as the student and go to the /grades page.
2. Verify the grade for GP1 is 50%.
3. Verify the grade for GP2 is 100%.
4. Verify the grade for ‘All Grading Periods’ is 62.5%.
5. Sign in as the account admin. Change the weight for GP1 to 20% and
change the weight for GP2 to 40%.
6. Sign in as the student and go to the /grades page.
7. Verify the grade for GP1 is 50%.
8. Verify the grade for GP2 is 100%.
9. Verify the grade for ‘All Grading Periods’ is 83.33%.
10. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 100%.
11. Sign in as the student and go to the /grades page.
12. Verify the grade for GP1 is 50%.
13. Verify the grade for GP2 is 100%.
14. Verify the grade for ‘All Grading Periods’ is 150%.
15. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 0%.
16. Sign in as the student and go to the /grades page.
17. Verify the grade for GP1 is 50%.
18. Verify the grade for GP2 is 100%.
19. Verify the grade for ‘All Grading Periods’ is 50%.
20. Sign in as the account admin. Change the weight for GP1 to 0% and
change the weight for GP2 to 0%.
21. Sign in as the student and go to the /grades page.
22. Verify the grade for GP1 is 50%.
23. Verify the grade for GP2 is 100%.
24. Verify the grade for ‘All Grading Periods’ is 0%.
25. Sign in as the account admin. Uncheck the box on the grading period
set for ‘weighting’.
26. Sign in as the student and go to the /grades page.
27. Verify the grade for GP1 is 50%.
28. Verify the grade for GP2 is 100%.
29. Verify the grade for ‘All Grading Periods’ is 75%.
Change-Id: Iac23e92986f371b13de2d5e0524d6bed8a277bc4
Reviewed-on: https://gerrit.instructure.com/99040
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-04 03:59:14 +08:00
|
|
|
end
|
|
|
|
|
2017-11-15 07:47:01 +08:00
|
|
|
def grading_period_scores(enrollment_id)
|
|
|
|
@grading_period_scores ||= Score.active.where(
|
|
|
|
enrollment: enrollments.map(&:id),
|
|
|
|
grading_period: grading_periods_for_course.map(&:id)
|
|
|
|
).group_by(&:enrollment_id)
|
|
|
|
@grading_period_scores[enrollment_id] || []
|
2017-09-27 06:06:09 +08:00
|
|
|
end
|
|
|
|
|
back-end grade calculator supports grading period weighting
closes CNVS-34105
test plan:
- Setup -
1. At the account-level, create a new grading period set that uses
weighted grading periods. Attach the default enrollment term to this
set.
2. Create a grading period (GP1) that runs from January 1, 2017 to June
30, 2017. Give it a weight of 75%.
3. Create a grading period (GP2) that runs from July 1, 2017 to
December 31, 2017. Give it a weight of 25%.
4. Create a course that belongs to the default enrollment term from
step 1. Enroll one student in the course. Make sure that student is
enrolled in at least one other course.
5. In the course settings, enable Multiple Grading Periods and enable
Display ‘All Grading Period’ Totals.
6. In the course, create an assignment (Assignment in GP1) that is
worth 10 points and due for everyone on March 15, 2017.
7. In the course, create an assignment (Assignment in GP2) that is
worth 10 points and due for everyone on September 15, 2017.
8. Go to the gradebook and give the student 5/10 on Assignment in GP1
and 10/10 on Assignment in GP2. Ignore the totals that show up in
the gradebook.
- Grade Verification -
1. Sign in as the student and go to the /grades page.
2. Verify the grade for GP1 is 50%.
3. Verify the grade for GP2 is 100%.
4. Verify the grade for ‘All Grading Periods’ is 62.5%.
5. Sign in as the account admin. Change the weight for GP1 to 20% and
change the weight for GP2 to 40%.
6. Sign in as the student and go to the /grades page.
7. Verify the grade for GP1 is 50%.
8. Verify the grade for GP2 is 100%.
9. Verify the grade for ‘All Grading Periods’ is 83.33%.
10. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 100%.
11. Sign in as the student and go to the /grades page.
12. Verify the grade for GP1 is 50%.
13. Verify the grade for GP2 is 100%.
14. Verify the grade for ‘All Grading Periods’ is 150%.
15. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 0%.
16. Sign in as the student and go to the /grades page.
17. Verify the grade for GP1 is 50%.
18. Verify the grade for GP2 is 100%.
19. Verify the grade for ‘All Grading Periods’ is 50%.
20. Sign in as the account admin. Change the weight for GP1 to 0% and
change the weight for GP2 to 0%.
21. Sign in as the student and go to the /grades page.
22. Verify the grade for GP1 is 50%.
23. Verify the grade for GP2 is 100%.
24. Verify the grade for ‘All Grading Periods’ is 0%.
25. Sign in as the account admin. Uncheck the box on the grading period
set for ‘weighting’.
26. Sign in as the student and go to the /grades page.
27. Verify the grade for GP1 is 50%.
28. Verify the grade for GP2 is 100%.
29. Verify the grade for ‘All Grading Periods’ is 75%.
Change-Id: Iac23e92986f371b13de2d5e0524d6bed8a277bc4
Reviewed-on: https://gerrit.instructure.com/99040
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-04 03:59:14 +08:00
|
|
|
def calculate_total_from_weighted_grading_periods(user_id)
|
|
|
|
enrollment = enrollments_by_user[user_id].first
|
2017-11-15 07:47:01 +08:00
|
|
|
grading_period_scores = grading_period_scores(enrollment.id)
|
back-end grade calculator supports grading period weighting
closes CNVS-34105
test plan:
- Setup -
1. At the account-level, create a new grading period set that uses
weighted grading periods. Attach the default enrollment term to this
set.
2. Create a grading period (GP1) that runs from January 1, 2017 to June
30, 2017. Give it a weight of 75%.
3. Create a grading period (GP2) that runs from July 1, 2017 to
December 31, 2017. Give it a weight of 25%.
4. Create a course that belongs to the default enrollment term from
step 1. Enroll one student in the course. Make sure that student is
enrolled in at least one other course.
5. In the course settings, enable Multiple Grading Periods and enable
Display ‘All Grading Period’ Totals.
6. In the course, create an assignment (Assignment in GP1) that is
worth 10 points and due for everyone on March 15, 2017.
7. In the course, create an assignment (Assignment in GP2) that is
worth 10 points and due for everyone on September 15, 2017.
8. Go to the gradebook and give the student 5/10 on Assignment in GP1
and 10/10 on Assignment in GP2. Ignore the totals that show up in
the gradebook.
- Grade Verification -
1. Sign in as the student and go to the /grades page.
2. Verify the grade for GP1 is 50%.
3. Verify the grade for GP2 is 100%.
4. Verify the grade for ‘All Grading Periods’ is 62.5%.
5. Sign in as the account admin. Change the weight for GP1 to 20% and
change the weight for GP2 to 40%.
6. Sign in as the student and go to the /grades page.
7. Verify the grade for GP1 is 50%.
8. Verify the grade for GP2 is 100%.
9. Verify the grade for ‘All Grading Periods’ is 83.33%.
10. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 100%.
11. Sign in as the student and go to the /grades page.
12. Verify the grade for GP1 is 50%.
13. Verify the grade for GP2 is 100%.
14. Verify the grade for ‘All Grading Periods’ is 150%.
15. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 0%.
16. Sign in as the student and go to the /grades page.
17. Verify the grade for GP1 is 50%.
18. Verify the grade for GP2 is 100%.
19. Verify the grade for ‘All Grading Periods’ is 50%.
20. Sign in as the account admin. Change the weight for GP1 to 0% and
change the weight for GP2 to 0%.
21. Sign in as the student and go to the /grades page.
22. Verify the grade for GP1 is 50%.
23. Verify the grade for GP2 is 100%.
24. Verify the grade for ‘All Grading Periods’ is 0%.
25. Sign in as the account admin. Uncheck the box on the grading period
set for ‘weighting’.
26. Sign in as the student and go to the /grades page.
27. Verify the grade for GP1 is 50%.
28. Verify the grade for GP2 is 100%.
29. Verify the grade for ‘All Grading Periods’ is 75%.
Change-Id: Iac23e92986f371b13de2d5e0524d6bed8a277bc4
Reviewed-on: https://gerrit.instructure.com/99040
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-04 03:59:14 +08:00
|
|
|
scores = apply_grading_period_weights_to_scores(grading_period_scores)
|
|
|
|
scale_and_round_scores(scores, grading_period_scores)
|
|
|
|
end
|
|
|
|
|
|
|
|
def apply_grading_period_weights_to_scores(grading_period_scores)
|
|
|
|
grading_period_scores.each_with_object(
|
|
|
|
{ current: { full_weight: 0.0, grade: 0.0 }, final: { full_weight: 0.0, grade: 0.0 } }
|
|
|
|
) do |score, scores|
|
|
|
|
weight = grading_period_weights[score.grading_period_id] || 0.0
|
|
|
|
scores[:final][:full_weight] += weight
|
|
|
|
scores[:current][:full_weight] += weight if score.current_score
|
|
|
|
scores[:current][:grade] += (score.current_score || 0.0) * (weight / 100.0)
|
|
|
|
scores[:final][:grade] += (score.final_score || 0.0) * (weight / 100.0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def scale_and_round_scores(scores, grading_period_scores)
|
|
|
|
[:current, :final].each_with_object({ current: {}, final: {} }) do |score_type, adjusted_scores|
|
|
|
|
score = scores[score_type][:grade]
|
|
|
|
full_weight = scores[score_type][:full_weight]
|
|
|
|
score = scale_score_up(score, full_weight) if full_weight < 100
|
2021-11-06 06:02:13 +08:00
|
|
|
if score.abs < Float::EPSILON && score_type == :current && grading_period_scores.none?(&:current_score)
|
back-end grade calculator supports grading period weighting
closes CNVS-34105
test plan:
- Setup -
1. At the account-level, create a new grading period set that uses
weighted grading periods. Attach the default enrollment term to this
set.
2. Create a grading period (GP1) that runs from January 1, 2017 to June
30, 2017. Give it a weight of 75%.
3. Create a grading period (GP2) that runs from July 1, 2017 to
December 31, 2017. Give it a weight of 25%.
4. Create a course that belongs to the default enrollment term from
step 1. Enroll one student in the course. Make sure that student is
enrolled in at least one other course.
5. In the course settings, enable Multiple Grading Periods and enable
Display ‘All Grading Period’ Totals.
6. In the course, create an assignment (Assignment in GP1) that is
worth 10 points and due for everyone on March 15, 2017.
7. In the course, create an assignment (Assignment in GP2) that is
worth 10 points and due for everyone on September 15, 2017.
8. Go to the gradebook and give the student 5/10 on Assignment in GP1
and 10/10 on Assignment in GP2. Ignore the totals that show up in
the gradebook.
- Grade Verification -
1. Sign in as the student and go to the /grades page.
2. Verify the grade for GP1 is 50%.
3. Verify the grade for GP2 is 100%.
4. Verify the grade for ‘All Grading Periods’ is 62.5%.
5. Sign in as the account admin. Change the weight for GP1 to 20% and
change the weight for GP2 to 40%.
6. Sign in as the student and go to the /grades page.
7. Verify the grade for GP1 is 50%.
8. Verify the grade for GP2 is 100%.
9. Verify the grade for ‘All Grading Periods’ is 83.33%.
10. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 100%.
11. Sign in as the student and go to the /grades page.
12. Verify the grade for GP1 is 50%.
13. Verify the grade for GP2 is 100%.
14. Verify the grade for ‘All Grading Periods’ is 150%.
15. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 0%.
16. Sign in as the student and go to the /grades page.
17. Verify the grade for GP1 is 50%.
18. Verify the grade for GP2 is 100%.
19. Verify the grade for ‘All Grading Periods’ is 50%.
20. Sign in as the account admin. Change the weight for GP1 to 0% and
change the weight for GP2 to 0%.
21. Sign in as the student and go to the /grades page.
22. Verify the grade for GP1 is 50%.
23. Verify the grade for GP2 is 100%.
24. Verify the grade for ‘All Grading Periods’ is 0%.
25. Sign in as the account admin. Uncheck the box on the grading period
set for ‘weighting’.
26. Sign in as the student and go to the /grades page.
27. Verify the grade for GP1 is 50%.
28. Verify the grade for GP2 is 100%.
29. Verify the grade for ‘All Grading Periods’ is 75%.
Change-Id: Iac23e92986f371b13de2d5e0524d6bed8a277bc4
Reviewed-on: https://gerrit.instructure.com/99040
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-04 03:59:14 +08:00
|
|
|
score = nil
|
|
|
|
end
|
|
|
|
adjusted_scores[score_type][:grade] = score ? score.round(2) : score
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
adjusted_scores[score_type][:total] = adjusted_scores[score_type][:grade]
|
back-end grade calculator supports grading period weighting
closes CNVS-34105
test plan:
- Setup -
1. At the account-level, create a new grading period set that uses
weighted grading periods. Attach the default enrollment term to this
set.
2. Create a grading period (GP1) that runs from January 1, 2017 to June
30, 2017. Give it a weight of 75%.
3. Create a grading period (GP2) that runs from July 1, 2017 to
December 31, 2017. Give it a weight of 25%.
4. Create a course that belongs to the default enrollment term from
step 1. Enroll one student in the course. Make sure that student is
enrolled in at least one other course.
5. In the course settings, enable Multiple Grading Periods and enable
Display ‘All Grading Period’ Totals.
6. In the course, create an assignment (Assignment in GP1) that is
worth 10 points and due for everyone on March 15, 2017.
7. In the course, create an assignment (Assignment in GP2) that is
worth 10 points and due for everyone on September 15, 2017.
8. Go to the gradebook and give the student 5/10 on Assignment in GP1
and 10/10 on Assignment in GP2. Ignore the totals that show up in
the gradebook.
- Grade Verification -
1. Sign in as the student and go to the /grades page.
2. Verify the grade for GP1 is 50%.
3. Verify the grade for GP2 is 100%.
4. Verify the grade for ‘All Grading Periods’ is 62.5%.
5. Sign in as the account admin. Change the weight for GP1 to 20% and
change the weight for GP2 to 40%.
6. Sign in as the student and go to the /grades page.
7. Verify the grade for GP1 is 50%.
8. Verify the grade for GP2 is 100%.
9. Verify the grade for ‘All Grading Periods’ is 83.33%.
10. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 100%.
11. Sign in as the student and go to the /grades page.
12. Verify the grade for GP1 is 50%.
13. Verify the grade for GP2 is 100%.
14. Verify the grade for ‘All Grading Periods’ is 150%.
15. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 0%.
16. Sign in as the student and go to the /grades page.
17. Verify the grade for GP1 is 50%.
18. Verify the grade for GP2 is 100%.
19. Verify the grade for ‘All Grading Periods’ is 50%.
20. Sign in as the account admin. Change the weight for GP1 to 0% and
change the weight for GP2 to 0%.
21. Sign in as the student and go to the /grades page.
22. Verify the grade for GP1 is 50%.
23. Verify the grade for GP2 is 100%.
24. Verify the grade for ‘All Grading Periods’ is 0%.
25. Sign in as the account admin. Uncheck the box on the grading period
set for ‘weighting’.
26. Sign in as the student and go to the /grades page.
27. Verify the grade for GP1 is 50%.
28. Verify the grade for GP2 is 100%.
29. Verify the grade for ‘All Grading Periods’ is 75%.
Change-Id: Iac23e92986f371b13de2d5e0524d6bed8a277bc4
Reviewed-on: https://gerrit.instructure.com/99040
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-04 03:59:14 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def scale_score_up(score, weight)
|
|
|
|
return 0.0 if weight.zero?
|
2021-09-23 00:25:11 +08:00
|
|
|
|
back-end grade calculator supports grading period weighting
closes CNVS-34105
test plan:
- Setup -
1. At the account-level, create a new grading period set that uses
weighted grading periods. Attach the default enrollment term to this
set.
2. Create a grading period (GP1) that runs from January 1, 2017 to June
30, 2017. Give it a weight of 75%.
3. Create a grading period (GP2) that runs from July 1, 2017 to
December 31, 2017. Give it a weight of 25%.
4. Create a course that belongs to the default enrollment term from
step 1. Enroll one student in the course. Make sure that student is
enrolled in at least one other course.
5. In the course settings, enable Multiple Grading Periods and enable
Display ‘All Grading Period’ Totals.
6. In the course, create an assignment (Assignment in GP1) that is
worth 10 points and due for everyone on March 15, 2017.
7. In the course, create an assignment (Assignment in GP2) that is
worth 10 points and due for everyone on September 15, 2017.
8. Go to the gradebook and give the student 5/10 on Assignment in GP1
and 10/10 on Assignment in GP2. Ignore the totals that show up in
the gradebook.
- Grade Verification -
1. Sign in as the student and go to the /grades page.
2. Verify the grade for GP1 is 50%.
3. Verify the grade for GP2 is 100%.
4. Verify the grade for ‘All Grading Periods’ is 62.5%.
5. Sign in as the account admin. Change the weight for GP1 to 20% and
change the weight for GP2 to 40%.
6. Sign in as the student and go to the /grades page.
7. Verify the grade for GP1 is 50%.
8. Verify the grade for GP2 is 100%.
9. Verify the grade for ‘All Grading Periods’ is 83.33%.
10. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 100%.
11. Sign in as the student and go to the /grades page.
12. Verify the grade for GP1 is 50%.
13. Verify the grade for GP2 is 100%.
14. Verify the grade for ‘All Grading Periods’ is 150%.
15. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 0%.
16. Sign in as the student and go to the /grades page.
17. Verify the grade for GP1 is 50%.
18. Verify the grade for GP2 is 100%.
19. Verify the grade for ‘All Grading Periods’ is 50%.
20. Sign in as the account admin. Change the weight for GP1 to 0% and
change the weight for GP2 to 0%.
21. Sign in as the student and go to the /grades page.
22. Verify the grade for GP1 is 50%.
23. Verify the grade for GP2 is 100%.
24. Verify the grade for ‘All Grading Periods’ is 0%.
25. Sign in as the account admin. Uncheck the box on the grading period
set for ‘weighting’.
26. Sign in as the student and go to the /grades page.
27. Verify the grade for GP1 is 50%.
28. Verify the grade for GP2 is 100%.
29. Verify the grade for ‘All Grading Periods’ is 75%.
Change-Id: Iac23e92986f371b13de2d5e0524d6bed8a277bc4
Reviewed-on: https://gerrit.instructure.com/99040
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-04 03:59:14 +08:00
|
|
|
(score * 100.0) / weight
|
|
|
|
end
|
|
|
|
|
|
|
|
def compute_course_scores_from_weighted_grading_periods?
|
|
|
|
return @compute_from_weighted_periods if @compute_from_weighted_periods.present?
|
|
|
|
|
|
|
|
@compute_from_weighted_periods = if @grading_period || grading_periods_for_course.empty?
|
2021-11-11 23:30:33 +08:00
|
|
|
false
|
|
|
|
else
|
back-end grade calculator supports grading period weighting
closes CNVS-34105
test plan:
- Setup -
1. At the account-level, create a new grading period set that uses
weighted grading periods. Attach the default enrollment term to this
set.
2. Create a grading period (GP1) that runs from January 1, 2017 to June
30, 2017. Give it a weight of 75%.
3. Create a grading period (GP2) that runs from July 1, 2017 to
December 31, 2017. Give it a weight of 25%.
4. Create a course that belongs to the default enrollment term from
step 1. Enroll one student in the course. Make sure that student is
enrolled in at least one other course.
5. In the course settings, enable Multiple Grading Periods and enable
Display ‘All Grading Period’ Totals.
6. In the course, create an assignment (Assignment in GP1) that is
worth 10 points and due for everyone on March 15, 2017.
7. In the course, create an assignment (Assignment in GP2) that is
worth 10 points and due for everyone on September 15, 2017.
8. Go to the gradebook and give the student 5/10 on Assignment in GP1
and 10/10 on Assignment in GP2. Ignore the totals that show up in
the gradebook.
- Grade Verification -
1. Sign in as the student and go to the /grades page.
2. Verify the grade for GP1 is 50%.
3. Verify the grade for GP2 is 100%.
4. Verify the grade for ‘All Grading Periods’ is 62.5%.
5. Sign in as the account admin. Change the weight for GP1 to 20% and
change the weight for GP2 to 40%.
6. Sign in as the student and go to the /grades page.
7. Verify the grade for GP1 is 50%.
8. Verify the grade for GP2 is 100%.
9. Verify the grade for ‘All Grading Periods’ is 83.33%.
10. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 100%.
11. Sign in as the student and go to the /grades page.
12. Verify the grade for GP1 is 50%.
13. Verify the grade for GP2 is 100%.
14. Verify the grade for ‘All Grading Periods’ is 150%.
15. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 0%.
16. Sign in as the student and go to the /grades page.
17. Verify the grade for GP1 is 50%.
18. Verify the grade for GP2 is 100%.
19. Verify the grade for ‘All Grading Periods’ is 50%.
20. Sign in as the account admin. Change the weight for GP1 to 0% and
change the weight for GP2 to 0%.
21. Sign in as the student and go to the /grades page.
22. Verify the grade for GP1 is 50%.
23. Verify the grade for GP2 is 100%.
24. Verify the grade for ‘All Grading Periods’ is 0%.
25. Sign in as the account admin. Uncheck the box on the grading period
set for ‘weighting’.
26. Sign in as the student and go to the /grades page.
27. Verify the grade for GP1 is 50%.
28. Verify the grade for GP2 is 100%.
29. Verify the grade for ‘All Grading Periods’ is 75%.
Change-Id: Iac23e92986f371b13de2d5e0524d6bed8a277bc4
Reviewed-on: https://gerrit.instructure.com/99040
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-04 03:59:14 +08:00
|
|
|
grading_periods_for_course.first.grading_period_group.weighted?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def grading_periods_for_course
|
|
|
|
@periods ||= GradingPeriod.for(@course)
|
|
|
|
end
|
|
|
|
|
|
|
|
def grading_period_weights
|
|
|
|
@grading_period_weights ||= grading_periods_for_course.each_with_object({}) do |period, weights|
|
|
|
|
weights[period.id] = period.weight
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def submissions_by_user
|
2017-09-27 06:06:09 +08:00
|
|
|
@submissions_by_user ||= submissions.group_by { |s| Shard.relative_id_for(s.user_id, Shard.current, @course.shard) }
|
|
|
|
end
|
|
|
|
|
2020-10-13 05:32:34 +08:00
|
|
|
def compute_branch(**opts)
|
2017-09-27 06:06:09 +08:00
|
|
|
opts = opts.reverse_merge(
|
|
|
|
groups: @groups,
|
|
|
|
grading_period: @grading_period,
|
|
|
|
update_all_grading_period_scores: false,
|
|
|
|
update_course_score: false,
|
|
|
|
assignments: @assignments,
|
2019-11-27 07:31:32 +08:00
|
|
|
emit_live_event: @emit_live_event,
|
2017-09-27 06:06:09 +08:00
|
|
|
ignore_muted: @ignore_muted,
|
2020-11-04 03:43:24 +08:00
|
|
|
ignore_unposted_anonymous: @ignore_unposted_anonymous,
|
2017-09-27 06:06:09 +08:00
|
|
|
periods: grading_periods_for_course,
|
|
|
|
effective_due_dates: effective_due_dates,
|
|
|
|
enrollments: enrollments,
|
2017-12-12 06:29:35 +08:00
|
|
|
submissions: submissions,
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
only_update_course_gp_metadata: @only_update_course_gp_metadata,
|
|
|
|
only_update_points: @only_update_points
|
2017-09-27 06:06:09 +08:00
|
|
|
)
|
2020-10-13 05:32:34 +08:00
|
|
|
GradeCalculator.new(@user_ids, @course, **opts).compute_and_save_scores
|
2017-09-27 06:06:09 +08:00
|
|
|
end
|
|
|
|
|
2019-05-04 02:29:33 +08:00
|
|
|
def calculate_hidden_scores
|
|
|
|
# re-run this calculator, except include muted assignments/unposted submissions
|
2019-11-27 07:31:32 +08:00
|
|
|
compute_branch(ignore_muted: false, emit_live_event: false)
|
back-end grade calculator supports grading period weighting
closes CNVS-34105
test plan:
- Setup -
1. At the account-level, create a new grading period set that uses
weighted grading periods. Attach the default enrollment term to this
set.
2. Create a grading period (GP1) that runs from January 1, 2017 to June
30, 2017. Give it a weight of 75%.
3. Create a grading period (GP2) that runs from July 1, 2017 to
December 31, 2017. Give it a weight of 25%.
4. Create a course that belongs to the default enrollment term from
step 1. Enroll one student in the course. Make sure that student is
enrolled in at least one other course.
5. In the course settings, enable Multiple Grading Periods and enable
Display ‘All Grading Period’ Totals.
6. In the course, create an assignment (Assignment in GP1) that is
worth 10 points and due for everyone on March 15, 2017.
7. In the course, create an assignment (Assignment in GP2) that is
worth 10 points and due for everyone on September 15, 2017.
8. Go to the gradebook and give the student 5/10 on Assignment in GP1
and 10/10 on Assignment in GP2. Ignore the totals that show up in
the gradebook.
- Grade Verification -
1. Sign in as the student and go to the /grades page.
2. Verify the grade for GP1 is 50%.
3. Verify the grade for GP2 is 100%.
4. Verify the grade for ‘All Grading Periods’ is 62.5%.
5. Sign in as the account admin. Change the weight for GP1 to 20% and
change the weight for GP2 to 40%.
6. Sign in as the student and go to the /grades page.
7. Verify the grade for GP1 is 50%.
8. Verify the grade for GP2 is 100%.
9. Verify the grade for ‘All Grading Periods’ is 83.33%.
10. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 100%.
11. Sign in as the student and go to the /grades page.
12. Verify the grade for GP1 is 50%.
13. Verify the grade for GP2 is 100%.
14. Verify the grade for ‘All Grading Periods’ is 150%.
15. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 0%.
16. Sign in as the student and go to the /grades page.
17. Verify the grade for GP1 is 50%.
18. Verify the grade for GP2 is 100%.
19. Verify the grade for ‘All Grading Periods’ is 50%.
20. Sign in as the account admin. Change the weight for GP1 to 0% and
change the weight for GP2 to 0%.
21. Sign in as the student and go to the /grades page.
22. Verify the grade for GP1 is 50%.
23. Verify the grade for GP2 is 100%.
24. Verify the grade for ‘All Grading Periods’ is 0%.
25. Sign in as the account admin. Uncheck the box on the grading period
set for ‘weighting’.
26. Sign in as the student and go to the /grades page.
27. Verify the grade for GP1 is 50%.
28. Verify the grade for GP2 is 100%.
29. Verify the grade for ‘All Grading Periods’ is 75%.
Change-Id: Iac23e92986f371b13de2d5e0524d6bed8a277bc4
Reviewed-on: https://gerrit.instructure.com/99040
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-04 03:59:14 +08:00
|
|
|
end
|
|
|
|
|
update grading period scores when student is graded
When a student is graded, the score for their grading period will now
be updated in addition to their total course score. Previously, when a
student was graded, their grading period score was not updated.
closes CNVS-26709
test plan:
1) In a course with multiple grading periods enabled and grading
periods set up, grade students for assignments that fall in grading
periods and make sure the scores get updated for the grading period
and for the course total.
* To make sure the scores get updated for the grading period, open a
rails console and find the grading period scores (we'll assume the
student's enrollment ID is 5, and the ID of the grading period
that the assignment falls in is 8).
$ Enrollment.find(5).scores.where(grading_period_id: 8)
Then, give a different grade to the student for the assignment
that falls in the grading period and run the command above again.
You should see that the current_score and final_score have
changed.
* To make sure the scores get updated for the course total, open a
rails console and find the course total scores (we'll assume the
student's enrollment ID is 5).
$ Enrollment.find(5).scores.where(grading_period_id: nil)
Then, give a different grade to the student for the assignment
that falls in the grading period and run the command above again.
You should see that the current_score and final_score have
changed.
Edge case: make sure that grading period scores continue to get updated
even if MGP is turned off. To verify this, turn off MGP in a course
that originally had MGP turned on. Then, grade students in assignments
that fell in a grading period when MGP was enabled. After grading, the
grading period scores should be updated.
Change-Id: I29e4e22a0b73d1062a93c6ad420d876c2f5d040a
Reviewed-on: https://gerrit.instructure.com/98603
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2016-12-30 05:05:07 +08:00
|
|
|
def calculate_grading_period_scores
|
back-end grade calculator supports grading period weighting
closes CNVS-34105
test plan:
- Setup -
1. At the account-level, create a new grading period set that uses
weighted grading periods. Attach the default enrollment term to this
set.
2. Create a grading period (GP1) that runs from January 1, 2017 to June
30, 2017. Give it a weight of 75%.
3. Create a grading period (GP2) that runs from July 1, 2017 to
December 31, 2017. Give it a weight of 25%.
4. Create a course that belongs to the default enrollment term from
step 1. Enroll one student in the course. Make sure that student is
enrolled in at least one other course.
5. In the course settings, enable Multiple Grading Periods and enable
Display ‘All Grading Period’ Totals.
6. In the course, create an assignment (Assignment in GP1) that is
worth 10 points and due for everyone on March 15, 2017.
7. In the course, create an assignment (Assignment in GP2) that is
worth 10 points and due for everyone on September 15, 2017.
8. Go to the gradebook and give the student 5/10 on Assignment in GP1
and 10/10 on Assignment in GP2. Ignore the totals that show up in
the gradebook.
- Grade Verification -
1. Sign in as the student and go to the /grades page.
2. Verify the grade for GP1 is 50%.
3. Verify the grade for GP2 is 100%.
4. Verify the grade for ‘All Grading Periods’ is 62.5%.
5. Sign in as the account admin. Change the weight for GP1 to 20% and
change the weight for GP2 to 40%.
6. Sign in as the student and go to the /grades page.
7. Verify the grade for GP1 is 50%.
8. Verify the grade for GP2 is 100%.
9. Verify the grade for ‘All Grading Periods’ is 83.33%.
10. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 100%.
11. Sign in as the student and go to the /grades page.
12. Verify the grade for GP1 is 50%.
13. Verify the grade for GP2 is 100%.
14. Verify the grade for ‘All Grading Periods’ is 150%.
15. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 0%.
16. Sign in as the student and go to the /grades page.
17. Verify the grade for GP1 is 50%.
18. Verify the grade for GP2 is 100%.
19. Verify the grade for ‘All Grading Periods’ is 50%.
20. Sign in as the account admin. Change the weight for GP1 to 0% and
change the weight for GP2 to 0%.
21. Sign in as the student and go to the /grades page.
22. Verify the grade for GP1 is 50%.
23. Verify the grade for GP2 is 100%.
24. Verify the grade for ‘All Grading Periods’ is 0%.
25. Sign in as the account admin. Uncheck the box on the grading period
set for ‘weighting’.
26. Sign in as the student and go to the /grades page.
27. Verify the grade for GP1 is 50%.
28. Verify the grade for GP2 is 100%.
29. Verify the grade for ‘All Grading Periods’ is 75%.
Change-Id: Iac23e92986f371b13de2d5e0524d6bed8a277bc4
Reviewed-on: https://gerrit.instructure.com/99040
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-04 03:59:14 +08:00
|
|
|
grading_periods_for_course.each do |grading_period|
|
2017-09-27 06:06:09 +08:00
|
|
|
# update this grading period score
|
|
|
|
compute_branch(grading_period: grading_period)
|
update grading period scores when student is graded
When a student is graded, the score for their grading period will now
be updated in addition to their total course score. Previously, when a
student was graded, their grading period score was not updated.
closes CNVS-26709
test plan:
1) In a course with multiple grading periods enabled and grading
periods set up, grade students for assignments that fall in grading
periods and make sure the scores get updated for the grading period
and for the course total.
* To make sure the scores get updated for the grading period, open a
rails console and find the grading period scores (we'll assume the
student's enrollment ID is 5, and the ID of the grading period
that the assignment falls in is 8).
$ Enrollment.find(5).scores.where(grading_period_id: 8)
Then, give a different grade to the student for the assignment
that falls in the grading period and run the command above again.
You should see that the current_score and final_score have
changed.
* To make sure the scores get updated for the course total, open a
rails console and find the course total scores (we'll assume the
student's enrollment ID is 5).
$ Enrollment.find(5).scores.where(grading_period_id: nil)
Then, give a different grade to the student for the assignment
that falls in the grading period and run the command above again.
You should see that the current_score and final_score have
changed.
Edge case: make sure that grading period scores continue to get updated
even if MGP is turned off. To verify this, turn off MGP in a course
that originally had MGP turned on. Then, grade students in assignments
that fell in a grading period when MGP was enabled. After grading, the
grading period scores should be updated.
Change-Id: I29e4e22a0b73d1062a93c6ad420d876c2f5d040a
Reviewed-on: https://gerrit.instructure.com/98603
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2016-12-30 05:05:07 +08:00
|
|
|
end
|
2017-03-07 06:57:02 +08:00
|
|
|
|
|
|
|
# delete any grading period scores that are no longer relevant
|
2017-04-05 01:17:29 +08:00
|
|
|
grading_period_ids = grading_periods_for_course.empty? ? nil : grading_periods_for_course.map(&:id)
|
|
|
|
@course.shard.activate do
|
|
|
|
Score.active.joins(:enrollment)
|
|
|
|
.where(enrollments: { user_id: @user_ids, course_id: @course.id })
|
|
|
|
.where.not(grading_period_id: grading_period_ids)
|
|
|
|
.update_all(workflow_state: :deleted)
|
|
|
|
end
|
update grading period scores when student is graded
When a student is graded, the score for their grading period will now
be updated in addition to their total course score. Previously, when a
student was graded, their grading period score was not updated.
closes CNVS-26709
test plan:
1) In a course with multiple grading periods enabled and grading
periods set up, grade students for assignments that fall in grading
periods and make sure the scores get updated for the grading period
and for the course total.
* To make sure the scores get updated for the grading period, open a
rails console and find the grading period scores (we'll assume the
student's enrollment ID is 5, and the ID of the grading period
that the assignment falls in is 8).
$ Enrollment.find(5).scores.where(grading_period_id: 8)
Then, give a different grade to the student for the assignment
that falls in the grading period and run the command above again.
You should see that the current_score and final_score have
changed.
* To make sure the scores get updated for the course total, open a
rails console and find the course total scores (we'll assume the
student's enrollment ID is 5).
$ Enrollment.find(5).scores.where(grading_period_id: nil)
Then, give a different grade to the student for the assignment
that falls in the grading period and run the command above again.
You should see that the current_score and final_score have
changed.
Edge case: make sure that grading period scores continue to get updated
even if MGP is turned off. To verify this, turn off MGP in a course
that originally had MGP turned on. Then, grade students in assignments
that fell in a grading period when MGP was enabled. After grading, the
grading period scores should be updated.
Change-Id: I29e4e22a0b73d1062a93c6ad420d876c2f5d040a
Reviewed-on: https://gerrit.instructure.com/98603
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2016-12-30 05:05:07 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def calculate_course_score
|
|
|
|
# update the overall course score now that we've finished
|
|
|
|
# updating the grading period score
|
2017-09-27 06:06:09 +08:00
|
|
|
compute_branch(grading_period: nil)
|
update grading period scores when student is graded
When a student is graded, the score for their grading period will now
be updated in addition to their total course score. Previously, when a
student was graded, their grading period score was not updated.
closes CNVS-26709
test plan:
1) In a course with multiple grading periods enabled and grading
periods set up, grade students for assignments that fall in grading
periods and make sure the scores get updated for the grading period
and for the course total.
* To make sure the scores get updated for the grading period, open a
rails console and find the grading period scores (we'll assume the
student's enrollment ID is 5, and the ID of the grading period
that the assignment falls in is 8).
$ Enrollment.find(5).scores.where(grading_period_id: 8)
Then, give a different grade to the student for the assignment
that falls in the grading period and run the command above again.
You should see that the current_score and final_score have
changed.
* To make sure the scores get updated for the course total, open a
rails console and find the course total scores (we'll assume the
student's enrollment ID is 5).
$ Enrollment.find(5).scores.where(grading_period_id: nil)
Then, give a different grade to the student for the assignment
that falls in the grading period and run the command above again.
You should see that the current_score and final_score have
changed.
Edge case: make sure that grading period scores continue to get updated
even if MGP is turned off. To verify this, turn off MGP in a course
that originally had MGP turned on. Then, grade students in assignments
that fell in a grading period when MGP was enabled. After grading, the
grading period scores should be updated.
Change-Id: I29e4e22a0b73d1062a93c6ad420d876c2f5d040a
Reviewed-on: https://gerrit.instructure.com/98603
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2016-12-30 05:05:07 +08:00
|
|
|
end
|
|
|
|
|
2016-07-20 01:31:02 +08:00
|
|
|
def enrollments
|
2017-04-05 01:17:29 +08:00
|
|
|
@enrollments ||= Enrollment.shard(@course.shard).active
|
2016-07-20 01:31:02 +08:00
|
|
|
.where(user_id: @user_ids, course_id: @course.id)
|
2017-12-14 14:13:45 +08:00
|
|
|
.select(:id, :user_id, :workflow_state)
|
2016-07-20 01:31:02 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def joined_enrollment_ids
|
2017-04-05 01:17:29 +08:00
|
|
|
# use local_id because we'll exec the query on the enrollment's shard
|
|
|
|
@joined_enrollment_ids ||= enrollments.map(&:local_id).join(",")
|
2016-07-20 01:31:02 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def enrollments_by_user
|
|
|
|
@enrollments_by_user ||= begin
|
|
|
|
hsh = enrollments.group_by { |e| Shard.relative_id_for(e.user_id, Shard.current, @course.shard) }
|
|
|
|
hsh.default = []
|
|
|
|
hsh
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-01-07 07:10:49 +08:00
|
|
|
def number_or_null(score)
|
|
|
|
# GradeCalculator sometimes divides by 0 somewhere,
|
|
|
|
# resulting in NaN. Treat that as null here
|
|
|
|
score = nil if score.try(:nan?)
|
2017-08-17 21:47:36 +08:00
|
|
|
score || "NULL::float"
|
|
|
|
end
|
|
|
|
|
2017-10-05 02:34:31 +08:00
|
|
|
def group_score_rows
|
2017-08-17 21:47:36 +08:00
|
|
|
enrollments_by_user.keys.map do |user_id|
|
2021-11-17 06:39:28 +08:00
|
|
|
current_group_scores = @current_groups[user_id].index_by { |group| group[:global_id] }
|
|
|
|
final_group_scores = @final_groups[user_id].index_by { |group| group[:global_id] }
|
2017-08-17 21:47:36 +08:00
|
|
|
@groups.map do |group|
|
|
|
|
agid = group.global_id
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
current = current_group_scores[agid]
|
|
|
|
final = final_group_scores[agid]
|
2017-08-17 21:47:36 +08:00
|
|
|
enrollments_by_user[user_id].map do |enrollment|
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
fields = [enrollment.id, group.id]
|
|
|
|
|
|
|
|
unless @only_update_points
|
|
|
|
fields << number_or_null(current[:grade])
|
|
|
|
fields << number_or_null(final[:grade])
|
|
|
|
end
|
|
|
|
|
|
|
|
fields << number_or_null(current[:score])
|
|
|
|
fields << number_or_null(final[:score])
|
|
|
|
|
|
|
|
"(#{fields.join(", ")})"
|
2017-08-17 21:47:36 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end.flatten
|
|
|
|
end
|
|
|
|
|
2017-10-05 02:34:31 +08:00
|
|
|
def group_dropped_rows
|
|
|
|
enrollments_by_user.keys.map do |user_id|
|
|
|
|
current = @current_groups[user_id].pluck(:global_id, :dropped).to_h
|
|
|
|
final = @final_groups[user_id].pluck(:global_id, :dropped).to_h
|
|
|
|
@groups.map do |group|
|
|
|
|
agid = group.global_id
|
|
|
|
hsh = {
|
|
|
|
current: { dropped: current[agid] },
|
|
|
|
final: { dropped: final[agid] }
|
|
|
|
}
|
|
|
|
enrollments_by_user[user_id].map do |enrollment|
|
|
|
|
"(#{enrollment.id}, #{group.id}, '#{hsh.to_json}')"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end.flatten
|
|
|
|
end
|
|
|
|
|
2017-08-17 21:47:36 +08:00
|
|
|
def updated_at
|
|
|
|
@updated_at ||= Score.connection.quote(Time.now.utc)
|
2017-01-07 07:10:49 +08:00
|
|
|
end
|
|
|
|
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
def column_prefix
|
|
|
|
@ignore_muted ? "" : "unposted_"
|
|
|
|
end
|
|
|
|
|
2017-09-27 06:06:09 +08:00
|
|
|
def current_score_column
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
"#{column_prefix}current_score"
|
2017-09-27 06:06:09 +08:00
|
|
|
end
|
2011-07-08 05:53:21 +08:00
|
|
|
|
2017-09-27 06:06:09 +08:00
|
|
|
def final_score_column
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
"#{column_prefix}final_score"
|
|
|
|
end
|
|
|
|
|
|
|
|
def points_column(type)
|
|
|
|
"#{column_prefix}#{type}_points"
|
2017-09-27 06:06:09 +08:00
|
|
|
end
|
|
|
|
|
2018-03-26 23:38:27 +08:00
|
|
|
def update_score_statistics
|
|
|
|
return if @grading_period # only update score statistics when calculating course scores
|
|
|
|
return unless @ignore_muted # only update when calculating final scores
|
|
|
|
|
2022-03-15 03:09:12 +08:00
|
|
|
ScoreStatisticsGenerator.update_score_statistics_in_singleton(@course)
|
2018-03-26 23:38:27 +08:00
|
|
|
end
|
|
|
|
|
2017-09-27 06:06:09 +08:00
|
|
|
def save_scores
|
2016-07-20 01:31:02 +08:00
|
|
|
return if @current_updates.empty? && @final_updates.empty?
|
|
|
|
return if joined_enrollment_ids.blank?
|
2021-04-22 02:24:11 +08:00
|
|
|
return if @grading_period&.deleted?
|
2016-07-20 01:31:02 +08:00
|
|
|
|
2019-11-01 00:35:29 +08:00
|
|
|
save_scores_in_transaction
|
|
|
|
end
|
|
|
|
|
|
|
|
def save_scores_in_transaction
|
|
|
|
Score.transaction do
|
|
|
|
@course.shard.activate do
|
|
|
|
save_course_and_grading_period_scores
|
|
|
|
save_course_and_grading_period_metadata
|
|
|
|
score_rows = group_score_rows
|
|
|
|
if @grading_period.nil? && score_rows.any?
|
|
|
|
dropped_rows = group_dropped_rows
|
|
|
|
save_assignment_group_scores(score_rows.join(","), dropped_rows.join(","))
|
|
|
|
end
|
2017-04-05 01:17:29 +08:00
|
|
|
end
|
2016-07-20 01:31:02 +08:00
|
|
|
end
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
|
|
|
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
def user_specific_updates(updates:, default_value:, key:)
|
|
|
|
specific_values = updates.flat_map do |user_id, score_details|
|
|
|
|
enrollments_by_user[user_id].map do |enrollment|
|
|
|
|
"WHEN #{enrollment.id} THEN #{number_or_null(score_details[key])}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
"#{specific_values.join(" ")} ELSE #{default_value}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def update_values_for(column, updates: {}, key: :grade)
|
|
|
|
return unless column
|
|
|
|
|
2019-05-07 06:15:24 +08:00
|
|
|
actual_updates = user_specific_updates(updates: updates, default_value: "excluded.#{column}", key: key)
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
|
2019-05-07 06:15:24 +08:00
|
|
|
"#{column} = CASE excluded.enrollment_id #{actual_updates} END"
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def insert_values_for(column, updates: {}, key: :grade)
|
|
|
|
return unless column
|
|
|
|
|
|
|
|
actual_updates = user_specific_updates(updates: updates, default_value: "NULL", key: key)
|
|
|
|
|
|
|
|
"CASE enrollments.id #{actual_updates} END :: float AS #{column}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def columns_to_insert_or_update
|
|
|
|
return @columns_to_insert_or_update if defined? @columns_to_insert_or_update
|
|
|
|
|
|
|
|
# Use a hash with Array values to ensure ordering of data
|
|
|
|
column_list = { columns: [], insert_values: [], update_values: [] }
|
|
|
|
|
|
|
|
unless @only_update_points
|
|
|
|
column_list[:columns] << current_score_column
|
|
|
|
column_list[:insert_values] << insert_values_for(current_score_column, updates: @current_updates)
|
|
|
|
column_list[:update_values] << update_values_for(current_score_column, updates: @current_updates)
|
|
|
|
|
|
|
|
column_list[:columns] << final_score_column
|
|
|
|
column_list[:insert_values] << insert_values_for(final_score_column, updates: @final_updates)
|
|
|
|
column_list[:update_values] << update_values_for(final_score_column, updates: @final_updates)
|
|
|
|
end
|
|
|
|
|
|
|
|
column_list[:columns] << points_column(:current)
|
|
|
|
column_list[:insert_values] << insert_values_for(points_column(:current), updates: @current_updates, key: :total)
|
|
|
|
column_list[:update_values] << update_values_for(points_column(:current), updates: @current_updates, key: :total)
|
|
|
|
|
|
|
|
column_list[:columns] << points_column(:final)
|
|
|
|
column_list[:insert_values] << insert_values_for(points_column(:final), updates: @final_updates, key: :total)
|
|
|
|
column_list[:update_values] << update_values_for(points_column(:final), updates: @final_updates, key: :total)
|
|
|
|
|
|
|
|
@columns_to_insert_or_update = column_list
|
|
|
|
end
|
|
|
|
|
2017-08-17 21:47:36 +08:00
|
|
|
def save_course_and_grading_period_scores
|
2017-12-12 06:29:35 +08:00
|
|
|
return if @only_update_course_gp_metadata
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
|
2019-05-07 06:15:24 +08:00
|
|
|
# Depending on whether we're updating course scores or grading period
|
|
|
|
# scores, we need to check our inserted values against different uniqueness
|
|
|
|
# constraints
|
|
|
|
conflict_target = if @grading_period.present?
|
|
|
|
"(enrollment_id, grading_period_id) WHERE grading_period_id IS NOT NULL"
|
|
|
|
else
|
|
|
|
"(enrollment_id) WHERE course_score"
|
|
|
|
end
|
|
|
|
|
|
|
|
# Update existing course and grading period Scores or create them if needed.
|
2021-11-13 03:01:16 +08:00
|
|
|
Score.connection.execute(<<~SQL.squish)
|
2017-08-17 21:47:36 +08:00
|
|
|
INSERT INTO #{Score.quoted_table_name}
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
(
|
|
|
|
enrollment_id, grading_period_id,
|
|
|
|
#{columns_to_insert_or_update[:columns].join(", ")},
|
2020-06-06 03:38:28 +08:00
|
|
|
course_score, root_account_id, created_at, updated_at
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
)
|
2017-08-17 21:47:36 +08:00
|
|
|
SELECT
|
|
|
|
enrollments.id as enrollment_id,
|
|
|
|
#{@grading_period.try(:id) || "NULL"} as grading_period_id,
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
#{columns_to_insert_or_update[:insert_values].join(", ")},
|
2017-08-17 21:47:36 +08:00
|
|
|
#{@grading_period ? "FALSE" : "TRUE"} AS course_score,
|
2020-06-06 03:38:28 +08:00
|
|
|
#{@course.root_account_id} AS root_account_id,
|
2017-08-17 21:47:36 +08:00
|
|
|
#{updated_at} as created_at,
|
|
|
|
#{updated_at} as updated_at
|
|
|
|
FROM #{Enrollment.quoted_table_name} enrollments
|
|
|
|
WHERE
|
2019-05-07 06:15:24 +08:00
|
|
|
enrollments.id IN (#{joined_enrollment_ids})
|
2021-04-22 02:24:11 +08:00
|
|
|
ORDER BY enrollment_id
|
2019-05-07 06:15:24 +08:00
|
|
|
ON CONFLICT #{conflict_target}
|
|
|
|
DO UPDATE SET
|
|
|
|
#{columns_to_insert_or_update[:update_values].join(", ")},
|
|
|
|
updated_at = excluded.updated_at,
|
2020-06-06 03:38:28 +08:00
|
|
|
root_account_id = #{@course.root_account_id},
|
2021-11-13 03:01:16 +08:00
|
|
|
/* if workflow_state was previously deleted for some reason, update it to active */
|
2019-05-07 06:15:24 +08:00
|
|
|
workflow_state = COALESCE(NULLIF(excluded.workflow_state, 'deleted'), 'active')
|
2021-11-13 03:01:16 +08:00
|
|
|
SQL
|
2020-12-12 05:00:12 +08:00
|
|
|
rescue ActiveRecord::Deadlocked => e
|
|
|
|
Canvas::Errors.capture_exception(:grade_calcuator, e, :warn)
|
|
|
|
raise Delayed::RetriableError, "Deadlock in upserting course or grading period scores"
|
2017-12-12 06:29:35 +08:00
|
|
|
end
|
2017-10-05 02:34:31 +08:00
|
|
|
|
2017-12-12 06:29:35 +08:00
|
|
|
def save_course_and_grading_period_metadata
|
2018-01-11 06:44:00 +08:00
|
|
|
# We only save score metadata for posted grades. This means, if we're
|
|
|
|
# calculating unposted grades (which means @ignore_muted is false),
|
|
|
|
# we don't want to update the score metadata. TODO: start storing the
|
|
|
|
# score metadata for unposted grades.
|
|
|
|
return unless @ignore_muted
|
|
|
|
|
2017-10-05 02:34:31 +08:00
|
|
|
ScoreMetadata.connection.execute("
|
|
|
|
INSERT INTO #{ScoreMetadata.quoted_table_name}
|
|
|
|
(score_id, calculation_details, created_at, updated_at)
|
|
|
|
SELECT
|
|
|
|
scores.id AS score_id,
|
|
|
|
CASE enrollments.user_id
|
|
|
|
#{@dropped_updates.map do |user_id, dropped|
|
|
|
|
"WHEN #{user_id} THEN cast('#{dropped.to_json}' as json)"
|
|
|
|
end.join(" ")}
|
|
|
|
ELSE NULL
|
|
|
|
END AS calculation_details,
|
|
|
|
#{updated_at} AS created_at,
|
|
|
|
#{updated_at} AS updated_at
|
|
|
|
FROM #{Score.quoted_table_name} scores
|
|
|
|
INNER JOIN #{Enrollment.quoted_table_name} enrollments ON
|
|
|
|
enrollments.id = scores.enrollment_id
|
|
|
|
LEFT OUTER JOIN #{ScoreMetadata.quoted_table_name} metadata ON
|
|
|
|
metadata.score_id = scores.id
|
|
|
|
WHERE
|
|
|
|
scores.enrollment_id IN (#{joined_enrollment_ids}) AND
|
|
|
|
scores.assignment_group_id IS NULL AND
|
2019-05-07 06:15:24 +08:00
|
|
|
#{@grading_period ? "scores.grading_period_id = #{@grading_period.id}" : "scores.course_score IS TRUE"}
|
2021-04-22 02:24:11 +08:00
|
|
|
ORDER BY enrollment_id
|
2019-05-07 06:15:24 +08:00
|
|
|
ON CONFLICT (score_id)
|
|
|
|
DO UPDATE SET
|
|
|
|
calculation_details = excluded.calculation_details,
|
|
|
|
updated_at = excluded.updated_at
|
|
|
|
;
|
2017-10-05 02:34:31 +08:00
|
|
|
")
|
2017-08-17 21:47:36 +08:00
|
|
|
end
|
|
|
|
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
def assignment_group_columns_to_insert_or_update
|
|
|
|
return @assignment_group_columns_to_insert_or_update if defined? @assignment_group_columns_to_insert_or_update
|
|
|
|
|
2019-05-07 06:15:24 +08:00
|
|
|
column_list = {
|
|
|
|
insert_columns: [],
|
|
|
|
insert_values: [],
|
|
|
|
update_columns: [],
|
|
|
|
update_values: [],
|
|
|
|
value_names: []
|
|
|
|
}
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
|
|
|
|
unless @only_update_points
|
|
|
|
column_list[:value_names] << "current_score"
|
2019-05-07 06:15:24 +08:00
|
|
|
column_list[:update_columns] << "#{current_score_column} = excluded.current_score"
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
column_list[:insert_columns] << "val.current_score AS #{current_score_column}"
|
|
|
|
|
|
|
|
column_list[:value_names] << "final_score"
|
2019-05-07 06:15:24 +08:00
|
|
|
column_list[:update_columns] << "#{final_score_column} = excluded.final_score"
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
column_list[:insert_columns] << "val.final_score AS #{final_score_column}"
|
|
|
|
end
|
|
|
|
|
|
|
|
column_list[:value_names] << "current_points"
|
2019-05-07 06:15:24 +08:00
|
|
|
column_list[:update_columns] << "#{points_column(:current)} = excluded.current_points"
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
column_list[:insert_columns] << "val.current_points AS #{points_column(:current)}"
|
|
|
|
|
|
|
|
column_list[:value_names] << "final_points"
|
2019-05-07 06:15:24 +08:00
|
|
|
column_list[:update_columns] << "#{points_column(:final)} = excluded.final_points"
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
column_list[:insert_columns] << "val.final_points AS #{points_column(:final)}"
|
|
|
|
|
|
|
|
@assignment_group_columns_to_insert_or_update = column_list
|
|
|
|
end
|
|
|
|
|
2017-10-05 02:34:31 +08:00
|
|
|
def save_assignment_group_scores(score_values, dropped_values)
|
2019-05-07 06:15:24 +08:00
|
|
|
# Update existing assignment group Scores or create them if needed.
|
2017-08-17 21:47:36 +08:00
|
|
|
Score.connection.execute("
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
INSERT INTO #{Score.quoted_table_name} (
|
2019-05-07 06:15:24 +08:00
|
|
|
enrollment_id, assignment_group_id,
|
|
|
|
#{assignment_group_columns_to_insert_or_update[:value_names].join(", ")},
|
2020-06-06 03:38:28 +08:00
|
|
|
course_score, root_account_id, created_at, updated_at
|
2019-05-07 06:15:24 +08:00
|
|
|
)
|
|
|
|
SELECT
|
|
|
|
val.enrollment_id AS enrollment_id,
|
|
|
|
val.assignment_group_id as assignment_group_id,
|
|
|
|
#{assignment_group_columns_to_insert_or_update[:insert_columns].join(", ")},
|
|
|
|
FALSE AS course_score,
|
2020-06-06 03:38:28 +08:00
|
|
|
#{@course.root_account_id} AS root_account_id,
|
2019-05-07 06:15:24 +08:00
|
|
|
#{updated_at} AS created_at,
|
|
|
|
#{updated_at} AS updated_at
|
|
|
|
FROM (VALUES #{score_values}) val
|
|
|
|
(
|
|
|
|
enrollment_id,
|
|
|
|
assignment_group_id,
|
|
|
|
#{assignment_group_columns_to_insert_or_update[:value_names].join(", ")}
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
)
|
2021-04-22 02:24:11 +08:00
|
|
|
ORDER BY assignment_group_id, enrollment_id
|
2019-05-07 06:15:24 +08:00
|
|
|
ON CONFLICT (enrollment_id, assignment_group_id) WHERE assignment_group_id IS NOT NULL
|
|
|
|
DO UPDATE SET
|
|
|
|
#{assignment_group_columns_to_insert_or_update[:update_columns].join(", ")},
|
|
|
|
updated_at = excluded.updated_at,
|
2020-06-06 03:38:28 +08:00
|
|
|
root_account_id = #{@course.root_account_id},
|
2019-05-07 06:15:24 +08:00
|
|
|
workflow_state = COALESCE(NULLIF(excluded.workflow_state, 'deleted'), 'active')
|
2017-08-17 21:47:36 +08:00
|
|
|
")
|
2017-10-05 02:34:31 +08:00
|
|
|
|
2018-01-11 06:44:00 +08:00
|
|
|
# We only save score metadata for posted grades. This means, if we're
|
|
|
|
# calculating unposted grades (which means @ignore_muted is false),
|
|
|
|
# we don't want to update the score metadata. TODO: start storing the
|
|
|
|
# score metadata for unposted grades.
|
|
|
|
if @ignore_muted
|
|
|
|
ScoreMetadata.connection.execute("
|
|
|
|
INSERT INTO #{ScoreMetadata.quoted_table_name}
|
|
|
|
(score_id, calculation_details, created_at, updated_at)
|
|
|
|
SELECT
|
|
|
|
scores.id AS score_id,
|
|
|
|
CAST(val.calculation_details as json) AS calculation_details,
|
|
|
|
#{updated_at} AS created_at,
|
|
|
|
#{updated_at} AS updated_at
|
|
|
|
FROM (VALUES #{dropped_values}) val
|
|
|
|
(enrollment_id, assignment_group_id, calculation_details)
|
|
|
|
LEFT OUTER JOIN #{Score.quoted_table_name} scores ON
|
|
|
|
scores.enrollment_id = val.enrollment_id AND
|
|
|
|
scores.assignment_group_id = val.assignment_group_id
|
2020-12-04 02:22:30 +08:00
|
|
|
ORDER BY score_id
|
2019-05-07 06:15:24 +08:00
|
|
|
ON CONFLICT (score_id)
|
|
|
|
DO UPDATE SET
|
|
|
|
calculation_details = excluded.calculation_details,
|
|
|
|
updated_at = excluded.updated_at
|
|
|
|
;
|
2018-01-11 06:44:00 +08:00
|
|
|
")
|
|
|
|
end
|
2020-12-12 05:00:12 +08:00
|
|
|
rescue ActiveRecord::Deadlocked => e
|
|
|
|
Canvas::Errors.capture_exception(:grade_calculator, e, :warn)
|
|
|
|
raise Delayed::RetriableError, "Deadlock in upserting assignment group scores"
|
2017-08-17 21:47:36 +08:00
|
|
|
end
|
|
|
|
|
2012-12-22 04:31:53 +08:00
|
|
|
# returns information about assignments groups in the form:
|
2013-01-12 07:32:38 +08:00
|
|
|
# [
|
|
|
|
# {
|
|
|
|
# :id => 1
|
|
|
|
# :score => 5,
|
|
|
|
# :possible => 7,
|
2014-01-22 05:20:33 +08:00
|
|
|
# :grade => 71.42,
|
2013-01-12 07:32:38 +08:00
|
|
|
# :weight => 50},
|
|
|
|
# ...]
|
2012-12-22 04:31:53 +08:00
|
|
|
# each group
|
back-end grade calculator supports grading period weighting
closes CNVS-34105
test plan:
- Setup -
1. At the account-level, create a new grading period set that uses
weighted grading periods. Attach the default enrollment term to this
set.
2. Create a grading period (GP1) that runs from January 1, 2017 to June
30, 2017. Give it a weight of 75%.
3. Create a grading period (GP2) that runs from July 1, 2017 to
December 31, 2017. Give it a weight of 25%.
4. Create a course that belongs to the default enrollment term from
step 1. Enroll one student in the course. Make sure that student is
enrolled in at least one other course.
5. In the course settings, enable Multiple Grading Periods and enable
Display ‘All Grading Period’ Totals.
6. In the course, create an assignment (Assignment in GP1) that is
worth 10 points and due for everyone on March 15, 2017.
7. In the course, create an assignment (Assignment in GP2) that is
worth 10 points and due for everyone on September 15, 2017.
8. Go to the gradebook and give the student 5/10 on Assignment in GP1
and 10/10 on Assignment in GP2. Ignore the totals that show up in
the gradebook.
- Grade Verification -
1. Sign in as the student and go to the /grades page.
2. Verify the grade for GP1 is 50%.
3. Verify the grade for GP2 is 100%.
4. Verify the grade for ‘All Grading Periods’ is 62.5%.
5. Sign in as the account admin. Change the weight for GP1 to 20% and
change the weight for GP2 to 40%.
6. Sign in as the student and go to the /grades page.
7. Verify the grade for GP1 is 50%.
8. Verify the grade for GP2 is 100%.
9. Verify the grade for ‘All Grading Periods’ is 83.33%.
10. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 100%.
11. Sign in as the student and go to the /grades page.
12. Verify the grade for GP1 is 50%.
13. Verify the grade for GP2 is 100%.
14. Verify the grade for ‘All Grading Periods’ is 150%.
15. Sign in as the account admin. Change the weight for GP1 to 100% and
change the weight for GP2 to 0%.
16. Sign in as the student and go to the /grades page.
17. Verify the grade for GP1 is 50%.
18. Verify the grade for GP2 is 100%.
19. Verify the grade for ‘All Grading Periods’ is 50%.
20. Sign in as the account admin. Change the weight for GP1 to 0% and
change the weight for GP2 to 0%.
21. Sign in as the student and go to the /grades page.
22. Verify the grade for GP1 is 50%.
23. Verify the grade for GP2 is 100%.
24. Verify the grade for ‘All Grading Periods’ is 0%.
25. Sign in as the account admin. Uncheck the box on the grading period
set for ‘weighting’.
26. Sign in as the student and go to the /grades page.
27. Verify the grade for GP1 is 50%.
28. Verify the grade for GP2 is 100%.
29. Verify the grade for ‘All Grading Periods’ is 75%.
Change-Id: Iac23e92986f371b13de2d5e0524d6bed8a277bc4
Reviewed-on: https://gerrit.instructure.com/99040
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-01-04 03:59:14 +08:00
|
|
|
def create_group_sums(submissions, user_id, ignore_ungraded: true)
|
2017-04-19 12:03:23 +08:00
|
|
|
visible_assignments = @assignments.select { |assignment| assignment_visible_to_student?(assignment.id, user_id) }
|
feature flag for 'All Grading Periods' totals
Add grading period dropdowns on the 'grades' page,
and add a "Display Totals for 'All Grading Periods'"
feature flag. By default, the feature will be turned
'off'.
When the feature is 'off':
- Totals will not display in the gradebook
or the 'student grades' page when the 'All
Grading Periods' option is selected.
- The grading period dropdowns on the 'grades'
page will not have an 'All Grading Periods'
option.
When the feature is 'on':
- Totals will display in the gradebook and the
'student grades' page when the 'All Grading
Periods' option is selected.
- The grading period dropdowns on the 'grades'
page will have an 'All Grading Periods' option.
closes CNVS-23995
test plan:
1) as a teacher, enable the 'multiple grading
periods' feature (do not enable the 'display
totals for all grading periods' feature yet).
a) verify the gradebook does not show totals
when the 'All Grading Periods' option is
selected.
b) verify the 'student grades page'
(courses/4/grades/9#tab-assignments) does
not show totals, and the calculation of
'what-if' grades is disabled when the
'All Grading Periods' option is selected.
c) turn on the 'display totals for all
grading periods' feature. repeat steps
a & b and verify that the totals now
show up (and you can calculate what-if
grades on the student grades page when
'All Grading Periods is selected')
2) sign in as a student that is enrolled in
3 courses: 1 course with MGP disabled, 1
course with MGP enabled and 'display all
grading periods totals' (DAGPT) disabled,
and 1 course with MGP enabled and DAGPT
enabled. go the the 'grades' page (/grades).
a) verify there is a grading period dropdown
next to the totals for courses that have
MGP enabled. verify there is not a grading
period dropdown next to the total for the
course with MGP disabled.
b) verify that the current grading period is
selected by default, if one exists. if a
current grading period does not exist, then:
- the dropdown next to the total for the
course with DAGPT disabled should show
'Select a grading period' and the total
grade should show as '--'.
- the dropdown next to the total for the
course with DAGPT enabled should show
'All Grading Periods' and the total grade
should be displayed.
c) verify clicking a grading period in the
dropdown changes the total, and shows
the correct total for that grading period.
3) repeat steps 2a-c, but sign in as an observer that
is observing at least 3 students in 3 different
courses(1 course with MGP disabled, 1 with MGP
enabled and DAGPT disabled, and 1 course with
MGP enabled + DAGPT enabled).
4) verify that the grading period dropdowns that were
added are accessible.
Note: The 'grades' page (/grades) will _always_
display the total for 'All Grading Periods' when
signed in as a teacher. We are aware of this
existing bug and we're working on a solution.
Change-Id: If501b47aa57121d17d4e6629d1dcdbc8676971a2
Reviewed-on: https://gerrit.instructure.com/65847
Tested-by: Jenkins
Reviewed-by: Strand McCutchen <smccutchen@instructure.com>
Reviewed-by: Dylan Ross <dross@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
QA-Review: Jason Carter <jcarter@instructure.com>
Product-Review: Spencer Olson <solson@instructure.com>
2015-10-14 03:20:03 +08:00
|
|
|
|
|
|
|
if @grading_period
|
2017-04-19 12:03:23 +08:00
|
|
|
visible_assignments.select! do |assignment|
|
|
|
|
effective_due_dates.grading_period_id_for(
|
|
|
|
student_id: user_id,
|
|
|
|
assignment_id: assignment.id
|
|
|
|
) == Shard.relative_id_for(@grading_period.id, Shard.current, @course.shard)
|
|
|
|
end
|
feature flag for 'All Grading Periods' totals
Add grading period dropdowns on the 'grades' page,
and add a "Display Totals for 'All Grading Periods'"
feature flag. By default, the feature will be turned
'off'.
When the feature is 'off':
- Totals will not display in the gradebook
or the 'student grades' page when the 'All
Grading Periods' option is selected.
- The grading period dropdowns on the 'grades'
page will not have an 'All Grading Periods'
option.
When the feature is 'on':
- Totals will display in the gradebook and the
'student grades' page when the 'All Grading
Periods' option is selected.
- The grading period dropdowns on the 'grades'
page will have an 'All Grading Periods' option.
closes CNVS-23995
test plan:
1) as a teacher, enable the 'multiple grading
periods' feature (do not enable the 'display
totals for all grading periods' feature yet).
a) verify the gradebook does not show totals
when the 'All Grading Periods' option is
selected.
b) verify the 'student grades page'
(courses/4/grades/9#tab-assignments) does
not show totals, and the calculation of
'what-if' grades is disabled when the
'All Grading Periods' option is selected.
c) turn on the 'display totals for all
grading periods' feature. repeat steps
a & b and verify that the totals now
show up (and you can calculate what-if
grades on the student grades page when
'All Grading Periods is selected')
2) sign in as a student that is enrolled in
3 courses: 1 course with MGP disabled, 1
course with MGP enabled and 'display all
grading periods totals' (DAGPT) disabled,
and 1 course with MGP enabled and DAGPT
enabled. go the the 'grades' page (/grades).
a) verify there is a grading period dropdown
next to the totals for courses that have
MGP enabled. verify there is not a grading
period dropdown next to the total for the
course with MGP disabled.
b) verify that the current grading period is
selected by default, if one exists. if a
current grading period does not exist, then:
- the dropdown next to the total for the
course with DAGPT disabled should show
'Select a grading period' and the total
grade should show as '--'.
- the dropdown next to the total for the
course with DAGPT enabled should show
'All Grading Periods' and the total grade
should be displayed.
c) verify clicking a grading period in the
dropdown changes the total, and shows
the correct total for that grading period.
3) repeat steps 2a-c, but sign in as an observer that
is observing at least 3 students in 3 different
courses(1 course with MGP disabled, 1 with MGP
enabled and DAGPT disabled, and 1 course with
MGP enabled + DAGPT enabled).
4) verify that the grading period dropdowns that were
added are accessible.
Note: The 'grades' page (/grades) will _always_
display the total for 'All Grading Periods' when
signed in as a teacher. We are aware of this
existing bug and we're working on a solution.
Change-Id: If501b47aa57121d17d4e6629d1dcdbc8676971a2
Reviewed-on: https://gerrit.instructure.com/65847
Tested-by: Jenkins
Reviewed-by: Strand McCutchen <smccutchen@instructure.com>
Reviewed-by: Dylan Ross <dross@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
QA-Review: Jason Carter <jcarter@instructure.com>
Product-Review: Spencer Olson <solson@instructure.com>
2015-10-14 03:20:03 +08:00
|
|
|
end
|
2017-04-19 12:03:23 +08:00
|
|
|
|
2014-08-18 23:55:26 +08:00
|
|
|
assignments_by_group_id = visible_assignments.group_by(&:assignment_group_id)
|
2021-11-17 06:39:28 +08:00
|
|
|
submissions_by_assignment_id =
|
|
|
|
submissions.index_by(&:assignment_id)
|
2012-12-22 04:31:53 +08:00
|
|
|
|
2013-01-12 07:32:38 +08:00
|
|
|
@groups.map do |group|
|
2012-12-22 04:31:53 +08:00
|
|
|
assignments = assignments_by_group_id[group.id] || []
|
2014-01-15 08:29:38 +08:00
|
|
|
|
2012-12-22 04:31:53 +08:00
|
|
|
group_submissions = assignments.map do |a|
|
|
|
|
s = submissions_by_assignment_id[a.id]
|
|
|
|
|
2019-05-04 02:29:33 +08:00
|
|
|
# ignore unposted submissions and all submissions for muted assignments
|
|
|
|
s = nil if ignore_submission?(submission: s, assignment: a)
|
2012-12-22 04:31:53 +08:00
|
|
|
|
2016-03-31 01:13:20 +08:00
|
|
|
# ignore pending_review quiz submissions
|
|
|
|
s = nil if ignore_ungraded && s.try(:pending_review?)
|
|
|
|
|
2012-12-22 04:31:53 +08:00
|
|
|
{
|
2015-04-17 07:24:31 +08:00
|
|
|
assignment: a,
|
|
|
|
submission: s,
|
2017-12-14 14:13:45 +08:00
|
|
|
score: s&.score,
|
2018-11-16 05:00:55 +08:00
|
|
|
total: BigDecimal(a.points_possible || 0, 15),
|
2017-12-14 14:13:45 +08:00
|
|
|
excused: s&.excused?,
|
2012-12-22 04:31:53 +08:00
|
|
|
}
|
2012-09-14 08:53:07 +08:00
|
|
|
end
|
2015-04-17 07:24:31 +08:00
|
|
|
|
2017-12-14 14:13:45 +08:00
|
|
|
if enrollments_by_user[user_id].all? { |e| e.workflow_state == "completed" }
|
|
|
|
group_submissions.reject! { |s| s[:submission].nil? }
|
|
|
|
end
|
|
|
|
|
2012-12-22 04:31:53 +08:00
|
|
|
group_submissions.reject! { |s| s[:score].nil? } if ignore_ungraded
|
2015-04-17 07:24:31 +08:00
|
|
|
group_submissions.reject! { |s| s[:excused] }
|
2016-04-12 05:56:35 +08:00
|
|
|
group_submissions.reject! { |s| s[:assignment].omit_from_final_grade? }
|
2012-12-22 04:31:53 +08:00
|
|
|
group_submissions.each { |s| s[:score] ||= 0 }
|
|
|
|
|
2015-02-13 11:08:45 +08:00
|
|
|
logged_submissions = group_submissions.map { |s| loggable_submission(s) }
|
2018-03-06 02:24:06 +08:00
|
|
|
Rails.logger.debug "GRADES: calculating for assignment_group=#{group.global_id} user=#{user_id}"
|
|
|
|
Rails.logger.debug "GRADES: calculating... ignore_ungraded=#{ignore_ungraded}"
|
|
|
|
Rails.logger.debug "GRADES: calculating... submissions=#{logged_submissions.inspect}"
|
2015-02-13 11:08:45 +08:00
|
|
|
|
2012-12-22 04:31:53 +08:00
|
|
|
kept = drop_assignments(group_submissions, group.rules_hash)
|
2021-11-15 23:09:24 +08:00
|
|
|
dropped_submissions = (group_submissions - kept).filter_map { |s| s[:submission]&.id }
|
2012-12-22 04:31:53 +08:00
|
|
|
|
2020-08-17 23:53:20 +08:00
|
|
|
score, possible = kept.reduce([0.0, 0.0]) do |(s_sum, p_sum), s|
|
|
|
|
[s_sum.to_d + s[:score].to_d, p_sum.to_d + s[:total].to_d]
|
2021-11-23 23:20:14 +08:00
|
|
|
end
|
2013-01-12 07:32:38 +08:00
|
|
|
|
|
|
|
{
|
2017-08-17 21:47:36 +08:00
|
|
|
id: group.id,
|
|
|
|
global_id: group.global_id,
|
|
|
|
score: score,
|
|
|
|
possible: possible,
|
|
|
|
weight: group.group_weight,
|
2018-11-16 05:00:55 +08:00
|
|
|
grade: ((score.to_f / possible * 100).round(2).to_f if possible > 0),
|
2017-10-05 02:34:31 +08:00
|
|
|
dropped: dropped_submissions
|
2015-02-13 11:08:45 +08:00
|
|
|
}.tap do |group_grade_info|
|
2018-03-06 02:24:06 +08:00
|
|
|
Rails.logger.debug "GRADES: calculated #{group_grade_info.inspect}"
|
2021-11-23 23:20:14 +08:00
|
|
|
end
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
|
|
|
end
|
2012-12-22 04:31:53 +08:00
|
|
|
|
|
|
|
# see comments for dropAssignments in grade_calculator.coffee
|
|
|
|
def drop_assignments(submissions, rules)
|
|
|
|
drop_lowest = rules[:drop_lowest] || 0
|
|
|
|
drop_highest = rules[:drop_highest] || 0
|
|
|
|
never_drop_ids = rules[:never_drop] || []
|
|
|
|
return submissions if drop_lowest.zero? && drop_highest.zero?
|
|
|
|
|
2018-03-06 02:24:06 +08:00
|
|
|
Rails.logger.debug "GRADES: dropping assignments! #{rules.inspect}"
|
2015-02-13 11:08:45 +08:00
|
|
|
|
2012-12-29 17:39:44 +08:00
|
|
|
cant_drop = []
|
2019-08-09 22:09:42 +08:00
|
|
|
if never_drop_ids.present?
|
|
|
|
cant_drop, submissions = submissions.partition { |submission| never_drop_ids.include?(submission[:assignment].id) }
|
2012-12-22 04:31:53 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
# fudge the drop rules if there aren't enough submissions
|
|
|
|
return cant_drop if submissions.empty?
|
2021-09-23 00:25:11 +08:00
|
|
|
|
2012-12-22 04:31:53 +08:00
|
|
|
drop_lowest = submissions.size - 1 if drop_lowest >= submissions.size
|
|
|
|
drop_highest = 0 if drop_lowest + drop_highest >= submissions.size
|
|
|
|
|
2012-12-29 17:39:44 +08:00
|
|
|
keep_highest = submissions.size - drop_lowest
|
|
|
|
keep_lowest = keep_highest - drop_highest
|
|
|
|
|
2013-01-15 05:06:16 +08:00
|
|
|
submissions.sort! { |a, b| a[:assignment].id - b[:assignment].id }
|
|
|
|
|
2012-12-29 17:39:44 +08:00
|
|
|
# assignment groups that have no points possible have to be dropped
|
|
|
|
# differently (it's a simpler case, but not one that fits in with our
|
|
|
|
# usual bisection approach)
|
|
|
|
kept = if (cant_drop + submissions).any? { |s| s[:total] > 0 }
|
2013-01-10 08:59:16 +08:00
|
|
|
drop_pointed(submissions, cant_drop, keep_highest, keep_lowest)
|
2021-11-20 05:10:36 +08:00
|
|
|
else
|
2012-12-29 17:39:44 +08:00
|
|
|
drop_unpointed(submissions, keep_highest, keep_lowest)
|
2021-11-20 05:10:36 +08:00
|
|
|
end
|
2012-12-29 17:39:44 +08:00
|
|
|
|
2015-02-13 11:08:45 +08:00
|
|
|
(kept + cant_drop).tap do |all_kept|
|
|
|
|
loggable_kept = all_kept.map { |s| loggable_submission(s) }
|
2018-03-06 02:24:06 +08:00
|
|
|
Rails.logger.debug "GRADES.calculating... kept=#{loggable_kept.inspect}"
|
2015-02-13 11:08:45 +08:00
|
|
|
end
|
2012-12-29 17:39:44 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def drop_unpointed(submissions, keep_highest, keep_lowest)
|
|
|
|
sorted_submissions = submissions.sort_by { |s| s[:score] }
|
|
|
|
sorted_submissions.last(keep_highest).first(keep_lowest)
|
|
|
|
end
|
2012-12-22 04:31:53 +08:00
|
|
|
|
2013-01-10 08:59:16 +08:00
|
|
|
def drop_pointed(submissions, cant_drop, n_highest, n_lowest)
|
2021-11-16 06:57:07 +08:00
|
|
|
max_total = (submissions + cant_drop).pluck(:total).max
|
2013-01-10 08:59:16 +08:00
|
|
|
|
|
|
|
kept = keep_highest(submissions, cant_drop, n_highest, max_total)
|
2021-10-20 05:23:50 +08:00
|
|
|
keep_lowest(kept, cant_drop, n_lowest, max_total)
|
2012-12-22 04:31:53 +08:00
|
|
|
end
|
|
|
|
|
2013-01-10 08:59:16 +08:00
|
|
|
def keep_highest(submissions, cant_drop, keep, max_total)
|
2019-05-15 05:34:33 +08:00
|
|
|
keep_helper(submissions, cant_drop, keep, max_total, keep_mode: :highest) { |*args| big_f_best(*args) }
|
2012-12-22 04:31:53 +08:00
|
|
|
end
|
|
|
|
|
2013-01-10 08:59:16 +08:00
|
|
|
def keep_lowest(submissions, cant_drop, keep, max_total)
|
2019-05-15 05:34:33 +08:00
|
|
|
keep_helper(submissions, cant_drop, keep, max_total, keep_mode: :lowest) { |*args| big_f_worst(*args) }
|
2012-12-22 04:31:53 +08:00
|
|
|
end
|
|
|
|
|
2021-11-16 06:05:02 +08:00
|
|
|
# @param submissions [Array<Submission>] set of droppable submissions
|
|
|
|
# @param cant_drop [Array<Submission>] submissions that are not eligible for dropping
|
|
|
|
# @param keep [Integer] number of submissions to keep from +submissions+
|
|
|
|
# @param max_total [Float] the highest number of points possible
|
|
|
|
# @yield sorting block for the big_f function
|
2013-01-10 08:59:16 +08:00
|
|
|
# returns +keep+ +submissions+
|
2021-11-16 06:05:02 +08:00
|
|
|
def keep_helper(submissions, cant_drop, keep, max_total, keep_mode: nil)
|
2012-12-22 04:31:53 +08:00
|
|
|
return submissions if submissions.size <= keep
|
|
|
|
|
2013-01-10 08:59:16 +08:00
|
|
|
unpointed, pointed = (submissions + cant_drop).partition do |s|
|
|
|
|
s[:total].zero?
|
2021-11-23 23:20:14 +08:00
|
|
|
end
|
2012-12-29 17:39:44 +08:00
|
|
|
|
2019-05-15 05:34:33 +08:00
|
|
|
kept = nil
|
|
|
|
if pointed.empty? && keep_mode == :lowest
|
|
|
|
# this is a really dumb situation that we saw in the wild. 17
|
|
|
|
# assignments, 2 of them have points possible, the rest have 0
|
|
|
|
# points possible with drop rules of drop 8 lowest and drop 7
|
|
|
|
# highest.
|
|
|
|
#
|
|
|
|
# In drop_pointed above, the call to keep_highest that
|
|
|
|
# goes here ends up eliminating the pointed assignments, so when
|
|
|
|
# keep_lowest is called, we end up here with unpointed
|
|
|
|
# assignments which completely breaks math. estimate_q_high
|
|
|
|
# comes back as NaN and q_low is nil. "(nil + NaN)/2" means
|
|
|
|
# you're gonna have a bad time.
|
|
|
|
#
|
|
|
|
# What we'll do instead is just sort by score like
|
|
|
|
# drop_unpointed above, and drop the unpointed
|
|
|
|
# ones up to keep.
|
|
|
|
kept = unpointed.sort_by { |s| s[:score].to_f }[-keep, keep]
|
|
|
|
else
|
|
|
|
grades = pointed.map { |s| s[:score].to_f / s[:total] }.sort
|
2013-02-17 07:42:10 +08:00
|
|
|
|
2019-05-15 05:34:33 +08:00
|
|
|
q_high = estimate_q_high(pointed, unpointed, grades)
|
|
|
|
q_low = grades.first
|
|
|
|
q_mid = (q_low + q_high) / 2
|
2013-02-17 07:42:10 +08:00
|
|
|
|
2021-11-16 06:05:02 +08:00
|
|
|
x, kept = yield(q_mid, submissions, cant_drop, keep)
|
2021-09-27 23:58:39 +08:00
|
|
|
threshold = 1 / (2 * keep * (max_total**2))
|
2019-05-15 05:34:33 +08:00
|
|
|
until q_high - q_low < threshold
|
|
|
|
if x < 0
|
|
|
|
q_high = q_mid
|
2021-11-20 05:10:36 +08:00
|
|
|
else
|
2019-05-15 05:34:33 +08:00
|
|
|
q_low = q_mid
|
2021-11-20 05:10:36 +08:00
|
|
|
end
|
2019-05-15 05:34:33 +08:00
|
|
|
q_mid = (q_low + q_high) / 2
|
|
|
|
|
|
|
|
# bail if we can't can't ever satisfy the threshold (floats!)
|
|
|
|
break if q_mid == q_high || q_mid == q_low
|
|
|
|
|
2021-11-16 06:05:02 +08:00
|
|
|
x, kept = yield(q_mid, submissions, cant_drop, keep)
|
2019-05-15 05:34:33 +08:00
|
|
|
end
|
2012-12-22 04:31:53 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
kept
|
|
|
|
end
|
|
|
|
|
2013-01-10 08:59:16 +08:00
|
|
|
def big_f(q, submissions, cant_drop, keep, &sort_blk)
|
2012-12-22 04:31:53 +08:00
|
|
|
kept = submissions.map do |s|
|
2021-09-27 23:58:39 +08:00
|
|
|
rated_score = s[:score] - (q * s[:total])
|
2012-12-22 04:31:53 +08:00
|
|
|
[rated_score, s]
|
|
|
|
end.sort(&sort_blk).first(keep)
|
|
|
|
|
|
|
|
q_kept = kept.reduce(0) { |sum, (rated_score, _)| sum + rated_score }
|
2021-09-27 23:58:39 +08:00
|
|
|
q_cant_drop = cant_drop.reduce(0) { |sum, s| sum + (s[:score] - (q * s[:total])) }
|
2013-01-10 08:59:16 +08:00
|
|
|
|
|
|
|
[q_kept + q_cant_drop, kept.map(&:last)]
|
2012-12-22 04:31:53 +08:00
|
|
|
end
|
|
|
|
|
2012-12-29 17:39:44 +08:00
|
|
|
# we can't use the student's highest grade as an upper-bound for bisection
|
|
|
|
# when 0-points-possible assignments are present, so guess the best possible
|
|
|
|
# grade the student could have earned in that case
|
|
|
|
def estimate_q_high(pointed, unpointed, grades)
|
|
|
|
if unpointed.present?
|
|
|
|
points_possible = pointed.reduce(0) { |sum, s| sum + s[:total] }
|
|
|
|
best_pointed_score = [
|
|
|
|
points_possible, # 100%
|
|
|
|
pointed.reduce(0) { |sum, s| sum + s[:score] } # ... or extra credit
|
|
|
|
].max
|
|
|
|
unpointed_score = unpointed.reduce(0) { |sum, s| sum + s[:score] }
|
|
|
|
max_score = best_pointed_score + unpointed_score
|
|
|
|
max_score.to_f / points_possible
|
|
|
|
else
|
|
|
|
grades.last
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-12-22 04:31:53 +08:00
|
|
|
# determines the best +keep+ assignments from submissions for the given q
|
|
|
|
# (suitable for use with drop_lowest)
|
2013-01-10 08:59:16 +08:00
|
|
|
def big_f_best(q, submissions, cant_drop, keep)
|
|
|
|
big_f(q, submissions, cant_drop, keep) { |(a, _), (b, _)| b <=> a }
|
2012-12-22 04:31:53 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
# determines the worst +keep+ assignments from submissions for the given q
|
|
|
|
# (suitable for use with drop_highest)
|
2013-01-10 08:59:16 +08:00
|
|
|
def big_f_worst(q, submissions, cant_drop, keep)
|
|
|
|
big_f(q, submissions, cant_drop, keep) { |(a, _), (b, _)| a <=> b }
|
2012-12-22 04:31:53 +08:00
|
|
|
end
|
2013-04-30 08:29:45 +08:00
|
|
|
|
2017-10-05 02:34:31 +08:00
|
|
|
def gather_dropped_from_group_scores(group_sums)
|
2021-11-16 06:57:07 +08:00
|
|
|
dropped = group_sums.pluck(:dropped)
|
2017-10-05 02:34:31 +08:00
|
|
|
dropped.flatten!
|
|
|
|
dropped.uniq!
|
|
|
|
dropped
|
|
|
|
end
|
|
|
|
|
2013-04-30 08:29:45 +08:00
|
|
|
# returns grade information from all the assignment groups
|
2013-01-12 07:32:38 +08:00
|
|
|
def calculate_total_from_group_scores(group_sums)
|
2017-10-05 02:34:31 +08:00
|
|
|
dropped = gather_dropped_from_group_scores(group_sums)
|
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
if @course.group_weighting_scheme == "percent"
|
2013-01-12 07:32:38 +08:00
|
|
|
relevant_group_sums = group_sums.reject do |gs|
|
|
|
|
gs[:possible].zero? || gs[:possible].nil?
|
2021-11-23 23:20:14 +08:00
|
|
|
end
|
2013-01-12 07:32:38 +08:00
|
|
|
final_grade = relevant_group_sums.reduce(0) do |grade, gs|
|
2021-09-27 23:58:39 +08:00
|
|
|
grade + ((gs[:score].to_d / gs[:possible]) * gs[:weight].to_d)
|
2021-11-23 23:20:14 +08:00
|
|
|
end
|
2013-01-12 07:32:38 +08:00
|
|
|
|
|
|
|
# scale the grade up if total weights don't add up to 100%
|
|
|
|
full_weight = relevant_group_sums.reduce(0) { |w, gs| w + gs[:weight] }
|
|
|
|
if full_weight.zero?
|
|
|
|
final_grade = nil
|
|
|
|
elsif full_weight < 100
|
|
|
|
final_grade *= 100.0 / full_weight
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
2013-01-12 07:32:38 +08:00
|
|
|
|
2018-05-29 22:57:10 +08:00
|
|
|
rounded_grade = final_grade&.to_f.try(:round, 2)
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
{
|
2018-05-29 22:57:10 +08:00
|
|
|
grade: rounded_grade,
|
|
|
|
total: rounded_grade,
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
dropped: dropped
|
2013-01-12 07:32:38 +08:00
|
|
|
}
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
else
|
|
|
|
total, possible = group_sums.reduce([0, 0]) { |(m, n), gs| [m + gs[:score], n + gs[:possible]] }
|
2013-01-12 07:32:38 +08:00
|
|
|
if possible > 0
|
|
|
|
final_grade = (total.to_f / possible) * 100
|
2013-04-30 08:29:45 +08:00
|
|
|
{
|
2018-11-16 05:00:55 +08:00
|
|
|
grade: final_grade.round(2).to_f,
|
2017-10-05 02:34:31 +08:00
|
|
|
total: total.to_f,
|
2018-11-16 05:00:55 +08:00
|
|
|
possible: possible.to_f,
|
2017-10-05 02:34:31 +08:00
|
|
|
dropped: dropped
|
2013-04-30 08:29:45 +08:00
|
|
|
}
|
2013-01-12 07:32:38 +08:00
|
|
|
else
|
Store points and points_possible for all Scores
closes GRADE-8
test plan:
Store points and points_possible for all Scores
closes GRADE-8
test plan:
** Setup
* Create a course in a term with two grading periods GP1 and GP2
* Weight the grading periods as: GP1: 30%, GP2: 70%
* Create four assignment groups AG1, AG2, AG3 and AG4
- Ensure the assignment groups have a rule to drop the 1 lowest
score
* Weight the assignment groups as: AG1: 15%, AG2: 20%, AG3: 25%, AG4: 40%
* Create three assignments in AG1, AG1-1, AG1-2, AG1-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG1-1: 5, AG1-2: 10, AG1-3: 15
- Mute AG1-1
* Create three assignments in AG2, AG2-1, AG2-2, AG2-3
- Ensure they're all due in GP1
- Ensure they have the following points possible:
AG2-1: 5, AG2-2: 10, AG2-3: 15
- Mute AG2-2
* Create three assignments in AG3, AG3-1, AG3-2, AG3-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG3-1: 5, AG3-2: 10, AG3-3: 15
- Mute AG3-3
* Create three assignments in AG4, AG4-1, AG4-2, AG4-3
- Ensure they're all due in GP2
- Ensure they have the following points possible:
AG4-1: 5, AG4-2: 10, AG4-3: 15
- Mute AG4-1
* Enroll one student in this course
* Go to the Gradebook and ensure you're viewing all grading periods
* Assign the following grades to the student:
AG1-1: 3
AG1-2: 8
AG1-3: 5
AG2-1: 4
AG2-2: 6
AG2-3: 10
AG3-1: 2
AG3-2: 9
AG3-3: 14
AG4-1: 1
AG4-2: 7
AG4-3: 12
** Validating Assignment Group Scores
* Assuming your newly created course's id is course_id, run the
following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:current_points)
* Verify that this returns [8.0, 4.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:final_points)
* Verify that this returns [8.0, 10.0, 9.0, 12.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(assignment_group_id: nil).order(assignment_group_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [11.0, 14.0, 23.0, 19.0]
** Validating Grading Period Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:current_points)
* Verify that this returns [80.0, 83.85]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:final_points)
* Verify that this returns [45.71, 50.77]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_current_points)
* Verify that this returns [71.43, 82.15]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where.not(grading_period_id: nil).order(grading_period_id: :asc).
pluck(:unposted_final_points)
* Verify that this returns [71.43, 82.15]
** Validating Total Scores
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:final_points)
* Verify that this returns [49.25]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_current_points)
* Verify that this returns [82.7]
* Run the following command from the Rails console:
Score.where(enrollment: Course.find(course_id).enrollments).
where(course_score: true).pluck(:unposted_final_points)
* Verify that this returns [49.25]
Change-Id: I6a107f09bc43d6e82eab4e3476313380f3e5d819
Reviewed-on: https://gerrit.instructure.com/137257
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-01-09 07:41:49 +08:00
|
|
|
{
|
|
|
|
grade: nil,
|
|
|
|
total: total.to_f,
|
|
|
|
dropped: dropped
|
|
|
|
}
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-02-13 11:08:45 +08:00
|
|
|
|
|
|
|
# this takes a wrapped submission (like from create_group_sums)
|
|
|
|
def loggable_submission(wrapped_submission)
|
|
|
|
{
|
|
|
|
assignment_id: wrapped_submission[:assignment].id,
|
|
|
|
score: wrapped_submission[:score],
|
|
|
|
total: wrapped_submission[:total],
|
|
|
|
}
|
|
|
|
end
|
2017-07-06 02:03:02 +08:00
|
|
|
|
2019-05-04 02:29:33 +08:00
|
|
|
def ignore_submission?(submission:, assignment:)
|
|
|
|
return false unless @ignore_muted
|
|
|
|
|
2020-03-03 05:16:01 +08:00
|
|
|
# If we decided to ignore this submission earlier in this run (see
|
|
|
|
# create_group_sums), it will be nil, in which case keep ignoring it
|
|
|
|
submission.blank? || !submission.posted?
|
2019-05-04 02:29:33 +08:00
|
|
|
end
|
2011-04-12 02:30:31 +08:00
|
|
|
end
|