RuboCop: Style/PercentLiteralDelimiters
[skip-stages=Flakey] auto-corrected, with a post-review looking for multiline strings to convert to heredocs Change-Id: I7f7afb11edd63415cde10866822dd2ac5ba0d8be Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278669 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Jacob Burroughs <jburroughs@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com> Migration-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
59a58065de
commit
4d43809cae
|
@ -242,6 +242,8 @@ Style/OrAssignment:
|
|||
Severity: error
|
||||
Style/ParenthesesAroundCondition:
|
||||
Severity: error
|
||||
Style/PercentLiteralDelimiters:
|
||||
Severity: error
|
||||
Style/PerlBackrefs:
|
||||
Enabled: false # Regexp.last_match(1) is far worse than $1
|
||||
Style/PreferredHashMethods:
|
||||
|
@ -363,8 +365,6 @@ Style/NumericLiterals: # TODO: autocorrect
|
|||
Enabled: false
|
||||
Style/ParallelAssignment: # TODO: autocorrect (with probable exceptions)
|
||||
Enabled: false
|
||||
Style/PercentLiteralDelimiters: # TODO: autocorrect
|
||||
Enabled: false
|
||||
Style/PercentQLiterals: # TODO: autocorrect
|
||||
Enabled: false
|
||||
Style/RedundantSelf: # TODO: autocorrect
|
||||
|
|
|
@ -491,7 +491,7 @@ class AccountsController < ApplicationController
|
|||
#
|
||||
# @returns TermsOfService
|
||||
def terms_of_service
|
||||
keys = %w(id terms_type passive account_id)
|
||||
keys = %w[id terms_type passive account_id]
|
||||
tos = @account.root_account.terms_of_service
|
||||
res = tos.attributes.slice(*keys)
|
||||
res['content'] = tos.terms_of_service_content&.content
|
||||
|
@ -614,12 +614,12 @@ class AccountsController < ApplicationController
|
|||
starts_before = CanvasTime.try_parse(params[:starts_before])
|
||||
ends_after = CanvasTime.try_parse(params[:ends_after])
|
||||
|
||||
params[:state] ||= %w{created claimed available completed}
|
||||
params[:state] = %w{created claimed available completed deleted} if Array(params[:state]).include?('all')
|
||||
params[:state] ||= %w[created claimed available completed]
|
||||
params[:state] = %w[created claimed available completed deleted] if Array(params[:state]).include?('all')
|
||||
if value_to_boolean(params[:published])
|
||||
params[:state] -= %w{created claimed completed deleted}
|
||||
params[:state] -= %w[created claimed completed deleted]
|
||||
elsif !params[:published].nil? && !value_to_boolean(params[:published])
|
||||
params[:state] -= %w{available}
|
||||
params[:state] -= %w[available]
|
||||
end
|
||||
|
||||
sortable_name_col = User.sortable_name_order_by_clause('users')
|
||||
|
@ -1088,7 +1088,7 @@ class AccountsController < ApplicationController
|
|||
|
||||
# privacy settings
|
||||
unless @account.grants_right?(@current_user, :manage_privacy_settings)
|
||||
%w{enable_fullstory enable_google_analytics}.each do |setting|
|
||||
%w[enable_fullstory enable_google_analytics].each do |setting|
|
||||
params[:account][:settings].try(:delete, setting)
|
||||
end
|
||||
end
|
||||
|
@ -1565,7 +1565,7 @@ class AccountsController < ApplicationController
|
|||
courses_to_fetch_users_for = courses_to_fetch_users_for.reject { |c| @master_template_index[c.id] } # don't fetch the counts for the master/blueprint courses
|
||||
end
|
||||
|
||||
teachers = TeacherEnrollment.for_courses_with_user_name(courses_to_fetch_users_for).where.not(:enrollments => { :workflow_state => %w{rejected deleted} })
|
||||
teachers = TeacherEnrollment.for_courses_with_user_name(courses_to_fetch_users_for).where.not(:enrollments => { :workflow_state => %w[rejected deleted] })
|
||||
course_to_student_counts = StudentEnrollment.student_in_claimed_or_available.where(:course_id => courses_to_fetch_users_for).group(:course_id).distinct.count(:user_id)
|
||||
courses_to_teachers = teachers.each_with_object({}) do |teacher, result|
|
||||
result[teacher.course_id] ||= []
|
||||
|
|
|
@ -1534,12 +1534,12 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
@access = AssetUserAccess.log(user, @context, @accessed_asset) if @context
|
||||
|
||||
if @page_view.nil? && %w{participate submit}.include?(@accessed_asset[:level]) && page_views_enabled?
|
||||
if @page_view.nil? && %w[participate submit].include?(@accessed_asset[:level]) && page_views_enabled?
|
||||
generate_page_view(user)
|
||||
end
|
||||
|
||||
if @page_view
|
||||
@page_view.participated = %w{participate submit}.include?(@accessed_asset[:level])
|
||||
@page_view.participated = %w[participate submit].include?(@accessed_asset[:level])
|
||||
@page_view.asset_user_access = @access
|
||||
end
|
||||
|
||||
|
|
|
@ -425,7 +425,7 @@ class AssignmentGroupsController < ApplicationController
|
|||
if params[:exclude_assignment_submission_types].present?
|
||||
exclude_types = params[:exclude_assignment_submission_types]
|
||||
exclude_types = Array.wrap(exclude_types) &
|
||||
%w(online_quiz discussion_topic wiki_page external_tool)
|
||||
%w[online_quiz discussion_topic wiki_page external_tool]
|
||||
assignments = assignments.where.not(submission_types: exclude_types)
|
||||
end
|
||||
|
||||
|
|
|
@ -1448,7 +1448,7 @@ class AssignmentsApiController < ApplicationController
|
|||
return if @context.students_visible_to(@current_user).include?(@user)
|
||||
end
|
||||
# self, observer
|
||||
authorized_action(@user, @current_user, %i(read_as_parent read))
|
||||
authorized_action(@user, @current_user, %i[read_as_parent read])
|
||||
end
|
||||
|
||||
def needs_grading_permission?
|
||||
|
|
|
@ -284,10 +284,10 @@ class CalendarEventsApiController < ApplicationController
|
|||
include Api::V1::CalendarEvent
|
||||
include CalendarConferencesHelper
|
||||
|
||||
before_action :require_user, :except => %w(public_feed index)
|
||||
before_action :require_user, :except => %w[public_feed index]
|
||||
before_action :get_calendar_context, :only => :create
|
||||
before_action :require_user_or_observer, :only => [:user_index]
|
||||
before_action :require_authorization, :only => %w(index user_index)
|
||||
before_action :require_authorization, :only => %w[index user_index]
|
||||
|
||||
RECURRING_EVENT_LIMIT = 200
|
||||
|
||||
|
|
|
@ -147,8 +147,8 @@ class ContentExportsApiController < ApplicationController
|
|||
# @returns ContentExport
|
||||
def create
|
||||
if authorized_action(@context, @current_user, :read)
|
||||
valid_types = %w(zip)
|
||||
valid_types += %w(qti common_cartridge quizzes2) if @context.is_a?(Course)
|
||||
valid_types = %w[zip]
|
||||
valid_types += %w[qti common_cartridge quizzes2] if @context.is_a?(Course)
|
||||
return render json: { message: 'invalid export_type' }, status: :bad_request unless valid_types.include?(params[:export_type])
|
||||
|
||||
export = create_content_export_from_api(params, @context, @current_user)
|
||||
|
|
|
@ -26,10 +26,10 @@ class ContentImportsController < ApplicationController
|
|||
include Api::V1::Course
|
||||
include ContentImportsHelper
|
||||
|
||||
COPY_TYPES = %w{assignment_groups assignments context_modules
|
||||
COPY_TYPES = %w[assignment_groups assignments context_modules
|
||||
learning_outcomes quizzes assessment_question_banks folders
|
||||
attachments wiki_pages discussion_topics calendar_events
|
||||
context_external_tools learning_outcome_groups rubrics}.freeze
|
||||
context_external_tools learning_outcome_groups rubrics].freeze
|
||||
|
||||
# these are deprecated, but leaving them for a while so existing links get redirected
|
||||
def index
|
||||
|
|
|
@ -517,7 +517,7 @@ class ContentMigrationsController < ApplicationController
|
|||
def find_migration_plugin(name)
|
||||
if name.include?('context_external_tool')
|
||||
plugin = Canvas::Plugin.new(name)
|
||||
plugin.meta[:settings] = { requires_file_upload: true, worker: 'CCWorker', valid_contexts: %w{Course} }.with_indifferent_access
|
||||
plugin.meta[:settings] = { requires_file_upload: true, worker: 'CCWorker', valid_contexts: %w[Course] }.with_indifferent_access
|
||||
plugin
|
||||
else
|
||||
Canvas::Plugin.find(name)
|
||||
|
|
|
@ -93,8 +93,8 @@ class ContentSharesController < ApplicationController
|
|||
|
||||
before_action :require_user
|
||||
before_action :get_user_param
|
||||
before_action :require_current_user, :except => %w(show index unread_count)
|
||||
before_action :get_receivers, :only => %w(create add_users)
|
||||
before_action :require_current_user, :except => %w[show index unread_count]
|
||||
before_action :get_receivers, :only => %w[create add_users]
|
||||
|
||||
def get_user_param
|
||||
@user = api_find(User, params[:user_id])
|
||||
|
|
|
@ -472,7 +472,7 @@ class ContextModuleItemsApiController < ApplicationController
|
|||
return render :json => { :message => "missing module item parameter" }, :status => :bad_request unless params[:module_item]
|
||||
|
||||
@tag.title = params[:module_item][:title] if params[:module_item][:title]
|
||||
@tag.url = params[:module_item][:external_url] if %w(ExternalUrl ContextExternalTool).include?(@tag.content_type) && params[:module_item][:external_url]
|
||||
@tag.url = params[:module_item][:external_url] if %w[ExternalUrl ContextExternalTool].include?(@tag.content_type) && params[:module_item][:external_url]
|
||||
@tag.indent = params[:module_item][:indent] if params[:module_item][:indent]
|
||||
@tag.new_tab = value_to_boolean(params[:module_item][:new_tab]) if params[:module_item][:new_tab]
|
||||
if (target_module_id = params[:module_item][:module_id]) && target_module_id.to_i != @tag.context_module_id
|
||||
|
|
|
@ -274,7 +274,7 @@ class ContextModulesApiController < ApplicationController
|
|||
if authorized_action(@context, @current_user, :manage_content)
|
||||
event = params[:event]
|
||||
return render(:json => { :message => 'need to specify event' }, :status => :bad_request) unless event.present?
|
||||
return render(:json => { :message => 'invalid event' }, :status => :bad_request) unless %w(publish unpublish delete).include? event
|
||||
return render(:json => { :message => 'invalid event' }, :status => :bad_request) unless %w[publish unpublish delete].include? event
|
||||
return render(:json => { :message => 'must specify module_ids[]' }, :status => :bad_request) unless params[:module_ids].present?
|
||||
|
||||
module_ids = Api.map_non_sis_ids(Array(params[:module_ids]))
|
||||
|
|
|
@ -272,7 +272,7 @@ class ContextModulesController < ApplicationController
|
|||
end
|
||||
@tag = params[:last] ? @tags.last : @tags.first
|
||||
unless @tag
|
||||
flash[:notice] = t 'module_empty', %{There are no items in the module "%{module}"}, :module => @module.name
|
||||
flash[:notice] = t 'module_empty', %(There are no items in the module "%{module}"), :module => @module.name
|
||||
redirect_to named_context_url(@context, :context_context_modules_url, :anchor => "module_#{@module.id}")
|
||||
return
|
||||
end
|
||||
|
@ -400,7 +400,7 @@ class ContextModulesController < ApplicationController
|
|||
|
||||
if is_child_course || is_master_course
|
||||
tag_ids = GuardRail.activate(:secondary) do
|
||||
tag_scope = @context.module_items_visible_to(@current_user).where(:content_type => %w{Assignment Attachment DiscussionTopic Quizzes::Quiz WikiPage})
|
||||
tag_scope = @context.module_items_visible_to(@current_user).where(:content_type => %w[Assignment Attachment DiscussionTopic Quizzes::Quiz WikiPage])
|
||||
tag_scope = tag_scope.where(:id => params[:tag_id]) if params[:tag_id]
|
||||
tag_scope.pluck(:id)
|
||||
end
|
||||
|
@ -647,7 +647,7 @@ class ContextModulesController < ApplicationController
|
|||
@tag = @context.context_module_tags.not_deleted.find(params[:id])
|
||||
if authorized_action(@tag.context_module, @current_user, :update)
|
||||
@tag.title = params[:content_tag][:title] if params[:content_tag] && params[:content_tag][:title]
|
||||
@tag.url = params[:content_tag][:url] if %w(ExternalUrl ContextExternalTool).include?(@tag.content_type) && params[:content_tag] && params[:content_tag][:url]
|
||||
@tag.url = params[:content_tag][:url] if %w[ExternalUrl ContextExternalTool].include?(@tag.content_type) && params[:content_tag] && params[:content_tag][:url]
|
||||
@tag.indent = params[:content_tag][:indent] if params[:content_tag] && params[:content_tag][:indent]
|
||||
@tag.new_tab = params[:content_tag][:new_tab] if params[:content_tag] && params[:content_tag][:new_tab]
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ class ConversationsController < ApplicationController
|
|||
# batch up all delayed jobs to make this more responsive to the user
|
||||
batch_jobs_in_actions :only => :create
|
||||
|
||||
API_ALLOWED_FIELDS = %w{workflow_state subscribed starred}.freeze
|
||||
API_ALLOWED_FIELDS = %w[workflow_state subscribed starred].freeze
|
||||
|
||||
# @API List conversations
|
||||
# Returns the paginated list of conversations for the current user, most
|
||||
|
@ -975,7 +975,7 @@ class ConversationsController < ApplicationController
|
|||
conversation_ids = params[:conversation_ids]
|
||||
update_params = params.permit(:event).to_unsafe_h
|
||||
|
||||
allowed_events = %w(mark_as_read mark_as_unread star unstar archive destroy)
|
||||
allowed_events = %w[mark_as_read mark_as_unread star unstar archive destroy]
|
||||
return render(:json => { :message => 'conversation_ids not specified' }, :status => :bad_request) unless params[:conversation_ids].is_a?(Array)
|
||||
return render(:json => { :message => 'conversation batch size limit (500) exceeded' }, :status => :bad_request) unless params[:conversation_ids].size <= 500
|
||||
return render(:json => { :message => 'event not specified' }, :status => :bad_request) unless update_params[:event]
|
||||
|
|
|
@ -1123,18 +1123,18 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
enrollments_by_user = enrollment_scope.group_by(&:user_id)
|
||||
else
|
||||
confirmed_user_ids = @context.enrollments.where.not(:workflow_state => %w{invited creation_pending rejected})
|
||||
confirmed_user_ids = @context.enrollments.where.not(:workflow_state => %w[invited creation_pending rejected])
|
||||
.where(:user_id => users).distinct.pluck(:user_id)
|
||||
end
|
||||
|
||||
render :json => users.map { |u|
|
||||
enrollments = enrollments_by_user[u.id] || [] if includes.include?('enrollments')
|
||||
user_unconfirmed = if enrollments
|
||||
enrollments.all? { |e| %w{invited creation_pending rejected}.include?(e.workflow_state) }
|
||||
enrollments.all? { |e| %w[invited creation_pending rejected].include?(e.workflow_state) }
|
||||
else
|
||||
!confirmed_user_ids.include?(u.id)
|
||||
end
|
||||
excludes = user_unconfirmed ? %w{pseudonym personal_info} : []
|
||||
excludes = user_unconfirmed ? %w[pseudonym personal_info] : []
|
||||
if @context.sections_hidden_on_roster_page?(current_user: @current_user)
|
||||
excludes.append('course_section_id')
|
||||
end
|
||||
|
@ -3264,7 +3264,7 @@ class CoursesController < ApplicationController
|
|||
update_params = params.permit(:event).to_unsafe_h
|
||||
return render(:json => { :message => 'need to specify event' }, :status => :bad_request) unless update_params[:event]
|
||||
|
||||
return render(:json => { :message => 'invalid event' }, :status => :bad_request) unless %w(offer conclude delete undelete).include? update_params[:event]
|
||||
return render(:json => { :message => 'invalid event' }, :status => :bad_request) unless %w[offer conclude delete undelete].include? update_params[:event]
|
||||
|
||||
progress = Course.batch_update(@account, @current_user, @course_ids, update_params, :api)
|
||||
render :json => progress_json(progress, @current_user, session)
|
||||
|
@ -3462,7 +3462,7 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
|
||||
# NOTE: Similar to #user_progress, this endpoint should remain on the primary db
|
||||
users = Api.paginate(UserSearch.scope_for(@context, @current_user, :enrollment_type => %w(Student)), self, api_v1_course_bulk_user_progress_url)
|
||||
users = Api.paginate(UserSearch.scope_for(@context, @current_user, :enrollment_type => %w[Student]), self, api_v1_course_bulk_user_progress_url)
|
||||
cmps = ContextModuleProgression.where(user_id: users.map(&:id))
|
||||
.joins(:context_module)
|
||||
.where(context_modules: { context: @context, context_type: 'Course' })
|
||||
|
@ -3629,7 +3629,7 @@ class CoursesController < ApplicationController
|
|||
|
||||
if params[:state]
|
||||
states = Array(params[:state])
|
||||
states += %w(created claimed) if states.include?('unpublished')
|
||||
states += %w[created claimed] if states.include?('unpublished')
|
||||
conditions = states.filter_map do |state|
|
||||
Enrollment::QueryBuilder.new(nil, course_workflow_state: state, enforce_course_workflow_state: true).conditions
|
||||
end.join(" OR ")
|
||||
|
@ -3732,7 +3732,7 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
enrollments_by_course = Api.paginate(enrollments_by_course, self, paginate_url) if api_request?
|
||||
courses = enrollments_by_course.map(&:first).map(&:course)
|
||||
preloads = %i/account root_account/
|
||||
preloads = %i[account root_account]
|
||||
preload_teachers(courses) if includes.include?('teachers')
|
||||
preloads << :grading_standard if includes.include?('total_scores')
|
||||
preloads << :account if includes.include?('subaccount') || includes.include?('account')
|
||||
|
|
|
@ -148,7 +148,7 @@ class CustomGradebookColumnDataApiController < ApplicationController
|
|||
end
|
||||
|
||||
def allowed_users
|
||||
@context.students_visible_to(@current_user, include: %i{inactive completed})
|
||||
@context.students_visible_to(@current_user, include: %i[inactive completed])
|
||||
end
|
||||
private :allowed_users
|
||||
|
||||
|
|
|
@ -748,7 +748,7 @@ class DiscussionTopicsController < ApplicationController
|
|||
course_id: @context).not_fake.active_or_pending_by_date_ignoring_access
|
||||
.group(:course_section_id).count
|
||||
section_data = @topic.course_sections.map do |cs|
|
||||
cs.attributes.slice(*%w{id name}).merge(:user_count => user_counts[cs.id] || 0)
|
||||
cs.attributes.slice(*%w[id name]).merge(:user_count => user_counts[cs.id] || 0)
|
||||
end
|
||||
end
|
||||
api_url = lambda do |endpoint, *params|
|
||||
|
@ -1144,12 +1144,12 @@ class DiscussionTopicsController < ApplicationController
|
|||
@user_can_moderate
|
||||
end
|
||||
|
||||
API_ALLOWED_TOPIC_FIELDS = %w(title message discussion_type delayed_post_at lock_at podcast_enabled
|
||||
API_ALLOWED_TOPIC_FIELDS = %w[title message discussion_type delayed_post_at lock_at podcast_enabled
|
||||
podcast_has_student_posts require_initial_post pinned todo_date
|
||||
group_category_id allow_rating only_graders_can_rate sort_by_rating).freeze
|
||||
group_category_id allow_rating only_graders_can_rate sort_by_rating].freeze
|
||||
|
||||
API_ALLOWED_TOPIC_FIELDS_FOR_GROUP = %w(title message discussion_type podcast_enabled pinned todo_date
|
||||
allow_rating only_graders_can_rate sort_by_rating).freeze
|
||||
API_ALLOWED_TOPIC_FIELDS_FOR_GROUP = %w[title message discussion_type podcast_enabled pinned todo_date
|
||||
allow_rating only_graders_can_rate sort_by_rating].freeze
|
||||
|
||||
def set_sections
|
||||
if params[:specific_sections] != "all"
|
||||
|
@ -1228,7 +1228,7 @@ class DiscussionTopicsController < ApplicationController
|
|||
|
||||
allowed_fields = @context.is_a?(Group) ? API_ALLOWED_TOPIC_FIELDS_FOR_GROUP : API_ALLOWED_TOPIC_FIELDS
|
||||
discussion_topic_hash = params.permit(*allowed_fields)
|
||||
only_pinning = discussion_topic_hash.except(*%w{pinned}).blank?
|
||||
only_pinning = discussion_topic_hash.except(*%w[pinned]).blank?
|
||||
|
||||
# allow pinning/unpinning if a subtopic and we can update the root
|
||||
topic_to_check = only_pinning && @topic.root_topic ? @topic.root_topic : @topic
|
||||
|
|
|
@ -931,7 +931,7 @@ class EnrollmentsApiController < ApplicationController
|
|||
# by default, return active and invited courses. don't use the existing
|
||||
# current_and_invited_enrollments scope because it won't return enrollments
|
||||
# on unpublished courses.
|
||||
enrollments = enrollments.where(workflow_state: %w{active invited}) if params[:state].blank?
|
||||
enrollments = enrollments.where(workflow_state: %w[active invited]) if params[:state].blank?
|
||||
end
|
||||
|
||||
terms = @domain_root_account.enrollment_terms.active
|
||||
|
@ -989,14 +989,14 @@ class EnrollmentsApiController < ApplicationController
|
|||
|
||||
def enrollment_states_for_state_param
|
||||
states = Array(params[:state]).uniq
|
||||
states.concat(%w(active invited)) if states.delete 'current_and_invited'
|
||||
states.concat(%w(active invited creation_pending pending_active pending_invited)) if states.delete 'current_and_future'
|
||||
states.concat(%w(active completed)) if states.delete 'current_and_concluded'
|
||||
states.concat(%w[active invited]) if states.delete 'current_and_invited'
|
||||
states.concat(%w[active invited creation_pending pending_active pending_invited]) if states.delete 'current_and_future'
|
||||
states.concat(%w[active completed]) if states.delete 'current_and_concluded'
|
||||
states.uniq
|
||||
end
|
||||
|
||||
def check_sis_permissions(sis_context)
|
||||
sis_filters = %w(sis_account_id sis_course_id sis_section_id sis_user_id)
|
||||
sis_filters = %w[sis_account_id sis_course_id sis_section_id sis_user_id]
|
||||
if (params.keys & sis_filters).present?
|
||||
unless sis_context.grants_any_right?(@current_user, :read_sis, :manage_sis)
|
||||
return false
|
||||
|
|
|
@ -151,7 +151,7 @@ class ExternalContentController < ApplicationController
|
|||
message = IMS::LTI::Models::Messages::Message.generate(request.GET && request.POST)
|
||||
message.content_items
|
||||
else
|
||||
filtered_params = params.permit(*%w(url text title return_type content_type height width))
|
||||
filtered_params = params.permit(*%w[url text title return_type content_type height width])
|
||||
[Lti::ContentItemConverter.convert_resource_selection(filtered_params)]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -632,7 +632,7 @@ class FilesController < ApplicationController
|
|||
end
|
||||
|
||||
json_include = if @attachment.context.is_a?(User) || @attachment.context.is_a?(Course)
|
||||
{ include: %w(enhanced_preview_url) }
|
||||
{ include: %w[enhanced_preview_url] }
|
||||
else
|
||||
{}
|
||||
end
|
||||
|
@ -1159,7 +1159,7 @@ class FilesController < ApplicationController
|
|||
end
|
||||
|
||||
if (@attachment.folder_id_changed? || @attachment.display_name_changed?) && @attachment.folder.active_file_attachments.where(display_name: @attachment.display_name).where("id<>?", @attachment.id).exists?
|
||||
return render json: { message: "file already exists; use on_duplicate='overwrite' or 'rename'" }, status: :conflict unless %w(overwrite rename).include?(params[:on_duplicate])
|
||||
return render json: { message: "file already exists; use on_duplicate='overwrite' or 'rename'" }, status: :conflict unless %w[overwrite rename].include?(params[:on_duplicate])
|
||||
|
||||
on_duplicate = params[:on_duplicate].to_sym
|
||||
end
|
||||
|
|
|
@ -570,7 +570,7 @@ class FoldersController < ApplicationController
|
|||
if authorized_action(@attachment, @current_user, :create)
|
||||
on_duplicate, name = params[:on_duplicate].presence, params[:name].presence
|
||||
duplicate_options = (on_duplicate == 'rename' && name) ? { name: name } : {}
|
||||
return render :json => { :message => "on_duplicate must be 'overwrite' or 'rename'" }, :status => :bad_request if on_duplicate && %w(overwrite rename).exclude?(on_duplicate)
|
||||
return render :json => { :message => "on_duplicate must be 'overwrite' or 'rename'" }, :status => :bad_request if on_duplicate && %w[overwrite rename].exclude?(on_duplicate)
|
||||
if on_duplicate.nil? && @dest_folder.active_file_attachments.where(display_name: @source_file.display_name).exists?
|
||||
return render :json => { :message => "file already exists; set on_duplicate to 'rename' or 'overwrite'" }, :status => :conflict
|
||||
end
|
||||
|
|
|
@ -103,7 +103,7 @@ class GroupCategoriesController < ApplicationController
|
|||
include Api::V1::Group
|
||||
include Api::V1::Progress
|
||||
|
||||
SETTABLE_GROUP_ATTRIBUTES = %w(name description join_level is_public group_category avatar_attachment).freeze
|
||||
SETTABLE_GROUP_ATTRIBUTES = %w[name description join_level is_public group_category avatar_attachment].freeze
|
||||
|
||||
include TextHelper
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ class GroupMembershipsController < ApplicationController
|
|||
|
||||
include Api::V1::Group
|
||||
|
||||
ALLOWED_MEMBERSHIP_FILTER = %w(accepted invited requested).freeze
|
||||
ALLOWED_MEMBERSHIP_FILTER = %w[accepted invited requested].freeze
|
||||
|
||||
# @API List group memberships
|
||||
#
|
||||
|
@ -162,7 +162,7 @@ class GroupMembershipsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
UPDATABLE_MEMBERSHIP_ATTRIBUTES = %w(workflow_state moderator).freeze
|
||||
UPDATABLE_MEMBERSHIP_ATTRIBUTES = %w[workflow_state moderator].freeze
|
||||
|
||||
# @API Update a membership
|
||||
#
|
||||
|
|
|
@ -150,10 +150,10 @@ class GroupsController < ApplicationController
|
|||
include Context
|
||||
include K5Mode
|
||||
|
||||
SETTABLE_GROUP_ATTRIBUTES = %w(
|
||||
SETTABLE_GROUP_ATTRIBUTES = %w[
|
||||
name description join_level is_public group_category avatar_attachment
|
||||
storage_quota_mb max_membership leader
|
||||
).freeze
|
||||
].freeze
|
||||
|
||||
include TextHelper
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ module Lti::IMS::Concerns
|
|||
end
|
||||
end
|
||||
|
||||
CREATE_NEW_MODULE_PLACEMENTS = %w(course_assignments_menu module_index_menu_modal).freeze
|
||||
ALLOW_LINE_ITEM_PLACEMENTS = %w(course_assignments_menu module_index_menu_modal).freeze
|
||||
CREATE_NEW_MODULE_PLACEMENTS = %w[course_assignments_menu module_index_menu_modal].freeze
|
||||
ALLOW_LINE_ITEM_PLACEMENTS = %w[course_assignments_menu module_index_menu_modal].freeze
|
||||
|
||||
def content_items_for_modules
|
||||
@content_items_for_modules ||= lti_resource_links.reject { |item| item.key? :lineItem }
|
||||
|
|
|
@ -69,7 +69,7 @@ module Lti
|
|||
include Concerns::GradebookServices
|
||||
|
||||
before_action :prepare_line_item_for_ags!, only: :create
|
||||
before_action :verify_line_item_in_context, only: %i(show update destroy)
|
||||
before_action :verify_line_item_in_context, only: %i[show update destroy]
|
||||
before_action :verify_valid_resource_link, only: :create
|
||||
|
||||
ACTION_SCOPE_MATCHERS = {
|
||||
|
@ -221,7 +221,7 @@ module Lti
|
|||
private
|
||||
|
||||
def line_item_params
|
||||
@_line_item_params ||= params.permit(%i(resourceId resourceLinkId scoreMaximum label tag),
|
||||
@_line_item_params ||= params.permit(%i[resourceId resourceLinkId scoreMaximum label tag],
|
||||
Lti::LineItem::AGS_EXT_SUBMISSION_TYPE => [:type, :external_tool_url]).transform_keys do |k|
|
||||
k.to_s.underscore
|
||||
end.except(:resource_link_id)
|
||||
|
|
|
@ -45,29 +45,29 @@ module Lti
|
|||
{
|
||||
id: TOOL_SETTINGS_SERVICE,
|
||||
endpoint: 'api/lti/tool_settings/tool_proxy/{tool_proxy_id}',
|
||||
format: %w(
|
||||
format: %w[
|
||||
application/vnd.ims.lti.v2.toolsettings+json
|
||||
application/vnd.ims.lti.v2.toolsettings.simple+json
|
||||
).freeze,
|
||||
action: %w(GET PUT).freeze
|
||||
].freeze,
|
||||
action: %w[GET PUT].freeze
|
||||
}.freeze,
|
||||
{
|
||||
id: TOOL_PROXY_BINDING_SERVICE,
|
||||
endpoint: 'api/lti/tool_settings/bindings/{binding_id}',
|
||||
format: %w(
|
||||
format: %w[
|
||||
application/vnd.ims.lti.v2.toolsettings+json'
|
||||
application/vnd.ims.lti.v2.toolsettings.simple+json
|
||||
).freeze,
|
||||
action: %w(GET PUT).freeze
|
||||
].freeze,
|
||||
action: %w[GET PUT].freeze
|
||||
}.freeze,
|
||||
{
|
||||
id: LTI_LINK_SETTINGS,
|
||||
endpoint: 'api/lti/tool_proxy/{tool_proxy_guid}/courses/{course_id}/resource_link_id/{resource_link_id}/tool_setting',
|
||||
format: %w(
|
||||
format: %w[
|
||||
application/vnd.ims.lti.v2.toolsettings+json
|
||||
application/vnd.ims.lti.v2.toolsettings.simple+json
|
||||
).freeze,
|
||||
action: %w(GET PUT).freeze
|
||||
].freeze,
|
||||
action: %w[GET PUT].freeze
|
||||
}.freeze
|
||||
].freeze
|
||||
|
||||
|
@ -92,7 +92,7 @@ module Lti
|
|||
private
|
||||
|
||||
def tool_setting_json(tool_setting, bubble)
|
||||
if %w(all distinct).include?(bubble)
|
||||
if %w[all distinct].include?(bubble)
|
||||
graph = []
|
||||
distinct = bubble == 'distinct' ? [] : nil
|
||||
while tool_setting
|
||||
|
|
|
@ -60,7 +60,7 @@ module Lti
|
|||
end
|
||||
|
||||
def membership_service_params
|
||||
keys = %w(role page per_page)
|
||||
keys = %w[role page per_page]
|
||||
params.select { |k, _| keys.include?(k) }
|
||||
end
|
||||
|
||||
|
|
|
@ -260,7 +260,7 @@ module Lti
|
|||
end
|
||||
|
||||
def prep_tool_settings(parameters, tool_proxy, resource_link_id)
|
||||
params = %w(LtiLink.custom.url ToolProxyBinding.custom.url ToolProxy.custom.url)
|
||||
params = %w[LtiLink.custom.url ToolProxyBinding.custom.url ToolProxy.custom.url]
|
||||
if parameters && (parameters.filter_map { |p| p['variable'] } & params).any?
|
||||
link = ToolSetting.where(
|
||||
tool_proxy_id: tool_proxy.id,
|
||||
|
|
|
@ -293,7 +293,7 @@ module Lti
|
|||
end
|
||||
|
||||
def lti_link_attributes
|
||||
[tool_setting: %i(resource_url resource_type_code)].freeze
|
||||
[tool_setting: %i[resource_url resource_type_code]].freeze
|
||||
end
|
||||
|
||||
def assignment
|
||||
|
|
|
@ -233,7 +233,7 @@ module Lti
|
|||
end
|
||||
|
||||
def api_json(submission)
|
||||
submission_attributes = %w(id body url submitted_at assignment_id user_id submission_type workflow_state attempt attachments)
|
||||
submission_attributes = %w[id body url submitted_at assignment_id user_id submission_type workflow_state attempt attachments]
|
||||
sub_hash = filtered_json(model: submission, allow_list: submission_attributes)
|
||||
sub_hash[:user_id] = Lti::Asset.opaque_identifier_for(User.find(sub_hash[:user_id]), context: submission.assignment.context)
|
||||
if submission.turnitin_data[:eula_agreement_timestamp].present?
|
||||
|
@ -247,7 +247,7 @@ module Lti
|
|||
end
|
||||
|
||||
def attachment_json(attachment)
|
||||
attachment_attributes = %w(id display_name filename content-type size created_at updated_at)
|
||||
attachment_attributes = %w[id display_name filename content-type size created_at updated_at]
|
||||
attach = filtered_json(model: attachment, allow_list: attachment_attributes)
|
||||
attach[:upload_status] = AttachmentUploadStatus.upload_status(attachment)
|
||||
attach[:url] = attachment_url(attachment)
|
||||
|
|
|
@ -46,7 +46,7 @@ module Lti
|
|||
}.freeze
|
||||
].freeze
|
||||
|
||||
USER_INCLUDES = %w(email lti_id).freeze
|
||||
USER_INCLUDES = %w[email lti_id].freeze
|
||||
|
||||
def lti2_service_name
|
||||
USER_SERVICE
|
||||
|
|
|
@ -417,7 +417,7 @@ class MasterCourses::MasterTemplatesController < ApplicationController
|
|||
#
|
||||
def restrict_item
|
||||
content_type = params[:content_type]
|
||||
unless %w{assignment attachment discussion_topic external_tool lti-quiz quiz wiki_page}.include?(content_type)
|
||||
unless %w[assignment attachment discussion_topic external_tool lti-quiz quiz wiki_page].include?(content_type)
|
||||
return render :json => { :message => "Must be a valid content type (assignment,attachment,discussion_topic,external_tool,lti-quiz,quiz,wiki_page)" }, :status => :bad_request
|
||||
end
|
||||
unless params.key?(:restricted)
|
||||
|
|
|
@ -195,7 +195,7 @@ class OutcomeImportsApiController < ApplicationController
|
|||
#
|
||||
# @returns OutcomeImport
|
||||
def show
|
||||
if authorized_action(@context, @current_user, %i(import_outcomes manage_outcomes))
|
||||
if authorized_action(@context, @current_user, %i[import_outcomes manage_outcomes])
|
||||
begin
|
||||
@import = if params[:id] == 'latest'
|
||||
@context.latest_outcome_import or raise ActiveRecord::RecordNotFound
|
||||
|
|
|
@ -487,13 +487,13 @@ class OutcomeResultsController < ApplicationController
|
|||
|
||||
def verify_aggregate_parameter
|
||||
aggregate = params[:aggregate]
|
||||
reject! "invalid aggregate parameter value" if aggregate && !%w(course).include?(aggregate)
|
||||
reject! "invalid aggregate parameter value" if aggregate && !%w[course].include?(aggregate)
|
||||
true
|
||||
end
|
||||
|
||||
def verify_aggregate_stat_parameter
|
||||
aggregate_stat = params[:aggregate_stat]
|
||||
reject! "invalid aggregate_stat parameter value" if aggregate_stat && !%w(mean median).include?(aggregate_stat)
|
||||
reject! "invalid aggregate_stat parameter value" if aggregate_stat && !%w[mean median].include?(aggregate_stat)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -501,14 +501,14 @@ class OutcomeResultsController < ApplicationController
|
|||
return true unless params[:sort_by]
|
||||
|
||||
sort_by = params[:sort_by]
|
||||
reject! "invalid sort_by parameter value" if sort_by && !%w(student outcome).include?(sort_by)
|
||||
reject! "invalid sort_by parameter value" if sort_by && !%w[student outcome].include?(sort_by)
|
||||
if sort_by == 'outcome'
|
||||
sort_outcome_id = params[:sort_outcome_id]
|
||||
reject! "missing required sort_outcome_id parameter value" unless sort_outcome_id
|
||||
reject! "invalid sort_outcome_id parameter value" unless /\A\d+\z/.match?(sort_outcome_id)
|
||||
end
|
||||
sort_order = params[:sort_order]
|
||||
reject! "invalid sort_order parameter value" if sort_by && sort_order && !%w(asc desc).include?(sort_order)
|
||||
reject! "invalid sort_order parameter value" if sort_by && sort_order && !%w[asc desc].include?(sort_order)
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ class OutcomesController < ApplicationController
|
|||
@outcome.tie_to(@context)
|
||||
render :json => @outcome.as_json(
|
||||
:methods => :artifacts_count_for_tied_context,
|
||||
:user_content => %w(description)
|
||||
:user_content => %w[description]
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -335,7 +335,7 @@ class PlannerController < ApplicationController
|
|||
end
|
||||
|
||||
def set_params
|
||||
includes = Array.wrap(params[:include]) & %w{concluded}
|
||||
includes = Array.wrap(params[:include]) & %w[concluded]
|
||||
@per_page = params[:per_page] || 50
|
||||
@page = params[:page] || 'first'
|
||||
@include_concluded = includes.include? 'concluded'
|
||||
|
|
|
@ -62,7 +62,7 @@ class ProvisionalGradesBaseController < ApplicationController
|
|||
provisional_grade: pg,
|
||||
current_user: @current_user,
|
||||
avatars: service_enabled?(:avatars) && !@assignment.grade_as_group?,
|
||||
includes: %w(submission_comments rubric_assessment)
|
||||
includes: %w[submission_comments rubric_assessment]
|
||||
)
|
||||
pg_json[:selected] = !!(selection && selection.selected_provisional_grade_id == pg.id)
|
||||
pg_json[:readonly] = !pg.final && (pg.scorer_id != @current_user.id)
|
||||
|
|
|
@ -127,7 +127,7 @@ class ProvisionalGradesController < ProvisionalGradesBaseController
|
|||
selection.save!
|
||||
selection.create_moderation_event(@current_user)
|
||||
changed_submission_ids.push(map[:submission].id)
|
||||
selection_json = selection.as_json(include_root: false, only: %w(assignment_id student_id selected_provisional_grade_id))
|
||||
selection_json = selection.as_json(include_root: false, only: %w[assignment_id student_id selected_provisional_grade_id])
|
||||
|
||||
unless @assignment.can_view_student_names?(@current_user)
|
||||
selection_json.delete(:student_id)
|
||||
|
@ -197,7 +197,7 @@ class ProvisionalGradesController < ProvisionalGradesBaseController
|
|||
# related student is selected.
|
||||
submission.touch
|
||||
|
||||
json = selection.as_json(include_root: false, only: %w(assignment_id student_id selected_provisional_grade_id))
|
||||
json = selection.as_json(include_root: false, only: %w[assignment_id student_id selected_provisional_grade_id])
|
||||
unless @assignment.can_view_student_names?(@current_user)
|
||||
json.delete(:student_id)
|
||||
json[:anonymous_id] = submission.anonymous_id
|
||||
|
|
|
@ -100,12 +100,12 @@ class QuestionBanksController < ApplicationController
|
|||
end
|
||||
@questions = @bank.assessment_questions.where(:id => ids)
|
||||
if params[:move] != '1'
|
||||
attributes = @questions.columns.map(&:name) - %w{id created_at updated_at assessment_question_bank_id}
|
||||
attributes = @questions.columns.map(&:name) - %w[id created_at updated_at assessment_question_bank_id]
|
||||
connection = @questions.connection
|
||||
attributes = attributes.map { |attr| connection.quote_column_name(attr) }
|
||||
now = connection.quote(Time.now.utc)
|
||||
connection.insert(
|
||||
"INSERT INTO #{AssessmentQuestion.quoted_table_name} (#{(%w{assessment_question_bank_id created_at updated_at} + attributes).join(', ')})" +
|
||||
"INSERT INTO #{AssessmentQuestion.quoted_table_name} (#{(%w[assessment_question_bank_id created_at updated_at] + attributes).join(', ')})" +
|
||||
@questions.select(([@new_bank.id, now, now] + attributes).join(', ')).to_sql
|
||||
)
|
||||
else
|
||||
|
|
|
@ -133,8 +133,8 @@ class RoleOverridesController < ApplicationController
|
|||
def api_index
|
||||
if authorized_action(@context, @current_user, :manage_role_overrides)
|
||||
route = polymorphic_url([:api, :v1, @context, :roles])
|
||||
states = params[:state].to_a.reject { |s| %w(active inactive).exclude?(s) }
|
||||
states = %w(active) if states.empty?
|
||||
states = params[:state].to_a.reject { |s| %w[active inactive].exclude?(s) }
|
||||
states = %w[active] if states.empty?
|
||||
|
||||
roles = []
|
||||
roles += Role.visible_built_in_roles(root_account_id: @context.resolved_root_account_id) if states.include?('active')
|
||||
|
@ -576,7 +576,7 @@ class RoleOverridesController < ApplicationController
|
|||
# Could be generalized for other use cases by adding to the whitelist
|
||||
|
||||
def check_account_permission
|
||||
whitelist = %w(manage_catalog)
|
||||
whitelist = %w[manage_catalog]
|
||||
permission = params[:permission]
|
||||
|
||||
if whitelist.include?(permission)
|
||||
|
|
|
@ -113,7 +113,7 @@ class RubricAssociationsController < ApplicationController
|
|||
:rubric => @rubric.as_json(:methods => :criteria, :include_root => false, :permissions => { :user => @current_user,
|
||||
:session => session }),
|
||||
:rubric_association => @association.as_json(:include_root => false,
|
||||
:include => %i{rubric_assessments assessment_requests},
|
||||
:include => %i[rubric_assessments assessment_requests],
|
||||
:permissions => { :user => @current_user, :session => session })
|
||||
}
|
||||
render :json => json_res
|
||||
|
|
|
@ -266,8 +266,8 @@ class RubricsApiController < ApplicationController
|
|||
before_action :require_context
|
||||
before_action :validate_args
|
||||
|
||||
VALID_ASSESSMENT_SCOPES = %w(assessments graded_assessments peer_assessments).freeze
|
||||
VALID_ASSOCIATION_SCOPES = %w(associations assignment_associations course_associations account_associations).freeze
|
||||
VALID_ASSESSMENT_SCOPES = %w[assessments graded_assessments peer_assessments].freeze
|
||||
VALID_ASSOCIATION_SCOPES = %w[associations assignment_associations course_associations account_associations].freeze
|
||||
|
||||
VALID_INCLUDE_PARAMS = (VALID_ASSESSMENT_SCOPES + VALID_ASSOCIATION_SCOPES).freeze
|
||||
|
||||
|
|
|
@ -318,7 +318,7 @@ class SectionsController < ApplicationController
|
|||
add_crumb(@section.name, named_context_url(@context, :context_section_url, @section))
|
||||
@enrollments_count = @section.enrollments.not_fake.where(:workflow_state => 'active').count
|
||||
@completed_enrollments_count = @section.enrollments.not_fake.where(:workflow_state => 'completed').count
|
||||
@pending_enrollments_count = @section.enrollments.not_fake.where(:workflow_state => %w{invited pending}).count
|
||||
@pending_enrollments_count = @section.enrollments.not_fake.where(:workflow_state => %w[invited pending]).count
|
||||
@student_enrollments_count = @section.enrollments.not_fake.where(:type => 'StudentEnrollment').count
|
||||
js_env
|
||||
if @context.grants_right?(@current_user, session, :manage)
|
||||
|
|
|
@ -82,7 +82,7 @@ class SisImportErrorsApiController < ApplicationController
|
|||
#
|
||||
# @returns [SisImportError]
|
||||
def index
|
||||
if authorized_action(@account, @current_user, %i(import_sis manage_sis))
|
||||
if authorized_action(@account, @current_user, %i[import_sis manage_sis])
|
||||
scope = @account.sis_batch_errors.order('created_at DESC')
|
||||
if params[:id]
|
||||
batch = @account.sis_batches.find(params[:id])
|
||||
|
|
|
@ -929,7 +929,7 @@ class SubmissionsApiController < ApplicationController
|
|||
@submission.reload
|
||||
bulk_load_attachments_and_previews([@submission])
|
||||
|
||||
includes = %w(submission_comments)
|
||||
includes = %w[submission_comments]
|
||||
includes.concat(Array.wrap(params[:include]) & ['visibility'])
|
||||
includes << 'provisional_grades' if submission[:provisional]
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ class SubmissionsBaseController < ApplicationController
|
|||
|
||||
render :json => @submission.as_json(
|
||||
Submission.json_serialization_full_parameters(
|
||||
except: %i(quiz_submission submission_history)
|
||||
except: %i[quiz_submission submission_history]
|
||||
).merge({
|
||||
except: submission_json_exclusions,
|
||||
permissions: {
|
||||
|
|
|
@ -321,7 +321,7 @@ class SubmissionsController < SubmissionsBaseController
|
|||
end
|
||||
format.json do
|
||||
if api_request?
|
||||
includes = %|submission_comments attachments|
|
||||
includes = %(submission_comments attachments)
|
||||
json = submission_json(@submission, @assignment, @current_user, session, @context, includes, params)
|
||||
render json: json,
|
||||
status: :created,
|
||||
|
|
|
@ -152,7 +152,7 @@ class TabsController < ApplicationController
|
|||
pos = tab_config.index { |t| t['id'] == tab['id'] }
|
||||
if pos.nil?
|
||||
pos = (tab['position'] || tab_config.size) - 1
|
||||
tab_config.insert(pos, tab.with_indifferent_access.slice(*%w{id hidden position}))
|
||||
tab_config.insert(pos, tab.with_indifferent_access.slice(*%w[id hidden position]))
|
||||
end
|
||||
|
||||
if value_to_boolean(params['hidden'])
|
||||
|
|
|
@ -159,7 +159,7 @@ class TermsApiController < ApplicationController
|
|||
# @returns EnrollmentTerm
|
||||
def show
|
||||
term = api_find(@context.enrollment_terms, params[:id])
|
||||
render json: enrollment_term_json(term, @current_user, session, nil, %w{overrides})
|
||||
render json: enrollment_term_json(term, @current_user, session, nil, %w[overrides])
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
|
@ -125,7 +125,7 @@ class TermsController < ApplicationController
|
|||
params.require(:enrollment_term)
|
||||
overrides = params[:enrollment_term][:overrides]&.to_unsafe_h
|
||||
if overrides.present?
|
||||
unless (overrides.keys.map(&:classify) - %w(StudentEnrollment TeacherEnrollment TaEnrollment DesignerEnrollment)).empty?
|
||||
unless (overrides.keys.map(&:classify) - %w[StudentEnrollment TeacherEnrollment TaEnrollment DesignerEnrollment]).empty?
|
||||
return render :json => { :message => 'Invalid enrollment type in overrides' }, :status => :bad_request
|
||||
end
|
||||
end
|
||||
|
|
|
@ -346,7 +346,7 @@ class UserObserveesController < ApplicationController
|
|||
end
|
||||
|
||||
def root_account_for_new_link
|
||||
if %w{create update}.include?(action_name)
|
||||
if %w[create update].include?(action_name)
|
||||
case params[:root_account_id]
|
||||
when "all"
|
||||
nil
|
||||
|
|
|
@ -421,7 +421,7 @@ class UsersController < ApplicationController
|
|||
end
|
||||
page_opts[:total_entries] = nil unless @context.root_account.allow_last_page_on_users?
|
||||
|
||||
includes = (params[:include] || []) & %w{avatar_url email last_login time_zone uuid}
|
||||
includes = (params[:include] || []) & %w[avatar_url email last_login time_zone uuid]
|
||||
includes << 'last_login' if params[:sort] == 'last_login' && !includes.include?('last_login')
|
||||
GuardRail.activate(:secondary) do
|
||||
users = Api.paginate(users, self, api_v1_account_users_url, page_opts)
|
||||
|
@ -1310,7 +1310,7 @@ class UsersController < ApplicationController
|
|||
render status: status
|
||||
end
|
||||
format.json do
|
||||
render json: user_json(@user, @current_user, session, %w{locale avatar_url},
|
||||
render json: user_json(@user, @current_user, session, %w[locale avatar_url],
|
||||
@current_user.pseudonym.account),
|
||||
status: status
|
||||
end
|
||||
|
@ -1606,7 +1606,7 @@ class UsersController < ApplicationController
|
|||
create_user
|
||||
end
|
||||
|
||||
BOOLEAN_PREFS = %i(manual_mark_as_read collapse_global_nav hide_dashcard_color_overlays release_notes_badge_disabled comment_library_suggestions_enabled elementary_dashboard_disabled).freeze
|
||||
BOOLEAN_PREFS = %i[manual_mark_as_read collapse_global_nav hide_dashcard_color_overlays release_notes_badge_disabled comment_library_suggestions_enabled elementary_dashboard_disabled].freeze
|
||||
|
||||
# @API Update user settings.
|
||||
# Update an existing user's settings.
|
||||
|
@ -1681,8 +1681,8 @@ class UsersController < ApplicationController
|
|||
return render(json: { :message => "This endpoint only works against the current user" }, status: :unauthorized)
|
||||
end
|
||||
|
||||
valid_names = %w{home modules pages assignments quizzes settings files people announcements
|
||||
grades discussions syllabus collaborations import conferences}
|
||||
valid_names = %w[home modules pages assignments quizzes settings files people announcements
|
||||
grades discussions syllabus collaborations import conferences]
|
||||
|
||||
# Check if the page_name is valid
|
||||
unless valid_names.include?(params[:page_name])
|
||||
|
@ -2030,7 +2030,7 @@ class UsersController < ApplicationController
|
|||
@user.grants_right?(@current_user, :update_avatar) &&
|
||||
@user.grants_right?(@current_user, :manage_user_details)
|
||||
|
||||
includes = %w{locale avatar_url email time_zone}
|
||||
includes = %w[locale avatar_url email time_zone]
|
||||
if (title = user_params.delete(:title))
|
||||
@user.profile.title = title
|
||||
includes << "title"
|
||||
|
@ -2408,7 +2408,7 @@ class UsersController < ApplicationController
|
|||
render(:json => user_json(into_user,
|
||||
@current_user,
|
||||
session,
|
||||
%w{locale},
|
||||
%w[locale],
|
||||
destination_account))
|
||||
end
|
||||
end
|
||||
|
@ -2869,7 +2869,7 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def api_show_includes
|
||||
includes = %w{locale avatar_url permissions email effective_locale}
|
||||
includes = %w[locale avatar_url permissions email effective_locale]
|
||||
includes += Array.wrap(params[:include]) & ['uuid', 'last_login']
|
||||
includes
|
||||
end
|
||||
|
@ -2928,7 +2928,7 @@ class UsersController < ApplicationController
|
|||
|
||||
notify_policy = Users::CreationNotifyPolicy.new(manage_user_logins, params[:pseudonym])
|
||||
|
||||
includes = %w{locale}
|
||||
includes = %w[locale]
|
||||
|
||||
cc_params = params[:communication_channel]
|
||||
|
||||
|
|
|
@ -548,7 +548,7 @@ class WikiPagesApiController < ApplicationController
|
|||
end
|
||||
|
||||
def get_wiki_page
|
||||
GuardRail.activate(%w{update update_front_page}.include?(params[:action]) ? :primary : :secondary) do
|
||||
GuardRail.activate(%w[update update_front_page].include?(params[:action]) ? :primary : :secondary) do
|
||||
@wiki = @context.wiki
|
||||
|
||||
# attempt to find an existing page
|
||||
|
@ -588,7 +588,7 @@ class WikiPagesApiController < ApplicationController
|
|||
|
||||
def get_update_params(allowed_fields = Set[])
|
||||
# normalize parameters
|
||||
page_params = params[:wiki_page] ? params[:wiki_page].permit(*%w(title body notify_of_update published front_page editing_roles)) : {}
|
||||
page_params = params[:wiki_page] ? params[:wiki_page].permit(*%w[title body notify_of_update published front_page editing_roles]) : {}
|
||||
|
||||
if page_params.key?(:published)
|
||||
published_value = page_params.delete(:published)
|
||||
|
@ -599,7 +599,7 @@ class WikiPagesApiController < ApplicationController
|
|||
|
||||
if page_params.key?(:editing_roles)
|
||||
editing_roles = page_params[:editing_roles].split(',').map(&:strip)
|
||||
invalid_roles = editing_roles.reject { |role| %w(teachers students members public).include?(role) }
|
||||
invalid_roles = editing_roles.reject { |role| %w[teachers students members public].include?(role) }
|
||||
unless invalid_roles.empty?
|
||||
@page.errors.add(:editing_roles, t(:invalid_editing_roles, 'The provided editing roles are invalid'))
|
||||
return :bad_request
|
||||
|
|
|
@ -101,7 +101,7 @@ module AssignmentsHelper
|
|||
end
|
||||
|
||||
def i18n_grade(grade, grading_type = nil)
|
||||
if grading_type == "pass_fail" && %w{complete incomplete}.include?(grade)
|
||||
if grading_type == "pass_fail" && %w[complete incomplete].include?(grade)
|
||||
return grade == "complete" ? I18n.t("Complete") : I18n.t("Incomplete")
|
||||
end
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ module AttachmentHelper
|
|||
attrs[:attachment_preview_processing] = true
|
||||
end
|
||||
attrs.map { |attr, val|
|
||||
%|data-#{attr}="#{ERB::Util.html_escape(val)}"|
|
||||
%(data-#{attr}="#{ERB::Util.html_escape(val)}")
|
||||
}.join(" ").html_safe
|
||||
end
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ module ContentImportsHelper
|
|||
|
||||
def error_link_or_message(string)
|
||||
if string =~ /ErrorReport(?: id)?: ?(\d+)\z/
|
||||
%{<a href="#{error_url($1)}">Error Report #{$1}</a>}.html_safe
|
||||
%(<a href="#{error_url($1)}">Error Report #{$1}</a>).html_safe
|
||||
else
|
||||
user_content(string)
|
||||
end
|
||||
|
|
|
@ -130,7 +130,7 @@ module CoursesHelper
|
|||
end
|
||||
|
||||
type = enrollment.type.remove(/Enrollment/).downcase
|
||||
type = "student" if %w/studentview observer/.include?(type)
|
||||
type = "student" if %w[studentview observer].include?(type)
|
||||
|
||||
type
|
||||
end
|
||||
|
|
|
@ -147,7 +147,7 @@ module GradebooksHelper
|
|||
def ungraded_submission_display(submission_type)
|
||||
sub_score = ungraded_submission_icon_attributes_for(submission_type)
|
||||
if sub_score
|
||||
screenreadable_icon(sub_score, %w{submission_icon})
|
||||
screenreadable_icon(sub_score, %w[submission_icon])
|
||||
else
|
||||
'-'
|
||||
end
|
||||
|
@ -159,7 +159,7 @@ module GradebooksHelper
|
|||
else
|
||||
fail_icon_attributes
|
||||
end
|
||||
screenreadable_icon(icon_attrs, %w{graded_icon})
|
||||
screenreadable_icon(icon_attrs, %w[graded_icon])
|
||||
end
|
||||
|
||||
def screenreadable_icon(icon_attrs, html_classes = [])
|
||||
|
|
|
@ -33,10 +33,10 @@ module StreamItemsHelper
|
|||
categorized_items = {}
|
||||
return categorized_items unless stream_items.present? # if we have no items (possibly because we have no user), don't try to activate the user's shard
|
||||
|
||||
supported_categories = %w(Announcement Conversation Assignment DiscussionTopic DiscussionEntry AssessmentRequest)
|
||||
supported_categories = %w[Announcement Conversation Assignment DiscussionTopic DiscussionEntry AssessmentRequest]
|
||||
supported_categories.each { |category| categorized_items[category] = [] }
|
||||
|
||||
topic_types = %w{DiscussionTopic Announcement}
|
||||
topic_types = %w[DiscussionTopic Announcement]
|
||||
ActiveRecord::Associations::Preloader.new.preload(
|
||||
stream_items.select { |i| topic_types.include?(i.asset_type) }.map(&:data), :context
|
||||
)
|
||||
|
|
|
@ -27,7 +27,7 @@ class Account < ActiveRecord::Base
|
|||
|
||||
INSTANCE_GUID_SUFFIX = 'canvas-lms'
|
||||
# a list of columns necessary for validation and save callbacks to work on a slim object
|
||||
BASIC_COLUMNS_FOR_CALLBACKS = %i{id parent_account_id root_account_id name workflow_state}.freeze
|
||||
BASIC_COLUMNS_FOR_CALLBACKS = %i[id parent_account_id root_account_id name workflow_state].freeze
|
||||
|
||||
include Workflow
|
||||
include BrandConfigHelpers
|
||||
|
|
|
@ -67,9 +67,9 @@ class AccountReportRunner < ActiveRecord::Base
|
|||
self.update!(workflow_state: 'error', ended_at: Time.now.utc)
|
||||
end
|
||||
|
||||
scope :in_progress, -> { where(workflow_state: %w(running)) }
|
||||
scope :completed, -> { where(workflow_state: %w(completed)) }
|
||||
scope :incomplete, -> { where(workflow_state: %w(created running)) }
|
||||
scope :in_progress, -> { where(workflow_state: %w[running]) }
|
||||
scope :completed, -> { where(workflow_state: %w[completed]) }
|
||||
scope :incomplete, -> { where(workflow_state: %w[created running]) }
|
||||
|
||||
def delete_account_report_rows
|
||||
cleanup = self.account_report_rows.limit(10_000)
|
||||
|
|
|
@ -71,7 +71,7 @@ class AccountUser < ActiveRecord::Base
|
|||
being_deleted = self.workflow_state == 'deleted' && self.workflow_state_before_last_save != 'deleted'
|
||||
if (self.saved_change_to_account_id? || self.saved_change_to_user_id?) || being_deleted
|
||||
if self.new_record?
|
||||
return if %w{creation_pending deleted}.include?(self.user.workflow_state)
|
||||
return if %w[creation_pending deleted].include?(self.user.workflow_state)
|
||||
|
||||
account_chain = self.account.account_chain
|
||||
associations = {}
|
||||
|
|
|
@ -265,8 +265,8 @@ class AssetUserAccess < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def log_action(level)
|
||||
increment(:view_score) if %w{view participate}.include?(level)
|
||||
increment(:participate_score) if %w{participate submit}.include?(level)
|
||||
increment(:view_score) if %w[view participate].include?(level)
|
||||
increment(:participate_score) if %w[participate submit].include?(level)
|
||||
|
||||
if self.action_level != 'participate'
|
||||
self.action_level = (level == 'submit') ? 'participate' : level
|
||||
|
|
|
@ -42,9 +42,9 @@ class Assignment < ActiveRecord::Base
|
|||
|
||||
self.ignored_columns = %i[context_code]
|
||||
|
||||
ALLOWED_GRADING_TYPES = %w(points percent letter_grade gpa_scale pass_fail not_graded).freeze
|
||||
OFFLINE_SUBMISSION_TYPES = %i(on_paper external_tool none not_graded wiki_page).freeze
|
||||
SUBMITTABLE_TYPES = %w(online_quiz discussion_topic wiki_page).freeze
|
||||
ALLOWED_GRADING_TYPES = %w[points percent letter_grade gpa_scale pass_fail not_graded].freeze
|
||||
OFFLINE_SUBMISSION_TYPES = %i[on_paper external_tool none not_graded wiki_page].freeze
|
||||
SUBMITTABLE_TYPES = %w[online_quiz discussion_topic wiki_page].freeze
|
||||
LTI_EULA_SERVICE = 'vnd.Canvas.Eula'
|
||||
AUDITABLE_ATTRIBUTES = %w[
|
||||
muted
|
||||
|
@ -456,7 +456,7 @@ class Assignment < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
API_NEEDED_FIELDS = %w(
|
||||
API_NEEDED_FIELDS = %w[
|
||||
id
|
||||
title
|
||||
context_id
|
||||
|
@ -504,7 +504,7 @@ class Assignment < ActiveRecord::Base
|
|||
grader_comments_visible_to_graders
|
||||
grader_names_visible_to_final_grader
|
||||
grader_count
|
||||
).freeze
|
||||
].freeze
|
||||
|
||||
def external_tool?
|
||||
self.submission_types == 'external_tool'
|
||||
|
@ -1387,7 +1387,7 @@ class Assignment < ActiveRecord::Base
|
|||
def process_if_quiz
|
||||
if self.submission_types == "online_quiz"
|
||||
self.points_possible = quiz.points_possible if quiz&.available?
|
||||
copy_attrs = %w(due_at lock_at unlock_at)
|
||||
copy_attrs = %w[due_at lock_at unlock_at]
|
||||
if quiz && @saved_by != :quiz &&
|
||||
copy_attrs.any? { |attr| changes[attr] }
|
||||
copy_attrs.each { |attr| quiz.send "#{attr}=", send(attr) }
|
||||
|
@ -1674,7 +1674,7 @@ class Assignment < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.assignment_type?(type)
|
||||
%w(quiz attendance discussion_topic wiki_page external_tool).include? type.to_s
|
||||
%w[quiz attendance discussion_topic wiki_page external_tool].include? type.to_s
|
||||
end
|
||||
|
||||
def self.get_submission_type(assignment_type)
|
||||
|
@ -1715,7 +1715,7 @@ class Assignment < ActiveRecord::Base
|
|||
|
||||
def each_submission_type
|
||||
if block_given?
|
||||
submittable_types = %i(discussion_topic quiz)
|
||||
submittable_types = %i[discussion_topic quiz]
|
||||
submittable_types << :wiki_page if self.context.try(:feature_enabled?, :conditional_release)
|
||||
submittable_types.each do |asg_type|
|
||||
submittable = self.send(asg_type)
|
||||
|
@ -1761,7 +1761,7 @@ class Assignment < ActiveRecord::Base
|
|||
can :submit
|
||||
|
||||
given do |user, session|
|
||||
(submittable_type? || %w(discussion_topic online_quiz).include?(submission_types)) &&
|
||||
(submittable_type? || %w[discussion_topic online_quiz].include?(submission_types)) &&
|
||||
context.grants_right?(user, session, :participate_as_student) &&
|
||||
visible_to_user?(user)
|
||||
end
|
||||
|
@ -2968,10 +2968,10 @@ class Assignment < ActiveRecord::Base
|
|||
}
|
||||
|
||||
scope :expecting_submission, -> do
|
||||
where.not(submission_types: [nil, ''] + %w(none not_graded on_paper wiki_page))
|
||||
where.not(submission_types: [nil, ''] + %w[none not_graded on_paper wiki_page])
|
||||
end
|
||||
|
||||
scope :gradeable, -> { where.not(submission_types: %w(not_graded wiki_page)) }
|
||||
scope :gradeable, -> { where.not(submission_types: %w[not_graded wiki_page]) }
|
||||
|
||||
scope :active, -> { where.not(workflow_state: 'deleted') }
|
||||
scope :before, lambda { |date| where("assignments.created_at<?", date) }
|
||||
|
@ -3063,11 +3063,11 @@ class Assignment < ActiveRecord::Base
|
|||
def expects_submission?
|
||||
submission_types.present? &&
|
||||
!expects_external_submission? &&
|
||||
!%w(none not_graded wiki_page).include?(submission_types)
|
||||
!%w[none not_graded wiki_page].include?(submission_types)
|
||||
end
|
||||
|
||||
def expects_external_submission?
|
||||
%w(on_paper external_tool).include?(submission_types)
|
||||
%w[on_paper external_tool].include?(submission_types)
|
||||
end
|
||||
|
||||
def non_digital_submission?
|
||||
|
@ -3142,9 +3142,9 @@ class Assignment < ActiveRecord::Base
|
|||
end
|
||||
protected :infer_comment_context_from_filename
|
||||
|
||||
FREEZABLE_ATTRIBUTES = %w{title description lock_at points_possible grading_type
|
||||
FREEZABLE_ATTRIBUTES = %w[title description lock_at points_possible grading_type
|
||||
submission_types assignment_group_id allowed_extensions
|
||||
group_category_id notify_of_update peer_reviews workflow_state}.freeze
|
||||
group_category_id notify_of_update peer_reviews workflow_state].freeze
|
||||
def frozen?
|
||||
!!(self.freeze_on_copy && self.copied &&
|
||||
PluginSetting.settings_for_plugin(:assignment_freezer))
|
||||
|
|
|
@ -49,7 +49,7 @@ class Assignment::BulkUpdate
|
|||
if base.any?
|
||||
assignment.content_being_saved_by(@current_user)
|
||||
assignment.updating_user = @current_user
|
||||
assignment.assign_attributes(base.first.slice(*%w(due_at unlock_at lock_at)))
|
||||
assignment.assign_attributes(base.first.slice(*%w[due_at unlock_at lock_at]))
|
||||
assignments_to_save << assignment if assignment.changed?
|
||||
end
|
||||
|
||||
|
@ -58,7 +58,7 @@ class Assignment::BulkUpdate
|
|||
override = assignment.assignment_overrides.detect { |o| o.id == override_data['id'].to_i }
|
||||
raise ActiveRecord::RecordNotFound, "invalid assignment override id #{override_data['id']} for assignment #{assignment.id}" unless override
|
||||
|
||||
%w(due_at unlock_at lock_at).each do |date|
|
||||
%w[due_at unlock_at lock_at].each do |date|
|
||||
if override_data.key?(date)
|
||||
override.send("#{date}=", override_data[date])
|
||||
override.send("#{date}_overridden=", true)
|
||||
|
|
|
@ -296,7 +296,7 @@ class AssignmentOverride < ActiveRecord::Base
|
|||
(override.assignment || override.quiz).context.enrollments_visible_to(user)
|
||||
end
|
||||
|
||||
OVERRIDDEN_DATES = %i(due_at unlock_at lock_at).freeze
|
||||
OVERRIDDEN_DATES = %i[due_at unlock_at lock_at].freeze
|
||||
OVERRIDDEN_DATES.each do |field|
|
||||
override field
|
||||
end
|
||||
|
|
|
@ -91,7 +91,7 @@ class AssignmentOverrideStudent < ActiveRecord::Base
|
|||
|
||||
valid_student_ids = Enrollment
|
||||
.where(course_id: assignment.context_id)
|
||||
.where.not(workflow_state: %w{completed inactive deleted})
|
||||
.where.not(workflow_state: %w[completed inactive deleted])
|
||||
.pluck(:user_id)
|
||||
|
||||
AssignmentOverrideStudent
|
||||
|
|
|
@ -40,8 +40,8 @@ class Attachment < ActiveRecord::Base
|
|||
PERMITTED_ATTRIBUTES
|
||||
end
|
||||
|
||||
EXCLUDED_COPY_ATTRIBUTES = %w{id root_attachment_id uuid folder_id user_id
|
||||
filename namespace workflow_state root_account_id}.freeze
|
||||
EXCLUDED_COPY_ATTRIBUTES = %w[id root_attachment_id uuid folder_id user_id
|
||||
filename namespace workflow_state root_account_id].freeze
|
||||
|
||||
CLONING_ERROR_TYPE = 'attachment_clone_url'
|
||||
|
||||
|
@ -201,7 +201,7 @@ class Attachment < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
RELATIVE_CONTEXT_TYPES = %w(Course Group User Account).freeze
|
||||
RELATIVE_CONTEXT_TYPES = %w[Course Group User Account].freeze
|
||||
# returns true if the context is a type that supports relative file paths
|
||||
def self.relative_context?(context_class)
|
||||
RELATIVE_CONTEXT_TYPES.include?(context_class.to_s)
|
||||
|
@ -228,7 +228,7 @@ class Attachment < ActiveRecord::Base
|
|||
@after_attachment_saved_workflow_state = nil
|
||||
end
|
||||
|
||||
if %w(pending_upload processing).include?(workflow_state)
|
||||
if %w[pending_upload processing].include?(workflow_state)
|
||||
# we don't call .process here so that we don't have to go through another whole save cycle
|
||||
self.workflow_state = 'processed'
|
||||
end
|
||||
|
@ -1958,7 +1958,7 @@ class Attachment < ActiveRecord::Base
|
|||
end
|
||||
protected :automatic_thumbnail_sizes
|
||||
|
||||
DYNAMIC_THUMBNAIL_SIZES = %w(640x>).freeze
|
||||
DYNAMIC_THUMBNAIL_SIZES = %w[640x>].freeze
|
||||
|
||||
# the list of allowed thumbnail sizes to be generated dynamically
|
||||
def self.dynamic_thumbnail_sizes
|
||||
|
|
|
@ -235,7 +235,7 @@ class AuthenticationProvider < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
CANVAS_ALLOWED_FEDERATED_ATTRIBUTES = %w{
|
||||
CANVAS_ALLOWED_FEDERATED_ATTRIBUTES = %w[
|
||||
admin_roles
|
||||
display_name
|
||||
email
|
||||
|
@ -247,7 +247,7 @@ class AuthenticationProvider < ActiveRecord::Base
|
|||
sortable_name
|
||||
surname
|
||||
time_zone
|
||||
}.freeze
|
||||
].freeze
|
||||
|
||||
def provision_user(unique_id, provider_attributes = {})
|
||||
User.transaction(requires_new: true) do
|
||||
|
|
|
@ -23,7 +23,7 @@ require 'aws-sdk-sqs'
|
|||
class BounceNotificationProcessor
|
||||
attr_reader :config
|
||||
|
||||
POLL_PARAMS = %i{idle_timeout wait_time_seconds visibility_timeout}.freeze
|
||||
POLL_PARAMS = %i[idle_timeout wait_time_seconds visibility_timeout].freeze
|
||||
DEFAULT_CONFIG = {
|
||||
bounce_queue_name: 'canvas_notifications_bounces',
|
||||
idle_timeout: 10
|
||||
|
|
|
@ -21,8 +21,8 @@ module ConditionalRelease
|
|||
class AssignmentSetAction < ActiveRecord::Base
|
||||
include Deletion
|
||||
|
||||
validates :action, inclusion: { in: %w(assign unassign) }
|
||||
validates :source, inclusion: { in: %w(grade_change select_assignment_set) }
|
||||
validates :action, inclusion: { in: %w[assign unassign] }
|
||||
validates :source, inclusion: { in: %w[grade_change select_assignment_set] }
|
||||
validates :student_id, presence: true
|
||||
validates :actor_id, presence: true
|
||||
validates :assignment_set_id, presence: true
|
||||
|
|
|
@ -229,10 +229,10 @@ module ConditionalRelease
|
|||
end
|
||||
|
||||
def assignment_keys
|
||||
%i(id title name description due_at unlock_at lock_at
|
||||
%i[id title name description due_at unlock_at lock_at
|
||||
points_possible min_score max_score grading_type
|
||||
submission_types workflow_state context_id
|
||||
context_type updated_at context_code)
|
||||
context_type updated_at context_code]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -425,7 +425,7 @@ class ContentMigration < ActiveRecord::Base
|
|||
running_cutoff = Setting.get('content_migration_job_block_hours', '4').to_i.hours.ago # at some point just let the jobs keep going
|
||||
|
||||
if self.context && self.context.content_migrations
|
||||
.where(:workflow_state => %w{created queued pre_processing pre_processed exporting importing}).where("id < ?", self.id)
|
||||
.where(:workflow_state => %w[created queued pre_processing pre_processed exporting importing]).where("id < ?", self.id)
|
||||
.where("started_at > ?", running_cutoff).exists?
|
||||
|
||||
# there's another job already going so punt
|
||||
|
@ -1041,16 +1041,16 @@ class ContentMigration < ActiveRecord::Base
|
|||
def handle_import_in_progress_notice
|
||||
return unless context.is_a?(Course) && is_set?(migration_settings[:import_in_progress_notice])
|
||||
|
||||
if (just_created || (saved_change_to_workflow_state? && %w{created queued}.include?(workflow_state_before_last_save))) &&
|
||||
%w(pre_processing pre_processed exporting importing).include?(workflow_state)
|
||||
if (just_created || (saved_change_to_workflow_state? && %w[created queued].include?(workflow_state_before_last_save))) &&
|
||||
%w[pre_processing pre_processed exporting importing].include?(workflow_state)
|
||||
context.add_content_notice(:import_in_progress, 4.hours)
|
||||
elsif saved_change_to_workflow_state? && %w(pre_process_error exported imported failed).include?(workflow_state)
|
||||
elsif saved_change_to_workflow_state? && %w[pre_process_error exported imported failed].include?(workflow_state)
|
||||
context.remove_content_notice(:import_in_progress)
|
||||
end
|
||||
end
|
||||
|
||||
def check_for_blocked_migration
|
||||
if self.saved_change_to_workflow_state? && %w(pre_process_error exported imported failed).include?(workflow_state)
|
||||
if self.saved_change_to_workflow_state? && %w[pre_process_error exported imported failed].include?(workflow_state)
|
||||
if self.context && (next_cm = self.context.content_migrations.where(:workflow_state => 'queued').order(:id).first)
|
||||
job_id = next_cm.job_progress.try(:delayed_job_id)
|
||||
if job_id && (job = Delayed::Job.where(:id => job_id, :locked_at => nil).first)
|
||||
|
|
|
@ -40,7 +40,7 @@ class ContentShare < ActiveRecord::Base
|
|||
belongs_to :sender, class_name: "User"
|
||||
belongs_to :root_account, class_name: "Account"
|
||||
|
||||
validates :read_state, inclusion: { in: %w(read unread) }
|
||||
validates :read_state, inclusion: { in: %w[read unread] }
|
||||
|
||||
before_create :set_root_account_id
|
||||
|
||||
|
|
|
@ -278,7 +278,7 @@ module Context
|
|||
object = ContextExternalTool.find_external_tool_by_id(params[:id], context)
|
||||
end
|
||||
when 'context_modules'
|
||||
object = if %w(item_redirect item_redirect_mastery_paths choose_mastery_path).include?(params[:action])
|
||||
object = if %w[item_redirect item_redirect_mastery_paths choose_mastery_path].include?(params[:action])
|
||||
context.context_module_tags.find_by(id: params[:id])
|
||||
else
|
||||
context.context_modules.find_by(id: params[:id])
|
||||
|
|
|
@ -146,7 +146,7 @@ class ContextExternalTool < ActiveRecord::Base
|
|||
|
||||
def visible?(visibility, user, context, session = nil)
|
||||
visibility = visibility.to_s
|
||||
return true unless %w(public members admins).include?(visibility)
|
||||
return true unless %w[public members admins].include?(visibility)
|
||||
return true if visibility == 'public'
|
||||
return true if visibility == 'members' &&
|
||||
context.grants_any_right?(user, session, :participate_as_student, :read_as_admin)
|
||||
|
@ -295,7 +295,7 @@ class ContextExternalTool < ActiveRecord::Base
|
|||
extension_keys += custom_keys
|
||||
end
|
||||
extension_keys += {
|
||||
:visibility => lambda { |v| %w{members admins public}.include?(v) || v.nil? }
|
||||
:visibility => lambda { |v| %w[members admins public].include?(v) || v.nil? }
|
||||
}.to_a
|
||||
|
||||
# merge with existing settings so that no caller can complain
|
||||
|
|
|
@ -513,9 +513,9 @@ class ContextModule < ActiveRecord::Base
|
|||
tags = self.content_tags.not_deleted.index_by(&:id)
|
||||
validated_reqs = requirements.select do |req|
|
||||
if req[:id] && (tag = tags[req[:id]])
|
||||
if %w(must_view must_mark_done must_contribute).include?(req[:type])
|
||||
if %w[must_view must_mark_done must_contribute].include?(req[:type])
|
||||
true
|
||||
elsif %w(must_submit min_score).include?(req[:type])
|
||||
elsif %w[must_submit min_score].include?(req[:type])
|
||||
true if tag.scoreable?
|
||||
end
|
||||
end
|
||||
|
@ -756,7 +756,7 @@ class ContextModule < ActiveRecord::Base
|
|||
new_tags = []
|
||||
items.each do |item|
|
||||
next unless item.is_a?(ActiveRecord::Base)
|
||||
next unless %w(Attachment Assignment WikiPage Quizzes::Quiz DiscussionTopic ContextExternalTool).include?(item.class_name)
|
||||
next unless %w[Attachment Assignment WikiPage Quizzes::Quiz DiscussionTopic ContextExternalTool].include?(item.class_name)
|
||||
|
||||
item = item.submittable_object if item.is_a?(Assignment) && item.submittable_object
|
||||
next if tags.any? { |tag| tag.content_type == item.class_name && tag.content_id == item.id }
|
||||
|
|
|
@ -196,7 +196,7 @@ class ContextModuleProgression < ActiveRecord::Base
|
|||
|
||||
if req[:type] == 'must_view'
|
||||
calc.add_view_requirement(req)
|
||||
elsif %w(must_contribute must_mark_done).include? req[:type]
|
||||
elsif %w[must_contribute must_mark_done].include? req[:type]
|
||||
# must_contribute is handled by ContextModule#update_for
|
||||
calc.check_action!(req, false)
|
||||
elsif req[:type] == 'must_submit'
|
||||
|
@ -204,7 +204,7 @@ class ContextModuleProgression < ActiveRecord::Base
|
|||
if sub.workflow_state == 'graded' && sub.attempt.nil?
|
||||
# is a manual grade - doesn't count for submission
|
||||
false
|
||||
elsif %w(submitted graded complete pending_review).include?(sub.workflow_state)
|
||||
elsif %w[submitted graded complete pending_review].include?(sub.workflow_state)
|
||||
true
|
||||
end
|
||||
})
|
||||
|
|
|
@ -759,7 +759,7 @@ class Conversation < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def replies_locked_for?(user)
|
||||
return false unless %w{Course Group}.include?(self.context_type)
|
||||
return false unless %w[Course Group].include?(self.context_type)
|
||||
|
||||
course = self.context.is_a?(Course) ? self.context : self.context.context
|
||||
|
||||
|
|
|
@ -367,8 +367,8 @@ class Course < ActiveRecord::Base
|
|||
def update_enrollment_states_if_necessary
|
||||
return if saved_change_to_id # new object, nothing to possibly invalidate
|
||||
|
||||
if (saved_changes.keys & %w{restrict_enrollments_to_course_dates account_id enrollment_term_id}).any? ||
|
||||
(self.restrict_enrollments_to_course_dates? && (saved_changes.keys & %w{start_at conclude_at}).any?) ||
|
||||
if (saved_changes.keys & %w[restrict_enrollments_to_course_dates account_id enrollment_term_id]).any? ||
|
||||
(self.restrict_enrollments_to_course_dates? && (saved_changes.keys & %w[start_at conclude_at]).any?) ||
|
||||
(self.saved_change_to_workflow_state? && (completed? || self.workflow_state_before_last_save == 'completed'))
|
||||
# a lot of things can change the date logic here :/
|
||||
|
||||
|
@ -519,7 +519,7 @@ class Course < ActiveRecord::Base
|
|||
|
||||
def validate_default_view
|
||||
if self.default_view_changed?
|
||||
if !%w{assignments feed modules syllabus wiki}.include?(self.default_view)
|
||||
if !%w[assignments feed modules syllabus wiki].include?(self.default_view)
|
||||
self.errors.add(:default_view, t("Home page is not valid"))
|
||||
return false
|
||||
elsif self.default_view == 'wiki' && !(self.wiki_id && self.wiki.has_front_page?)
|
||||
|
@ -868,8 +868,8 @@ class Course < ActiveRecord::Base
|
|||
none :
|
||||
where("EXISTS (?)", CourseAccountAssociation.where("course_account_associations.course_id=courses.id AND course_account_associations.account_id IN (?)", account_ids))
|
||||
}
|
||||
scope :published, -> { where(workflow_state: %w(available completed)) }
|
||||
scope :unpublished, -> { where(workflow_state: %w(created claimed)) }
|
||||
scope :published, -> { where(workflow_state: %w[available completed]) }
|
||||
scope :unpublished, -> { where(workflow_state: %w[created claimed]) }
|
||||
|
||||
scope :deleted, -> { where(:workflow_state => 'deleted') }
|
||||
|
||||
|
@ -1027,7 +1027,7 @@ class Course < ActiveRecord::Base
|
|||
def user_has_been_instructor?(user)
|
||||
return unless user
|
||||
if @user_ids_by_enroll_type
|
||||
return preloaded_user_has_been?(user, %w{TaEnrollment TeacherEnrollment})
|
||||
return preloaded_user_has_been?(user, %w[TaEnrollment TeacherEnrollment])
|
||||
end
|
||||
|
||||
# enrollments should be on the course's shard
|
||||
|
@ -1039,7 +1039,7 @@ class Course < ActiveRecord::Base
|
|||
def user_has_been_admin?(user)
|
||||
return unless user
|
||||
if @user_ids_by_enroll_type
|
||||
return preloaded_user_has_been?(user, %w{TaEnrollment TeacherEnrollment DesignerEnrollment})
|
||||
return preloaded_user_has_been?(user, %w[TaEnrollment TeacherEnrollment DesignerEnrollment])
|
||||
end
|
||||
|
||||
fetch_on_enrollments('user_has_been_admin', user) do
|
||||
|
@ -1061,7 +1061,7 @@ class Course < ActiveRecord::Base
|
|||
def user_has_been_student?(user)
|
||||
return unless user
|
||||
if @user_ids_by_enroll_type
|
||||
return preloaded_user_has_been?(user, %w{StudentEnrollment StudentViewEnrollment})
|
||||
return preloaded_user_has_been?(user, %w[StudentEnrollment StudentViewEnrollment])
|
||||
end
|
||||
|
||||
fetch_on_enrollments('user_has_been_student', user) do
|
||||
|
@ -1974,7 +1974,7 @@ class Course < ActiveRecord::Base
|
|||
end
|
||||
overall_status = "error"
|
||||
overall_status = "unpublished" unless found_statuses.size > 0
|
||||
overall_status = %w{error unpublished pending publishing published unpublishable}.detect { |s| found_statuses.include?(s) } || overall_status
|
||||
overall_status = %w[error unpublished pending publishing published unpublishable].detect { |s| found_statuses.include?(s) } || overall_status
|
||||
[enrollments, overall_status]
|
||||
end
|
||||
|
||||
|
@ -2656,7 +2656,7 @@ class Course < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
ADMIN_TYPES = %w{TeacherEnrollment TaEnrollment DesignerEnrollment}.freeze
|
||||
ADMIN_TYPES = %w[TeacherEnrollment TaEnrollment DesignerEnrollment].freeze
|
||||
def section_visibilities_for(user, opts = {})
|
||||
fetch_on_enrollments('section_visibilities_for', user, opts) do
|
||||
workflow_not = opts[:excluded_workflows] || 'deleted'
|
||||
|
@ -3706,7 +3706,7 @@ class Course < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
%w{student_count teacher_count primary_enrollment_type primary_enrollment_role_id primary_enrollment_rank primary_enrollment_state primary_enrollment_date invitation}.each do |method|
|
||||
%w[student_count teacher_count primary_enrollment_type primary_enrollment_role_id primary_enrollment_rank primary_enrollment_state primary_enrollment_date invitation].each do |method|
|
||||
class_eval <<~RUBY
|
||||
def #{method}
|
||||
read_attribute(:#{method}) || @#{method}
|
||||
|
|
|
@ -406,7 +406,7 @@ class CourseSection < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def update_enrollment_states_if_necessary
|
||||
if self.saved_change_to_restrict_enrollments_to_section_dates? || (self.restrict_enrollments_to_section_dates? && (saved_changes.keys & %w{start_at end_at}).any?)
|
||||
if self.saved_change_to_restrict_enrollments_to_section_dates? || (self.restrict_enrollments_to_section_dates? && (saved_changes.keys & %w[start_at end_at]).any?)
|
||||
EnrollmentState.delay_if_production(n_strand: ["invalidate_enrollment_states", self.global_root_account_id])
|
||||
.invalidate_states_for_course_or_section(self)
|
||||
end
|
||||
|
|
|
@ -27,7 +27,7 @@ class CrocodocDocument < ActiveRecord::Base
|
|||
|
||||
has_many :canvadocs_submissions
|
||||
|
||||
MIME_TYPES = %w(
|
||||
MIME_TYPES = %w[
|
||||
application/pdf
|
||||
application/msword
|
||||
application/vnd.openxmlformats-officedocument.wordprocessingml.document
|
||||
|
@ -36,7 +36,7 @@ class CrocodocDocument < ActiveRecord::Base
|
|||
application/excel
|
||||
application/vnd.ms-excel
|
||||
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
|
||||
).freeze
|
||||
].freeze
|
||||
|
||||
def upload
|
||||
return if uuid.present?
|
||||
|
@ -194,7 +194,7 @@ class CrocodocDocument < ActiveRecord::Base
|
|||
def self.update_process_states
|
||||
bs = Setting.get('crocodoc_status_check_batch_size', '45').to_i
|
||||
GuardRail.activate(:secondary) do
|
||||
CrocodocDocument.where(:process_state => %w(QUEUED PROCESSING)).find_in_batches do |docs|
|
||||
CrocodocDocument.where(:process_state => %w[QUEUED PROCESSING]).find_in_batches do |docs|
|
||||
GuardRail.activate(:primary) do
|
||||
statuses = []
|
||||
docs.each_slice(bs) do |sub_docs|
|
||||
|
|
|
@ -219,7 +219,7 @@ class DiscussionEntry < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def update_discussion
|
||||
if %w(workflow_state message attachment_id editor_id).any? { |a| self.saved_change_to_attribute?(a) }
|
||||
if %w[workflow_state message attachment_id editor_id].any? { |a| self.saved_change_to_attribute?(a) }
|
||||
dt = self.discussion_topic
|
||||
loop do
|
||||
dt.touch
|
||||
|
|
|
@ -25,8 +25,8 @@ class DiscussionEntryDraft < ActiveRecord::Base
|
|||
belongs_to :user, inverse_of: :discussion_entry_drafts
|
||||
|
||||
def self.upsert_draft(user:, topic:, message:, entry: nil, parent: nil, attachment: nil, reply_preview: false)
|
||||
insert_columns = %w(user_id discussion_topic_id discussion_entry_id root_entry_id parent_id
|
||||
attachment_id message include_reply_preview updated_at created_at)
|
||||
insert_columns = %w[user_id discussion_topic_id discussion_entry_id root_entry_id parent_id
|
||||
attachment_id message include_reply_preview updated_at created_at]
|
||||
|
||||
topic.shard.activate do
|
||||
insert_values = []
|
||||
|
@ -44,7 +44,7 @@ class DiscussionEntryDraft < ActiveRecord::Base
|
|||
conflict_condition = '(root_entry_id, user_id) WHERE discussion_entry_id IS NULL' if parent
|
||||
conflict_condition = '(discussion_entry_id, user_id)' if entry
|
||||
|
||||
update_columns = %w(message include_reply_preview)
|
||||
update_columns = %w[message include_reply_preview]
|
||||
update_columns << 'parent_id' if parent
|
||||
update_columns << 'attachment' if attachment
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class DiscussionEntryParticipant < ActiveRecord::Base
|
|||
validates :discussion_entry_id, :user_id, :workflow_state, presence: true
|
||||
validate :prevent_creates
|
||||
|
||||
validates :report_type, inclusion: { in: %w(inappropriate offensive other),
|
||||
validates :report_type, inclusion: { in: %w[inappropriate offensive other],
|
||||
message: "%{value} is not valid" }
|
||||
|
||||
def prevent_creates
|
||||
|
@ -81,7 +81,7 @@ class DiscussionEntryParticipant < ActiveRecord::Base
|
|||
return not_null_column_object(column: :entry, entry: entry_or_topic, user: user) unless entry_or_topic
|
||||
return not_null_column_object(column: :user, entry: entry_or_topic, user: user) unless user
|
||||
|
||||
insert_columns = %w(discussion_entry_id user_id root_account_id workflow_state)
|
||||
insert_columns = %w[discussion_entry_id user_id root_account_id workflow_state]
|
||||
update_columns = []
|
||||
update_values = []
|
||||
|
||||
|
@ -98,7 +98,7 @@ class DiscussionEntryParticipant < ActiveRecord::Base
|
|||
end
|
||||
|
||||
unless report_type.nil?
|
||||
unless %w(inappropriate offensive other).include? report_type
|
||||
unless %w[inappropriate offensive other].include? report_type
|
||||
raise(ArgumentError)
|
||||
end
|
||||
|
||||
|
|
|
@ -349,7 +349,7 @@ class Enrollment < ActiveRecord::Base
|
|||
return if self.fake_student?
|
||||
|
||||
if id_before_last_save.nil? || being_restored?
|
||||
return if %w{creation_pending deleted}.include?(self.user.workflow_state)
|
||||
return if %w[creation_pending deleted].include?(self.user.workflow_state)
|
||||
|
||||
associations = User.calculate_account_associations_from_accounts([self.course.account_id, self.course_section.course.account_id, self.course_section.nonxlist_course.try(:account_id)].compact.uniq)
|
||||
self.user.update_account_associations(:incremental => true, :precalculated_associations => associations)
|
||||
|
@ -510,7 +510,7 @@ class Enrollment < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def cancel_future_appointments
|
||||
if saved_change_to_workflow_state? && %w{completed deleted}.include?(workflow_state)
|
||||
if saved_change_to_workflow_state? && %w[completed deleted].include?(workflow_state)
|
||||
unless self.course.current_enrollments.where(:user_id => self.user_id).exists? # ignore if they have another still valid enrollment
|
||||
course.appointment_participants.active.current.for_context_codes(user.asset_string).update_all(:workflow_state => 'deleted')
|
||||
end
|
||||
|
@ -752,7 +752,7 @@ class Enrollment < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def recalculate_enrollment_state
|
||||
if (self.saved_changes.keys & %w{workflow_state start_at end_at}).any?
|
||||
if (self.saved_changes.keys & %w[workflow_state start_at end_at]).any?
|
||||
@enrollment_dates = nil
|
||||
self.enrollment_state.state_is_current = false
|
||||
self.enrollment_state.is_direct_recalculation = true
|
||||
|
@ -763,7 +763,7 @@ class Enrollment < ActiveRecord::Base
|
|||
|
||||
def state_based_on_date
|
||||
RequestCache.cache('enrollment_state_based_on_date', self, self.workflow_state, self.saved_changes?) do
|
||||
if %w{invited active completed}.include?(self.workflow_state)
|
||||
if %w[invited active completed].include?(self.workflow_state)
|
||||
self.enrollment_state.get_effective_state
|
||||
else
|
||||
self.workflow_state.to_sym
|
||||
|
@ -1148,7 +1148,7 @@ class Enrollment < ActiveRecord::Base
|
|||
|
||||
def find_score(id_opts = nil)
|
||||
id_opts ||= Score.params_for_course
|
||||
valid_keys = %i(course_score grading_period grading_period_id assignment_group assignment_group_id)
|
||||
valid_keys = %i[course_score grading_period grading_period_id assignment_group assignment_group_id]
|
||||
return nil if id_opts.except(*valid_keys).any?
|
||||
|
||||
result = if scores.loaded?
|
||||
|
|
|
@ -56,7 +56,7 @@ class Enrollment::BatchStateUpdater
|
|||
e.workflow_state = 'deleted'
|
||||
e.readonly!
|
||||
}
|
||||
@user_course_tuples = Enrollment.where(id: batch).active.select(%i(user_id course_id)).distinct.to_a
|
||||
@user_course_tuples = Enrollment.where(id: batch).active.select(%i[user_id course_id]).distinct.to_a
|
||||
@user_ids = Enrollment.where(id: batch).order(:user_id).distinct.pluck(:user_id)
|
||||
@courses = Course.where(id: Enrollment.where(id: batch).select(:course_id).distinct).to_a
|
||||
@root_account = @courses.first.root_account
|
||||
|
|
|
@ -105,7 +105,7 @@ class EnrollmentState < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def pending?
|
||||
%w{pending_active pending_invited creation_pending}.include?(self.state)
|
||||
%w[pending_active pending_invited creation_pending].include?(self.state)
|
||||
end
|
||||
|
||||
def recalculate_state
|
||||
|
@ -113,7 +113,7 @@ class EnrollmentState < ActiveRecord::Base
|
|||
self.state_started_at = nil
|
||||
|
||||
wf_state = self.enrollment.workflow_state
|
||||
invited_or_active = %w{invited active}.include?(wf_state)
|
||||
invited_or_active = %w[invited active].include?(wf_state)
|
||||
|
||||
if invited_or_active
|
||||
if self.enrollment.course.completed?
|
||||
|
@ -254,7 +254,7 @@ class EnrollmentState < ActiveRecord::Base
|
|||
enrollment.enrollment_state.ensure_current_state
|
||||
end
|
||||
|
||||
INVALIDATEABLE_STATES = %w{pending_invited pending_active invited active completed inactive}.freeze # don't worry about creation_pending or rejected, etc
|
||||
INVALIDATEABLE_STATES = %w[pending_invited pending_active invited active completed inactive].freeze # don't worry about creation_pending or rejected, etc
|
||||
def self.invalidate_states(enrollment_scope)
|
||||
EnrollmentState.where(:enrollment_id => enrollment_scope, :state => INVALIDATEABLE_STATES)
|
||||
.update_all(["lock_version = COALESCE(lock_version, 0) + 1, state_is_current = ?", false])
|
||||
|
@ -280,7 +280,7 @@ class EnrollmentState < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.enrollments_for_account_ids(account_ids)
|
||||
Enrollment.joins(:course).where(:courses => { :account_id => account_ids }).where(:type => %w{StudentEnrollment ObserverEnrollment})
|
||||
Enrollment.joins(:course).where(:courses => { :account_id => account_ids }).where(:type => %w[StudentEnrollment ObserverEnrollment])
|
||||
end
|
||||
|
||||
ENROLLMENT_BATCH_SIZE = 1_000
|
||||
|
@ -327,7 +327,7 @@ class EnrollmentState < ActiveRecord::Base
|
|||
|
||||
def self.invalidate_access_for_course(course, changed_keys)
|
||||
states_to_update = access_states_to_update(changed_keys)
|
||||
scope = course.enrollments.where(:type => %w{StudentEnrollment ObserverEnrollment})
|
||||
scope = course.enrollments.where(:type => %w[StudentEnrollment ObserverEnrollment])
|
||||
if invalidate_access(scope, states_to_update) > 0
|
||||
process_states_for(enrollments_needing_calculation(scope))
|
||||
end
|
||||
|
|
|
@ -35,11 +35,11 @@ module Exporters
|
|||
folders = (content_export.selected_content['folders'] || {})
|
||||
.select { |_tag, included| Canvas::Plugin.value_to_boolean(included) }
|
||||
.keys
|
||||
.filter_map { |folder_tag| context.folders.active.find_by_asset_string(folder_tag, %w(Folder)) }
|
||||
.filter_map { |folder_tag| context.folders.active.find_by_asset_string(folder_tag, %w[Folder]) }
|
||||
files = (content_export.selected_content['attachments'] || {})
|
||||
.select { |_tag, included| Canvas::Plugin.value_to_boolean(included) }
|
||||
.keys
|
||||
.filter_map { |att_tag| context.attachments.not_deleted.find_by_asset_string(att_tag, %w(Attachment)) }
|
||||
.filter_map { |att_tag| context.attachments.not_deleted.find_by_asset_string(att_tag, %w[Attachment]) }
|
||||
end
|
||||
[folders, files]
|
||||
end
|
||||
|
|
|
@ -35,7 +35,7 @@ class ExternalFeed < ActiveRecord::Base
|
|||
uniqueness: { scope: [:context_id, :context_type, :verbosity, :header_match] },
|
||||
length: { maximum: maximum_string_length }
|
||||
|
||||
VERBOSITIES = %w(full link_only truncate).freeze
|
||||
VERBOSITIES = %w[full link_only truncate].freeze
|
||||
validates :verbosity, inclusion: { :in => VERBOSITIES, :allow_nil => true }
|
||||
|
||||
def infer_defaults
|
||||
|
|
|
@ -114,7 +114,7 @@ module GroupCategories
|
|||
return nil unless raw_value
|
||||
|
||||
raw_value = raw_value.to_s.downcase
|
||||
%w(enabled restricted).include?(raw_value) ? raw_value : nil
|
||||
%w[enabled restricted].include?(raw_value) ? raw_value : nil
|
||||
end
|
||||
|
||||
def _auto_leader
|
||||
|
@ -122,7 +122,7 @@ module GroupCategories
|
|||
return nil unless raw_value
|
||||
|
||||
raw_value = raw_value.to_s.downcase
|
||||
%w(random first).include?(raw_value) ? raw_value : nil
|
||||
%w[random first].include?(raw_value) ? raw_value : nil
|
||||
end
|
||||
|
||||
def auto_leader_type
|
||||
|
|
|
@ -272,7 +272,7 @@ module Importers
|
|||
if gs
|
||||
item.grading_standard = gs if gs
|
||||
else
|
||||
migration.add_warning(t('errors.import.grading_standard_not_found', %{The assignment "%{title}" referenced a grading scheme that was not found in the target course's account chain.}, :title => hash[:title]))
|
||||
migration.add_warning(t('errors.import.grading_standard_not_found', %(The assignment "%{title}" referenced a grading scheme that was not found in the target course's account chain.), :title => hash[:title]))
|
||||
end
|
||||
end
|
||||
if quiz
|
||||
|
|
|
@ -36,7 +36,7 @@ module Importers
|
|||
item ||= LearningOutcomeGroup.global.where(vendor_guid: hash[:vendor_guid]).first if hash[:vendor_guid]
|
||||
item ||= LearningOutcomeGroup.new
|
||||
else
|
||||
migration.add_warning(t(:no_global_permission, %{You're not allowed to manage global outcomes, can't add "%{title}"}, :title => hash[:title]))
|
||||
migration.add_warning(t(:no_global_permission, %(You're not allowed to manage global outcomes, can't add "%{title}"), :title => hash[:title]))
|
||||
return
|
||||
end
|
||||
else
|
||||
|
|
|
@ -68,7 +68,7 @@ module Importers
|
|||
end
|
||||
|
||||
unless outcome
|
||||
migration.add_warning(t(:no_context_found, %{The external Learning Outcome couldn't be found for "%{title}", creating a copy.}, :title => hash[:title]))
|
||||
migration.add_warning(t(:no_context_found, %(The external Learning Outcome couldn't be found for "%{title}", creating a copy.), :title => hash[:title]))
|
||||
migration.copied_external_outcome_map[hash[:external_identifier]] = hash[:migration_id]
|
||||
end
|
||||
end
|
||||
|
@ -91,7 +91,7 @@ module Importers
|
|||
item ||= LearningOutcome.global.where(vendor_guid: hash[:vendor_guid]).first if hash[:vendor_guid]
|
||||
item ||= LearningOutcome.new
|
||||
else
|
||||
migration.add_warning(t(:no_global_permission, %{You're not allowed to manage global outcomes, can't add "%{title}"}, :title => hash[:title]))
|
||||
migration.add_warning(t(:no_global_permission, %(You're not allowed to manage global outcomes, can't add "%{title}"), :title => hash[:title]))
|
||||
return
|
||||
end
|
||||
else
|
||||
|
|
|
@ -35,7 +35,7 @@ module Importers
|
|||
|
||||
include Helpers
|
||||
|
||||
REFERENCE_KEYWORDS = %w{CANVAS_COURSE_REFERENCE CANVAS_OBJECT_REFERENCE WIKI_REFERENCE IMS_CC_FILEBASE IMS-CC-FILEBASE}.freeze
|
||||
REFERENCE_KEYWORDS = %w[CANVAS_COURSE_REFERENCE CANVAS_OBJECT_REFERENCE WIKI_REFERENCE IMS_CC_FILEBASE IMS-CC-FILEBASE].freeze
|
||||
LINK_PLACEHOLDER = "LINK.PLACEHOLDER"
|
||||
|
||||
attr_reader :unresolved_link_map
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#
|
||||
|
||||
class LatePolicy < ActiveRecord::Base
|
||||
POINT_DEDUCTIBLE_GRADING_TYPES = %w(points percent letter_grade gpa_scale).freeze
|
||||
POINT_DEDUCTIBLE_GRADING_TYPES = %w[points percent letter_grade gpa_scale].freeze
|
||||
|
||||
belongs_to :course, inverse_of: :late_policy
|
||||
|
||||
|
@ -31,7 +31,7 @@ class LatePolicy < ActiveRecord::Base
|
|||
numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 100 }
|
||||
validates :late_submission_interval,
|
||||
presence: true,
|
||||
inclusion: { in: %w(day hour) }
|
||||
inclusion: { in: %w[day hour] }
|
||||
|
||||
before_save :set_root_account_id
|
||||
after_save :update_late_submissions, if: :late_policy_attributes_changed?
|
||||
|
|
|
@ -32,20 +32,20 @@ module Lti
|
|||
WEBHOOK_GRANT_ALL_CAPABILITY = 'vnd.instructure.webhooks.root_account.all'
|
||||
WEBHOOK_SUBSCRIPTION_CAPABILITIES = {
|
||||
all: [WEBHOOK_GRANT_ALL_CAPABILITY].freeze,
|
||||
quiz_submitted: %w(vnd.instructure.webhooks.root_account.quiz_submitted
|
||||
vnd.instructure.webhooks.assignment.quiz_submitted).freeze,
|
||||
grade_change: %w(vnd.instructure.webhooks.root_account.grade_change).freeze,
|
||||
attachment_created: %w(vnd.instructure.webhooks.root_account.attachment_created
|
||||
vnd.instructure.webhooks.assignment.attachment_created).freeze,
|
||||
submission_created: %w(vnd.instructure.webhooks.root_account.submission_created
|
||||
vnd.instructure.webhooks.assignment.submission_created).freeze,
|
||||
plagiarism_resubmit: %w(vnd.instructure.webhooks.root_account.plagiarism_resubmit
|
||||
vnd.instructure.webhooks.assignment.plagiarism_resubmit).freeze,
|
||||
submission_updated: %w(vnd.instructure.webhooks.root_account.submission_updated
|
||||
vnd.instructure.webhooks.assignment.submission_updated).freeze,
|
||||
quiz_submitted: %w[vnd.instructure.webhooks.root_account.quiz_submitted
|
||||
vnd.instructure.webhooks.assignment.quiz_submitted].freeze,
|
||||
grade_change: %w[vnd.instructure.webhooks.root_account.grade_change].freeze,
|
||||
attachment_created: %w[vnd.instructure.webhooks.root_account.attachment_created
|
||||
vnd.instructure.webhooks.assignment.attachment_created].freeze,
|
||||
submission_created: %w[vnd.instructure.webhooks.root_account.submission_created
|
||||
vnd.instructure.webhooks.assignment.submission_created].freeze,
|
||||
plagiarism_resubmit: %w[vnd.instructure.webhooks.root_account.plagiarism_resubmit
|
||||
vnd.instructure.webhooks.assignment.plagiarism_resubmit].freeze,
|
||||
submission_updated: %w[vnd.instructure.webhooks.root_account.submission_updated
|
||||
vnd.instructure.webhooks.assignment.submission_updated].freeze,
|
||||
}.freeze
|
||||
|
||||
DEFAULT_CAPABILITIES = %w(
|
||||
DEFAULT_CAPABILITIES = %w[
|
||||
basic-lti-launch-request
|
||||
ToolProxyRegistrationRequest
|
||||
Canvas.placements.accountNavigation
|
||||
|
@ -57,7 +57,7 @@ module Lti
|
|||
Canvas.placements.postGrades
|
||||
Security.splitSecret
|
||||
Context.sourcedId
|
||||
).concat(
|
||||
].concat(
|
||||
Lti::VariableExpander.expansion_keys
|
||||
).freeze
|
||||
|
||||
|
|
|
@ -23,10 +23,10 @@ module MasterCourses
|
|||
end
|
||||
|
||||
# probably not be a comprehensive list but oh well
|
||||
ALLOWED_CONTENT_TYPES = %w{
|
||||
ALLOWED_CONTENT_TYPES = %w[
|
||||
Announcement AssessmentQuestionBank Assignment AssignmentGroup Attachment CalendarEvent DiscussionTopic
|
||||
ContextExternalTool ContextModule ContentTag LearningOutcome LearningOutcomeGroup Quizzes::Quiz Rubric Wiki WikiPage
|
||||
}.freeze
|
||||
].freeze
|
||||
|
||||
CONTENT_TYPES_FOR_DELETIONS = (ALLOWED_CONTENT_TYPES - ['Wiki']).freeze
|
||||
CONTENT_TYPES_FOR_UNSYNCED_CHANGES = (ALLOWED_CONTENT_TYPES - ['ContentTag', 'Wiki'] + ['Folder']).freeze
|
||||
|
@ -35,5 +35,5 @@ module MasterCourses
|
|||
|
||||
LOCK_TYPES = [:content, :settings, :points, :due_dates, :availability_dates, :state].freeze
|
||||
|
||||
RESTRICTED_OBJECT_TYPES = %w{Assignment Attachment DiscussionTopic Quizzes::Quiz WikiPage}.freeze
|
||||
RESTRICTED_OBJECT_TYPES = %w[Assignment Attachment DiscussionTopic Quizzes::Quiz WikiPage].freeze
|
||||
end
|
||||
|
|
|
@ -97,7 +97,7 @@ class MasterCourses::MasterMigration < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def in_running_state?
|
||||
%w{created queued exporting imports_queued}.include?(self.workflow_state)
|
||||
%w[created queued exporting imports_queued].include?(self.workflow_state)
|
||||
end
|
||||
|
||||
def still_running?
|
||||
|
@ -322,7 +322,7 @@ class MasterCourses::MasterMigration < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
unless self.migration_results.where.not(:state => %w{completed failed}).exists?
|
||||
unless self.migration_results.where.not(:state => %w[completed failed]).exists?
|
||||
self.class.transaction do
|
||||
self.lock!
|
||||
if self.workflow_state == 'imports_queued'
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue