Commit Graph

88 Commits

Author SHA1 Message Date
Cody Cutrer 3e27ddeae0 bundle update rubocop-performance, rubocop-rails
[skip-stages=Flakey]
[skip-crystalball]

99% of fixes are Performance/StringIdentifierArgument, but one or
two instances of each of Performance/Count, Performance/MapCompact,
Rails/Pluck in safe navigation chains

Change-Id: Ibd2292fb9e7c1e9162068021073c3c0f4b0d65df
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/335489
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Aaron Ogata <aogata@instructure.com>
Build-Review: Aaron Ogata <aogata@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2023-12-18 20:28:02 +00:00
Cameron Ray 8e25fecec6 Rename DueDateCacher to SubmissionLifecycleManager
closes EVAL-3285

[fsc-timeout=30]

We will need to follow this up next release with a commit
to remove the alias `DueDateCacher = SubmissionLifecycleManager`.

flag=none

Test plan
- Tests pass

Change-Id: Ib3566e9d581f5826ab07ee2265277bb75ba02ee0
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/320685
Migration-Review: Isaac Moore <isaac.moore@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
Reviewed-by: Christopher Soto <christopher.soto@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Cameron Ray <cameron.ray@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
2023-07-11 14:43:12 +00:00
Jackson Howe 22c671369b Clear cache keys for bulk-updated classic quizzes
Clears the cache register values for quizzes (not just their
assignments) when updating availability dates with the bulk due date
updater.

fixes LS-2899
flag = none

Test plan:
 - Create a classic quiz and assign to just a single student/ section
   with an 'available from' date in the future
 - As the student (or a student in the assigned section), visit the
   quiz and notice its locked
 - As the teacher/admin, visit the assignments index and open the bulk
   due date editor
 - Change the 'availabile from' date to the past and save
 - As the student, visit the quiz again and expect it to be visible

Change-Id: I8bbcd97e7ad59344c3d4629a25758b3e93c68282
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/283357
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Robin Kuss <rkuss@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: Jackson Howe <jackson.howe@instructure.com>
2022-01-24 16:40:17 +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 4d43809cae RuboCop: Style/PercentLiteralDelimiters
[skip-stages=Flakey]

auto-corrected, with a post-review looking for multiline strings
to convert to heredocs

Change-Id: I7f7afb11edd63415cde10866822dd2ac5ba0d8be
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278669
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-18 23:05:50 +00:00
Cody Cutrer cf213ee24b RuboCop: Style/RedundantFreeze
[skip-stages=Flakey]

auto-corrected

Change-Id: Id1b8bafdd744219a4797e6e1ba5891cd7ce4bccd
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/277888
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 02:06:47 +00:00
Cody Cutrer 649e5b36a2 RuboCop: Lint/ShadowingOuterLocalVariable
[skip-stages=Flakey]

all manual

Change-Id: Ieb74efcd4206426973dd72eb2ca7c5f5af5167f4
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/277394
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-04 14:02:24 +00:00
Cody Cutrer f5cdb0d986 RuboCop: Layout app/models
Change-Id: Ieae2904fb81739476d806b01bd7b4ff98c5ee35c
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274155
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 19:32:32 +00:00
Cody Cutrer 548a2a1732 update all invocations of send_later and friends to new syntax
Change-Id: I7f40ed058b50882121da69f0cb05966854b8e920
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/250924
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2020-10-30 19:13:54 +00:00
Cody Cutrer f299f76b75 add # frozen_string_literal: true for models
Change-Id: I70825be7ec7e24458afe0c63dc48c5a76158f520
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/251150
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2020-10-28 22:08:12 +00:00
Spencer Olson 93aee7f242 optimize grading period assignments fetching
closes EVAL-1246
flag=none

Test Plan:
1. Create a course that uses grading periods. Have at least 2 grading
   periods.
2. Create an assignment. Assign it to one student in the first grading
   period, and the rest of the students ("Everyone Else") in the second
   grading period.
3. Sign in as the "one student" from the previous step. Click on
   "Grades". Select the first grading period from the Grading Period
   dropdown and click "Apply". You should see the assignment show up.
   Then, select the second grading period from the Grading Period
   dropdown and click "Apply". You should no longer see the assignment
   listed.

Change-Id: I69d4b8369784086034a7883460e63f4f259a79ca
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/248932
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Adrian Packel <apackel@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
QA-Review: Syed Hussain <shussain@instructure.com>
Product-Review: Jody Sailor
2020-10-21 16:12:52 +00:00
James Williams ec3f38ec97 fix assignment availability cache clearing after bulk edit
test plan:
* with redis enabled locally, create an assignment with
 a due date and add it to a module
* view the modules page as a student and take note
of the due date
* use the bulk assignment date editing feature to
 edit the assignment date
* re-view the modules page a the student
* the due date should be updated

closes #LA-957

Change-Id: I71d2f14f70109bc1d9ae137371afc89122efcd5b
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/236120
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: James Williams <jamesw@instructure.com>
2020-05-06 22:46:23 +00:00
Jeremy Stanley 81b55c2e9d bulk date editing API
test plan:
 - render API documentation
 - have a course with multiple assignments, some of which have
   multiple due dates
 - use the assignments index endpoint with include[]=all_dates
   to get a list of assignments and dates
 - use a JSON request body to update multiple dates for
   multiple assignments. then reload the assignments page
   and confirm the dates have changed
 - set up grading periods and ensure the endpoint returns an
   error if you try to move a due date into or out of a
   closed grading period
 - ensure you get a 401 if your update batch includes an
   assignment you don't have permission to update due to
   moderated grading (keeping in mind that TAs have
   select_final_grade permission by default)

closes LA-831

Change-Id: I804fd16c38410cbd3607f94e6a4da6e19a489d59
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/230102
Reviewed-by: James Williams <jamesw@instructure.com>
Reviewed-by: Jon Willesen <jonw+gerrit@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Lauren Williams <lcwilliams@instructure.com>
2020-03-27 14:59:15 +00:00
Gary Mei 85ee64f3ae allow provisional graders to delete grades
When a provisional grade has been left, it should be deletable by the
provisional grader who left it. Invalid grades still be unacceptable,
but now "no provisional grade" is considered valid. Deleting a
provisional grade will not change the fact that the provisional
grader took up a moderation slot.

A provisional grade cannot be deleted nor changed after the
provisional grader has been been selected by the final grader in the
moderation page. After grades have posted, grades can be deleted
or changed.

fixes GRADE-1637

Test Plan
- Create a moderated assignment with just 1 number of graders.
- As the provisional grader, launch SpeedGrader and give a grade to a
  student. Tab away.
- Delete the provisional grade; there should be no error messages.
- Enter a valid, non-empty grade.
- Replace the valid provisional grade with an invalid provisional grade
  (e.g. "asdf"). There should be an error message, and the
  provisional grade should have reverted to the last valid provisional
  grade.

- Delete the provisional grade.
- As another provisional grader, launch SpeedGrader and attempt to
  leave a provisional grade. There should be an error message stating
  that the max number of graders has already been reached.

- Leave a provisional grade again, as the first provisional grader.
- As the final grader, open the moderation page and select the
  provisional grader.
- As the provisional grader, attempt the delete the provisional
  grade. It should have an error message.
- As the provisional grader, attempt to change the provisional grade.
  It should have an error message.

- As the final grader, post the grades.
- As the provisional grader, attempt to delete the grade. It should be
  okay.
- As the provisional grader, attempt to leave and change a grade. It
  should be okay.

