graphql: student-in-course analytics summary types
refs CNVS-37582, refs CNVS-37583 Test plan: querying for a users summaryAnalytics should return null (the real implementation is provided by the analytics plugin) Change-Id: I6fb746ac0ed5b1ca6192e6b814eab0bf112bef9b Reviewed-on: https://gerrit.instructure.com/123216 Reviewed-by: Jonathan Featherstone <jfeatherstone@instructure.com> Tested-by: Jenkins QA-Review: Collin Parrish <cparrish@instructure.com> Product-Review: Cameron Matheson <cameron@instructure.com>
This commit is contained in:
parent
135e26df83
commit
c1e10627e4
|
@ -0,0 +1,14 @@
|
|||
# This is a dummy implementation. The real implementation is provided by the
|
||||
# Canvas analytics plugin
|
||||
class Loaders::CourseStudentAnalyticsLoader < GraphQL::Batch::Loader
|
||||
def initialize(course_id, current_user:, session:)
|
||||
@course_id = course_id
|
||||
@current_user = current_user
|
||||
@session = session
|
||||
end
|
||||
|
||||
def perform(users)
|
||||
users.each { |u| fulfill(u, nil) }
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
module Types
|
||||
StudentSummaryAnalyticsType = GraphQL::ObjectType.define do
|
||||
name "StudentSummaryAnalytics"
|
||||
description "basic information about a students activity in a course"
|
||||
|
||||
field :pageViews, PageViewAnalysisType, property: :page_views
|
||||
field :participations, PageViewAnalysisType, property: :participations
|
||||
field :tardinessBreakdown, TardinessBreakdownType, property: :tardiness_breakdown
|
||||
end
|
||||
|
||||
PageViewAnalysisType = GraphQL::ObjectType.define do
|
||||
name "PageViewAnalysis"
|
||||
|
||||
field :total, types.Int do
|
||||
description "The number of views/participations this student has"
|
||||
hash_key :total
|
||||
end
|
||||
|
||||
field :max, types.Int do
|
||||
description "The maximum number of views/participations in this course"
|
||||
hash_key :max
|
||||
end
|
||||
|
||||
field :level, types.Int do
|
||||
description "This number (0-3) is intended to give an idea of how the student is doing relative to others in the course"
|
||||
hash_key :level
|
||||
end
|
||||
end
|
||||
|
||||
TardinessBreakdownType = GraphQL::ObjectType.define do
|
||||
name "TardinessBreakdown"
|
||||
description "statistics based on timeliness of student submissions"
|
||||
|
||||
field :total, types.Int, hash_key: :total
|
||||
field :late, types.Float, hash_key: :late
|
||||
field :missing, types.Float, hash_key: :missing
|
||||
field :onTime, types.Float, hash_key: :on_time
|
||||
end
|
||||
end
|
|
@ -44,7 +44,21 @@ module Types
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
field :summaryAnalytics, StudentSummaryAnalyticsType do
|
||||
argument :courseId, !types.ID,
|
||||
"returns summary analytics for this course",
|
||||
prepare: GraphQLHelpers.relay_or_legacy_id_prepare_func("Course")
|
||||
|
||||
resolve ->(user, args, ctx) do
|
||||
Loaders::CourseStudentAnalyticsLoader.for(
|
||||
args[:courseId],
|
||||
current_user: ctx[:current_user], session: ctx[:session]
|
||||
).load(user)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class UserCourseEnrollmentLoader < Loaders::ForeignKeyLoader
|
||||
|
|
Loading…
Reference in New Issue