RuboCop: Style/NegatedIfElseCondition

[skip-stages=Flakey]

auto-corrected

Change-Id: I973e75a76d2103c802fab2c52676baf080bd516d
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/279080
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>
This commit is contained in:
Cody Cutrer 2021-11-20 07:33:31 -07:00
parent 60be8542df
commit eecafdca0b
73 changed files with 284 additions and 282 deletions

View File

@ -308,6 +308,8 @@ Style/MutableConstant:
Severity: error
Style/NegatedIf:
Severity: error
Style/NegatedIfElseCondition:
Severity: error
Style/NegatedUnless:
Severity: error
Style/NegatedWhile:

View File

@ -847,11 +847,11 @@ class AccountsController < ApplicationController
next unless quota_settings.key?(quota_type)
quota_value = quota_settings[quota_type].to_s.strip
if !INTEGER_REGEX.match?(quota_value.to_s)
@account.errors.add(quota_type, t(:quota_integer_required, 'An integer value is required'))
else
if INTEGER_REGEX.match?(quota_value.to_s)
@account.errors.add(quota_type, t(:quota_must_be_positive, 'Value must be positive')) if quota_value.to_i < 0
@account.errors.add(quota_type, t(:quota_too_large, 'Value too large')) if quota_value.to_i >= (2**62) / 1.megabytes
else
@account.errors.add(quota_type, t(:quota_integer_required, 'An integer value is required'))
end
end
else

View File

@ -1870,10 +1870,7 @@ class ApplicationController < ActionController::Base
@assignment&.prepare_for_ags_if_needed!(@tool)
tag.context_module_action(@current_user, :read)
if !@tool
flash[:error] = t "#application.errors.invalid_external_tool", "Couldn't find valid settings for this link"
redirect_to named_context_url(context, error_redirect_symbol)
else
if @tool
log_asset_access(@tool, "external_tools", "external_tools", overwrite: false)
@opaque_id = @tool.opaque_identifier_for(@tag)
@ -1969,6 +1966,9 @@ class ApplicationController < ActionController::Base
@append_template = 'context_modules/tool_sequence_footer' if render_external_tool_append_template?
render Lti::AppUtil.display_template(external_tool_redirect_display_type)
else
flash[:error] = t "#application.errors.invalid_external_tool", "Couldn't find valid settings for this link"
redirect_to named_context_url(context, error_redirect_symbol)
end
else
flash[:error] = t "#application.errors.invalid_tag_type", "Didn't recognize the item type for this tag"

View File

@ -176,7 +176,10 @@ class ContextModulesController < ApplicationController
# locked assignments always have 0 sets, so this check makes it not return 404 if locked
# but instead progress forward and return a warning message if is locked later on
if rule.present? && (rule[:locked] || !rule[:selected_set_id] || rule[:assignment_sets].length > 1)
if !rule[:locked]
if rule[:locked]
flash[:warning] = t('Module Item is locked.')
return redirect_to named_context_url(@context, :context_context_modules_url)
else
options = rule[:assignment_sets].map { |set|
option = {
setId: set[:id]
@ -207,9 +210,6 @@ class ContextModulesController < ApplicationController
@page_title = join_title(t('Choose Assignment Set'), @context.name)
return render :html => '', :layout => true
else
flash[:warning] = t('Module Item is locked.')
return redirect_to named_context_url(@context, :context_context_modules_url)
end
end
end

View File

@ -1103,10 +1103,10 @@ class ConversationsController < ApplicationController
@conversations_scope.where(:conversation_id => conversations.map(&:conversation_id)).pluck(:conversation_id)
end
visible_conversation_ids.each { |c_id| result[Shard.relative_id_for(c_id, @current_user.shard, Shard.current)] = true }
if !multiple
result[conversations.first.conversation_id]
else
if multiple
result
else
result[conversations.first.conversation_id]
end
end

View File

@ -1782,14 +1782,14 @@ class CoursesController < ApplicationController
session[:accepted_enrollment_uuid] = enrollment.uuid
if params[:action] != 'show'
# Redirects back to HTTP_REFERER if it exists (so if you accept from an assignent page it will put
# you back on the same page you were looking at). Otherwise, it redirects back to the course homepage
redirect_back(fallback_location: course_url(@context.id))
else
if params[:action] == 'show'
@context_enrollment = enrollment
enrollment = nil
false
else
# Redirects back to HTTP_REFERER if it exists (so if you accept from an assignent page it will put
# you back on the same page you were looking at). Otherwise, it redirects back to the course homepage
redirect_back(fallback_location: course_url(@context.id))
end
elsif (!@current_user && enrollment.user.registered?) || !enrollment.user.email_channel
session[:return_to] = course_url(@context.id)

View File

@ -1174,7 +1174,9 @@ class DiscussionTopicsController < ApplicationController
allow_rating only_graders_can_rate sort_by_rating].freeze
def set_sections
if params[:specific_sections] != "all"
if params[:specific_sections] == "all"
@topic.is_section_specific = false
else
@topic.is_section_specific = true
section_ids = params[:specific_sections]
section_ids = section_ids.split(",") if section_ids.is_a?(String)
@ -1183,8 +1185,6 @@ class DiscussionTopicsController < ApplicationController
@topic.course_sections = CourseSection.find(new_section_ids)
@topic.sections_changed = true
end
else
@topic.is_section_specific = false
end
end
@ -1291,9 +1291,7 @@ class DiscussionTopicsController < ApplicationController
else
@topic.skip_broadcasts = true
DiscussionTopic.transaction do
if !@topic.is_section_specific
@topic.course_sections = []
else
if @topic.is_section_specific
# HACK: For some reason apply_assignment_parameters saves the submittable
# so we can't run it until everything is already good. But if the topic
# is section specific stuff isn't good until we clear out the assignment,
@ -1301,6 +1299,8 @@ class DiscussionTopicsController < ApplicationController
if params[:assignment] && !value_to_boolean(params[:assignment][:set_assignment])
@topic.assignment = nil
end
else
@topic.course_sections = []
end
@topic.update(discussion_topic_hash)
@topic.root_topic.try(:save)

View File

@ -186,15 +186,7 @@ class EportfoliosController < ApplicationController
@attachment = nil
end
if !@attachment
@attachment = @portfolio.attachments.build(:display_name => zip_filename)
@attachment.workflow_state = 'to_be_zipped'
@attachment.file_state = '0'
@attachment.user = @current_user
@attachment.save!
ContentZipper.delay(priority: Delayed::LOW_PRIORITY).process_attachment(@attachment)
render :json => @attachment
else
if @attachment
respond_to do |format|
if @attachment.zipped?
if @attachment.stored_locally?
@ -214,6 +206,14 @@ class EportfoliosController < ApplicationController
format.json { render :json => @attachment }
end
end
else
@attachment = @portfolio.attachments.build(:display_name => zip_filename)
@attachment.workflow_state = 'to_be_zipped'
@attachment.file_state = '0'
@attachment.user = @current_user
@attachment.save!
ContentZipper.delay(priority: Delayed::LOW_PRIORITY).process_attachment(@attachment)
render :json => @attachment
end
end
end

View File

@ -395,11 +395,11 @@ class GroupsController < ApplicationController
return
end
@group.request_user(@current_user)
if !@group.grants_right?(@current_user, session, :read)
render :membership_pending
else
if @group.grants_right?(@current_user, session, :read)
flash[:notice] = t('notices.welcome', "Welcome to the group %{group_name}!", :group_name => @group.name)
redirect_to named_context_url(@group.context, :context_groups_url)
else
render :membership_pending
end
return
end

View File

@ -302,9 +302,7 @@ class OutcomesApiController < ApplicationController
# @returns [OutcomeAlignment]
def outcome_alignments
if !params[:student_id]
render json: { message: "student_id is required" }, status: :bad_request
else
if params[:student_id]
course = Course.find(params[:course_id])
can_manage = course.grants_any_right?(@current_user, session, :manage_grades, :view_all_grades)
student_id = params[:student_id].to_i
@ -359,6 +357,8 @@ class OutcomesApiController < ApplicationController
alignments.concat(quiz_alignments, magic_marker_alignments)
render :json => alignments
else
render json: { message: "student_id is required" }, status: :bad_request
end
rescue ActiveRecord::RecordNotFound => e
render json: { message: e.message }, status: :not_found

View File

@ -100,9 +100,7 @@ class PseudonymsController < ApplicationController
end
@ccs = @ccs.flatten.compact.uniq.select do |cc|
if !cc.user
false
else
if cc.user
cc.pseudonym ||= cc.user.pseudonym rescue nil
cc.save if cc.changed?
found = false
@ -115,6 +113,8 @@ class PseudonymsController < ApplicationController
end
end
found
else
false
end
end
respond_to do |format|

View File

@ -99,7 +99,9 @@ class QuestionBanksController < ApplicationController
ids << key.to_i if value != '0' && key.to_i != 0
end
@questions = @bank.assessment_questions.where(:id => ids)
if params[:move] != '1'
if params[:move] == '1'
@questions.update_all(:assessment_question_bank_id => @new_bank.id)
else
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) }
@ -108,8 +110,6 @@ class QuestionBanksController < ApplicationController
"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
@questions.update_all(:assessment_question_bank_id => @new_bank.id)
end
[@bank, @new_bank].each(&:touch)