Change-Id: I169ac65a5d8785007b3c71aed87bbef968c86e9e
Reviewed-on: https://gerrit.instructure.com/168804
Tested-by: Jenkins
Reviewed-by: Adrian Packel <apackel@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: James Butters <jbutters@instructure.com>
Product-Review: Keith Garner <kgarner@instructure.com>
2018-10-30 19:34:18 +00:00
Derek Bender d80c0fe38f Invert Assignment::SpeedGrader namespaces
With the addition of SpeedGrader::Submission, Assignment::SpeedGrader
needs to be migrated to SpeedGrader::Assignment to not cause naming
confusion and to be able to remove the require_dependency calls

Closes: GRADE-1622

Test plan:
 - Speed Grader still loads
 - Test pass

Change-Id: Ic19d42fe028da2efc926ba58e52f049ec34f15e2
Reviewed-on: https://gerrit.instructure.com/165182
Tested-by: Jenkins
Reviewed-by: Gary Mei <gmei@instructure.com>
Reviewed-by: Adrian Packel <apackel@instructure.com>
QA-Review: Adrian Packel <apackel@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-09-21 23:08:11 +00:00
Derek Bender 8fcbb94141 fix comment visibilities for speed grader
fixes: GRADE-1599

test plan:
 - given an anonymous assignment
 - given at least one TA is enrolled
 - given at least one student
 - given the student has submitted their homework with a comment
 - given Speed Grader page as the TA
 - when a grade is left by the TA
 - then the student's submission comment is not deanonymized and is
   still authored by a string like "Student 1"

Change-Id: Id2b348b550e9cedee74bf4223ae452a2a56d833d
Reviewed-on: https://gerrit.instructure.com/164742
Tested-by: Jenkins
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Reviewed-by: Adrian Packel <apackel@instructure.com>
QA-Review: James Butters <jbutters@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-09-20 16:09:45 +00:00
Jeremy Neander ad925d9c1d unblock speedgrader with max graders
closes GRADE-1518

test plan:
 1. Create a moderated assignment with 2 graders
    * Select a file upload submission type
 2. Submit to the assignment as a student
 3. Grade a student as both graders
 4. Visit SpeedGrader as a third grader
 5. Verify SpeedGrader can be viewed
 6. Verify DocViewer is in read-only mode

Change-Id: I8ad58615724a94859cdf90b069cad4809c9e0e08
Reviewed-on: https://gerrit.instructure.com/164038
Tested-by: Jenkins
Reviewed-by: Adrian Packel <apackel@instructure.com>
Reviewed-by: Gary Mei <gmei@instructure.com>
QA-Review: Adrian Packel <apackel@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-09-18 16:48:09 +00:00
Gary Mei b0865129a5 pass audit related info when launching docviewer
Re-used files in attachments in submissions will re-use the same
attachment, making it impossible to identify which Submission a
document belongs to, and thus which Assignment. This commit also
adds a callback url for DocViewer to use when posting audit events
back to Canvas.

refs GRADE-1507

Test Plan
 - Drop a debugger statement before the redirect_to_url call in
   canvadocs sessions controller.
 - Launch a DocViewer session from within Canvas.
 - Inspect the opts object once the debugger statement stops you.
 - Verify that there is indeed a submission id.

Change-Id: If985646b6b8f4bf3507c68dec0f66a91c167b329
Reviewed-on: https://gerrit.instructure.com/161838
Tested-by: Jenkins
Reviewed-by: Spencer Olson <solson@instructure.com>
Reviewed-by: Daniel Lee <dlee@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
QA-Review: Gary Mei <gmei@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-08-31 14:56:19 +00:00
Derek Bender 1190cbad6b anonymize status endpoint
closes: GRADE-1351

test plan:
- given an anonymous-moderated-assignment
- given a rubric on the assignment
- given a student with a submission for the moderated assignment
- given comments, grades, rubric assessments including grades
  and comments
- when the following API is requested as an admin or final grader:

    /api/v1/courses/<course-id>/assignments/<assignment-id> \
      /anonymous_provisional_grades/status? \
      anonymous_id=<student-anonymous-id>&last_updated_at=nil

- then all identifying information (e.g. user_id) is no longer present

Change-Id: I5a053df9c257ebf152b22b6d9bafaabcdf96788c
Reviewed-on: https://gerrit.instructure.com/161485
Reviewed-by: Gary Mei <gmei@instructure.com>
Tested-by: Jenkins
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
QA-Review: Spencer Olson <solson@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-08-27 17:46:21 +00:00
Adrian Packel dd3122c88a Show provisional grader rubrics to moderator
For a moderated assignment, allow the moderator to view rubrics
submitted by provisional graders and enter a custom assessment.

fixes GRADE-1377

Test plan:
  - Set up a rubric
  - Set up two moderated assignments, one with grader names visible to
    the final grader and the other with them not visible
      - Attach the rubric to each assignment
  - As one or more provisional graders, assess some students using the
    rubric in each assignment
    - This should function as normal
  - As the moderator, open each assignment in SpeedGrader
    - The right side should have a dropdown letting you select among
      provisional graders' submitted assessments
      - If grader names are visible, the dropdown options will show that
        provisional grader's name
      - If not, they will appear as "Grader # Rubric" (note the "Rubric"
        suffix for anonymous graders), numbered as elsewhere on the page
      - A "Custom" option representing the moderator's assessment should
        always be present, and be the first option
        - The button to edit the rubric should only appear when this
          option is selected
    - Note that assessment scores are not (as of the time of writing)
      automatically propagated to provisional grades, so the scores
      shown in the grade selector will not necessarily reflect the
      contents of the rubric

Change-Id: I3cc05bc64b687096638c64f02633b37484a63455
Reviewed-on: https://gerrit.instructure.com/161822
Tested-by: Jenkins
Reviewed-by: Gary Mei <gmei@instructure.com>
QA-Review: Gary Mei <gmei@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-08-24 21:55:45 +00:00
Adrian Packel 6a5a916e45 pass user-related params to docviewer
When talking to DocViewer, include relevant data for the current user as
well as the filter of users whose comments should be shown. This commit
enables functionality for anonymous annotations.

closes GRADE-1427
closes GRADE-1456

Test Plan 1: Moderated Assignments
1. Create a moderated assignment and allow for at least two provisional
   graders in addition to the final grader. Then, leave at least one
   annotation and one comment per provisional grader, final grader, and
   the student.
2. When "Graders cannot view student names" is checked, verify that
   no instructor or admin can see the students identity on annotaions.
   Instead, the student's name should show up simply as 'Student'.
3. When "Graders cannot view each other's names" is checked, verify that
   non-admin, non-final-grader provisional graders cannot see each
   other's names on annotations. Instead, they should see a generic
   grader name such as "Grader 1".
4. When "Final grader can view other grader names" is unchecked, verify
   the final grader cannot view the other graders' names on annotations.
   Instead, they should see a generic grader name such as "Grader 1".
5. Smoke test the settings listed in steps 2, 3, and 4 in various
   combinations of being on or off.
6. While the assignment is still in moderation, verify the student can
   only see their own annotations.
7. When grades are published for the assignment, verify the assignment
   no longer shows any anonymous annotations.

Test Plan 2: Anonymous, Not Moderated Assignments
1. Create an anonymous assignment. Submit to the assignment as a student
   and leave some annotations as the student and as an instructor.
2. Verify the student can only see their own annotations while the
   assignment is still muted.
3. An instructor *should* be able to see any annotations made by an
   instructor, but DocViewer has not implemented this functionality
   on their side yet. As a result, just verify that an instructor
   can see the student's annotations but they are anonymized while
   the assignment is muted.
4. Unmute the assignment and verify the annotations are no longer
   anonymized, and the student can now see annotations from instructors.

Test Plan 3: Normal, Not Anonymous Assignments
1. Do a general smoke test of not anonymous, not moderated assignments
   to verify annotations still show up as expected.

