Commit Graph

17 Commits

Author SHA1 Message Date
Aaron Ogata f38beb9fea fix run_mutation pattern for ruby 3.x
refs AE-92

Change-Id: Ifa4b7f6b03ecf9da9113698004dd5c48bf294b22
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/307213
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Aaron Ogata <aogata@instructure.com>
Product-Review: Aaron Ogata <aogata@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2022-12-12 20:42:32 +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 e73cf9ddf4 RuboCop: Style/HashSyntax
[skip-stages=Flakey]

auto-corrected

Change-Id: I9371a61046aee6b148f89dd434114a8ba2b1188c
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/279533
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>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
2021-11-25 14:02:35 +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 06a2c9df42 spec: remove manual requires of spec_helper
[skip-stages=Flakey]

Change-Id: Id65c835b72e1c0a4bb825b58490ce0ff7c8d9873
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/276829
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-26 20:38:27 +00:00
Adrian Packel a79d13a1f5 Add LTI fields to submission drafts
Add several fields to submission drafts to facilitate saving LTI launch
submissions, and allow drafts to be of the type basic_lti_launch. (To
avoid breaking the new workflow, we don't yet let drafts with this type
be saved as actual submissions.)

To avoid accumulating content from a potentially infinite number of
external tools, a draft may only contain data from a single external
tool at a time. This is fine since drafts of this type will be a link to
work done somewhere else, rather than local work that could be lost.

closes EVAL-1998
flag=assignments_2_student

Test plan:
- Test that the migration works
- Smoke test creating and submitting a draft with one of the existing
  types in the UI to make sure nothing has broken

Change-Id: I2f9d66af5f479812177d47aa1b925fbecbd95d97
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/275253
QA-Review: Adrian Packel <apackel@instructure.com>
Product-Review: Syed Hussain <shussain@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Xander Moffatt <xmoffatt@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
Reviewed-by: Spencer Olson <solson@instructure.com>
2021-10-07 18:23:01 +00:00
Cody Cutrer 6b0095610c RuboCop: Layout spec
[skip-stages=Flakey]

Change-Id: Id479617328562fd009f00db27f248c2ebafa4b7a
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274151
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
2021-09-22 22:40:24 +00:00
Han Yan 79ce88779e fix errors on dup draft records
closes DEMO-114
flag=none

test plan:
- make sure `Assignment Enhancements - Student` FF is enabled in Canvas
- create online assignments with text entry (or file uploads ...)
- in Canvas rails console, find the text entry draft (SubmissionDraft)
- create another SubmissionDraft records with the same submission and attempt
  (see new addtions in create_submission_draft_spec.rb, to bypass activerecord
  validations)
- add a new text entry draft without submitting
- update the text entry, draft is persited without errors

Change-Id: I47a9aa2420e6e2e9f200c0c66b60d80bf5ad8a3e
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/257920
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Stephen Kacsmark <skacsmark@instructure.com>
QA-Review: Mark McDermott <mmcdermott@instructure.com>
Product-Review: Han Yan <hyan@instructure.com>
2021-02-10 23:52:57 +00:00
Cody Cutrer 81d0bbc465 add # frozen_string_literal: true for specs
Change-Id: Id508bec1817937b1c24c29f1db7221e09cb9c2ab
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/251157
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:48:35 +00:00
Matthew Lemon 989ada446a add media object to submission_draft
Test Plan
- run migrations
- Create a course and add a student to it
- Create an assignment with a media_recording submission type
- Masquerade as the student and navigate to the assignment
- Upload/record a new media entry
- In the rails console find the MediaObject you just uploaded and grab
  the media_id from it. Also grab the Submission id.
    m = MediaObject.last
    m.media_id
    s = Submission.last
    s.id
- Navigate to /graphiql
- Create a new submission draft

mutation MyMutation {
  __typename
  createSubmissionDraft(input: {
      activeSubmissionType: media_recording,
      submissionId: <your_submission_id>,
      mediaId: <your_media_id>,
      attempt: 1
    }) {
    submissionDraft {
      mediaObject {
        _id
        canAddCaptions
        id
        mediaType
        title
      }
    }
  }
}

- Verify that the mediaObject looks good

refs COMMS-2502
flag=assignments_2_student

Change-Id: I93e86d7d7914fe9aeaa68223c752f09c323938e4
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/214136
Tested-by: Jenkins
QA-Review: Ben Nelson <bnelson@instructure.com>
Product-Review: Matthew Lemon <mlemon@instructure.com>
Reviewed-by: Landon Gilbert-Bland <lbland@instructure.com>
2019-10-25 21:02:05 +00:00
Matthew Lemon a96959d92c allow submitting url submissions in A2
TEST PLAN
- create a course and add a student to it
- Create an assignment with an online url submission type
- Masquerade as the student and navigate to the assignment
- Open the network tab in your dev tools
- Enter an invalid url e.g. 'ooooooh eeeeee'
- You should see a helpful message with an example of what a valid url
  looks like
