Add grading status filter to submissions connection
refs: MBL-12809 Test Plan: - Create an assignment with a submission that needs grading, and a submission that is already graded - request submissions for the assignment through gql using the gradingStatus filter for needs_grading - It should return the submission requiring grading and not the other one Change-Id: I2ac6b7e95819122d085898255a352a002aefa9f7 Reviewed-on: https://gerrit.instructure.com/202156 Tested-by: Jenkins Reviewed-by: Cameron Matheson <cameron@instructure.com> QA-Review: Matt Sessions <msessions@instructure.com> Product-Review: Matt Sessions <msessions@instructure.com>
This commit is contained in:
parent
f0858936ab
commit
eec763a245
|
@ -132,7 +132,7 @@ module Interfaces::SubmissionInterface
|
|||
end
|
||||
end
|
||||
|
||||
field :grading_status, String, null: true
|
||||
field :grading_status, Types::SubmissionGradingStatusType, null: true
|
||||
field :late_policy_status, LatePolicyStatusType, null: true
|
||||
field :late, Boolean, method: :late?, null: true
|
||||
field :missing, Boolean, method: :missing?, null: true
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
#
|
||||
# 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/>.
|
||||
#
|
||||
|
||||
module Types
|
||||
class SubmissionGradingStatusType < BaseEnum
|
||||
graphql_name "SubmissionGradingStatus"
|
||||
|
||||
value "needs_grading", value: :needs_grading
|
||||
value "excused", value: :excused
|
||||
value "needs_review", value: :needs_review
|
||||
value "graded", value: :graded
|
||||
end
|
||||
end
|
|
@ -35,5 +35,7 @@ module Types
|
|||
argument :scored_less_than, Float, "Limit results to submissions that scored below the specified value", required: false
|
||||
argument :scored_more_than, Float, "Limit results to submissions that scored above the specified value", required: false
|
||||
argument :late, Boolean, "Limit results to submissions that are late", required: false
|
||||
|
||||
argument :grading_status, SubmissionGradingStatusType, "Limit results by grading status", required: false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -79,6 +79,19 @@ class SubmissionSearch
|
|||
search_scope = @options[:late] ? search_scope.late : search_scope.not_late
|
||||
end
|
||||
|
||||
if @options[:grading_status].present?
|
||||
case @options[:grading_status]
|
||||
when "needs_grading"
|
||||
search_scope = search_scope.where(Submission.needs_grading_conditions)
|
||||
when "excused"
|
||||
search_scope = search_scope.where(excused: true)
|
||||
when "needs_review"
|
||||
search_scope = search_scope.where(workflow_state: 'pending_review')
|
||||
when "graded"
|
||||
search_scope = search_scope.where(workflow_state: 'graded')
|
||||
end
|
||||
end
|
||||
|
||||
search_scope
|
||||
end
|
||||
|
||||
|
|
|
@ -2406,7 +2406,7 @@ type Submission implements Node & SubmissionInterface & Timestamped {
|
|||
"""
|
||||
gradeMatchesCurrentSubmission: Boolean
|
||||
gradedAt: DateTime
|
||||
gradingStatus: String
|
||||
gradingStatus: SubmissionGradingStatus
|
||||
id: ID!
|
||||
late: Boolean
|
||||
latePolicyStatus: LatePolicyStatusType
|
||||
|
@ -2560,6 +2560,13 @@ input SubmissionFilterInput {
|
|||
submittedSince: DateTime
|
||||
}
|
||||
|
||||
enum SubmissionGradingStatus {
|
||||
excused
|
||||
graded
|
||||
needs_grading
|
||||
needs_review
|
||||
}
|
||||
|
||||
type SubmissionHistory implements SubmissionInterface & Timestamped {
|
||||
assignment: Assignment
|
||||
attachments: [File!]
|
||||
|
@ -2614,7 +2621,7 @@ type SubmissionHistory implements SubmissionInterface & Timestamped {
|
|||
"""
|
||||
gradeMatchesCurrentSubmission: Boolean
|
||||
gradedAt: DateTime
|
||||
gradingStatus: String
|
||||
gradingStatus: SubmissionGradingStatus
|
||||
late: Boolean
|
||||
latePolicyStatus: LatePolicyStatusType
|
||||
missing: Boolean
|
||||
|
@ -2735,7 +2742,7 @@ interface SubmissionInterface {
|
|||
"""
|
||||
gradeMatchesCurrentSubmission: Boolean
|
||||
gradedAt: DateTime
|
||||
gradingStatus: String
|
||||
gradingStatus: SubmissionGradingStatus
|
||||
late: Boolean
|
||||
latePolicyStatus: LatePolicyStatusType
|
||||
missing: Boolean
|
||||
|
@ -2763,6 +2770,11 @@ enum SubmissionOrderField {
|
|||
input SubmissionSearchFilterInput {
|
||||
enrollmentTypes: [EnrollmentType!]
|
||||
|
||||
"""
|
||||
Limit results by grading status
|
||||
"""
|
||||
gradingStatus: SubmissionGradingStatus
|
||||
|
||||
"""
|
||||
Limit results to submissions that are late
|
||||
"""
|
||||
|
|
|
@ -118,7 +118,7 @@ describe Types::SubmissionType do
|
|||
end
|
||||
end
|
||||
|
||||
describe "submission and grading status" do
|
||||
describe "submissionStatus" do
|
||||
before do
|
||||
quiz_with_submission
|
||||
@quiz_assignment = @quiz.assignment
|
||||
|
@ -127,14 +127,12 @@ describe Types::SubmissionType do
|
|||
|
||||
let(:submission_type_quiz) { GraphQLTypeTester.new(@quiz_submission, current_user: @teacher) }
|
||||
|
||||
it "should contain submissionStatus and gradingStatus fields" do
|
||||
it "should contain submissionStatus field" do
|
||||
expect(submission_type.resolve("submissionStatus")).to eq "unsubmitted"
|
||||
expect(submission_type.resolve("gradingStatus")).to eq "graded"
|
||||
end
|
||||
|
||||
it "should preload quiz type assignments" do
|
||||
expect(submission_type_quiz.resolve("submissionStatus")).to eq "submitted"
|
||||
expect(submission_type_quiz.resolve("gradingStatus")).to eq "graded"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -103,6 +103,36 @@ describe SubmissionSearch do
|
|||
expect(results).to eq [submission]
|
||||
end
|
||||
|
||||
it 'filters by needs_grading' do
|
||||
submission = assignment.submit_homework(amanda, body: 'asdf')
|
||||
results = SubmissionSearch.new(assignment, teacher, nil, grading_status: 'needs_grading').search
|
||||
expect(results).to eq [submission]
|
||||
end
|
||||
|
||||
it 'filters by excused' do
|
||||
submission = Submission.find_by(user: jonah)
|
||||
submission.excused = true
|
||||
submission.save!
|
||||
results = SubmissionSearch.new(assignment, teacher, nil, grading_status: 'excused').search
|
||||
expect(results).to eq [submission]
|
||||
end
|
||||
|
||||
it 'filters by needs_review' do
|
||||
submission = Submission.find_by(user: peter)
|
||||
submission.workflow_state = 'pending_review'
|
||||
submission.save!
|
||||
results = SubmissionSearch.new(assignment, teacher, nil, grading_status: 'needs_review').search
|
||||
expect(results).to eq [submission]
|
||||
end
|
||||
|
||||
it 'filters by graded' do
|
||||
submission = Submission.find_by(user: mandy)
|
||||
submission.workflow_state = 'graded'
|
||||
submission.save!
|
||||
results = SubmissionSearch.new(assignment, teacher, nil, grading_status: 'graded').search
|
||||
expect(results).to eq [submission]
|
||||
end
|
||||
|
||||
it "limits results to just the user's submission if the user is a student" do
|
||||
results = SubmissionSearch.new(assignment, amanda, nil, {}).search
|
||||
expect(results).to eq [Submission.find_by(user: amanda)]
|
||||
|
|
Loading…
Reference in New Issue