Commit Graph

137 Commits

Author SHA1 Message Date
Jacob Burroughs 7109a6cbae Clean up more bulk update warnings
refs AE-158

Change-Id: Ibede015c86ec7f04bab5235ed57acc42a4659b8f
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/317117
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Jacob Burroughs <jburroughs@instructure.com>
Product-Review: Jacob Burroughs <jburroughs@instructure.com>
2023-05-02 15:08:03 +00:00
Cody Cutrer 502aa068da rubocop: Layout/Multiline*LineBreaks
[skip-stages=Flakey]

Change-Id: I24912809267088bc19a4082c49bc5f78ca7b76bb
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/317302
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
Build-Review: Jacob Burroughs <jburroughs@instructure.com>
Migration-Review: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2023-05-01 19:31:42 +00:00
Aaron Shafovaloff c33d6b9e07 updated .coffee-related comments
Change-Id: I3057ac993ca5e846deae98c8a3e29b2609c07231
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/315700
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Drake Harper <drake.harper@instructure.com>
QA-Review: Drake Harper <drake.harper@instructure.com>
Product-Review: Drake Harper <drake.harper@instructure.com>
2023-04-20 17:39:28 +00:00
Jacob Burroughs b8940e7594 Fix some more bulk updates
refs AE-158

Change-Id: I3d1e4c35d85ccf978de0b09d5700575e255e979a
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/315450
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Aaron Ogata <aogata@instructure.com>
QA-Review: Jacob Burroughs <jburroughs@instructure.com>
Product-Review: Jacob Burroughs <jburroughs@instructure.com>
2023-04-11 15:07:24 +00:00
Isaac Moore d6584b490a Remove unnecessary require statements
closes AE-30

flag=none

test plan:
- verify Canvas boots in CD
- verify no influx of new errors in CD

[fsc-timeout=30]

Change-Id: Ifa04bebe1b09f01c6d3b8b2d8f3bb424759730f5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/308067
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Isaac Moore <isaac.moore@instructure.com>
Product-Review: Isaac Moore <isaac.moore@instructure.com>
Build-Review: James Butters <jbutters@instructure.com>
2023-01-04 21:38:21 +00:00
Jacob Burroughs 5dcd66d8c6 Some rails 7 tests passing
Change-Id: Iad400936d7e53a5f92644f260c95bfb5bf9e972f
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/293144
QA-Review: Jacob Burroughs <jburroughs@instructure.com>
Product-Review: Jacob Burroughs <jburroughs@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: August Thornton <august@instructure.com>
Reviewed-by: Alex Slaughter <aslaughter@instructure.com>
Migration-Review: Alex Slaughter <aslaughter@instructure.com>
2022-06-06 14:23:03 +00:00
Aaron Ogata 2339e86b23 strand ScoreStatisticsGenerator by root account ID
refs DE-1084

Prior to this change, an unlimited number of ScoreStatisticsGenerator
jobs could be run at once, which had the potential to overload the DB.
After this change, the number of simultaneously running jobs is capped
at 1 per root account by default. In order to change this, run:

```
Setting.set("ScoreStatisticsGenerator_num_strands", 10)
```

Change-Id: Ib9a24a04134c3ec0d621b2a81b1366541afc8ece
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/287069
QA-Review: Aaron Ogata <aogata@instructure.com>
Product-Review: Aaron Ogata <aogata@instructure.com>
Reviewed-by: Keith Garner <kgarner@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2022-03-14 21:14:51 +00:00
Cody Cutrer c2cba46851 RuboCop: Style/StringLiterals, Style/StringLiteralsInInterpolation
[skip-stages=Flakey]

auto-corrected

Change-Id: I4a0145abfd50f126669b20f3deaeae8377bac24d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/279535
Tested-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Migration-Review: Cody Cutrer <cody@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
2021-11-25 14:03:06 +00:00
Cody Cutrer 9b71ed2054 RuboCop: Style/BlockDelimiters, Style/Lambda
[skip-stages=Flakey]

auto-corrected