View File

@ -295,15 +295,15 @@ class RubricsApiController < ApplicationController
rubric = @context.rubric_associations.bookmarked.find_by(rubric_id: params[:id])&.rubric
return render json: { message: "Rubric not found" }, status: :not_found unless rubric.present? && !rubric.deleted?
if !@context.errors.present?
if @context.errors.present?
render json: @context.errors, status: :bad_request
else
assessments = rubric_assessments(rubric)
associations = rubric_associations(rubric)
render json: rubric_json(rubric, @current_user, session,
assessments: assessments,
associations: associations,
style: params[:style])
else
render json: @context.errors, status: :bad_request
end
end

View File

@ -472,18 +472,18 @@ class SubmissionsApiController < ApplicationController
assignments_hash = assignments.index_by(&:id)
if params[:submitted_since].present?
if !Api::ISO8601_REGEX.match?(params[:submitted_since])
return render(json: { errors: { submitted_since: t('Invalid datetime for submitted_since') } }, status: :bad_request)
else
if Api::ISO8601_REGEX.match?(params[:submitted_since])
submitted_since_date = Time.zone.parse(params[:submitted_since])
else
return render(json: { errors: { submitted_since: t('Invalid datetime for submitted_since') } }, status: :bad_request)
end
end
if params[:graded_since].present?
if !Api::ISO8601_REGEX.match?(params[:graded_since])
return render(json: { errors: { graded_since: t('Invalid datetime for graded_since') } }, status: :bad_request)
else
if Api::ISO8601_REGEX.match?(params[:graded_since])
graded_since_date = Time.zone.parse(params[:graded_since])
else
return render(json: { errors: { graded_since: t('Invalid datetime for graded_since') } }, status: :bad_request)
end
end

View File

@ -3008,14 +3008,14 @@ class UsersController < ApplicationController
@invalid_observee_code = nil
if @user.initial_enrollment_type == 'observer'
@pairing_code = find_observer_pairing_code(params[:pairing_code]&.[](:code))
if !@pairing_code.nil?
if @pairing_code.nil?
@invalid_observee_code = ObserverPairingCode.new
@invalid_observee_code.errors.add('code', 'invalid')
else
@observee = @pairing_code.user
# If the user is using a valid pairing code, we don't need recaptcha
# Just clear out any errors it may have generated
@recaptcha_errors = nil
else
@invalid_observee_code = ObserverPairingCode.new
@invalid_observee_code.errors.add('code', 'invalid')
end
end
@ -3068,10 +3068,10 @@ class UsersController < ApplicationController
# unless the user is registered/pre_registered (if the latter, he still
# needs to confirm his email and set a password, otherwise he can't get
# back in once his session expires)
if !@current_user # automagically logged in
PseudonymSession.new(@pseudonym).save unless @pseudonym.new_record?
else
if @current_user
@pseudonym.send(:skip_session_maintenance=, true)
else # automagically logged in
PseudonymSession.new(@pseudonym).save unless @pseudonym.new_record?
end
@user.save!

View File

@ -426,13 +426,13 @@ class WikiPagesApiController < ApplicationController
if authorized_action(@page, @current_user, :delete)
return render_unauthorized_action if editing_restricted?(@page)
if !@was_front_page
if @was_front_page
@page.errors.add(:front_page, t(:cannot_delete_front_page, 'The front page cannot be deleted'))
render :json => @page.errors, :status => :bad_request
else
@page.destroy
process_front_page
render :json => wiki_page_json(@page, @current_user, session)
else
@page.errors.add(:front_page, t(:cannot_delete_front_page, 'The front page cannot be deleted'))
render :json => @page.errors, :status => :bad_request
end
end
end