Change-Id: I181a6ace3c00ca93ab8e6c7608a034b521ed78b7
Reviewed-on: https://gerrit.instructure.com/161486
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
QA-Review: Derek Bender <djbender@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-08-24 18:55:06 +00:00
Jeremy Neander 9a593b971c do not duplicate comments when posting grades
fixes GRADE-1387

test plan:
 A. Setup
    1. Select or create a published course
    2. Enroll a teacher
    3. Enroll two TAs
    4. Enroll one student (more is fine, but means more work)
    5. Create a moderated assignment
       * optionally assign to only one student for less work
       * Teacher is final grader

    6. As the student:
       a. Submit to the assignment
       b. Leave a comment

    7. As each TA:
       a. Visit SpeedGrader
       b. Grade and comment on the submission

 B. Verification
    1. Sign in or act as the Teacher
    2. Visit the moderation page
    3. Select the grade made by the first TA
    4. Post grades
    5. View the student's submission in SpeedGrader
    6. Verify the student comment is visible
    7. Verify the first TA's comment is visible
    8. Verify the second TA's comment is not visible

Change-Id: Id2803fbde8641206ab9727a9946346fe1a1722e8
Reviewed-on: https://gerrit.instructure.com/160863
Tested-by: Jenkins
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
QA-Review: James Butters <jbutters@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-08-20 16:34:27 +00:00
Spencer Olson b766794156 add slot_taken to moderation_graders
closes GRADE-1426

Test Plan:
1. Before running migrations, make sure you have some moderation_grader
   records.
2. Run migrations. Verify 1) the moderation_graders table now has a
   slot_taken column, and 2) the existing moderation_grader records have
   slot_taken set to true.
3. Create a moderated assignment, then log in as a provisional grader.
4. Verify there are no moderation_grader records for the provisional
   grader for that assignment.

   assignment.moderation_graders.find_by(user: provisional_grader)
   => nil

5. Visit SpeedGrader, but don't grade or comment. Verify a moderation
   grader record has been created for the provisional grader, and verify
   it has slot_taken set to false.

   grader =
   	assignment.moderation_graders.find_by(user: provisional_grader)
   grader.slot_taken?
   => false

6. Leave a submission comment or a grade in SpeedGrader. Verify the
   moderation grader record for the provisional grader has been updated
   with slot_taken set to true.

   grader.reload.slot_taken?
   => true

7. Verify you can roll the migration back. The slot_taken column should
   be removed.

Change-Id: I94fafc259df5022ed1af27d3457d8df87947153e
Reviewed-on: https://gerrit.instructure.com/159544
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
QA-Review: Jeremy Neander <jneander@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-08-15 20:01:19 +00:00
Jeremy Neander 424eb6d5e3 ignore students not assigned to anonymous assignments
fixes GRADE-1444

test plan:
 1. Select or create a course
 2. Enroll at least two students
 3. Create an assignment
    * student names hidden to graders
    * assigned to all but at least one student
 4. As the teacher, visit SpeedGrader
 5. Verify SpeedGrader loads successfully

Change-Id: I377383f6edab80be1810ca98459abf347d955d82
Reviewed-on: https://gerrit.instructure.com/159518
Tested-by: Jenkins
Reviewed-by: Spencer Olson <solson@instructure.com>
Reviewed-by: Gary Mei <gmei@instructure.com>
QA-Review: Spencer Olson <solson@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-08-07 17:04:38 +00:00
Spencer Olson 79e8729e13 fix annotations shown in speedgrader for moderated assignments
closes GRADE-1438

Test Plan:
1. Verify moderated, non-anonymous assignments adhere to the following
   rules:

   A. While an assignment is still in moderation (meaning grades have
   not yet been published):

   - The final grader will see all annotations left by themselves,
     provisional graders, and the student.
   - Provisional graders will see their own annotations and the
     annotations left by the student. However, if the "graders can view
     each other's comments" setting is selected on the assignment, then
     provisional graders will additionally be able to see annotations
     left by other provisional graders (including the final grader).
   - Eligible provisional graders (meaning users who can be a
     provisional grader but have not yet left a grade or a comment)
     have the same visibility as provisional graders.
   - Students will see their own annotations, and nothing else.
   - Admins will see annotations left by themselves, provisional
     graders (including the final grader), and the student.

   B. Once a provisional grade has been selected and the assignment has
      published grades:

   - The final grader will see all annotations left by themselves, the
     author of the selected provisional grade, and the student.
   - Provisional graders will see their own annotations, annotations
     left by the author of the selected provisional grade, and the
     annotations left by the student.
   - Eligible provisional graders have the same visibility as
     provisional graders.
   - Students will see their own annotations and annotations left by
     the author of the selected provisional grade.
   - Admins will see annotations left by themselves, the author of the
     selected provisional grade, and the student.

Change-Id: Ic5df2291eeb76f6a34aa628d60e3afc4a3e5facd
Reviewed-on: https://gerrit.instructure.com/159481
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Tested-by: Jenkins
QA-Review: James Butters <jbutters@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-08-03 16:32:01 +00:00
Cody Cutrer 9cd45df86e fix several N+1 found by Bullet
Change-Id: I086b6a2265014ff5327f1ab6f60430b155150df7
Reviewed-on: https://gerrit.instructure.com/158980
Tested-by: Jenkins
Reviewed-by: Rob Orton <rob@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2018-08-02 21:24:00 +00:00
Gary Mei f0cc68b7cb fix broken comment names for AMM assignments
The backend wasn't returning ids for the provisional grades when
provisional graders were looking at SpeedGrader, so all the names
were indexed by the same key: nil.
When the final grader was looking at SpeedGrader, the provisional
grader display names weren't refreshed moving from one submission
to the next, so the wrong display names would be requested, resulting
in empty names.

*Special Case
This also fixes another scenario where if you had three graders
comment on a student, and then only two graders comment on the next
student, it was possible that the provisional grader names would
look different. For example, on the first student you might see
"Grader 2, Grader 1, Grader 3" as the order of the comments, and
if Grader 1 and Grader 3 commented on the second student, the text
would instead show "Grader 1, Grader 2". This change happens to fix
that as well.

fixes GRADE-1360

Test Plan
 - Don't apply the commit just yet.
 - Have 3 teachers and 2 students.
 - Create an anonymous, moderated assignment with these settings:
     - Moderated Grading on
     - Number of graders 2
     - Graders can view each other's comments on
     - Select some final grader
     - Final grader can view other graders names off
     - Anonymous Grading on
     - Graders cannot view each others names on
     - Anything else not specified can be off

 - As Grader 1, go to SpeedGrader for the assignment and leave a
   comment, but not a grade, for both students.
 - As Grader 2, do the same.
 - As the final grader, go to SpeedGrader and check comments on both
   students' submissions. Notice that at least one comment won't have
   an author name.
 - As Grader 2, go to SpeedGrader and notice that at least one
   comment author has "Custom" as the name rather than "Grader 1" or
   some such.

 - Apply the commit.
 - Navigate to SpeedGrader as the three different teachers and verify
   that comment author names are as expected.

Extra Test Plan (for the Special Case)
 - Set up an assignment such that three graders commented on one
   student, and two of those three commented on a second student.
 - If the order of the comments on the first student is NOT 1, 2, 3
   then you are good to keep going. If it IS 1, 2, 3 then you either
   have to re-do the first step until it is NOT 1, 2, 3 or hop into
   a rails console to update anonymous_id of the ModerationGraders to
   change the order.
 - Once you've reached this step, open SpeedGrader and verify that
   comments belong to the Grader that it says they do.

Change-Id: I732dfd1ade5a88f799782202a6225c99a2c9a108
Reviewed-on: https://gerrit.instructure.com/157901
Tested-by: Jenkins
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-08-02 21:17:14 +00:00
Adrian Packel 49fe00157e Use current anon ID for old submission versions
If an older version of a submission does not include an anonymous ID in
its serialized form (perhaps because it was saved before anonymous IDs
existed), fill in the anonymous ID from the current Submission object
when returning the relevant JSON for SpeedGrader.

