Add studentReporting to DiscussionTopicPermissionsType
refs VICE-2174 flag=discussions_reporting Test Plan: - turn discussion reporting ff on - go to http://localhost:3000/graphiql - run a query similar to the example below > should see studentReporting as true - go to the discussions landing page in the course you queried against - click the settings cog in the top right - change student reporting to be false (unchecked) - run the query again - studentReporting should be false Example Query: (remember to update the _id for the discussion) query MyQuery { __typename legacyNode(_id: "23", type: Discussion) { ... on Discussion { id _id title permissions { studentReporting } } } } Change-Id: Ibbbae7e546efdcbc52901a38bcf1e606f3881055 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/276278 Reviewed-by: Omar Soto-Fortuño <omar.soto@instructure.com> QA-Review: Omar Soto-Fortuño <omar.soto@instructure.com> Product-Review: Omar Soto-Fortuño <omar.soto@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
This commit is contained in:
parent
75a442a563
commit
38cc6c7f45
|
@ -37,6 +37,11 @@ module Types
|
|||
object[:loader].load(:reply)
|
||||
end
|
||||
|
||||
field :student_reporting, Boolean, null: true
|
||||
def student_reporting
|
||||
object[:loader].load(:student_reporting)
|
||||
end
|
||||
|
||||
field :update, Boolean, null: true
|
||||
def update
|
||||
object[:loader].load(:update)
|
||||
|
|
|
@ -2632,6 +2632,10 @@ class Course < ActiveRecord::Base
|
|||
:homeroom_course, :course_color, :alt_name]
|
||||
end
|
||||
|
||||
def student_reporting?
|
||||
!!self.allow_student_discussion_reporting
|
||||
end
|
||||
|
||||
def set_course_dates_if_blank(shift_options)
|
||||
unless Canvas::Plugin.value_to_boolean(shift_options[:remove_dates])
|
||||
self.start_at ||= shift_options[:default_start_at]
|
||||
|
|
|
@ -1173,6 +1173,9 @@ class DiscussionTopic < ActiveRecord::Base
|
|||
given { |user, session| context.respond_to?(:allow_student_forum_attachments) && context.allow_student_forum_attachments && context.grants_any_right?(user, session, :create_forum, :post_to_forum) }
|
||||
can :attach
|
||||
|
||||
given { course.student_reporting? }
|
||||
can :student_reporting
|
||||
|
||||
given { |user, session| !self.root_topic_id && self.context.grants_all_rights?(user, session, :read_forum, :moderate_forum) && self.available_for?(user) }
|
||||
can :update and can :read_as_admin and can :delete and can :create and can :read and can :attach
|
||||
|
||||
|
|
|
@ -58,6 +58,10 @@ RSpec.shared_examples "DiscussionType" do
|
|||
value: 'readAsAdmin',
|
||||
allowed: ->(user) { discussion.grants_right?(user, nil, :read_as_admin) }
|
||||
},
|
||||
{
|
||||
value: 'studentReporting',
|
||||
allowed: ->(user) { discussion.course.student_reporting? }
|
||||
},
|
||||
{
|
||||
value: 'manageContent',
|
||||
allowed: ->(user) { discussion.context.grants_right?(user, :manage_content) }
|
||||
|
|
|
@ -272,7 +272,7 @@ describe DiscussionTopic do
|
|||
|
||||
it "does not grant moderate permissions without read permissions" do
|
||||
@course.account.role_overrides.create!(:role => teacher_role, :permission => 'read_forum', :enabled => false)
|
||||
expect(@topic.reload.check_policy(@teacher2)).to eql [:create, :duplicate, :attach]
|
||||
expect(@topic.reload.check_policy(@teacher2)).to eql [:create, :duplicate, :attach, :student_reporting]
|
||||
end
|
||||
|
||||
it "grants permissions if it not locked" do
|
||||
|
|
Loading…
Reference in New Issue