- Refresh the page. Note that despite being invalid the draft is still
  saved
- Enter a valid url e.g. http://www.reddit.com and then wait 1 second or
  click out of the input.
- You should see a graphql mutation to create the submission draft in
  the network tab
- You should also see the submit button show up
- Enter something else e.g. google.com
- The input should update to show http://google.com
- Click the submit button
- You should see the graphql mutation to create the submission in the
  network tab
- The pizza tracker should also reflect the submitted status

fixes COMMS-2331
flag=assignments_2

Change-Id: I8fc19df31112e3fc504da88f65b5ef609ed35869
Reviewed-on: https://gerrit.instructure.com/209181
Tested-by: Jenkins
QA-Review: Steven Burnett <sburnett@instructure.com>
Reviewed-by: Landon Gilbert-Bland <lbland@instructure.com>
Product-Review: Matthew Lemon <mlemon@instructure.com>
2019-10-16 00:10:18 +00:00
Ryan Norton 9037b545df persist selected submission in a2
when there are multiple submission types and the user updates
a submission type, we should persist that choice the next time
they access the assignment.

Test Plan:
* run the db migration to add active_submission_type to the
  submission draft:
** bundle exec rake db:migrate:up VERSION=20191001164744

* as a teacher, create an assignment with multiple submission
  types (i.e. file upload, text entry)
* as a student in A2, navigate to the assignment
* you should see the landing page requesting you choose a
  submission type
* select a type but do not create a draft
* on refreshing the page, you should be taken back to the landing
  page

* select the File type
* add a file to the draft
* on refreshing the page, you should be taken to the file upload
  component

* select the Text Entry type
* create a text entry draft
* on refreshing the page, you should be taken to the text entry
  component

* re-select the File type
* remove the file you added
* on refreshing the page, you should be taken to the file upload
  component again

* re-select the Text Entry type
* do not modify the draft
* on refreshing the page, you should be taken to the file upload
  component again

* re-select the Text Entry type
* remove the text draft
* on refreshing the page, you should be taken to the text entry
  component again

Misc Confirmations:
* when adding drafts to multiple submission types, the drafts
  persist and are not erased when adding a draft to a different
  type

* in the rails console, if you manually set the active submission
  type to something that is not a valid submission type on the
  assignment, you should be taken to the landing page

```
sd = SubmissionDraft.last # or whatever draft you're working against
sd.active_submission_type = 'online_url'
sd.save!
```

flag=assignments_2_student
fixes COMMS-2476

Change-Id: Iebf78fc785a2df0acc03c0ce8a13efd34060f341
Reviewed-on: https://gerrit.instructure.com/211701
Reviewed-by: James Williams <jamesw@instructure.com>
Reviewed-by: Landon Gilbert-Bland <lbland@instructure.com>
Tested-by: Jenkins
QA-Review: Steven Burnett <sburnett@instructure.com>
Product-Review: Ryan Norton <rnorton@instructure.com>
2019-10-04 02:32:50 +00:00
Matthew Lemon 726ee1a6f5 add url to the submission draft model/graphql type
Test Plan
- run the db migration to add url to the SubmissionDraft table
  - bundle exec rake db:migrate:up VERSION=20190916193616

- Create a course and add a student to it
- Create an assignment with a submission type of online url
- Masquerade as the student and navigate to the /graphiql endpoint
- Run the following mutation updated with the appropriate submissionID:
```
mutation MyMutation {
  __typename
  createSubmissionDraft(input: {submissionId: <your_submission_id>, url: "http://www.google.com", attempt: 1}) {
    errors {
      attribute
      message
    }
    submissionDraft {
      _id
      url
      submissionAttempt
    }
  }
}
```

- The mutation should return 0 errors and the submission draft should
  reflect the given url
- Run the following query updated with the appropriate submissionID:
```
query MyQuery {
  __typename
  legacyNode(_id: <your_submission_id>, type: Submission) {
    ... on Submission {
      id
      submissionDraft {
        url
        submissionAttempt
        _id
      }
    }
  }
}
```

- The query result should show the url you entered in the previous
  mutation

refs COMMS-2331
flag=assignments_2

Change-Id: I60d756a9f0a29ea5aece960416edbb43c0949ddc
Reviewed-on: https://gerrit.instructure.com/209727
Tested-by: Jenkins
Reviewed-by: Landon Gilbert-Bland <lbland@instructure.com>
QA-Review: Ben Nelson <bnelson@instructure.com>
Product-Review: Matthew Lemon <mlemon@instructure.com>
2019-09-18 16:35:30 +00:00
Ryan Norton b54f9f6a8f add body to submission draft mutation in graphql
we need to allow setting a 'body' in the submission draft
mutation in graphql for text entry assignments