fixes GRADE-1417

Test plan:
- Create an assignment with anonymous grading enabled that accepts
  online submissions
- As a student, submit and then re-submit to the assignment
- Edit the YAML serializations to remove the anonymous ID (see below)
- As a teacher, open the assignment in SpeedGrader and attempt to
  download one or both of the student's submitted files
- They should download correctly and not throw an error

(To remove the ID from the YAML, you can do something like the following
in the Rails console:

> submission = <the submission in question>
> temp_anonymous_id = submission.anonymous_id
> submission.anonymous_id = nil
> submission.versions.each do |v|
>   v.model = submission
>   v.save!
> end
> submission.anonymous_id = temp_anonymous_id

Calling submission.submission_history should now return an array of
submission objects with nil anonymous IDs.
)

Change-Id: I399949bfac0713d568f23adef0707ec81b038f8b
Reviewed-on: https://gerrit.instructure.com/158490
Tested-by: Jenkins
Reviewed-by: Gary Mei <gmei@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: James Butters <jbutters@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-08-02 19:51:54 +00:00
Spencer Olson 1ea0da8868 reference current_user instead of user in speedgrader
Change-Id: I562195021ea8f3a976068c78c61393bb4140f2d7
Reviewed-on: https://gerrit.instructure.com/158356
Reviewed-by: Derek Bender <djbender@instructure.com>
Product-Review: Derek Bender <djbender@instructure.com>
QA-Review: Derek Bender <djbender@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Jenkins
2018-07-23 19:11:25 +00:00
Derek Bender e15aa37067 extract submission serializer shared code
closes: GRADE-1312

test plan: specs pass

Change-Id: I274ae211ab55d7c0a135c609f9917df5ccc2c716
Reviewed-on: https://gerrit.instructure.com/157760
Tested-by: Jenkins
Reviewed-by: Adrian Packel <apackel@instructure.com>
Reviewed-by: Gary Mei <gmei@instructure.com>
QA-Review: Derek Bender <djbender@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-07-23 16:22:46 +00:00
Adrian Packel e0c61756f6 Hide SG viewed/submitted dates if anonymizing
Hide view/submission dates on submission details page and SpeedGrader if
the assignment should be anonymizing student information.

closes GRADE-1070

Test plan:
* Create an anonymous assignment allowing file-upload submissions
* Logged in as a student (S1):
  * Submit something
* As another student (S2), submit multiple files for the same assignment
  (i.e., submit something, then re-submit and upload something else)