Change-Id: I642f868d75c079e698f1fe4161bbbe419dbe1827
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/279374
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Migration-Review: Cody Cutrer <cody@instructure.com>
2021-11-23 21:30:47 +00:00
Cody Cutrer c776b6ef3a RuboCop: Style/CommentAnnotation
[skip-stages=Flakey]

auto-corrected

Change-Id: Ic82dbc22b8e63cc5f2ccb9b561cb3b9ed6628966
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/279100
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Migration-Review: Cody Cutrer <cody@instructure.com>
2021-11-21 00:50:46 +00:00
Cody Cutrer ecd0798aeb RuboCop: Style grab bag
[skip-stages=Flakey]

see .rubocop.common.yml changes for enabled cops

auto-corrected

Change-Id: Ia63a1c597c58646394b251ce81b707f32828bd4c
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/279010
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Migration-Review: Cody Cutrer <cody@instructure.com>
2021-11-20 03:04:04 +00:00
Cody Cutrer 9792b6780d RuboCop: Performance/RedundantBlockCall
[skip-stages=Flakey]

auto-corrected, with a few post-correction tweaks

Change-Id: Ic8ad959a4c331ae879644f473ffda20e63e353e9
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278341
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-17 20:03:24 +00:00
Cody Cutrer e0c69c330e RuboCop: Rails/Pluck
[skip-stages=Flakey]

auto-corrected

Change-Id: Iaad8a0eeece0bb57dae8f274ce4b98766b6f0261
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278362
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-17 20:00:28 +00:00
Cody Cutrer 2bc9e0e304 RuboCop: Rails/IndexBy
auto-corrected

Change-Id: I7f6ca0f5a10a2f04849c5d0378641e2d3e8fc704
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278485
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-17 15:16:45 +00:00
Cody Cutrer 1c51242f3d RuboCop: Rails/IndexWith
[skip-stages=Flakey]

auto-corrected

Change-Id: I2e2cf6f21942df3a3531d2fdc08e260586375960
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278482
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-17 15:16:37 +00:00
Cody Cutrer 58eb4175fb RuboCop: Performance/MapCompact
[skip-stages=Flakey]

auto-corrected

Change-Id: I9e768e051924cfe58bf282f85d3cf6ca48735e9d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278264
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-16 16:20:07 +00:00
Cody Cutrer e50edd485f RuboCop: heredocs
[skip-stages=Flakey]

Naming/HeredocDelimiterNaming and Rails/SquishedSQLHeredocs

the former was manual, the latter was automatic. I also changed
some <<- to <<~ to allow for better formatting

I also had to change comments inside squished SQL heredocs to
be block comments (since newlines are removed); searching for those
I found some multi-line strings that are better as heredocs

Change-Id: I6b138f8e32544b97df1e4c56f09ee5316cbdef9d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278184
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-16 06:36:00 +00:00
Cody Cutrer ba1fdaf2a9 RuboCop: Style/ConditionalAssignment
auto-corrected

Change-Id: Ie87e4c1b6c05bc31ce13481a94c413dcf7b20278
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/277964
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-11 17:39:06 +00:00
Cody Cutrer 7fdf9d7588 RuboCop: Lint
[skip-stages=Flakey]

the balance. mostly. Lint/UriEscapeUnescape is put in the pending
block because it's so touchy, and I didn't want to deal with it
right now

all manual

Change-Id: Ibeb81e013f56f160d51f7d237a9bcfe98daa1e53
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/277569
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-09 21:42:31 +00:00
Cody Cutrer 44614b47d7 RuboCop: Lint/UselessAssignment app, config, doc, gems, lib
(everything except spec)

all manual

Change-Id: I6c49a3139efb0f0802ba63a15cab4d4d2cd0b8dd
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/276310
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-10-27 15:36:29 +00:00
Cody Cutrer dbd8c46655 RuboCop: Lint
[skip-stages=Flakey]

auto corrections applied:
 * Lint/AmbiguousOperator
 * Lint/AmbiguousOperatorPrecedence
 * Lint/AmbiguousRegexpLiteral
 * Lint/DeprecatedClassMethods
 * Lint/DeprecatedOpenSSLConstant
 * Lint/NonDeterministicRequireOrder
 * Lint/ParenthesesAsGroupedExpression
 * Lint/RedundantRequireStatement
 * Lint/RedundantSafeNavigation
 * Lint/RedundantSplatExpansion
 * Lint/RedundantStringCoercion
 * Lint/RedundantWithIndex
 * Lint/SendWithMixinArgument
 * Lint/SymbolConversion

