canvas-lms/spec/graphql/mutations/create_submission_draft_spe...

336 lines
11 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
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-05-18 06:50:20 +08:00
#
# Copyright (C) 2019 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require_relative '../graphql_spec_helper'
RSpec.describe Mutations::CreateSubmissionDraft do
before(:once) do
@submission = submission_model
@attachments = [
attachment_with_context(@student),
attachment_with_context(@student)
]
@media_object = factory_with_protected_attributes(MediaObject, :media_id => 'm-123456')
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-05-18 06:50:20 +08:00
end
def mutation_str(
submission_id: @submission.id,
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-02 05:17:06 +08:00
active_submission_type: nil,
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-05-18 06:50:20 +08:00
attempt: nil,
body: nil,
file_ids: [],
media_id: nil,
url: nil
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-05-18 06:50:20 +08:00
)
<<~GQL
mutation {
createSubmissionDraft(input: {
submissionId: "#{submission_id}"
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-02 05:17:06 +08:00
#{"activeSubmissionType: #{active_submission_type}" if active_submission_type}
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-05-18 06:50:20 +08:00
#{"attempt: #{attempt}" if attempt}
#{"body: \"#{body}\"" if body}
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-05-18 06:50:20 +08:00
fileIds: #{file_ids}
#{"mediaId: \"#{media_id}\"" if media_id}
#{"url: \"#{url}\"" if url}
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-05-18 06:50:20 +08:00
}) {
submissionDraft {
_id
submissionAttempt
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-02 05:17:06 +08:00
activeSubmissionType
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-05-18 06:50:20 +08:00
attachments {
_id
displayName
}
body
mediaObject {
_id
}
url
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-05-18 06:50:20 +08:00
}
errors {
attribute
message
}
}
}
GQL
end
def run_mutation(opts = {}, current_user = @student)
result = CanvasSchema.execute(mutation_str(opts), context: {current_user: current_user, request: ActionDispatch::TestRequest.create})
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-05-18 06:50:20 +08:00
result.to_h.with_indifferent_access
end
it 'creates a new submission draft' do
result = run_mutation(
submission_id: @submission.id,
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-02 05:17:06 +08:00
active_submission_type: 'online_upload',
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-05-18 06:50:20 +08:00
attempt: @submission.attempt,
file_ids: @attachments.map(&:id)
)
expect(
result.dig(:data, :createSubmissionDraft, :submissionDraft, :_id)
).to eq SubmissionDraft.last.id.to_s
end
it 'updates an existing submission draft' do
first_result = run_mutation(
submission_id: @submission.id,
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-02 05:17:06 +08:00
active_submission_type: 'online_upload',
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-05-18 06:50:20 +08:00
attempt: @submission.attempt,
file_ids: @attachments.map(&:id)
)
attachment_ids = first_result.dig(:data, :createSubmissionDraft, :submissionDraft, :attachments).map { |attachment| attachment[:_id] }
expect(attachment_ids.count).to eq 2
@attachments.each do |attachment|
expect(attachment_ids.include?(attachment[:id].to_s)).to be true
end
second_result = run_mutation(
submission_id: @submission.id,
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-02 05:17:06 +08:00
active_submission_type: 'online_upload',
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-05-18 06:50:20 +08:00
attempt: @submission.attempt,
file_ids: [@attachments[0].id]
)
attachment_ids = second_result.dig(:data, :createSubmissionDraft, :submissionDraft, :attachments).map { |attachment| attachment[:_id] }
expect(attachment_ids.count).to eq 1
expect(attachment_ids[0]).to eq @attachments[0].id.to_s
expect(
first_result.dig(:data, :createSubmissionDraft, :submissionDraft, :submissionAttempt)
).to eq second_result.dig(:data, :createSubmissionDraft, :submissionDraft, :submissionAttempt)
end
it 'allows you to set a body on the submission draft' do
result = run_mutation(
submission_id: @submission.id,
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-02 05:17:06 +08:00
active_submission_type: 'online_text_entry',
attempt: @submission.attempt,
body: 'some text body'
)
expect(
result.dig(:data, :createSubmissionDraft, :submissionDraft, :body)
).to eq 'some text body'
end
it 'allows you to set a url on the submission draft' do
result = run_mutation(
submission_id: @submission.id,
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-02 05:17:06 +08:00
active_submission_type: 'online_url',
attempt: @submission.attempt,
url: 'http://www.google.com'
)
expect(
result.dig(:data, :createSubmissionDraft, :submissionDraft, :url)
).to eq 'http://www.google.com'
end
it 'allows you to set a media_object_id on the submission draft' do
result = run_mutation(
submission_id: @submission.id,
active_submission_type: 'media_recording',
attempt: @submission.attempt,
media_id: @media_object.media_id
)
expect(
result.dig(:data, :createSubmissionDraft, :submissionDraft, :mediaObject, :_id)
).to eq @media_object.media_id
end
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-02 05:17:06 +08:00
it 'allows you to set an active_submission_type on the submission draft' do
result = run_mutation(
active_submission_type: 'online_text_entry',
attempt: @submission.attempt,
body: 'some text body',
submission_id: @submission.id
)
expect(
result.dig(:data, :createSubmissionDraft, :submissionDraft, :activeSubmissionType)
).to eq 'online_text_entry'
end
it 'only updates attachments when the active submission type is online_upload' do
result = run_mutation(
submission_id: @submission.id,
active_submission_type: 'online_upload',
attempt: @submission.attempt,
body: 'some text body',
file_ids: @attachments.map(&:id)
)
attachment_ids = result.dig(:data, :createSubmissionDraft, :submissionDraft, :attachments).map { |attachment| attachment[:_id] }
expect(attachment_ids.count).to eq 2
@attachments.each do |attachment|
expect(attachment_ids.include?(attachment[:id].to_s)).to be true
end
expect(
result.dig(:data, :createSubmissionDraft, :submissionDraft, :body)
).to be nil
end
it 'only updates the body when the active submission type is online_text_entry' do
result = run_mutation(
submission_id: @submission.id,
active_submission_type: 'online_text_entry',
attempt: @submission.attempt,
body: 'some text body',
url: 'http://www.google.com'
)
expect(
result.dig(:data, :createSubmissionDraft, :submissionDraft, :body)
).to eq 'some text body'
expect(
result.dig(:data, :createSubmissionDraft, :submissionDraft, :url)
).to be nil
end
it 'only updates the url when the active submission type is online_url' do
result = run_mutation(
submission_id: @submission.id,
active_submission_type: 'online_url',
attempt: @submission.attempt,
body: 'some text body',
url: 'http://www.google.com'
)
expect(
result.dig(:data, :createSubmissionDraft, :submissionDraft, :body)
).to be nil
expect(
result.dig(:data, :createSubmissionDraft, :submissionDraft, :url)
).to eq 'http://www.google.com'
end
it 'returns an error if the active submission type is not included' do
result = run_mutation(
attempt: @submission.attempt,
body: 'some text body',
submission_id: @submission.id
)
expect(
result.dig(:errors, 0, :message)
).to include "Argument 'activeSubmissionType' on InputObject 'CreateSubmissionDraftInput' is required"
end
it 'returns an error if the active submission type is not valid' do
result = run_mutation(
active_submission_type: 'thundercougarfalconbird',
attempt: @submission.attempt,
body: 'some text body',
submission_id: @submission.id
)
expect(
result.dig(:errors, 0, :message)
).to include "Expected type 'DraftableSubmissionType!'"
end
it 'prefixes the url with a scheme if missing' do
@submission.assignment.update!(submission_types: 'online_url')
result = run_mutation(
submission_id: @submission.id,
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-02 05:17:06 +08:00
active_submission_type: 'online_url',
attempt: @submission.attempt,
url: 'www.google.com'
)
expect(
result.dig(:data, :createSubmissionDraft, :submissionDraft, :url)
).to eq 'http://www.google.com'
end
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-05-18 06:50:20 +08:00
it 'returns an error if the attachments are not owned by the user' do
attachment = attachment_with_context(@teacher)
result = run_mutation(
submission_id: @submission.id,
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-02 05:17:06 +08:00
active_submission_type: 'online_upload',
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-05-18 06:50:20 +08:00
attempt: @submission.attempt,
file_ids: [attachment.id]
)
expect(
result.dig(:data, :createSubmissionDraft, :errors, 0, :message)
).to eq "No attachments found for the following ids: [\"#{attachment.id}\"]"
end
it 'returns an error if the attachments don\'t have an allowed file extension' do
@submission.assignment.update!(allowed_extensions: ['lemon'])
result = run_mutation(
submission_id: @submission.id,
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-02 05:17:06 +08:00
active_submission_type: 'online_upload',
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-05-18 06:50:20 +08:00
attempt: @submission.attempt,
file_ids: [@attachments[0].id]
)
expect(
result.dig(:data, :createSubmissionDraft, :errors, 0, :message)
).to eq 'Invalid file type'
end
it 'returns a graceful error if the submission is not found' do
result = run_mutation(
submission_id: 1337,
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-02 05:17:06 +08:00
active_submission_type: 'online_upload',
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-05-18 06:50:20 +08:00
attempt: 0,
file_ids: []
)
expect(
result.dig(:errors, 0, :message)
).to eq 'not found'
end
it 'returns an error if the draft is more then one attempt more the current submission attempt' do
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-05-18 06:50:20 +08:00
result = run_mutation(
submission_id: @submission.id,
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-02 05:17:06 +08:00
active_submission_type: 'online_upload',
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-05-18 06:50:20 +08:00
attempt: 1337,
file_ids: [@attachments[0].id]
)
expect(
result.dig(:data, :createSubmissionDraft, :errors, 0, :message)
).to eq 'submission draft cannot be more then one attempt ahead of the current submission'
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-05-18 06:50:20 +08:00
end
it 'uses the submission attempt plus one if an explicit attempt is not provided' do
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-05-18 06:50:20 +08:00
result = run_mutation(
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-02 05:17:06 +08:00
active_submission_type: 'online_upload',
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-05-18 06:50:20 +08:00
submission_id: @submission.id,
file_ids: [@attachments[0].id]
)
expect(
result.dig(:data, :createSubmissionDraft, :submissionDraft, :submissionAttempt)
).to eq @submission.attempt + 1
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-05-18 06:50:20 +08:00
end
it 'uses the given attempt when provided' do
@submission.update!(attempt: 2)
result = run_mutation(
submission_id: @submission.id,
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-02 05:17:06 +08:00
active_submission_type: 'online_upload',
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-05-18 06:50:20 +08:00
attempt: 1,
file_ids: [@attachments[0].id]
)
expect(
result.dig(:data, :createSubmissionDraft, :submissionDraft, :submissionAttempt)
).to eq 1
end
end