View File

@ -55,10 +55,10 @@ module QuizzesHelper
end
def quiz_published_state_warning(quiz = @quiz)
if !quiz.available?
unpublished_quiz_warning
else
if quiz.available?
unsaved_changes_warning
else
unpublished_quiz_warning
end
end

View File

@ -59,11 +59,11 @@ class RequestThrottle
up_front_cost = bucket.get_up_front_cost_for_path(path)
pre_judged = (approved?(request) || blocked?(request))
cost = bucket.reserve_capacity(up_front_cost, request_prejudged: pre_judged) do
status, headers, response = if !allowed?(request, bucket)
status, headers, response = if allowed?(request, bucket)
@app.call(env)
else
throttled = true
rate_limit_exceeded
else
@app.call(env)
end
ending_cpu = Process.times

View File

@ -615,14 +615,14 @@ class Account < ActiveRecord::Base
def equella_settings
endpoint = settings[:equella_endpoint] || equella_endpoint
if !endpoint.blank?
if endpoint.blank?
nil
else
OpenObject.new({
:endpoint => endpoint,
:default_action => settings[:equella_action] || 'selectOrAdd',
:teaser => settings[:equella_teaser]
})
else
nil
end
end
@ -1709,10 +1709,10 @@ class Account < ActiveRecord::Base
end
def self_enrollment_allowed?(course)
if !settings[:self_enrollment].blank?
!!(settings[:self_enrollment] == 'any' || (!course.sis_source_id && settings[:self_enrollment] == 'manually_created'))
else
if settings[:self_enrollment].blank?
!!(parent_account && parent_account.self_enrollment_allowed?(course))
else
!!(settings[:self_enrollment] == 'any' || (!course.sis_source_id && settings[:self_enrollment] == 'manually_created'))
end
end

View File

@ -274,7 +274,9 @@ class AssessmentQuestion < ActiveRecord::Base
assessment_questions.map do |aq|
aq.force_version_number(current_versions[aq.id] || 0)
qq = existing_quiz_questions[aq.id].try(:first)
if !qq
if qq
qq.update_assessment_question!(aq, quiz_group_id, duplicate_index)
else
begin
Quizzes::QuizQuestion.transaction(requires_new: true) do
qq = aq.create_quiz_question(quiz_id, quiz_group_id, duplicate_index)
@ -285,8 +287,6 @@ class AssessmentQuestion < ActiveRecord::Base
duplicate_index: duplicate_index).take!
qq.update_assessment_question!(aq, quiz_group_id, duplicate_index)
end
else
qq.update_assessment_question!(aq, quiz_group_id, duplicate_index)
end
qq
end

View File

@ -713,28 +713,7 @@ class AssetUserAccessLog
agg_sql = pulsar_ripcord_aggregation_query(partition_model, log_id_bookmark, batch_upper_boundary, root_account_max_ids_map, ts.wday)
end
log_segment_aggregation = partition_model.connection.execute(agg_sql)
if !log_segment_aggregation.to_a.empty?
# we found records in this segment, we need to both
# compute the new iterator position (it's just the max
# of all ids because we constrained the aggregation to a range of ids,
# taking the full set of logs in that range)
update_query = compaction_sql(log_segment_aggregation)
new_iterator_pos = log_segment_aggregation.map { |r| r["max_id"] }.max
GuardRail.activate(:primary) do
partition_model.transaction do
log_message("batch updating (sometimes these queries don't get logged)...")
partition_model.connection.execute(update_query)
log_message("...batch update complete")
# Here we want to write the iteration state into the database
# so that we don't double count rows later. The next time the job
# runs it can pick up at this point and only count rows that haven't yet been counted.
compaction_state[:max_log_ids][ts.wday] = new_iterator_pos
update_metadatum(compaction_state)
end
end
log_id_bookmark = new_iterator_pos
sleep(intra_batch_pause) if intra_batch_pause > 0.0
else
if log_segment_aggregation.to_a.empty?
# no records found in this range, we must be paging through an open segment.
# If we actually have a jump in sequences, there will
# be more records greater than the batch, so we will choose
@ -760,6 +739,27 @@ class AssetUserAccessLog
update_metadatum(compaction_state)
end
log_id_bookmark = new_bookmark_id
else
# we found records in this segment, we need to both
# compute the new iterator position (it's just the max
# of all ids because we constrained the aggregation to a range of ids,
# taking the full set of logs in that range)
update_query = compaction_sql(log_segment_aggregation)
new_iterator_pos = log_segment_aggregation.map { |r| r["max_id"] }.max
GuardRail.activate(:primary) do
partition_model.transaction do
log_message("batch updating (sometimes these queries don't get logged)...")
partition_model.connection.execute(update_query)
log_message("...batch update complete")
# Here we want to write the iteration state into the database
# so that we don't double count rows later. The next time the job
# runs it can pick up at this point and only count rows that haven't yet been counted.
compaction_state[:max_log_ids][ts.wday] = new_iterator_pos
update_metadatum(compaction_state)
end
end
log_id_bookmark = new_iterator_pos
sleep(intra_batch_pause) if intra_batch_pause > 0.0
end
batch_timestamp = Time.now.utc
if (batch_timestamp - compaction_start) > (max_compaction_time * 60)

View File

@ -2101,7 +2101,11 @@ class Assignment < ActiveRecord::Base
submissions = []
students.each do |student|
submission = submissions_hash[student.id]
if !submission
if submission
submission.assignment = self
submission.user = student
yield submission if block_given?
else
begin
transaction(requires_new: true) do
submission = self.submissions.build(user: student)
@ -2117,10 +2121,6 @@ class Assignment < ActiveRecord::Base
submission.user = student
yield submission if block_given?
end
else
submission.assignment = self
submission.user = student
yield submission if block_given?
end
submissions << submission
end

View File

@ -726,10 +726,10 @@ class CalendarEvent < ActiveRecord::Base
# there is always at least one element in current_apts
current_appts = user_events.select { |appointment| @event.id == appointment[:parent_id] }
if current_appts.any?
if !event.description.nil?
event.description.concat("\n\n" + current_appts[0][:course_name] + "\n\n")
else
if event.description.nil?
event.description = current_appts[0][:course_name] + "\n\n"
else
event.description.concat("\n\n" + current_appts[0][:course_name] + "\n\n")
end
event.description.concat("Participants: ")

