canvas-lms/spec/graphql/mutations
Adrian Packel 7fa746b077 Add setOverrideScore mutation
closes GRADE-84

Test plan:
Note that you can also test this via the /graphiql endpoint on local
Canvas installation once you've logged in (you can use the query
string from the heredoc below).

- Identify a Score object you want to update and its corresponding
  Enrollment object
- In a Rails console:
  > mutation_str = <<~STR
    mutation {
      setOverrideScore(input: {
        enrollmentId: <the enrollment ID>
        gradingPeriodId: <ID of associated grading period if exists>
        overrideScore: 123.4567 <or whatever>
      }) {
        grades {
          gradingPeriod {
            id
            _id
          }
          overrideScore
        }
        errors {
          attribute
          message
        }
      }
    }
  STR
  > user = User.find(<a user ID with appropriate permissions>)
  > CanvasSchema.execute(mutation_str, context: {current_user: user})

- You should get back a response with no errors and a score-like object
  (technically a Grades type in GraphQL)
- The properties of the returned object should include the override score
  you set and, if you updated a score belonging to a grading period, the
  GraphQL and Rails ID fields for the grading period (in the gradingPeriod
  attribute)
- Check the Score object with the matching enrollment/grading period to
  make sure your call did indeed update it

- Also try the following:
  - Excluding the gradingPeriodId field from the input hash (i.e.,
    update the score associated with an enrollment and not belonging
    to a grading period)
  - Passing "null" (without the quotes) for the overrideScore; this
    should clear an existing value
- The following should return errors and no score data:
  - Passing in malformed values for overrideScore or the ID fields
  - Passing in an ID for a non-existent enrollment/grading period
  - Running the CanvasSchema.execute command with current_user set to a
    user who does not have permissions to modify the score in question
    (e.g., a student, or generally someone who's not a teacher in that
    course)

Change-Id: I2b5c6a80842a6febdb1e398a41aa71ea37cdb064
Reviewed-on: https://gerrit.instructure.com/172472
Tested-by: Jenkins
Reviewed-by: Cameron Matheson <cameron@instructure.com>
Reviewed-by: Gary Mei <gmei@instructure.com>
QA-Review: Adrian Packel <apackel@instructure.com>
Product-Review: Keith Garner <kgarner@instructure.com>
2018-11-16 17:26:23 +00:00
..
create_group_in_set_spec.rb graphql: add CreateGroupInSet mutation 2018-11-14 00:49:29 +00:00
set_override_score_spec.rb Add setOverrideScore mutation 2018-11-16 17:26:23 +00:00