Change-Id: I222ec19978033544513bb99755994d109435abad
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274551
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-09-29 03:38:23 +00:00
Cody Cutrer c65d57737a RuboCop: Layout lib
Change-Id: I0655d9a9d750f2debd6378b03d8ddc1403ebc31b
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274158
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-09-22 20:01:52 +00:00
Cody Cutrer dbe392f43d fix deadlock in GradeCalculator
fixes FOO-1450

Change-Id: Idb63e95fc728b4f063db25bcd54d5a419729aff4
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/263388
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Keith Garner <kgarner@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-04-21 19:48:18 +00:00
Spencer Olson 8b4661a0ff gradebook export: exclude anon unposted submissions in totals
closes EVAL-1333
flag=grade_calc_ignore_unposted_anonymous

Test Plan:
1. Enable the 'Ignore Unposted Anonymous Assignments in Grade
   Calculation' release flag. Create an anonymous assignment and
   grade some students.
2. Before posting the assignment, export the gradebook. Verify:
   - The CSV includes a column for the anonymous assignment.
   - The CSV totals (assignment group and final grade) exclude the
     scores for the anonymous assignment in their calculations.
3. Disable the 'Ignore Unposted Anonymous Assignments in Grade
   Calculation' release flag.
4. Re-export the gradebook. Verify:
   - The CSV includes a column for the anonymous assignment.
   - The CSV totals (assignment group and final grade) include the
     scores for the anonymous assignment in their calculations.
5. Post the assignment to students. Then export the gradebook again and
   verify the exported CSV includes a column for the anonymous
   assigment the totals include the scores for the anonymous
   assignment.
6. Re-enable the 'Ignore Unposted Anonymous Assignments in Grade
   Calculation' release flag and re-export the Gradebook. Verify the
   exported CSV includes a column for the anonymous assigment the
   totals include the scores for the anonymous assignment.

Change-Id: If83237344ee16c9f6621c5d58cfb49e2da099f7b
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/254081
Product-Review: Syed Hussain <shussain@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Gary Mei <gmei@instructure.com>
Reviewed-by: Gary Mei <gmei@instructure.com>
Reviewed-by: Adrian Packel <apackel@instructure.com>
2020-12-17 17:10:13 +00:00
Keith T. Garner 7fd0528c3a log expected exceptions and retry grade jobs
This catches expected exceptions from the GradeCalculator and
DueDateCacher, logs them, and then signals to delayed jobs to retry.

test plan:
 - specs pass

Change-Id: I7851c1df59c43facd621c7aab7fbc29fd6ff6fd9
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/254962
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Syed Hussain <shussain@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
QA-Review: Keith Garner <kgarner@instructure.com>
Product-Review: Keith Garner <kgarner@instructure.com>
2020-12-14 19:26:24 +00:00
Spencer Olson b0df8f5fac grade calculator: ignore unposted anonymous assignments
closes EVAL-1272
flag=grade_calc_ignore_unposted_anonymous

Test Plan:
1. Enable the 'Ignore Unposted Anonymous Assignments in Grade
   Calculation' release flag. Create an anonymous assignment and
   grade some students.
2. Before posting the assignment, enter a rails console and check the
   unposted_* scores for the students. Verify:
   - The unposted_* scores do not include the submission score from the
     anonymous unposted assignment.
3. Disable the 'Ignore Unposted Anonymous Assignments in Grade
   Calculation' release flag.
4. Enter a rails console again and check the unposted_* scores for the
   students. Verify:
   - The unposted_* scores include the submission score from the
     anonymous unposted assignment.
5. Post the assignment to students. Then enter a rails console again and
   verify the unposted_* scores for the students include the submission
   score from the anonymous (now posted) assignment.