View File

@ -34,11 +34,11 @@ class Collaborator < ActiveRecord::Base
p.to {
users = group_id.nil? ? [user] : group.users - [user]
if context.is_a?(Course)
if !context.workflow_state.in?(['available', 'completed'])
users = [] # do not send notifications to any users if the course is unpublished
else
if context.workflow_state.in?(['available', 'completed'])
enrolled_user_ids = context.enrollments.active_by_date.where(:user_id => users).pluck(:user_id).to_set
users = users.select { |u| enrolled_user_ids.include?(u.id) }
else
users = [] # do not send notifications to any users if the course is unpublished
end
end
if collaboration.collaboration_type == 'google_docs'

View File

@ -519,12 +519,12 @@ class Conversation < ActiveRecord::Base
message = opts.delete(:text).to_s.strip
participant = conversation_participants.where(user_id: user).first
user = nil unless user && participant
if !user
raise IncomingMail::Errors::InvalidParticipant
else
if user
participant.update_attribute(:workflow_state, 'read') if participant.workflow_state == 'unread'
message = truncate_message(message)
add_message(user, message, opts)
else
raise IncomingMail::Errors::InvalidParticipant
end
end

View File

@ -162,10 +162,10 @@ module Csp::AccountHelper
config = Canvas::DynamicSettings.find(tree: :private, cluster: root_account.shard.database_server.id)
if config['attachment_specific_file_domain'] == 'true'
separator = config['attachment_specific_file_domain_separator'] || '.'
files_host = if separator != '.'
"*.#{files_host[files_host.index('.') + 1..]}"
else
files_host = if separator == '.'
"*.#{files_host}"
else
"*.#{files_host[files_host.index('.') + 1..]}"
end
end
canvadocs_host = Canvadocs.enabled?.presence && URI.parse(Canvadocs.config['base_url']).host

View File

@ -175,9 +175,7 @@ class DiscussionEntry < ActiveRecord::Base
message = format_message(message).first
end
user = nil unless user && context.users.include?(user)
if !user
raise IncomingMail::Errors::InvalidParticipant
else
if user
shard.activate do
entry = discussion_topic.discussion_entries.new(message: message,
user: user,
@ -189,6 +187,8 @@ class DiscussionEntry < ActiveRecord::Base
raise IncomingMail::Errors::ReplyToLockedTopic
end
end
else
raise IncomingMail::Errors::InvalidParticipant
end
end
@ -501,7 +501,9 @@ class DiscussionEntry < ActiveRecord::Base
current_user ||= self.current_user
return nil unless current_user
if new_state != read_state(current_user)
if new_state == read_state(current_user)
true
else
entry_participant = update_or_create_participant(
opts.merge(current_user: current_user, new_state: new_state)
)
@ -512,8 +514,6 @@ class DiscussionEntry < ActiveRecord::Base
)
end
entry_participant
else
true
end
end

View File

@ -954,7 +954,7 @@ class DiscussionTopic < ActiveRecord::Base
end
on_update_send_to_streams do
check_state = !is_announcement ? 'unpublished' : 'post_delayed'
check_state = is_announcement ? 'post_delayed' : 'unpublished'
became_active = workflow_state_before_last_save == check_state && workflow_state == 'active'
if should_send_to_stream && (@content_changed || became_active)
active_participants_with_visibility
@ -1061,11 +1061,11 @@ class DiscussionTopic < ActiveRecord::Base
else
shard.activate do
entry = discussion_entries.new(message: message, user: user)
if !entry.grants_right?(user, :create)
raise IncomingMail::Errors::ReplyToLockedTopic
else
if entry.grants_right?(user, :create)
entry.save!
entry
else
raise IncomingMail::Errors::ReplyToLockedTopic
end
end
end
@ -1292,7 +1292,7 @@ class DiscussionTopic < ActiveRecord::Base
p.to { users_with_permissions(active_participants_with_visibility) }
p.whenever { |record|
record.send_notification_for_context? and
((record.just_created && record.active?) || record.changed_state(:active, !record.is_announcement ? :unpublished : :post_delayed))
((record.just_created && record.active?) || record.changed_state(:active, record.is_announcement ? :post_delayed : :unpublished))
}
p.data { course_broadcast_data }
end

View File

@ -125,7 +125,7 @@ class DiscussionTopic::MaterializedView < ActiveRecord::Base
if opts[:include_new_entries]
@for_mobile = true if opts[:include_mobile_overrides]
new_entries = all_entries.count != entry_ids.count ? all_entries.where.not(:id => entry_ids).to_a : []
new_entries = all_entries.count == entry_ids.count ? [] : all_entries.where.not(:id => entry_ids).to_a
participant_ids = (Set.new(participant_ids) + new_entries.filter_map(&:user_id) + new_entries.filter_map(&:editor_id)).to_a
entry_ids = (Set.new(entry_ids) + new_entries.map(&:id)).to_a
new_entries_json_structure = discussion_entry_api_json(new_entries, discussion_topic.context, nil, nil, [])

View File

@ -81,7 +81,12 @@ module Importers
end
end
if !outcome
if outcome
item = outcome
if context.respond_to?(:root_account) && context.root_account.feature_enabled?(:outcome_alignments_course_migration)
migration.add_imported_item(item, key: CC::CCHelper.create_key(item, global: true))
end
else
if hash[:is_global_standard]
if Account.site_admin.grants_right?(migration.user, :manage_global_outcomes)
# import from vendor with global outcomes
@ -127,11 +132,6 @@ module Importers
item.save!
migration.add_imported_item(item)
else
item = outcome
if context.respond_to?(:root_account) && context.root_account.feature_enabled?(:outcome_alignments_course_migration)
migration.add_imported_item(item, key: CC::CCHelper.create_key(item, global: true))
end
end
# don't add a deleted outcome to an outcome group, or align it with an assignment

View File

@ -93,7 +93,9 @@ class LearningOutcomeResult < ActiveRecord::Base
current_version = versions.current.try(:model)
if current_version.try(:attempt) && attempt < current_version.attempt
versions = self.versions.sort_by(&:created_at).reverse.select { |v| v.model.attempt == attempt }
if !versions.empty?
if versions.empty?
save
else
versions.each do |version|
version_data = YAML.load(version.yaml)
version_data["score"] = score
@ -104,8 +106,6 @@ class LearningOutcomeResult < ActiveRecord::Base
version.yaml = version_data.to_yaml
version.save
end
else
save
end
else
save

View File

@ -72,11 +72,11 @@ class MediaObject < ActiveRecord::Base
client = CanvasKaltura::ClientV3.new
client.startSession(CanvasKaltura::SessionType::ADMIN)
res = client.bulkUploadCsv(csv)
if !res[:ready]
if res[:ready]
build_media_objects(res, root_account_id)
else
MediaObject.delay(run_at: 1.minute.from_now, priority: Delayed::LOW_PRIORITY)
.refresh_media_files(res[:id], [], root_account_id)
else
build_media_objects(res, root_account_id)
end
res
end
@ -132,7 +132,9 @@ class MediaObject < ActiveRecord::Base
client = CanvasKaltura::ClientV3.new
client.startSession(CanvasKaltura::SessionType::ADMIN)
res = client.bulkUploadGet(bulk_upload_id)
if !res[:ready]
if res[:ready]
build_media_objects(res, root_account_id)
else
if attempt < Setting.get('media_object_bulk_refresh_max_attempts', '5').to_i
wait_period = Setting.get('media_object_bulk_refresh_wait_period', '30').to_i
MediaObject.delay(run_at: wait_period.minutes.from_now, priority: Delayed::LOW_PRIORITY)
@ -142,8 +144,6 @@ class MediaObject < ActiveRecord::Base
Attachment.where("id IN (?) OR root_attachment_id IN (?)", attachment_ids, attachment_ids).update_all(:media_entry_id => nil) unless attachment_ids.empty?
end
res
else
build_media_objects(res, root_account_id)
end
end

View File

@ -66,13 +66,13 @@ module Messages::SubmissionCommentForTeacher
end
def anonymous_author_id
if submission_comment.author != submission.user
if submission_comment.author == submission.user
submission.anonymous_id
else
return @author_submission&.anonymous_id if defined?(@author_submission)
@author_submission = Submission.find_by(assignment: assignment, user: submission_comment.author)
@author_submission&.anonymous_id
else
submission.anonymous_id
end
end
end

View File

@ -116,14 +116,14 @@ class Quizzes::QuizStatistics::StudentAnalysis < Quizzes::QuizStatistics::Report
stats[:submission_score_high] = score_counter.max
stats[:submission_score_low] = score_counter.min
stats[:submission_score_stdev] = score_counter.standard_deviation
if !submissions.empty?
stats[:submission_correct_count_average] = correct_cnt.to_f / submissions.size
stats[:submission_incorrect_count_average] = incorrect_cnt.to_f / submissions.size
stats[:submission_duration_average] = total_duration.to_f / submissions.size
else
if submissions.empty?
stats[:submission_correct_count_average] =
stats[:submission_incorrect_count_average] =
stats[:submission_duration_average] = 0
else
stats[:submission_correct_count_average] = correct_cnt.to_f / submissions.size
stats[:submission_incorrect_count_average] = incorrect_cnt.to_f / submissions.size
stats[:submission_duration_average] = total_duration.to_f / submissions.size
end
assessment_questions = if questions_hash.any? { |_, q| q[:assessment_question_id] }

View File

@ -296,9 +296,7 @@ class SubmissionComment < ActiveRecord::Base
user = opts[:user]
message = opts[:text].strip
user = nil unless user && submission.grants_right?(user, :comment)
if !user
raise IncomingMail::Errors::InvalidParticipant
else
if user
shard.activate do
submission.add_comment(
author: user,
@ -306,6 +304,8 @@ class SubmissionComment < ActiveRecord::Base
provisional: provisional_grade_id.present?
)
end
else
raise IncomingMail::Errors::InvalidParticipant
end
end

View File

@ -601,10 +601,10 @@ class User < ActiveRecord::Base
user_ids = user_ids.map(&:id) if user_ids.first.is_a?(User)
shards = [Shard.current]
unless precalculated_associations
users = if !users_or_user_ids.first.is_a?(User)
users_or_user_ids = User.select([:id, :preferences, :workflow_state, :updated_at]).where(id: user_ids).to_a
else
users = if users_or_user_ids.first.is_a?(User)
users_or_user_ids
else
users_or_user_ids = User.select([:id, :preferences, :workflow_state, :updated_at]).where(id: user_ids).to_a
end
if opts[:all_shards]
@ -2695,10 +2695,10 @@ class User < ActiveRecord::Base
favorites = courses_with_primary_enrollment(:favorite_courses, enrollment_uuid, opts)
.select { |c| can_favorite.call(c) }
# if favoritable courses (classic courses or k5 courses with admin enrollment) exist, show those and all non-favoritable courses
@menu_courses = if !favorites.empty?
favorites + courses.reject { |c| can_favorite.call(c) }
else
@menu_courses = if favorites.empty?
courses
else
favorites + courses.reject { |c| can_favorite.call(c) }
end
ActiveRecord::Associations::Preloader.new.preload(@menu_courses, :enrollment_term)
@menu_courses

View File

@ -478,10 +478,10 @@ class WebConference < ActiveRecord::Base
end
def valid_config?
if !config
false
else
if config
config[:class_name] == self.class.to_s
else
false
end
end

View File

@ -377,10 +377,10 @@ class WikiPage < ActiveRecord::Base
def participants
res = []
if context&.available?
res += if !active?
context.participating_admins
else
res += if active?
context.participants(by_date: true)
else
context.participating_admins
end
end
res.flatten.uniq

View File

@ -1308,10 +1308,10 @@ module UpdateAndDeleteWithJoins
def update_all(updates, *args)
db = Shard.current(klass.shard_category).database_server
if joins_values.empty?
if ::GuardRail.environment != db.guard_rail_environment
Shard.current.database_server.unguard { return super }
else
if ::GuardRail.environment == db.guard_rail_environment
return super
else
Shard.current.database_server.unguard { return super }
end
end
@ -1348,10 +1348,10 @@ module UpdateAndDeleteWithJoins
end
where_sql = collector.value
sql.concat('WHERE ' + where_sql)
if ::GuardRail.environment != db.guard_rail_environment
Shard.current.database_server.unguard { connection.update(sql, "#{name} Update") }
else
if ::GuardRail.environment == db.guard_rail_environment
connection.update(sql, "#{name} Update")
else
Shard.current.database_server.unguard { connection.update(sql, "#{name} Update") }
end
end

View File

@ -45,10 +45,10 @@ load_cache_config = -> do
last_cluster_cache_config = last_cache_config[cluster]
last_cache_config[cluster] = config
cache_map[cluster] = if last_cluster_cache_config != config
Canvas.lookup_cache_store(config, cluster)
else
cache_map[cluster] = if last_cluster_cache_config == config
Switchman.config[:cache_map][cluster]
else
Canvas.lookup_cache_store(config, cluster)
end
end

View File

@ -127,10 +127,10 @@ class MethodView < HashView
''
else
@nickname_suffix ||= create_nickname_suffix
if !@nickname_suffix[route.swagger_path].empty?
"_#{@nickname_suffix[route.swagger_path]}"
else
if @nickname_suffix[route.swagger_path].empty?
''
else
"_#{@nickname_suffix[route.swagger_path]}"
end
end
end

View File

@ -63,11 +63,11 @@ module BroadcastPolicy
other_attributes.instance_variable_get(:@attributes).delete(key)
next
end
if value.value != other_attributes[key].value
if value.value == other_attributes[key].value
other_attributes.write_from_database(key, value.value)
else
other_attributes[key].instance_variable_set(:@original_attribute, nil)
other_attributes.write_from_user(key, value.value)
else
other_attributes.write_from_database(key, value.value)
end
end
@mutations_before_last_save = ActiveModel::AttributeMutationTracker.new(other_attributes)

View File

@ -102,14 +102,14 @@ module LuckySneaks
conditions << send(self.class.scope_for_url)
end
url_owners = self.class.where(conditions).to_a
if !url_owners.empty?
if url_owners.empty?
write_attribute url_attribute, base_url
else
n = 1
while url_owners.detect { |u| u.send(url_attribute) == "#{base_url}-#{n}" }
n = n.succ
end
write_attribute url_attribute, "#{base_url}-#{n}"
else
write_attribute url_attribute, base_url
end
end
end

View File

@ -25,7 +25,7 @@ module GoogleDrive
@entry = google_drive_entry
@document_id = @entry['id']
@preferred_extensions = preferred_extensions
parent = !@entry['parents'].empty? ? @entry['parents'][0] : nil
parent = @entry['parents'].empty? ? nil : @entry['parents'][0]
@folder = (parent.nil? || parent['isRoot'] ? nil : parent['id'])
end

View File

@ -282,15 +282,15 @@ module AccountReports
end
def join_course_sub_account_scope(account, scope, table = 'courses')
if account != account.root_account
if account == account.root_account
scope
else
scope.joins(<<~SQL.squish)
join #{CourseAccountAssociation.quoted_table_name} caa
ON caa.account_id = #{account.id}
AND caa.course_id = #{table}.id
AND caa.course_section_id IS NULL
SQL
else
scope
end
end

View File

@ -134,7 +134,9 @@ module AccountReports::ReportHelper
end
def add_course_sub_account_scope(scope, table = 'courses')
if account != root_account
if account == root_account
scope
else
scope.where(<<~SQL.squish, account)
EXISTS (SELECT course_id
FROM #{CourseAccountAssociation.quoted_table_name} caa
@ -142,8 +144,6 @@ module AccountReports::ReportHelper
AND caa.course_id=#{table}.id
AND caa.course_section_id IS NULL)
SQL
else
scope
end
end
@ -156,13 +156,13 @@ module AccountReports::ReportHelper
end
def add_user_sub_account_scope(scope, table = 'users')
if account != root_account
if account == root_account
scope
else
scope.where("EXISTS (SELECT user_id
FROM #{UserAccountAssociation.quoted_table_name} uaa
WHERE uaa.account_id = ?
AND uaa.user_id=#{table}.id)", account)
else
scope
end
end

View File

@ -704,7 +704,13 @@ module AccountReports
end
root_account.shard.activate do
group_categories = if account != root_account
group_categories = if account == root_account
root_account.all_group_categories
.joins("LEFT JOIN #{Account.quoted_table_name} a ON a.id = group_categories.context_id
AND group_categories.context_type = 'Account'
LEFT JOIN #{Course.quoted_table_name} c ON c.id = group_categories.context_id
AND group_categories.context_type = 'Course'")
else
GroupCategory
.joins("LEFT JOIN #{Course.quoted_table_name} c ON c.id = group_categories.context_id
AND group_categories.context_type = 'Course'")
@ -713,12 +719,6 @@ module AccountReports
.where("a.id IN (#{Account.sub_account_ids_recursive_sql(account.id)}) OR a.id=? OR EXISTS (?)",
account,
CourseAccountAssociation.where("course_id=c.id").where(account_id: account))
else
root_account.all_group_categories
.joins("LEFT JOIN #{Account.quoted_table_name} a ON a.id = group_categories.context_id
AND group_categories.context_type = 'Account'
LEFT JOIN #{Course.quoted_table_name} c ON c.id = group_categories.context_id
AND group_categories.context_type = 'Course'")
end
group_categories = group_category_query_options(group_categories)

View File

@ -233,7 +233,7 @@ module Qti
else
response_identifier.to_s.sub(/response_/i, "").to_i
end
id != 0 ? id : unique_local_id
id == 0 ? unique_local_id : id
else
unique_local_id
end

View File

@ -594,9 +594,7 @@ Implemented for: Canvas LMS)]
session['pending_migration_id'] = migration.id
session['pending_migration_itemType'] = itemType
if Setting.get('respondus_endpoint.polling_api', 'true') != 'false'
poll_for_completion
else
if Setting.get('respondus_endpoint.polling_api', 'true') == 'false'
# Deprecated in-line waiting for the migration. We've worked with Respondus
# to implement an asynchronous, polling solution now.
timeout(5.minutes.to_i) do
@ -609,6 +607,8 @@ Implemented for: Canvas LMS)]
end
end
end
else
poll_for_completion
end
end

View File

@ -158,10 +158,7 @@ module Api::V1::AssignmentOverride
if !set_type && data.key?(:group_id)
group_category_id = assignment.group_category_id || assignment.discussion_topic.try(:group_category_id)
if !group_category_id
# don't recognize group_id for non-group assignments
errors << "group_id is not valid for non-group assignments"
else
if group_category_id
set_type = 'Group'
# look up the group
begin
@ -170,6 +167,9 @@ module Api::V1::AssignmentOverride
errors << "unknown group id #{data[:group_id].inspect}"
end
override_data[:group] = group
else
# don't recognize group_id for non-group assignments
errors << "group_id is not valid for non-group assignments"
end
end

View File

@ -249,9 +249,7 @@ module AssignmentOverrideApplicator
def self.current_override_version(assignment_or_quiz, all_overrides)
all_overrides.map do |override|
if !override.versions.exists?
override
else
if override.versions.exists?
override_version = override.versions.detect do |version|
model_version = assignment_or_quiz.is_a?(Quizzes::Quiz) ? version.model.quiz_version : version.model.assignment_version
next if model_version.nil?
@ -259,6 +257,8 @@ module AssignmentOverrideApplicator
model_version <= assignment_or_quiz.version_number
end
override_version ? override_version.model : nil
else
override
end
end
end

View File

@ -28,11 +28,11 @@ module Canvas::Plugins::Validators::AppCenterValidator
false
else
uri = URI.parse(settings[:base_url].strip) rescue nil
if !uri
if uri
settings.slice(:base_url, :token, :apps_index_endpoint, :app_reviews_endpoint).to_h.with_indifferent_access
else
plugin_setting.errors.add(:base, I18n.t('canvas.plugins.errors.invalid_url', 'Invalid URL'))
false
else
settings.slice(:base_url, :token, :apps_index_endpoint, :app_reviews_endpoint).to_h.with_indifferent_access
end
end
end

View File

@ -28,11 +28,11 @@ module Canvas::Plugins::Validators::PandaPubValidator
false
else
uri = URI.parse(settings[:base_url].strip) rescue nil
if !uri
if uri
settings.slice(:base_url, :application_id, :key_id, :key_secret).to_h.with_indifferent_access
else
plugin_setting.errors.add(:base, I18n.t('canvas.plugins.errors.invalid_url', 'Invalid URL'))
false
else
settings.slice(:base_url, :application_id, :key_id, :key_secret).to_h.with_indifferent_access
end
end
end

View File

@ -39,10 +39,10 @@ module CC::Exporter::Epub::Converters
next unless include_item?(meta_node, "active")
if get_node_val(meta_node, 'type') != "announcement"
topics << convert_topic(cc_doc, meta_node)
else
if get_node_val(meta_node, 'type') == "announcement"
announcements << convert_announcement(cc_doc, meta_node)
else
topics << convert_topic(cc_doc, meta_node)
end
end

View File

@ -442,7 +442,7 @@ module CC::Exporter::WebZip
def file_path(item_content)
folder = item_content&.folder&.full_name || ''
local_folder = folder.sub(%r{/?course files/?}, '')
!local_folder.empty? ? "/#{local_folder}/" : '/'
local_folder.empty? ? '/' : "/#{local_folder}/"
end
def dist_package_path

View File

@ -161,11 +161,11 @@ class CutyCapt
end
end
if !success
if success
logger.info("Capture took #{Time.now.to_i - start.to_i} seconds")
else
File.unlink(img_file) if File.exist?(img_file)
return nil
else
logger.info("Capture took #{Time.now.to_i - start.to_i} seconds")
end
if block_given?

View File

@ -125,12 +125,12 @@ module DataFixup::RebuildQuizSubmissionsFromQuizSubmissionVersions
end
if submission.reload.workflow_state == "pending_review"
if old_submission_grading_data.first != submission.score
if old_submission_grading_data.first == submission.score
Rails.logger.warn LOG_PREFIX + "GRADING REPORT - " + "Grading required for quiz_submission: #{persisted_qs.id}"
else
Rails.logger.warn LOG_PREFIX + "GRADING REPORT - " +
"score-- #{old_submission_grading_data.first}:#{submission.score} " +
"grader_id-- #{old_submission_grading_data[1]}:#{submission.grader_id} "
else
Rails.logger.warn LOG_PREFIX + "GRADING REPORT - " + "Grading required for quiz_submission: #{persisted_qs.id}"
end
end
persisted_qs

View File

@ -81,12 +81,12 @@ module DifferentiableAssignment
RequestCache.cache('teacher_or_public_user', user, context) do
Rails.cache.fetch([context, user, 'teacher_or_public_user'].cache_key) do
if !context.includes_user?(user)
true
else
if context.includes_user?(user)
permissions_implying_visibility = [:read_as_admin, :manage_grades, *RoleOverride::GRANULAR_MANAGE_ASSIGNMENT_PERMISSIONS]
permissions_implying_visibility << :manage_content if context.is_a?(Course)
context.grants_any_right?(user, *permissions_implying_visibility)
else
true
end
end
end

View File

@ -50,7 +50,7 @@ module DuplicatingObjects
potential_title = "#{entity_title} #{copy_suffix}"
num_to_try = 2
end
title_base = !is_multiple_copy ? potential_title + " " : potential_title.gsub(/\d+$/, '')
title_base = is_multiple_copy ? potential_title.gsub(/\d+$/, '') : potential_title + " "
title_search_term = title_base[0...-1]
conflicting_titles = entity.get_potentially_conflicting_titles(title_search_term).map { |x|
normalize_title(x)

View File

@ -465,13 +465,13 @@ module InstFS
query = (uri.query_values || {}).with_indifferent_access
# We only want to redirect once, if the redirect param is present then we already redirected.
# In which case we don't send the original_url param again
if !Canvas::Plugin.value_to_boolean(query[:redirect])
if Canvas::Plugin.value_to_boolean(query[:redirect])
nil
else
query[:redirect] = true
query[:no_cache] = true
uri.query_values = query
uri.to_s
else
nil
end
end
end

View File

@ -188,7 +188,7 @@ module Lti
end
def concluded_lis_roles
!concluded_course_enrollments.empty? ? enrollments_to_lis_roles(concluded_course_enrollments).join(',') : LtiOutbound::LTIRoles::System::NONE
concluded_course_enrollments.empty? ? LtiOutbound::LTIRoles::System::NONE : enrollments_to_lis_roles(concluded_course_enrollments).join(',')
end
def granted_permissions(permissions_to_check)

View File

@ -366,13 +366,13 @@ module SIS
SisBatch.transaction do
@batch.reload(:lock => true)
if !@batch.data[:completed_importers].include?(importer_type) # check for race condition
if @batch.data[:completed_importers].include?(importer_type)
false
else # check for race condition
@batch.data[:completed_importers] << importer_type
@batch.data[:counts][importer_type.to_s.pluralize.to_sym] = @batch.parallel_importers.where(:importer_type => importer_type).sum(:rows_processed).to_i
@batch.save
true
else
false
end
end
end

View File

@ -151,10 +151,10 @@ module SIS
root_account = @root_account
end
pseudo = if !enrollment_info.user_integration_id.blank?
root_account.pseudonyms.where(integration_id: enrollment_info.user_integration_id).take
else
pseudo = if enrollment_info.user_integration_id.blank?
root_account.pseudonyms.where(sis_user_id: enrollment_info.user_id).take
else
root_account.pseudonyms.where(integration_id: enrollment_info.user_integration_id).take
end
unless pseudo
@ -411,11 +411,11 @@ module SIS
# this will allow the enrollment to continue to be created
false
else
if enrollment.workflow_state != 'deleted'
@enrollments_to_delete << enrollment
else
if enrollment.workflow_state == 'deleted'
@enrollments_to_update_sis_batch_ids << enrollment.id
@success_count += 1
else
@enrollments_to_delete << enrollment
end
# we are done and we con go to the next enrollment
true

View File

@ -132,10 +132,10 @@ unless $canvas_tasks_loaded
output = `script/render_json_lint`
exit_status = $?.exitstatus
puts output
if exit_status != 0
raise "lint:render_json test failed"
else
if exit_status == 0
puts "lint:render_json test succeeded"
else
raise "lint:render_json test failed"
end
end
end

View File

@ -149,7 +149,9 @@ class UserList
user_start = 0
in_quotes = false
chars.each_with_index do |char, i|
if !in_quotes
if in_quotes
in_quotes = false if char == '"'
else
case char
when ','
user_line = str[user_start, i - user_start].strip
@ -158,8 +160,6 @@ class UserList
when '"'
in_quotes = true if quote_ends(chars, i)
end
else
in_quotes = false if char == '"'
end
end
end
@ -267,9 +267,9 @@ class UserList
number = sms[:address].gsub(/[^\d\w]/, '')
sms[:address] = "(#{number[0, 3]}) #{number[3, 3]}-#{number[6, 4]}"
end
sms_account_ids = @search_method != :closed ? [@root_account] : all_account_ids
sms_account_ids = @search_method == :closed ? all_account_ids : [@root_account]
Shard.partition_by_shard(sms_account_ids) do |account_ids|
sms_scope = @search_method != :closed ? Pseudonym : Pseudonym.where(:account_id => account_ids)
sms_scope = @search_method == :closed ? Pseudonym.where(:account_id => account_ids) : Pseudonym
sms_scope.active
.select('path AS address, users.name AS name, communication_channels.user_id AS user_id')
.joins(:user => :communication_channels)

View File

@ -323,9 +323,7 @@ class UserMerge
end
def finish_ccs(max_position, to_retire_ids)
if from_user.shard != target_user.shard
handle_cross_shard_cc
else
if from_user.shard == target_user.shard
from_user.shard.activate do
ccs = CommunicationChannel.where(id: to_retire_ids).where.not(workflow_state: 'retired')
merge_data.build_more_data(ccs, data: data) unless to_retire_ids.empty?
@ -338,6 +336,8 @@ class UserMerge
scope.touch_all
scope.update_all(["user_id=?, position=position+?, root_account_ids='{?}'", target_user, max_position, target_user.root_account_ids])
end
else
handle_cross_shard_cc
end
merge_data.bulk_insert_merge_data(data) unless data.empty?
@data = []

View File

@ -182,10 +182,10 @@ module VeriCite
course = assignment.context
object_id = submission.vericite_data_hash[asset_string][:object_id] rescue nil
response = sendRequest(:generate_report, :oid => object_id, :utp => '2', :current_user => current_user, :user => user, :course => course, :assignment => assignment)
if !response.nil?
response[:report_url]
else
if response.nil?
nil
else
response[:report_url]
end
end
@ -195,10 +195,10 @@ module VeriCite
course = assignment.context
object_id = submission.vericite_data_hash[asset_string][:object_id] rescue nil
response = sendRequest(:generate_report, :oid => object_id, :utp => '1', :current_user => current_user, :user => user, :course => course, :assignment => assignment, :tem => email(course))
if !response.nil?
response[:report_url]
else
if response.nil?
nil
else
response[:report_url]
end
end

View File

@ -682,7 +682,7 @@ describe OAuth2ProviderController do
it "returns 302 when #{assertion} missing" do
jwt.delete assertion.to_sym
expected = assertion != 'sub' ? request_url + assertion : client_url
expected = assertion == 'sub' ? client_url : request_url + assertion
expect(subject).to redirect_to(expected)
end
end

View File

@ -23,10 +23,10 @@ module Factories
@conversation = (options.delete(:sender) || @me || users.shift).initiate_conversation(users, options.delete(:private), options)
# if the "body" hash is passed in, use that for the message body
@message = if !options[:body].nil?
@conversation.add_message(options[:body].to_s)
else
@message = if options[:body].nil?
@conversation.add_message('test')
else
@conversation.add_message(options[:body].to_s)
end
@conversation.update(options.slice(:subscribed, :starred, :workflow_state, :user))

View File

@ -84,12 +84,12 @@ describe "instfs file uploads" do
def compare_md5s(image_element_src, original_file_path)
downloaded_data = download_file(image_element_src)
if downloaded_data != false
if downloaded_data == false
false
else
temp_md5 = Digest::MD5.hexdigest(downloaded_data)
original_md5 = Digest::MD5.hexdigest File.read(original_file_path)
temp_md5 == original_md5
else
false
end
end

View File

@ -66,11 +66,11 @@ class AnnouncementNewEdit
def select_a_section(section_name)
fj(section_autocomplete_css).click
if !section_name.empty?
if section_name.empty?
driver.action.send_keys(:backspace).perform
else
set_value(fj(section_autocomplete_css), section_name)
driver.action.send_keys(:enter).perform
else
driver.action.send_keys(:backspace).perform
end
wait_for_ajax_requests
end

View File

@ -67,11 +67,11 @@ class DiscussionNewEdit
def select_a_section(section_name)
fj(section_autocomplete_css).click
if !section_name.empty?
if section_name.empty?
driver.action.send_keys(:backspace).perform
else
set_value(fj(section_autocomplete_css), section_name)
driver.action.send_keys(:enter).perform
else
driver.action.send_keys(:backspace).perform
end
wait_for_ajax_requests
end

View File

@ -61,10 +61,10 @@ module ManageGroupsCommon
count = i + 1
student = user_model :name => "student #{count}"
students.push student
if !opts[count.to_s].nil?
@course.enroll_student(student, opts[count.to_s])
else
if opts[count.to_s].nil?
@course.enroll_student(student)
else
@course.enroll_student(student, opts[count.to_s])
end
end
students