graphql: add grading_type to assignments

closes RECNVS-276

Test plan:
  * query assignment grading_types in graphql

Change-Id: I37e607f41fbb7ab27d4de663a1ff244f4c52479a
Reviewed-on: https://gerrit.instructure.com/139655
Tested-by: Jenkins
Reviewed-by: Michael Jasper <mjasper@instructure.com>
QA-Review: Collin Parrish <cparrish@instructure.com>
Product-Review: Cameron Matheson <cameron@instructure.com>
This commit is contained in:
Cameron Matheson 2018-01-31 22:28:05 -07:00
parent d1cfe7ad71
commit 53133f3488
3 changed files with 30 additions and 0 deletions

View File

@ -64,6 +64,10 @@ module Types
end
end
field :gradingType, AssignmentGradingType, resolve: ->(assignment, _, _) {
GRADING_TYPES[assignment.grading_type]
}
field :submissionTypes, types[!AssignmentSubmissionType],
resolve: ->(assignment, _, _) {
# there's some weird data in the db so we'll just ignore anything that
@ -140,6 +144,10 @@ module Types
wiki_page
].to_set
GRADING_TYPES = Hash[
Assignment::ALLOWED_GRADING_TYPES.zip(Assignment::ALLOWED_GRADING_TYPES)
]
AssignmentSubmissionType = GraphQL::EnumType.define do
name "SubmissionType"
description "Types of submissions an assignment accepts"
@ -147,4 +155,9 @@ module Types
value(submission_type)
}
end
AssignmentGradingType = GraphQL::EnumType.define do
name "GradingType"
Assignment::ALLOWED_GRADING_TYPES.each { |type| value(type) }
end
end

View File

@ -27,6 +27,7 @@ type Assignment implements Node, Timestamped {
# when this assignment is due
dueAt: String
gradingType: GradingType
htmlUrl: URL
id: ID!
name: String
@ -415,6 +416,15 @@ type GradingPeriodEdge {
node: GradingPeriod
}
enum GradingType {
gpa_scale
letter_grade
not_graded
pass_fail
percent
points
}
type Group implements Timestamped {
# legacy canvas id
_id: ID!

View File

@ -84,4 +84,11 @@ describe Types::AssignmentType do
assignment.update_attribute :submission_types, "none,foodfight"
expect(assignment_type.submissionTypes).to eq ["none"]
end
it "returns (valid) grading types" do
expect(assignment_type.gradingType).to eq assignment.grading_type
assignment.update_attribute :grading_type, "fakefakefake"
expect(assignment_type.gradingType).to be_nil
end
end