6. Re-enable the 'Ignore Unposted Anonymous Assignments in Grade
   Calculation' release flag. Verify the unposted_* scores for the
   students include the submission score from the anonymous (now posted)
   assignment.

Change-Id: Ibb42b9f3164c08e3bc2a21fc02736760f58af51a
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/251786
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Product-Review: Syed Hussain <shussain@instructure.com>
Reviewed-by: Adrian Packel <apackel@instructure.com>
Reviewed-by: Gary Mei <gmei@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
2020-12-14 15:52:36 +00:00
Cody Cutrer e0b6115162 update scores in order to avoid deadlocks
fixes FOO-1201

Change-Id: I96d43545cf165bec3603430acab0ef47fe9f20c4
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/254170
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2020-12-08 16:41:04 +00:00
Spencer Olson 6929c029f9 remove grade_calculator_performance_improvements release flag
closes EVAL-1285
flag=grade_calculator_performance_improvements

Test Plan:
- specs pass

Change-Id: Ic60680a0bf9936b0b39b728b8caf93ffc90e6b84
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/251886
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
Reviewed-by: Adrian Packel <apackel@instructure.com>
Product-Review: Syed Hussain <shussain@instructure.com>
QA-Review: Spencer Olson <solson@instructure.com>
2020-11-05 15:38:27 +00:00
Cody Cutrer 06763dd519 add # frozen_string_literal: true for lib
Change-Id: I59b751cac52367a89e03f572477f0cf1d607b405
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/251155
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2020-10-27 20:49:50 +00:00
Cody Cutrer dfc0fe5f6a ruby 2.7/rails 6: several deprecation warning and spec fixes
Change-Id: I6314b3f304e8befc18ee2f832993a0740690d786
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/249956
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2020-10-14 16:13:04 +00:00
Gary Mei a97aeb35ea fix grade calculator with postgres 12
Switching to postgres 12 exposed some float addition that was resulting
in long precision. It looks like 9.5 was hiding that helpfully, but the
behavior isn't guaranteed and somewhere from 9.5 to 12 had changes in
that regard.

fixes EVAL-1104
flag=none

Test Plan
- Have postgres12.
- Have 2 assignments worth 1000 points each.
- Give a grade of 142.7 and a grade of 99.6.
- Verify in a console that there isn't floating point weirdness for the
user's scores.

Change-Id: Ic2c85a12909a3c99d7a58351ca9b4f0df4ff656e
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/245252
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Keith Garner <kgarner@instructure.com>
Reviewed-by: Syed Hussain <shussain@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Syed Hussain <shussain@instructure.com>
2020-08-19 19:25:00 +00:00
Spencer Olson 5a455d414a set root_account_id on scores
closes TALLY-704
flag=none

Test Plan:

1. Create a brand-new course and add some students.
2. Verify that all scores associated with the course have a
   root_account_id set:

   c = Course.find(<id>)
   scores = Score.where(enrollment: c.all_enrollments)
   scores.pluck(:root_account_id) # should all be set (not null)

Change-Id: I549d82c40a2057cc1fdcff604b5e5e7a9285f0ac
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/239417
Reviewed-by: Gary Mei <gmei@instructure.com>
Reviewed-by: Adrian Packel <apackel@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Syed Hussain <shussain@instructure.com>
Product-Review: Syed Hussain <shussain@instructure.com>
2020-06-18 16:38:40 +00:00
Keith T. Garner c62b2787f2 rewrite grades presenter course score statistic to be cached
This caches the averages for the teacher's grade as part of the score
statistics generator. This rewrite removes the need for a course-level
cache busting as it was only used

closes TALLY-851
flag=none

test plan:
 - Have a few courses with a few assignments and a few students
 - As a teacher, grade the students
 - As a teacher, go to /grades
 - Ensure values for all the teacher's courses appear
 - Ensure the values are correct (i.e. the average of each courses
   current scores for all active and invited enrollments)

Change-Id: Ieeb5ddb734d8bc21f40196014d062b9ba5935ebd
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/234109
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Adrian Packel <apackel@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Product-Review: Keith Garner <kgarner@instructure.com>
2020-04-23 19:37:50 +00:00
Keith T. Garner acaceb1a0d touch the course in grade calculator less often
We invalidate the course cache by touching the course too often. This
can cause issues in the database at scale. This patchset only touches
the course once after all the calculator work is done.