* Logged in as a teacher:
  * Open the assignment in SpeedGrader
    * For S1, the "submitted" and "student viewed at" lines on the right
      side should not appear
    * For S2, the dropdown letting you choose between submissions, which
      previously denoted them using the dates submitted, should now name
      them "Submission 1", "Submission 2" and so forth
    * In both cases, it's okay if the assignment is marked as late or
      missing for a given student (we're not trying to hide that info)
* Logged in as an admin:
  * Open the assignment in SpeedGrader
    * None of the above should apply; i.e., the admin should be able to
      view submission dates as though the assignment weren't anonymous
* Log back in as the teacher:
  * Unmute the assignment
  * For both students, the submitted at/viewed at information should now
    be shown again

Change-Id: I35bb3e6d189fd6f5aca333b6eb4419c209d95090
Reviewed-on: https://gerrit.instructure.com/157540
Tested-by: Jenkins
Reviewed-by: Gary Mei <gmei@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-07-23 12:29:28 +00:00
Derek Bender 5c010db736 remove dead code and rework comment specs
this patchset removes the unused provisional grade comments, they
weren't used! It also refactors some app code but the majority of the
work was in speed_grader_spec.rb

test plan:
this patchset removes unused code, so we could smoke test speedgrader
for submission comments with moderated grading, but honestly it seems
like overkill if the specs pass.

closes: GRADE-1311

Change-Id: I0b5d3417d3c113b4fa88542284d1e04b2a291be6
Reviewed-on: https://gerrit.instructure.com/155612
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Adrian Packel <apackel@instructure.com>
Tested-by: Jenkins
QA-Review: Derek Bender <djbender@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-07-13 16:36:18 +00:00
Adrian Packel 6bbdabfb3b Only show active students in SG if anonymizing
If the current assignment is anonymizing students (i.e., has anonymous
grading enabled and is muted), only include active students in
SpeedGrader. This prevents a potential issue involving concluded
students not having submissions and therefore not having anonymous IDs.

fixes GRADE-1367

Test plan:
* Have a course with the following student setup
  * At least one active student
  * One inactive student
  * *Two* concluded students
* In new Gradebook, enable display of inactive and completed students
* Create an anonymous assignment
* Open the assignment in SpeedGrader
* SpeedGrader should display only active students and should not produce
  a Javascript error
* Unmute the assignment
* SpeedGrader should now show all students and also not produce an error

Change-Id: I36c2160fbbfd28bc431d0d0887ec23609042d114
Reviewed-on: https://gerrit.instructure.com/157196
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
Tested-by: Jenkins
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-07-12 21:51:06 +00:00
Adrian Packel d021972901 Disallow invalid values in provisional grades
Insist that provisional grades must have a valid non-empty score to be
saved, just as non-provisional grades must. Similarly, ensure that an
existing valid provisional grade cannot be replaced with an empty value.
(In both cases the grade should silently revert back to its previous
value, or nothing if no grade was previously entered.)

fixes GRADE-1279

Test plan:

(Note that, while entering invalid grades, you may see an "Oops! The
last request didn't work out" flash error message; this is because we're
actually handling bad values on the back-end as errors now instead of
silently reverting them. The messages will only appear in development
and otherwise shouldn't affect anything.)

* Set up a moderated assignment
* Open it in SG as a provisional grader
  * Before issuing a real grade, try to enter some invalid values, like
    "asdf" or "EX" (invalid because a provisional grader cannot excuse)
    * The grade field should revert to its previous (empty) value
    * Check that a provisional grade object has *not* been created as a
      result of the invalid values (you can do so using the Rails
      console or by opening the assignment in SG as a moderator and
      checking the grades in the provisional grade selector)
  * As the same grader, make sure you can enter a valid grade
    * If you have entered a valid grade at least once, entering an
      invalid grade should revert to the last valid value
* Open the assignment in SG as a moderator
  * Check that you can excuse the assignment by grading as "EX"
  * Check for the following behavior with respect to the provisional
    grade selector:
    * If you enter an invalid value, the grade field should revert to
      the previously-selected value, whether it was your own grade
      ("Custom") or a provisional grade from someone else
    * Similarly, an invalid value should not change the selection of
      the provisional grade selector
    * Trying to enter a valid value should work as before, and select
      the "Custom" radio button if not already selected
* Finally, Create a non-moderated assignment, open it in SG, and check
  that it handles valid/invalid grades properly as before

Change-Id: I33fd9450ebea4f1f2d1cae2dd0a4c0c70d6e65c8
Reviewed-on: https://gerrit.instructure.com/156351
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-07-11 19:22:10 +00:00
Spencer Olson c5ee434ff5 make anonymous grading checks consider muted status
Unmuting an anonymous assignment will now cause that assignment to show
in the UI as though it is not anonymous. In addition, posting grades for
a moderated anonymous assignment will now cause that assignment to show
in the UI as though it is not anonymous.

closes GRADE-1310
closes GRADE-1313

Test Plan:
1. Verify unmuting an anonymous assignment causes that assignment to no
   longer be anonymized in the UI. You can do this by spot checking
   gradebook (old/new/individual) and SpeedGrader. In addition,
   re-muting an unmuted anonymous assignment should cause the assignment
   to become anonymized in the UI.
2. Verify posting grades for a moderated, anonymous assignment causes
   that assignment to no longer be anonymized in the UI (even if the
   assignment is muted).

Change-Id: I113c61b4e7fa0eb8909448d8ba7cffb22600e17c
Reviewed-on: https://gerrit.instructure.com/156151
Reviewed-by: Gary Mei <gmei@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
QA-Review: James Butters <jbutters@instructure.com>
Tested-by: Jenkins
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-07-10 16:24:26 +00:00
Gary Mei c6135e38aa hide concluded students in speedgrader
This changes SpeedGrader to be consistent with Gradebook in showing
or hiding concluded students in a soft concluded course. Concluded
students will show or be hidden depending on if "Show Concluded
enrollments" is checked or not.

closes GRADE-1204 and GRADE-585

Test Plan

 Setup
 - Have a course with at least 2 students.
 - Create an assignment.
 - Conclude 1 student.
 - Go to the course settings and change the course dates to start and
   end before the current day.
 - Under the course dates, check the box for
   "Users can only participate in the course between these dates"

 Testing SpeedGrader
 - Navigate to the Gradebook.
 - Uncheck the option to show concluded students, if it's checked.
 - Open SpeedGrader for the assignment.
 - Verify that the concluded student does not show.
 - Navigate to the Gradebook.
 - Check the option to show concluded students.
 - Open SpeedGrader for the assignment.
 - Verify that the concluded student does show.

 Testing Exports
 - Navigate to the Gradebook.
 - Uncheck the option to show concluded students, if it's checked.
 - Export the Gradebook.
 - Verify that the concluded student does not appear in the export.
 - Navigate to the Gradebook.
 - Check the option to show concluded students.
 - Export the Gradebook.
 - Verify that the concluded student does appear in the export.

Change-Id: Id237086263e47405c03e0ae4af20195fa4d8ca35
Reviewed-on: https://gerrit.instructure.com/155111
Tested-by: Jenkins
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Reviewed-by: Adrian Packel <apackel@instructure.com>
QA-Review: James Butters <jbutters@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-06-27 04:54:31 +00:00
Derek Bender 6725c76d8f tweak speed grader comment visiblity
closes: GRADE-1266

Test Plan:

enroll two students and two TAs and the teacher is the final grader (it
shouldn't matter if the final grader is a TA or a teacher, in fact feel
free to rotate them for more possibilities). If you're short on time the
following could be done on one assignment and for each test case toggle the
settings on and off, but then it would be difficult to quickly pull of the
correct configuration, if problems arise.

The titles of each feature are how they are found in the Assignment form.
This can cause some confusion due to some rules being enabling or disabling
a phrase with a 'not' present so be careful!

/------------+---------------------------+-----------+-----------------------+---------------------+-----------------------\
| assignment | anonymous (graders cannot | moderated | graders can view      | graders cannot view | final grader can view |
|            | view student names)       | grading   | each other's comments | each other's names  | other grader names    |
+------------+---------------------------+-----------+-----------------------+---------------------+-----------------------+
| I (basic)  |                           |           |                       |                     |                       |
+------------+---------------------------+-----------+-----------------------+---------------------+-----------------------+
| II         |                           | on        | on                    |                     | on                    |
+------------+---------------------------+-----------+-----------------------+---------------------+-----------------------+
| III        |                           | on        | on                    |                     |                       |
+------------+---------------------------+-----------+-----------------------+---------------------+-----------------------+
| IV         |                           | on        |                       |                     |                       |
+------------+---------------------------+-----------+-----------------------+---------------------+-----------------------+
| V          | on                        | on        | on                    | on                  | on                    |
+------------+---------------------------+-----------+-----------------------+---------------------+-----------------------+
| VI         | on                        | on        | on                    | on                  |                       |
+------------+---------------------------+-----------+-----------------------+---------------------+-----------------------+
| VII        | on                        | on        | on                    |                     |                       |
+------------+---------------------------+-----------+-----------------------+---------------------+-----------------------+
| VIII       | on                        | on        |                       |                     |                       |
+------------+---------------------------+-----------+-----------------------+---------------------+-----------------------+
| IX         | on                        |           |                       |                     |                       |
+------------+---------------------------+-----------+-----------------------+---------------------+-----------------------+
Note: if a cell is empty, it means `off`,

For assignments with Moderated Grading enabled the `Number of graders` will
always be `2` (the final grader makes three enrollments we'll use for
Speed Grader)

for each assignment do the following:
have the first student (Student A) submit their homework
- As the first TA (TA1), create a published comment and draft comment on
  Student A's submission
- As the second TA (TA2), create a published comment and draft comment on
  Student A's submission
- As the final grader (the teacher), create a published comment and draft
  comment on Student A's submission

For the follow instructions, negatives are presented in uppercase (`CANNOT`)
for enhanced clarity. Ensure for each grader (unless final grader is
specified) in each assignment referenced via the parens:

(I)
  1. can view student names
  2. can view each other's comments
(II)
  1. can view student names
  2. can view each other's comments
  3. final graders can view other graders' names
(III)
  1. can view student names
  2. can view each other's comments
  3. final grader CANNOT view other graders' names
(IV)
  1. can view student names
  2. CANNOT view each other's comments
  3. final grader can view each others' comments
(V)
  1. CANNOT view student names
  2. can view each other's comments
  3. CANNOT view each other's names
  4. final grader view other graders' names
(VI)
  1. CANNOT view student names
  2. can view each other's comments
  3. CANNOT each other's names
  4. final grader CANNOT view other graders' names
(VII)
  1. CANNOT view student names
  2. can view each other's comments
  3. can view each other's names
  4. final grader CANNOT view other graders' names
(VIII)
  1. CANNOT view student names
  2. CANNOT each other's comments
  3. final grader can view each others' comments
(IX)
  1. CANNOT view student names

Change-Id: I3e9a8787f04cf03a38ea651aa85b3eaa98f41f9c
Reviewed-on: https://gerrit.instructure.com/154391
Tested-by: Jenkins
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-06-24 20:37:22 +00:00
Gary Mei 48c917fcd5 pass user role to DocViewer
Pass the role of a user (Teacher, Student, TA) to DocViewer. This role
should only be passed when annotations are enabled.

closes GRADE-1219

Test Plan
- Create an assignment that takes doc files (or any DocViewer file).
- Submit an assignment as a student.

- Put a debugger statement before the redirect_to in
canvadoc_sessions_controller#show.
- Navigate to SpeedGrader.
- In the console after the debugger is tripped, verify that the opts
hash contains enrollment_type with value 'teacher'.

- Navigate to Submission Details of that submission as a student.
- Click View Feedback.
- In the console after the debugger is tripped, verify that the opts
hash contains enrollment_type with value 'student'.

Change-Id: I51c5cf60f90a73143c2f270126ef259426111632
Reviewed-on: https://gerrit.instructure.com/152836
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Tested-by: Jenkins
Reviewed-by: Neil Gupta <ngupta@instructure.com>
QA-Review: James Butters <jbutters@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-06-13 22:01:40 +00:00
Neil Gupta 6a659fbaa8 stop using anonymous moderated marking feature flag
fixes GRADE-976

test plan:
* Make sure the AMM flag is off
* All AMM features should be visible and work
* The Anonymous Marking and Moderated feature flags should be visible
* Toggling the AMM feature flag should do nothing

Change-Id: Ie0c52c23748389c6f5df5b85e8580bdf474c0a52
Reviewed-on: https://gerrit.instructure.com/152067
Reviewed-by: Adrian Packel <apackel@instructure.com>
Tested-by: Jenkins
Reviewed-by: Derek Bender <djbender@instructure.com>
QA-Review: James Butters <jbutters@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-06-12 20:58:47 +00:00
Gary Mei 9a441259a6 pass anonymous instructor annotations to DocViewer
This flag will let DocViewer know that any subsequent instructor
annotations should be hidden from viewers.

closes GRADE-1190

Test Plan
- Create an assignment, with anonymous instructor annotations
checked.
- Put a debugger statement in canvadoc_sessions_controller before
the redirect occurs.
- Ensure that the opts hash contains
anonymous_instructor_annotations and is set to true.
- In the debugger, type and enter 'continue'.
- Go to the submissions detail page of a submission.
- Open a preview of the submission.
- When the debugger is tripped again, verify that the opts hash
contains anonymous_instructor_annotations and is set to true.

Change-Id: I6611f06c08b03aad528942994e425d39c8014d24
Reviewed-on: https://gerrit.instructure.com/152428
Tested-by: Jenkins
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
QA-Review: James Butters <jbutters@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-06-07 17:00:26 +00:00
Jeremy Neander 8243eed6a9 hide comments by other graders in speed grader
closes GRADE-1167

QA Notes:

 * Anonymous Grading impacts the following parts of speed_grader.json

    * within `context.students[*].rubric_assessments[*]`
       * `.data[*].comments` (present)
       * `.data[*].comments_html` (present)

    * within `submissions[*]`:
       * `.submission_comments[*]` (current grader's are present)
       * `.submission_comments[*]` (student's are present)

       * within `.provisional_grades[*]`
          * `.submission_comments[*]` (student's are present)

          * within `.rubric_assessments[*]`
             * `.data[*].comments` (current grader's are present)
             * `.data[*].comments_html` (current grader's are present)

test plan:
 A. Setup
    1. Enable AMM
       a. Set Account AMM to "on"
       b. Set Course Moderated Grading to "on"
       c. Set Course Anonymous Marking to "on"
    2. Select or create
       a. A Course
       b. At least one Student
       c. At least one TA
       d. Two Teachers (A and B)
       e. One Assignment with all of the following
          * Moderated Grading "on"
          * Anonymous Grading "on"
          * A rubric
          * Teacher B as the moderator

    3. Set Account AMM feature flag to "off"
       * This un-breaks SpeedGrader for grading purposes

    4. As a Student
       a. Submit to the assignment
       b. Comment on the submission
    5. As the TA
       a. Provisionally grade the submissions using the rubric
       b. Comment on the rubric assessment
       c. Comment on the submission
    6. As Teacher A
       a. Provisionally grade the submissions using the rubric
       b. Comment on the rubric assessment
       c. Comment on the submission
    7. As Teacher B
       a. Comment on the rubric assessment
       b. Comment on the submission

 B. Massage Data
    1. Set Account AMM feature flag to "on"
       * This allows anonymity data to be saved
    2. Open the Rails console

    3. Load the assignments
    4. Update both assignments with:
       `{graders_anonymous_to_graders: true}`
       `{grader_comments_visible_to_graders: false}`

    * If moderation graders were automatically created, skip to C

    5. Load the Teachers and TA
    6. Create moderation graders for each assignment

       `assignment.moderation_graders.create!(…)`
       * `{user: ta, anonymous_id: 'atata'}`
       * `{user: teacher_a, anonymous_id: 'teach'}`
       * `{user: teacher_b, anonymous_id: 'moder'}`

 C. With Grader Comments Hidden
    1. Ensure AMM is "on"
    2. Visit the course in SpeedGrader as Teacher A
    3. Open the browser network dev tools tab
    4. Refresh to ensure the `speed_grader.json` request is present
    5. View the response to that request

    6. Dig in.

    7. Verify the Teacher A comments are present
    8. Verify the Student comments are present
    9. Verify the Teacher B comments are not present
    9. Verify the TA comments are not present

 D. With AMM Disabled
    1. Set Account AMM feature flag to "off"
    2. Visit the course in SpeedGrader as the Teacher
    3. Open the browser network dev tools tab
    4. Refresh to ensure the `speed_grader.json` request is present
    5. View the response to that request

    6. Dig in. Again.

    7. Verify the Teacher A comments are present
    7. Verify the Teacher B comments are present
    8. Verify the Student comments are present
    9. Verify the TA comments are present

Change-Id: Ica3104b3ce1ff4b4fe0039c9f184b186d3d83ea6
Reviewed-on: https://gerrit.instructure.com/151691
Reviewed-by: Adrian Packel <apackel@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-06-06 18:19:25 +00:00
Adrian Packel 94a8105cfa Add provisional grade selector in SG
Add a component in SpeedGrader to allow the moderator to select among
provisional grades or enter a custom grade. Update the grade input to
match the selected grade and indicate which grader is responsible.

closes GRADE-1069

Test plan:

NOTE: you only need to test this with points-based assignments at the
moment. Other grading types will probably work but the display will be
screwy. Those will be addressed more fully in a future ticket.

  * Turn on Anonymous Moderated Marking if the feature flag still exists
  * Have a course with multiple teachers and students
  * Create a moderated assignment and designate one of the teachers to
    be the final grader.
  * [If the old moderation page still exists when you read this]
    On the existing moderation page, add all the students to the
    assignment's moderation set.
  * As one or more non-final-grader teachers, hand out some grades for
    the assignment in SpeedGrader (no need to go through the moderation
    page; you can just use the SpeedGrader link on the assignment page).
    Make sure there is at least one student who does *not* receive any
    provisional grades for the assignment.
  * As the final grader, open the assignment in SpeedGrader.
  * For any student who HAS received provisional grades, there should
    be a "Show/Hide Details" link that toggles a set of radio buttons
    showing the existing provisional grades.
  * Do some testing with these and make sure they adhere to the
    behavior described in the next section.
  * For the student who has NOT received provisional grades, the grade
    selector should not appear, but you should be able to assign a
    grade and submit comments as usual.

Provisional grade selector behavior:
  * The top radio button, corresponding to the grade assigned by the
    moderator, should always be labeled "Custom." Below that, one
    radio button should appear for each provisional grade handed out,
    showing the grader and the assigned grade.
  * For assignments where grader names are visible to the final grader,
    the each button's label should show that grader's name.
  * For assignments where grader names are NOT visible to the final
    grader, the labels should be "Grader 1", "Grader 2" and so on,
    listed in that order.
  * When you select a radio button other than "Custom", the value
    associated with that button should appear in the grade text input
    and the selected grader should be shown to the right of the input.
  * When you select the "Custom" button, the last custom value you
    entered should appear in the text input, and "Custom" should appear
    as the grader name.
  * If you directly enter a value in the grade input and tab out,
    the "Custom" button should be selected (and the label changed).
  * Your selections should persist in moving back/forward between
    students and refreshing the page.

Change-Id: I3696f9e0edbbe1aa81aa85fa6e51e229fc2136b5
Reviewed-on: https://gerrit.instructure.com/151472
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
QA-Review: Jeremy Neander <jneander@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-06-05 18:03:05 +00:00
Neil Gupta 9b7ec59ee6 anonymize gradeable students endpoint
fixes GRADE-898 GRADE-1023

test plan:
1. create a course with 3 teachers and 1 student
2. create an anonymously graded and moderated assignment with 2 graders
3. as a teacher, give the student a provisional grade
4. as another teacher, give the student another provisional grade
5. as the final grader, visit the grade moderation page
6. inspect the API responses, there should be no identifiable ids or
  names in the responses
7. select a final grade
8. make sure the API request and response when selecting the final grade
  is also anonymous

Change-Id: I083673e29d4b49c1d97cedad46571bccc622a8a2
Reviewed-on: https://gerrit.instructure.com/151134
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-05-31 22:30:25 +00:00
Adrian Packel e99612d627 Show error in SG on grade/comment if max graders
When a moderated assignment's max grader count has been reached, further
provisional graders other than the moderator are not allowed to grade
or submit comments. Show an appropriate error in SpeedGrader if someone
tries to take either action.

closes GRADE-1058

Test plan:

Note that the plan below assumes that GRADE-1060 (which disables access
to SpeedGrader for new graders if the maximum number of graders has
already been reached) has been merged. If it has not been merged at the
time of testing, you can make the test plan a little easier by loading
both teachers sequentially in the same browser instead of using
different browsers.

  * Have a course with AMM enabled and at least three instructors
  * Enable AMM, create a moderated assignment, and set the max graders
    to 1
  * Open two browsers, each logged in as a teacher who is *not* the
    final grader. In each browser, open SpeedGrader for that assignment.
  * In one browser, enter a grade or submit a comment. This should
    complete without incident.
  * In the second browser, do the same thing. This time, you should get
    an alert stating that the maximum number of graders for the course
    has been reached.
  * The grader in the first browser should still be able to change their
    grade and leave comments.
  * Appoint a third teacher as the final grader; make sure this teacher
    can open SpeedGrader and grade/submit comments.

Change-Id: Ie2efa3c55bb71788210e7e1a02363712d8f7a2f0
Reviewed-on: https://gerrit.instructure.com/150804
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Sidharth Oberoi <soberoi@instructure.com>
2018-05-25 17:24:26 +00:00
Jeremy Neander 3bddf52f21 anonymize graders in speed_grader.json
closes GRADE-1021

QA Notes:

 * Anonymous Grading impacts the following parts of speed_grader.json

    For content associated with the current grader:

    * within `submissions[*]`:
       * `.submission_comments[*].author_id` (absent)
       * `.submission_comments[*].anonymous_id` (present)
       * `.submission_comments[*].author_name` (present)
       * `.submission_comments[*].avatar_path` (present)

       * `.provisional_grades[*].scorer_id` (absent)
       * `.provisional_grades[*].anonymous_grader_id` (present)

       * within `.provisional_grades[*]`

          * `.rubric_assessments[*].assessor_id` (absent)
          * `.rubric_assessments[*].anonymous_assessor_id` (present)

    For content associated with other graders:

    * within `submissions[*]`:
       * `.submission_comments[*].author_id` (absent)
       * `.submission_comments[*].anonymous_id` (present)
       * `.submission_comments[*].author_name` (absent)
       * `.submission_comments[*].avatar_path` (absent)

       * `.provisional_grades[*].scorer_id` (absent)
       * `.provisional_grades[*].anonymous_grader_id` (present)

       * within `.provisional_grades[*]`

          * `.rubric_assessments[*].assessor_id` (absent)
          * `.rubric_assessments[*].anonymous_assessor_id` (present)

 * When not anonymized:

    * within `submissions[*]`:
       * `.submission_comments[*].author_id` (present)
       * `.submission_comments[*].anonymous_id` (absent)
       * `.submission_comments[*].author_name` (present)
       * `.submission_comments[*].avatar_path` (present)

       * `.provisional_grades[*].scorer_id` (present)
       * `.provisional_grades[*].anonymous_grader_id` (absent)

       * within `.provisional_grades[*]`

          * `.rubric_assessments[*].assessor_id` (present)
          * `.rubric_assessments[*].anonymous_assessor_id` (absent)

test plan:
 A. Setup
    1. Enable AMM
       a. Set Account AMM to "on"
       b. Set Course Moderated Grading to "on"
       c. Set Course Anonymous Marking to "on"
    2. Select or create
       a. A Course
       b. At least one Student
       c. At least one TA
       d. A Teacher
       e. Two Assignments
          * Moderated Grading "on"
          * Anonymous Grading "on"
          * with rubrics
          * Teacher is the moderator
    3. Enable avatars

    4. Set Account AMM feature flag to "off"
       * This un-breaks SpeedGrader for grading purposes

    5. As a Student
       a. Give yo'self an avatar
          * Remember to smile
       b. Submit to both assignments
       c. Comment on the first submission
    6. As the TA
       a. Upload an avatar
          * No smiles. You are only an assistant.
       b. Grade both submissions using the rubric
       c. Comment on the first submission
    7. As the Teacher
       a. Avatar: The Last Gradebender
          * Wear that nice sweater you got for your birthday
       b. Grade both submissions using the rubric
       c. Comment on the first submission

 B. Massage Data
    1. Set Account AMM feature flag to "on"
       * This allows anonymity data to be saved
    2. Open the Rails console

    3. Load the assignments
    4. Update both assignments with:
       `{graders_anonymous_to_graders: true}`
       `{grader_comments_visible_to_graders: true}`

    5. Load the Teacher and TA (as `teacher` and `ta`)
    6. Create moderation graders for each assignment

       `assignment.moderation_graders.create!(…)`
       * `{user: teacher, anonymous_id: 'teach'}`
       * `{user: ta, anonymous_id: 'atata'}`

 C. With Grader Anonymity Enabled
    1. Ensure AMM is "on"
    2. Visit the course in SpeedGrader as the Teacher
    3. Open the browser network dev tools tab
    4. Refresh to ensure the `speed_grader.json` request is present
    5. View the response to that request

    6. Dig in.

    7. Verify the Teacher content is mostly anonymized
    8. Verify the TA content is fully anonymized

 D. With AMM Disabled
    1. Set Account AMM feature flag to "off"
    2. Visit the course in SpeedGrader as the Teacher
    3. Open the browser network dev tools tab
    4. Refresh to ensure the `speed_grader.json` request is present
    5. View the response to that request

    6. Dig in. Again.

    7. Verify the Teacher content is not anonymized
    8. Verify the TA content is not anonymized

    9. Smoke test SpeedGrader

Change-Id: I82a6afd79ce0a4cf6dac94ac2052ffa19a73dccb
Reviewed-on: https://gerrit.instructure.com/150148
Tested-by: Jenkins
Reviewed-by: Neil Gupta <ngupta@instructure.com>
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-05-17 00:18:05 +00:00
Jeremy Neander 47f8d66189 check assignment for student anonymity in speedgrader
refs GRADE-1021

test plan:
 * smoke test `speed_grader.json` for anonymous students
 * smoke test `speed_grader.json` for non-anonymous students

Change-Id: I8117eab29cc268427f2465e19f09875559b92904
Reviewed-on: https://gerrit.instructure.com/150147
Tested-by: Jenkins
Reviewed-by: Derek Bender <djbender@instructure.com>
Reviewed-by: Adrian Packel <apackel@instructure.com>
QA-Review: Adrian Packel <apackel@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-05-15 15:38:14 +00:00
Keith Garner e43c83971a add speedgrader check against assignment.anonymous_grading
Now that the anonymous_grading flag exists on the assignment model,
use that along with our dev flag existing as the key to put
speedgrader into anonymous mode.

fixes GRADE-988

test plan:
 - Have a course with some students and an assignment
 - Ensure that the anonymous moderated marking feature flag is on for
   the account and that the anonymous marking feature flag is on for the
   course.
 - Load the assignment in speedgrader (or hit the speed_grader.json end
   point.)
 - Note that nothing is anonymized
 - Edit the assignment and turn on anonymous grading
 - Load the assignment in speedgrader (or hit the speed_grader.json end
   point.)
 - Note that the identifying student information is anonymized

Change-Id: I8e0345eba058a7bf9d10062f95a410e6ea533651
Reviewed-on: https://gerrit.instructure.com/144209
Reviewed-by: Spencer Olson <solson@instructure.com>
Tested-by: Jenkins
QA-Review: Adrian Packel <apackel@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-03-20 20:29:42 +00:00
Jeremy Neander 760fca6969 anonymize students in speed_grader.json
closes GRADE-941

test plan:
 A. Setup
    1. Select or create
       a. A Course
       b. At least one Student
       c. At least one TA
       d. At least one Assignment with rubric
    2. Enable avatars
    3. As the Student
       a. Give yo'self an avatar
          * Remember to smile
       b. Submit to the assignment
       c. Comment on the submission
    4. As the TA
       a. Upload an avatar
          * No smiles. You are only an assistant.
       b. Comment on the submission
    5. As the Teacher
       a. Avatar: The Last Gradebender
          * Wear that nice sweater you for for your birthday
       b. Grade the submission using the rubric
       c. Comment on the submission
    6. In the Rails console
       a. Load the submission
       b. Assign `abcde` as the submission `anonymous_id`
       c. Save the submission

 B. With AMM Enabled
    1. Enable the AMM feature flag
    2. Visit the course in SpeedGrader
    3. Open the browser network dev tool tab
    4. Refresh to ensure the `speed_grader.json` request is present
    5. View the response to that request

    6. Verify for the enrollments
       a. The student id is absent from the student enrollment
          * `context.enrollments[*].user_id`
       b. The enrollment has an anonymous_id of `abcde`
          * `context.enrollments[*].anonymous_id`

    7. Verify for the submission
       a. The submission has an anonymous_id of `abcde`
          * `submissions[*].anonymous_id`
       b. The submission has no `user_id`
          * `submissions[*].user_id`
       c. The submission history has an anonymous_id of `abcde`
          * `submissions[*].submission_history[*].anonymous_id`
       d. The submission history has no `user_id`
          * `submissions[*].submission_history[*].user_id`

    8. Verify for the student
       a. The student id is absent from the student
          * `context.students[*].id`
       b. The student id is absent from rubric assessments
          * `context.students[*].rubric_assessments[*].user_id`
       c. The student id is absent from submission comments
          * `submissions[*].submission_comments[*].author_id`
       d. The student comment has an anonymous_id of `abcde`
          * `submissions[*].submission_comments[*].anonymous_id`
       e. The student name is absent from submission comments
          * `submissions[*].submission_comments[*].author_name`
       f. The student avatar is the fallback on submission comments
          * `submissions[*].submission_comments[*].avatar_path`
          * `/images/messages/avatar-50.png`

    9. Verify for the TA
       a. The TA id is present on submission comments
          * `submissions[*].submission_comments[*].author_id`
       b. The TA comment does not have an `anonymous_id`
          * `submissions[*].submission_comments[*].anonymous_id`
       c. The TA name is present on submission comments
          * `submissions[*].submission_comments[*].author_name`
       d. The TA avatar is present on submission comments
          * `submissions[*].submission_comments[*].avatar_path`

   10. Verify for the Teacher
       a. The Teacher id is present on submission comments
          * `submissions[*].submission_comments[*].author_id`
       b. The Teacher comment does not have an `anonymous_id`
          * `submissions[*].submission_comments[*].anonymous_id`
       c. The Teacher name is present on submission comments
          * `submissions[*].submission_comments[*].author_name`
       d. The Teacher avatar is present on submission comments
          * `submissions[*].submission_comments[*].avatar_path`

 C. With AMM Disabled
    1. Disable the AMM feature flag
    2. Visit the course in SpeedGrader
    3. Open the browser network dev tool tab
    4. Refresh to ensure the `speed_grader.json` request is present
    5. View the response to that request

    6. Verify for the enrollments
       a. The student id present on the student enrollment
          * `context.enrollments[*].user_id`
       b. The enrollment does not have an anonymous_id
          * `context.enrollments[*].anonymous_id`

    7. Verify for the submission
       a. The submission has no anonymous_id of `abcde`
          * `submissions[*].anonymous_id`
       b. The submission has the student id assigned to `user_id`
          * `submissions[*].user_id`
       c. The submission history has the student id assigned to `user_id`
          * `submissions[*].submission_history[*].user_id`

    8. Verify for the student
       a. The student id is present on the student
          * `context.students[*].id`
       b. The student id is present on rubric assessments
          * `context.students[*].rubric_assessments[*].user_id`
       c. The student id is present on submission comments
          * `submissions[*].submission_comments[*].author_id`
       d. The student comment does not have an anonymous_id
          * `submissions[*].submission_comments[*].anonymous_id`
       e. The student name is present on submission comments
          * `submissions[*].submission_comments[*].author_name`
       f. The student avatar is present on submission comments
          * `submissions[*].submission_comments[*].avatar_path`

    9. Verify for the TA
       a. The TA id is present on submission comments
          * `submissions[*].submission_comments[*].author_id`
       b. The TA comment does not have an `anonymous_id`
          * `submissions[*].submission_comments[*].anonymous_id`
       c. The TA name is present on submission comments
          * `submissions[*].submission_comments[*].author_name`
       d. The TA avatar is present on submission comments
          * `submissions[*].submission_comments[*].avatar_path`

   10. Verify for the Teacher
       a. The Teacher id is present on submission comments
          * `submissions[*].submission_comments[*].author_id`
       b. The Teacher comment does not have an `anonymous_id`
          * `submissions[*].submission_comments[*].anonymous_id`
       c. The Teacher name is present on submission comments
          * `submissions[*].submission_comments[*].author_name`
       d. The Teacher avatar is present on submission comments
          * `submissions[*].submission_comments[*].avatar_path`

   11. Smoke test SpeedGrader

Change-Id: I57806c555b904757876523f4e201cfd8dcd31e61
Reviewed-on: https://gerrit.instructure.com/143287
Reviewed-by: Spencer Olson <solson@instructure.com>
Tested-by: Jenkins
Reviewed-by: Derek Bender <djbender@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-03-20 14:35:25 +00:00
Spencer Olson 848b1714ee stop loading overrides in speedgrader
Assignment Overrides were only being used for one thing in SpeedGrader:
determining if a submission was in a closed grading period. Given that
we now store the grading_period_id on each submission, we can determine
if a submission is in a closed grading period without needing overrides
at all. This commit removes the call from SpeedGrader to get overrides,
and adds the grading_period_id to submissions in the speedgrader.json
response.

closes GRADE-951

Test Plan:

1. As a teacher, enter a course that is using grading periods, and one
   of the grading periods is closed.
2. Create an assignment and assign it to one student in the closed
   period, and to everyone else in an open period.
3. Go to SpeedGrader for the assignment and select the student who
   has the assignment due in the closed period. Verify there is a
   banner at the top of the page that says "Notice: The grading period
   is closed for this student".
4. Select a student that has the assignment due in an open period.
   Verify there is not a banner at the top of the page indicating the
   grading period is closed for the student.
5. General smoke-test of selecting students + grading students in
   SpeedGrader.

Change-Id: Ic608a9bd3d8c27ef30e84cbedf0897049ec34f49
Reviewed-on: https://gerrit.instructure.com/143471
Tested-by: Jenkins
Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com>
Reviewed-by: Adrian Packel <apackel@instructure.com>
Reviewed-by: Derek Bender <djbender@instructure.com>
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-03-19 15:14:21 +00:00
wdransfield fd0dde71fd Fix URL for Vericite Integ
Fixes PLAT-3169

Test Plan:
- Configure an assignment to use the Vericite plugin.
- Submit to the assignment as a studenet and populate
  the submission with Vericite data.
- Navigate to speedgrader for the submission and verify
  clicking on the similarity score redirects to the
  Vericite tool.
- Verify the following display and link correctly in
  all their places in Canvas UI:
  * Originality reports for online upload assignments
  * Originality reports for group upload assignments
  * Originality reports for text entry assignments

Change-Id: Ia5dfd7f09bf9f06af053764dcec6774c8b170245
Reviewed-on: https://gerrit.instructure.com/142243
Reviewed-by: Andrew Butterfield <abutterfield@instructure.com>
Tested-by: Jenkins
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Reviewed-by: Nathan Mills <nathanm@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: Jesse Poulos <jpoulos@instructure.com>
2018-03-01 17:01:28 +00:00