Test Plan:
* create an assignment as a teacher
* add a student to that assignment
* as a student, navigate to /graphiql
* run the following mutation
** set the submissionId to whatever your latest submissionId is
```
mutation {
  createSubmissionDraft(input: {submissionId: "1", attempt: 1, body: "stuff"}) {
    errors {
      message
      attribute
    }
    submissionDraft {
      _id
      body
    }
  }
}
```

* you should get a result like:
```
{
  "data": {
    "createSubmissionDraft": {
      "errors": null,
      "submissionDraft": {
        "_id": "42"
        "body": "stuff",
      }
    }
  }
}
```

* in the rails console, confirm the data (especially the body)
  is correct: SubmissionDraft.find(<id>)

fixes COMMS-2265

Change-Id: I6ba6a67e3a592e295c62365ca7fa13250d05e837
Reviewed-on: https://gerrit.instructure.com/203731
QA-Review: Matthew Lemon <mlemon@instructure.com>
Reviewed-by: Matthew Lemon <mlemon@instructure.com>
Tested-by: Jenkins
Product-Review: Ryan Norton <rnorton@instructure.com>
2019-08-06 18:14:20 +00:00
Landon Gilbert-Bland a1696706d7 Allow submisssion draft for future attempt
This changes the workflow around submission drafts. You will now always
create the draft for the attempt one ahead of the current submission
instead of parity for the current submission.

Closes COMMS-2218

Test Plan:
  - Jenkins passes

Change-Id: I2045847a974457a093a2ebf62f137f80dbdcf493
Reviewed-on: https://gerrit.instructure.com/202238
Tested-by: Jenkins
Reviewed-by: Michelle Simmons <misimmons@instructure.com>
Reviewed-by: Matthew Lemon <mlemon@instructure.com>
QA-Review: Landon Gilbert-Bland <lbland@instructure.com>
Product-Review: Landon Gilbert-Bland <lbland@instructure.com>
2019-07-23 21:51:06 +00:00
Landon Gilbert-Bland b40344ad87 Cycle through submission histories in A2 student view
Fixes COMMS-1986

Test Plan:
  * Create an assignment
  * As a student navigate to the assignment
  * Submit the assignment a couple times
  * Use the `Load Next` and `Load Previous` buttons at the bottom of the
    page to cycle between submissions, and make sure that is working as
    expected
  * Notice that it now says `Attempt x` in the header depending on what
    attempt you are currently on

Change-Id: I6e8263505450e8e85b7ce2bd93b9559bbc0fb2ac
Reviewed-on: https://gerrit.instructure.com/194153
Tested-by: Jenkins
Reviewed-by: Steven Burnett <sburnett@instructure.com>
QA-Review: Michelle Simmons <misimmons@instructure.com>
Product-Review: Landon Gilbert-Bland <lbland@instructure.com>
2019-06-03 20:50:11 +00:00
Matthew Lemon daa6ab0406 implement submission draft mutation in graphql
fixes COMMS-2066

Test Plan:
* create a course and create an assignment in that course
* add a student to the course
* masquerade as the student and navigate to Account > Files and upload a
  few files for the user
* Open the rails console
    `bundle exec rails c`
* look up the files you had uploaded in the previous step
    `attachments = Attachment.where(user_id: <your_student_id>)`
* grab the file ids of those attachments
    `ids = attachments.map(&:id)`
* Also grab the submission id
    `submission_id = Submission.last.id`
* while still masquerading as the student navigate to the /graphiql
  endpoint
* in the mutation list select creatSubmissionDraft or just copy and
  paste the following, updating the query params with the values we found
  in the previous steps (attempt should be 0):
  ```
  mutation {
    createSubmissionDraft(input: {
      submissionId: "47",
      attempt: 0,
      fileIds: ["28", "29", "31"]
    }) {
      errors {
        message
      }
      submissionDraft {
        submission {
          _id
          user {
            name
          }
        }
        submissionAttempt
        attachments {
          _id
          url
        }
        _id
      }
    }
  }
  ```
* press play and run the mutation
* note the returned submission draft
* validate that the submission draft exists in the rails console. The
  draft and its attachments should match the return values from running
  the mutation
  ```
  s = Submission.find(<the_submission_id>)
  draft = s.submission_drafts.last
  draft.attachments
  ```
* remove or add some of the files and run the mutation again
* note the returned submission draft
* validate that the submission draft was updated in the rails console

Change-Id: I0df1b12325f635e89ba2a28212dac651fb5d3ae9
Reviewed-on: https://gerrit.instructure.com/194267
Tested-by: Jenkins
Reviewed-by: Landon Gilbert-Bland <lbland@instructure.com>
QA-Review: Michelle Simmons <misimmons@instructure.com>
Product-Review: Steven Burnett <sburnett@instructure.com>
2019-06-01 01:40:40 +00:00