closes TALLY-849

test plan:
 - specs pass

Change-Id: Id006b9618ab89c003bd2d4b354247036dca9ce09
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/234082
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
QA-Review: Keith Garner <kgarner@instructure.com>
Product-Review: Keith Garner <kgarner@instructure.com>
2020-04-16 14:37:05 +00:00
Spencer Olson 14da94d954 fix observer N+1s in grade calculator
closes TALLY-792
flag=grade_calculator_performance_improvements

Fixes N+1s around observers, observer alerts, and observer alert
thresholds.

Test Plan:
1. Enable the 'Grade Calculator Performance Improvements' release
   flag at /accounts/site_admin/settings
2. Smoke test to make sure observers receive 'course_grade_high'
   and 'course_grade_low' alerts when an observee gets graded and the
   grade is above or below the set threshold, respectively.
3. Disable the 'Grade Calculator Performance Improvements' release
   flag at /accounts/site_admin/settings. Repeat step 2.

Change-Id: Ie9c3139006fed9eeec9af0aababad87bb6adb8df
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/232210
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Gary Mei <gmei@instructure.com>
Reviewed-by: Keith Garner <kgarner@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: Spencer Olson <solson@instructure.com>
2020-04-06 16:25:09 +00:00
Jeremy Neander e2adb9568f remove post policy check from grade calculator
refs TALLY-564
flag = none

test plan:
 * Verify Jenkins passes

Change-Id: I7ac67761d918392e3a9bc9493631f30e0dfbc6de
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/228598
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Keith Garner <kgarner@instructure.com>
QA-Review: Jeremy Neander <jneander@instructure.com>
Product-Review: Jeremy Neander <jneander@instructure.com>
2020-03-02 22:32:40 +00:00
Evan Battaglia 66315ea980 course_grade_change live event
Fires any time a student's course grade has changed.
Dig needs this event.

This also updates ObserverAlerts to only make one alert per
student+course in the case that the student is enrolled in multiple
sections of the same course. (Checked with mobile team to make sure
this is OK).

It also moves creating the alerts until after calculate_hidden_scores.
This shouldn't matter because the hidden (unposted) scores don't affect
the ObserverAlerts which only care about current_score. (Really we
could ignore the observer alert code if @ignore_muted is true
but I didn't want to change too much. Likewise, @ignore_muted
and @emit_live_event should be synonymous but I wanted to be explicit
and not rely on that always being the case.)

This also reloads scores all at once instead of individually, which
means less SQL queries and simplifies the code (especially since
reloading an object undoes the preloading of the enrollment).

refs PLAT-5189
flag=none

