Add checkpoint data to submissions and assignment group API response
closes VICE-4287 flag=discussion_checkpoints Test Plan 1. create assignments with Checkpoint data 2. Open assignment index page as student 3. Verify 3a: assignment api has: checkpoints 3b: assignment api has: discussion_topic reply_to_entry_required_count 3c: submissions api has: sub_assignment_submissions Change-Id: I5144c4a1dc38d0e969f7a4d301d29fccb6cebb2d Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/348368 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Caleb Guanzon <cguanzon@instructure.com> QA-Review: Omar Soto-Fortuño <omar.soto@instructure.com> Product-Review: Jason Gillett <jason.gillett@instructure.com>
This commit is contained in:
parent
a4e3b27be6
commit
84f10cbfda
|
@ -365,6 +365,7 @@ class ApplicationController < ActionController::Base
|
|||
rce_find_replace
|
||||
courses_popout_sisid
|
||||
dashboard_graphql_integration
|
||||
discussion_checkpoints
|
||||
].freeze
|
||||
JS_ENV_ROOT_ACCOUNT_FEATURES = %i[
|
||||
product_tours
|
||||
|
@ -2959,6 +2960,7 @@ class ApplicationController < ActionController::Base
|
|||
include: [
|
||||
"assignments",
|
||||
"discussion_topic",
|
||||
Account.site_admin.feature_enabled?(:discussion_checkpoints) && "checkpoints",
|
||||
(permissions[:manage] || current_user_has_been_observer_in_this_course) && "all_dates",
|
||||
permissions[:manage] && "module_ids",
|
||||
peer_reviews_for_a2_enabled? && "assessment_requests"
|
||||
|
|
|
@ -149,7 +149,9 @@ module Api::V1::DiscussionTopics
|
|||
if (hold = topic.subscription_hold(user, session))
|
||||
json[:subscription_hold] = hold
|
||||
end
|
||||
|
||||
if topic.checkpoints?
|
||||
json[:reply_to_entry_required_count] = topic.reply_to_entry_required_count
|
||||
end
|
||||
if opts[:include_assignment] && topic.assignment
|
||||
excludes = opts[:exclude_assignment_description] ? ["description"] : []
|
||||
json[:assignment] = assignment_json(topic.assignment,
|
||||
|
|
|
@ -808,6 +808,32 @@ describe "Submissions API", type: :request do
|
|||
)
|
||||
end
|
||||
|
||||
context "checkpointed discussions" do
|
||||
before do
|
||||
course_with_teacher(active_all: true)
|
||||
@student1 = student_in_course(course: @course, active_enrollment: true).user
|
||||
@course.root_account.enable_feature!(:discussion_checkpoints)
|
||||
@assignment = @course.assignments.create!(has_sub_assignments: true)
|
||||
@assignment.sub_assignments.create!(context: @course, sub_assignment_tag: CheckpointLabels::REPLY_TO_TOPIC, due_at: 2.days.from_now)
|
||||
@assignment.sub_assignments.create!(context: @course, sub_assignment_tag: CheckpointLabels::REPLY_TO_ENTRY, due_at: 3.days.from_now)
|
||||
@topic = @course.discussion_topics.create!(assignment: @assignment, reply_to_entry_required_count: 4)
|
||||
end
|
||||
|
||||
it "returns sub_assignment_submissions for checkpointed discussions submissions" do
|
||||
json = api_call(:get,
|
||||
"/api/v1/courses/#{@course.id}/assignments/#{@assignment.id}/submissions/#{@student.id}.json",
|
||||
{ controller: "submissions_api",
|
||||
action: "show",
|
||||
format: "json",
|
||||
course_id: @course.id.to_s,
|
||||
assignment_id: @assignment.id.to_s,
|
||||
user_id: @student1.id.to_s },
|
||||
include: %w[sub_assignment_submissions])
|
||||
|
||||
expect(json["sub_assignment_submissions"].size).to eq 2
|
||||
end
|
||||
end
|
||||
|
||||
def submission_with_comment
|
||||
@student = user_factory(active_all: true)
|
||||
course_with_teacher(active_all: true)
|
||||
|
|
|
@ -662,6 +662,35 @@ describe AssignmentGroupsController do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "passing include_param checkpoints", type: :request do
|
||||
before do
|
||||
course_with_teacher(active_all: true)
|
||||
@student1 = student_in_course(course: @course, active_enrollment: true).user
|
||||
@course.root_account.enable_feature!(:discussion_checkpoints)
|
||||
assignment = @course.assignments.create!(has_sub_assignments: true)
|
||||
assignment.sub_assignments.create!(context: @course, sub_assignment_tag: CheckpointLabels::REPLY_TO_TOPIC, due_at: 2.days.from_now)
|
||||
assignment.sub_assignments.create!(context: @course, sub_assignment_tag: CheckpointLabels::REPLY_TO_ENTRY, due_at: 3.days.from_now)
|
||||
@topic = @course.discussion_topics.create!(assignment:, reply_to_entry_required_count: 4)
|
||||
end
|
||||
|
||||
it "returns the checkpointed discussions data" do
|
||||
json = api_call_as_user(
|
||||
@student1,
|
||||
:get,
|
||||
"/api/v1/courses/#{@course.id}/assignment_groups?include[]=assignments&include[]=discussion_topic&include[]=checkpoints",
|
||||
{
|
||||
controller: "assignment_groups",
|
||||
action: "index",
|
||||
format: "json",
|
||||
course_id: @course.id,
|
||||
include: %w[assignments discussion_topic checkpoints]
|
||||
}
|
||||
)
|
||||
expect(json[0]["assignments"][0]["checkpoints"].count).to eq 2
|
||||
expect(json[0]["assignments"][0]["discussion_topic"]["reply_to_entry_required_count"]).to eq 4
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST 'reorder'" do
|
||||
|
|
|
@ -64,12 +64,17 @@ export default class AssignmentGroupCollection extends PaginatedCollection {
|
|||
const collection = new SubmissionCollection()
|
||||
const observedUser = this.getObservedUserId()
|
||||
|
||||
let baseUrl
|
||||
if (observedUser) {
|
||||
collection.url = () =>
|
||||
`${this.courseSubmissionsURL}?student_ids[]=${observedUser}&per_page=${PER_PAGE_LIMIT}`
|
||||
baseUrl = `${this.courseSubmissionsURL}?student_ids[]=${observedUser}&per_page=${PER_PAGE_LIMIT}`
|
||||
} else {
|
||||
collection.url = () => `${this.courseSubmissionsURL}?per_page=${PER_PAGE_LIMIT}`
|
||||
baseUrl = `${this.courseSubmissionsURL}?per_page=${PER_PAGE_LIMIT}`
|
||||
}
|
||||
collection.url = () =>
|
||||
ENV.FEATURES.discussion_checkpoints
|
||||
? `${baseUrl}&include[]=sub_assignment_submissions`
|
||||
: `${baseUrl}`
|
||||
|
||||
collection.loadAll = true
|
||||
collection.on('fetched:last', () => this.loadGradesFromSubmissions(collection.toArray()))
|
||||
return collection.fetch()
|
||||
|
|
Loading…
Reference in New Issue