Test plan:
- Add `puts JSON.pretty_generate(event)` to
  gems/live_events/lib/live_events/client.rb:103 (#post_event) to see
  events locally
- watch for live events when going through various workflows which
  change course grades and make sure only one event per course+student is
  emitted
  1. change an assignment grade for a student enrolled in multiple
     sections -- only one event should be triggered
  2. group assignments
  3. a call to compute_and_save_scores where
     @update_all_grading_period_scores is true (we start grading a
     course/student and this kicks off scoring of all grading period
     scores)
  4. a call to compute_and_save_scores where @update_course_score is
     true (we start by scoring a grading period and this starts scoring the
     related student/course)
  5. any thing else we can think of. grade_calculator experts or other
     product experts may be able to suggest other scenarios.
- test these scenarios out with the "observer alerts" in the Canvas
  Parent mobile app to make sure these events still work right.

Change-Id: I1d6d530149962a97890656566e26bc32dbb4c190
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/219208
Tested-by: Jenkins
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Product-Review: Oxana Jurosevic
Reviewed-by: Matt Sessions <msessions@instructure.com>
Reviewed-by: Xander Moffatt <xmoffatt@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
QA-Review: Tucker Mcknight <tmcknight@instructure.com>
2019-12-18 23:06:59 +00:00
Keith Garner add2814bc9 Revert "remove transaction around saving scores"
According to sentry removing the transaction made the deadlock problem worse. Reverting until a new approach can be had.

test plan:
 - grade calculator specs pass

This reverts commit 8aacb717cc.

Change-Id: I7899641b6e6f8430fa343bf9f1bd4ef6fe9822ea
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/215436
Tested-by: Jenkins
QA-Review: Keith Garner <kgarner@instructure.com>
Product-Review: Keith Garner <kgarner@instructure.com>
Reviewed-by: Nick Pitrak <npitrak@instructure.com>
2019-11-01 14:14:10 +00:00
Keith T. Garner 8aacb717cc remove transaction around saving scores
Removes a database transaction in the grade calculator that is scoped
around too much work.  The transaction was originally added before
postgres's upsert capability for two statements. Over time, more and
more work was added leading to deadlocks in production.

test plan:
 - spec pass

Change-Id: Ia95035be6934b148f8d836bf4419f978a0b45918
Reviewed-on: https://gerrit.instructure.com/212873
Reviewed-by: Spencer Olson <solson@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
QA-Review: Keith Garner <kgarner@instructure.com>
Product-Review: Keith Garner <kgarner@instructure.com>
2019-10-14 17:39:40 +00:00
Adrian Packel d561e2070d Make muted/unposted droppable once more
When the grade calculator attempts to apply drop rules, don't
automatically exempt muted assignments (or unposted submissions in the
case of Post Policies) from being dropped. Continue treating them as 0
points (if computing final score) or ignoring them altogether (if
computing posted score), but generally allow them to be dropped. This
fixes a calculation issue that could occur for an assignment group with
drop rules: muted/unposted submissions that should have been dropped
completely were still included (but treated as 0 points), with the
result that the group's points_possible value was higher than could ever
have been attained given the drop rules in place.

fixes GRADE-2356

Test plan:
- Have a course with New Gradebook and Post Policies enabled
- Set up an assignment group
  - Add 2 assignments worth 10 points each
  - Set a drop rule to drop the lowest assignment
- Open Gradebook
  - Grade a student on the first assignment but not the second
- Export to CSV
  - The "final score" column should reflect just the one graded
    assignment and should not treat the ungraded assignment as 0

- Repeat this setup in an Old Gradebook course
  - Mute the second assignment (to make it "unposted")
- Export to CSV
  - The "final score" column should be the same as above

Change-Id: I91903d481fcbedf60180e5dcabe96106308586e9
Reviewed-on: https://gerrit.instructure.com/205856
Product-Review: Keith Garner <kgarner@instructure.com>
Tested-by: Jenkins
Reviewed-by: Keith Garner <kgarner@instructure.com>
Reviewed-by: Gary Mei <gmei@instructure.com>
QA-Review: Derek Bender <djbender@instructure.com>
2019-08-21 15:28:50 +00:00
Adrian Packel eab8b85148 Fix post policy-related grade calculator issues
- A variable named "submission" was actually a hash containing (among
  other things) a submission and an assignment, so checking
  submission.posted? was not okay
- Moreover, the submission that said submission-hash contained could
  have been set to nil if the submission had not yet been posted (or, in
  the pre-post-policies world, the assignment was muted). This wasn't an
  issue before, but became one since with post policies we check
  individual submissions.

fixes GRADE-2268

Test plan:
- Specs pass
- Enable post policies/new gradebook
- Have a course with assignment groups and a drop rule (at least one
  "drop highest" or "drop lowest")
- Assign some grades
- Grade calculator should not cause an error

Change-Id: I3a94e7ee4808cc6f38f247b6ee9652ddf6e7f6d0
Reviewed-on: https://gerrit.instructure.com/199187
Tested-by: Jenkins
Reviewed-by: Keith Garner <kgarner@instructure.com>
QA-Review: Adrian Packel <apackel@instructure.com>
Product-Review: Keith Garner <kgarner@instructure.com>
2019-06-27 16:46:27 +00:00
Adrian Packel bfbe2faac9 Move post policies to setting, tie to NG
Convert post policies from a garden-variety feature flag into a global
setting and remove the old feature flag. Add some helper methods to
handle enabling and disabling, and have everywhere in the code that
references the feature use the new helper methods instead. Also, have
the activation of post policies for a given course depend on whether new
gradebook is active for that course.

closes GRADE-1974

Test plan:

Note that the Post Policies feature flag no longer exists, and instead
there's a setting you'll need to turn on. You can do so in the console
using:
  > PostPolicy.enable_feature!

To disable it:
  > PostPolicy.disabled_feature!

Note that, even when enabled, it should only apply to courses that have
new gradebook turned on.

- With the new setting ENABLED:
  - Courses with new gradebook behave as though post policies is enabled
    - Do a bit of smoke testing to see if stuff like posting/hiding and
      changing assignment posting policies hasn't broken
  - Courses with old gradebook do not
    - For example, calling a mutation like postAssignmentGrades on an OG
      course should return an error indicating the feature isn't enabled
- With the new setting DISABLED:
  - Courses with new gradebook behave as though post policies is
    disabled (e.g., old-style muting is active)
    - Calling a mutation, as described above, should return an error

Change-Id: I5e223d2c4ca4202cce0641f316ecaa505a66298c
Reviewed-on: https://gerrit.instructure.com/196062
Tested-by: Jenkins
Reviewed-by: Keith Garner <kgarner@instructure.com>
Reviewed-by: Gary Mei <gmei@instructure.com>
QA-Review: Derek Bender <djbender@instructure.com>
Product-Review: Keith Garner <kgarner@instructure.com>
2019-06-13 22:09:06 +00:00
Gary Mei 7c953cfed8 update submission details page to check posted
When Post Policies is enabled, the submission details page will check
that the submission is posted. Otherwise, it checks if the assignment
is muted.

closes GRADE-1995

Test Plan
- Enable Post Policies.
- Create an assignment graded with a rubric.
- Grade a submission via the rubric.
- Leave comments on the submission as the teacher.
- Leave comments on the submission as the student.
- Hide the submission.
- As a teacher, verify that you can see the rubric assessment and all
  comments.
- As the student, verify that you can see a blank rubric assessment
  and only the student's own comments.

- Post submissions. As both the teacher and student, verify that you
  can see all comments, rubric assessment, and the grade.

- Verify that when Post Policies is off, the assignment muted state
  is what determines the above, rather than the submission's posted
  state.

Change-Id: Id1662f43c24250a0ed6750a1f83f81ff5952ad95
Reviewed-on: https://gerrit.instructure.com/196253
Tested-by: Jenkins
Reviewed-by: Keith Garner <kgarner@instructure.com>
Reviewed-by: Adrian Packel <apackel@instructure.com>
QA-Review: Gary Mei <gmei@instructure.com>
Product-Review: Jonathan Fenton <jfenton@instructure.com>
2019-06-05 18:57:13 +00:00
Keith T. Garner 5adef8970e fix crash in backend grade calculator
This fixes a very specific corner case in the grade calculator. When
drop rules eliminated all pointed assignments in the drop highest
phase and ended up with only unpointed assignments being considered in
the dropped lowest phase the grade calculator would error out as it
attempted to subtract from nil. Since we can't do the drop math that
is expected in this phase, the grade calculator will act similar to
dropping for all unpointed assignments.

fixes GRADE-2209

test plan:
 - (For this test plan you'll need to look at the canvas logs)
 - Create an course with a student
 - In the default assignment group, create three assignments, 2 of
   which are 0 points possible and 1 with some number of points
   possible.
 - Adjust the assignment group drop rules to drop one highest
   and one lowest
 - Score the assignments
 - Confirm in the logs that none of the runs of the grade calculator
   crashed with the error "undefined method `+' for nil:NilClass"
 - Confirm the course score for the student is nil

Change-Id: I10ac06d5b99b5c328b0b509902268af57bfc0c37
Reviewed-on: https://gerrit.instructure.com/193580
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Adrian Packel <apackel@instructure.com>
QA-Review: Adrian Packel <apackel@instructure.com>
Tested-by: Jenkins
Product-Review: Keith Garner <kgarner@instructure.com>
2019-05-30 16:32:20 +00:00
Keith T. Garner cedc0090bc remove calls to invalidate a cache that is no longer populated
ff83302bb0 stopped populating the cache with assignment stat
data, however, the code to invalidate the cache remained just burning
time. This removes the function to invalidate the cache and the code
that calls it.

test plan:
 - specs pass
 - Confirm grade calculator and student grades page still function.

Change-Id: I5bcd29359addfd9d46f161c74d2e433417914a4f
Reviewed-on: https://gerrit.instructure.com/193869
Reviewed-by: Adrian Packel <apackel@instructure.com>
Tested-by: Jenkins
QA-Review: Keith Garner <kgarner@instructure.com>
Product-Review: Keith Garner <kgarner@instructure.com>
2019-05-16 22:35:20 +00:00
Adrian Packel 828a2bd522 Have grade calculator consider unposted
If post policies is enabled, have the grade calculator, rather than
ignoring all submissions for muted assignments, ignore submissions that
have not been posted. Also make sure we recalculate grades when
posting/hiding submissions.

closes GRADE-36

Test plan:
- Enable post policies
  - Create some assignments, make at least one manually-posted
  - Assign some scores
  - When you post or hide submissions, the Score objects associated
    with the students/enrollments should be updated
    - The computed_ values should not reflect unposted submissions
    - The unposted_ values should reflect them
- In a course with post policies disabled
  - Make sure muting/unmuting assignments kicks off the grade
    calculator (and it calculates as expected)

Change-Id: If08fbfa090cf0174f9f6ee306a3d5ecec81351fc
Reviewed-on: https://gerrit.instructure.com/192075
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Gary Mei <gmei@instructure.com>
Reviewed-by: Keith Garner <kgarner@instructure.com>
QA-Review: James Butters <jbutters@instructure.com>
Product-Review: Keith Garner <kgarner@instructure.com>
2019-05-16 16:15:01 +00:00
Adrian Packel 4aae92655d Have grade calc use INSERT ... ON CONFLICT
Have the grade calculator update the scores and score_metadata tables
using a single INSERT ... ON CONFLICT DO UPDATE statement rather than
consecutive UPDATE and INSERT statements. This will (we hope) prevent
separate invocations of the grade calculator from stepping on each
other's toes and interrupting calculations midway through due to
constraint errors.

fixes GRADE-2163

Test plan:
- Specs pass
- Set up a course with some assignment groups and grading periods
  - Assign some grades
  - Check that scores are being calculated properly and no errors

Change-Id: I894d5040f8a536c4b91d344dffd246fb0d9a6311
Reviewed-on: https://gerrit.instructure.com/192330
Tested-by: Jenkins
Reviewed-by: Keith Garner <kgarner@instructure.com>
QA-Review: Derek Bender <djbender@instructure.com>
Product-Review: Keith Garner <kgarner@instructure.com>
2019-05-07 21:32:04 +00:00
James Williams 3a3bf30cf7 reduce the grade calculator user batch size
refs #CORE-2390

Change-Id: Idbca2de8922fb0985cab7e5d3cccc609f69484d3
Reviewed-on: https://gerrit.instructure.com/179011
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
2019-01-24 17:31:27 +00:00
Jeremy Neander bade832f08 use bigdecimal for some grade calculator assertions
closes GRADE-1512

test plan:
 * Smoke test some grade calculations?

Change-Id: Ia26fe7fcb137dd1f5bc07bb77babf3694a268b70
Reviewed-on: https://gerrit.instructure.com/172851
Tested-by: Jenkins
Reviewed-by: Gary Mei <gmei@instructure.com>
Reviewed-by: Keith Garner <kgarner@instructure.com>
QA-Review: James Butters <jbutters@instructure.com>
Product-Review: Keith Garner <kgarner@instructure.com>
2018-11-19 20:21:47 +00:00
Cody Cutrer 3ceaceabff fix several N+1 or inadvertent loads
Change-Id: Icaf58edbc36103ebc43855a11e151489d8aca860
Reviewed-on: https://gerrit.instructure.com/157073
Tested-by: Jenkins
Reviewed-by: James Williams  <jamesw@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2018-07-23 20:25:37 +00:00