Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 0 additions & 84 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,6 @@ Lint/RedundantCopDisableDirective:
- 'spec/support/reference_timelines_helper.rb'
- 'spec/support/stubs/ssid/api_stubs.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Lint/RedundantRequireStatement:
Exclude:
- 'app/services/concerns/course/user_invitation_service/parse_invitation_concern.rb'

# Offense count: 2
Lint/ReturnInVoidContext:
Exclude:
Expand All @@ -111,12 +105,6 @@ Lint/SafeNavigationConsistency:
Exclude:
- 'app/views/course/assessment/answer/programming/_programming.json.jbuilder'

# Offense count: 1
# Configuration parameters: AllowRBSInlineAnnotation.
Lint/SelfAssignment:
Exclude:
- 'spec/libraries/has_one_many_attachments_spec.rb'

# Offense count: 1
Lint/StructNewOverride:
Exclude:
Expand All @@ -130,11 +118,6 @@ Lint/SymbolConversion:
Exclude:
- 'app/controllers/concerns/signals/emission_concern.rb'

# Offense count: 1
Lint/UnmodifiedReduceAccumulator:
Exclude:
- 'app/models/concerns/course/assessment/questions_concern.rb'

# Offense count: 7
# This cop supports safe autocorrection (--autocorrect).
Lint/UselessAssignment:
Expand All @@ -160,25 +143,6 @@ Lint/UselessConstantScoping:
- 'lib/autoload/coursemology_docker_container.rb'
- 'lib/extensions/attachable/active_record/base.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Lint/UselessMethodDefinition:
Exclude:
- 'app/models/course/settings/survey_component.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Lint/UselessOr:
Exclude:
- 'app/services/course/assessment/question/codaveri_problem_generation_service.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: CheckForMethodsWithNoSideEffects.
Lint/Void:
Exclude:
- 'app/models/concerns/course/video/watch_statistics_concern.rb'

# Offense count: 99
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
Metrics/AbcSize:
Expand Down Expand Up @@ -456,11 +420,6 @@ Metrics/PerceivedComplexity:
- 'app/services/course/assessment/reminder_service.rb'
- 'app/services/course/assessment/submission/statistics_download_service.rb'

# Offense count: 2
Naming/AccessorMethodName:
Exclude:
- 'app/controllers/concerns/application_authentication_concern.rb'

# Offense count: 24
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, BlockForwardingName.
Expand Down Expand Up @@ -799,14 +758,6 @@ Style/HashEachMethods:
- 'lib/tasks/db/populate_assessment_links.rake'
- 'spec/libraries/course/conditional/user_satisfiability_graph_spec.rb'

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
Style/IfUnlessModifier:
Exclude:
- 'app/controllers/course/assessment/question/text_responses_controller.rb'
- 'app/jobs/course/assessment/submission/auto_feedback_job.rb'
- 'app/views/course/assessment/question/programming/_response.json.jbuilder'

# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/MapIntoArray:
Expand All @@ -832,14 +783,6 @@ Style/MapToSet:
- 'app/models/instance/user_role_request.rb'
- 'lib/tasks/db/add_missing_email_settings.rake'

# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/MinMaxComparison:
Exclude:
- 'app/models/course/assessment/answer/programming_file.rb'
- 'app/services/course/duplication/object_duplication_service.rb'
- 'lib/autoload/duplicator.rb'

# Offense count: 7
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowMethodComparison, ComparisonsThreshold.
Expand Down Expand Up @@ -945,25 +888,6 @@ Style/RedundantParentheses:
- 'app/services/course/assessment/question/programming/java/java_package_service.rb'
- 'app/services/course/assessment/question/programming/python/python_package_service.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantRegexpArgument:
Exclude:
- 'app/helpers/application_html_formatters_helper.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantRegexpEscape:
Exclude:
- 'app/services/concerns/course/user_invitation_service/parse_invitation_concern.rb'

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantSelf:
Exclude:
- 'app/models/course/assessment/answer/multiple_response.rb'
- 'app/models/course/lesson_plan/item.rb'

# Offense count: 13
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantStringEscape:
Expand Down Expand Up @@ -1058,11 +982,3 @@ Style/TernaryParentheses:
- 'lib/tasks/coursemology/seed_600_gradebook.rake'
- 'lib/tasks/coursemology/seed_gradebook.rake'
- 'spec/libraries/coursemology_docker_container_spec.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma
Style/TrailingCommaInArguments:
Exclude:
- 'app/models/course/settings/email.rb'
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def current_session_id
end

def token_from_request
@token_from_request ||= get_token_from_bearer || get_token_from_cookies
@token_from_request ||= token_from_bearer || token_from_cookies
end

def current_decoded_token
Expand All @@ -46,7 +46,7 @@ def authenticate_token
@decoded_token.decoded_token
end

def get_token_from_bearer
def token_from_bearer
authorization_header_elements = request.headers['Authorization']&.split

# render json: REQUIRES_AUTHENTICATION, status: :unauthorized and return unless authorization_header_elements
Expand All @@ -65,7 +65,7 @@ def get_token_from_bearer
token
end

def get_token_from_cookies
def token_from_cookies
cookies.encrypted[:access_token]
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ class Course::Assessment::Question::TextResponsesController < Course::Assessment
before_action :load_question_assessment, only: [:edit, :update]

def new
if params[:file_upload] == 'true'
@text_response_question.hide_text = true
end
@text_response_question.hide_text = true if params[:file_upload] == 'true'
return unless params[:comprehension] == 'true'

@text_response_question.is_comprehension = true
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/application_html_formatters_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def sanitize_and_format_code(code, language, start_line)
def process_ckeditor_rich_text_with_pipeline(pipeline, text)
text_with_updated_code_tag = remove_internal_adjacent_code_tags(text)
format_with_pipeline(pipeline, text_with_updated_code_tag).
gsub(/<table>/, '<table class="table table-bordered">') # Add lines to tables
gsub('<table>', '<table class="table table-bordered">') # Add lines to tables
end

# Filters the given text through the given pipeline.
Expand Down
4 changes: 1 addition & 3 deletions app/jobs/course/assessment/submission/auto_feedback_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ def perform_tracked(submission)
instance = Course.unscoped { submission.assessment.course.instance }
ActsAsTenant.with_tenant(instance) do
submission.current_answers.each do |current_answer|
if current_answer.specific.self_respond_to?(:generate_feedback)
current_answer.specific.generate_feedback
end
current_answer.specific.generate_feedback if current_answer.specific.self_respond_to?(:generate_feedback)
end
end
end
Expand Down
4 changes: 1 addition & 3 deletions app/models/concerns/course/assessment/questions_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ def next_unanswered(submission)
correctly_answered_questions = correctly_answered_questions(submission)
return first if correctly_answered_questions.empty?

reduce(nil) do |_, question|
break question unless correctly_answered_questions.include?(question)
end
find { |question| correctly_answered_questions.exclude?(question) }
end

private
Expand Down
6 changes: 3 additions & 3 deletions app/models/concerns/course/video/watch_statistics_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ def correct_interval(event, last_start, video_duration)
# @return [Hash<Symbol, [Integer]>] The hash containing arrays of start times and end times
# of closed intervals.
def handle_unclosed_interval(result, last_start, video_duration)
if [result[:end].size, 0].include? result[:start].size
result
elsif last_start.session.last_video_time > correct_interval(last_start, last_start, video_duration)
return result if [result[:end].size, 0].include?(result[:start].size)

if last_start.session.last_video_time > correct_interval(last_start, last_start, video_duration)
result[:end] << last_start.session.last_video_time
else
result[:start].pop
Expand Down
2 changes: 1 addition & 1 deletion app/models/course/assessment/answer/multiple_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def retrieve_random_seed
self.random_seed ||= Random.new_seed
save

self.random_seed
random_seed
end

def compare_answer(other_answer)
Expand Down
2 changes: 1 addition & 1 deletion app/models/course/assessment/answer/programming_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def lines(line_numbers = nil)

case line_numbers
when Range
line_begin = line_numbers.min < 0 ? 0 : line_numbers.min
line_begin = [line_numbers.min, 0].max
lines[line_begin..line_numbers.max]
when Integer
lines[line_numbers]
Expand Down
4 changes: 2 additions & 2 deletions app/models/course/lesson_plan/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ def set_default_reference_time
end

def link_default_reference_time
self.default_reference_time.reference_timeline = course.default_reference_timeline
self.default_reference_time.lesson_plan_item = self
default_reference_time.reference_timeline = course.default_reference_timeline
default_reference_time.lesson_plan_item = self
end

def validate_only_one_default_reference_time
Expand Down
2 changes: 1 addition & 1 deletion app/models/course/settings/email.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Course::Settings::Email < ApplicationRecord

# A set of email settings that students are able to manage.
STUDENT_SETTING = Set[:opening_reminder, :closing_reminder, :grades_released, :new_comment,
:new_topic, :post_replied, ].map { |v| settings[v] }.freeze
:new_topic, :post_replied ].map { |v| settings[v] }.freeze

# A set of email settings that managers are able to manage.
MANAGER_SETTING = Set[:opening_reminder, :closing_reminder_summary, :new_comment, :new_submission, :new_topic,
Expand Down
4 changes: 0 additions & 4 deletions app/models/course/settings/survey_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
class Course::Settings::SurveyComponent < Course::Settings::Component
include Course::Settings::LessonPlanSettingsConcern

def lesson_plan_item_settings
super
end

def showable_in_lesson_plan?
settings.lesson_plan_items ? settings.lesson_plan_items['enabled'] : true
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true
require 'csv'
require 'set'

# This concern includes methods required to parse the invitations data.
# This can either be from a form, or a CSV file.
Expand Down Expand Up @@ -178,7 +177,7 @@ def header_alias_map
end

def normalize_header(value)
value&.strip&.downcase&.gsub(/[\s_\-]+/, '')
value&.strip&.downcase&.gsub(/[\s_-]+/, '')
end

def build_header_map!(row)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def codaveri_generate_problem
private

def initialize(assessment, params, language, version) # rubocop:disable Metrics/AbcSize
custom_prompt = params[:custom_prompt].to_s || ''
custom_prompt = params[:custom_prompt].to_s
@payload = {
userId: assessment.creator_id.to_s,
courseName: assessment.course.title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def duplicate_objects(source_course, destination_course, objects, options = {})
# @return [Float] Time difference between the +start_at+ of both courses.
def time_shift(source_course, destination_course)
shift = destination_course.start_at - source_course.start_at
shift >= 0 ? shift : 0
[shift, 0].max
end
end

Expand Down
7 changes: 7 additions & 0 deletions app/views/course/assessment/assessments/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true
achievements_enabled = !current_component_host[:course_achievements_component].nil?
marketplace_enabled = !current_component_host[:course_assessment_marketplace_component].nil?
submissions_hash = @assessments.to_h { |assessment| [assessment.id, assessment.submissions] }
# Empty for every course except the marketplace's snapshot container viewed by a system admin.
marketplace_versions = defined?(@marketplace_versions) ? @marketplace_versions : {}
Expand All @@ -16,6 +17,12 @@ json.display do
json.canCreateAssessments can?(:create, Course::Assessment.new(tab: @tab))
json.canManageMonitor @can_manage_monitor && @monitoring_component_enabled

# Gates the "Import Assessments" button, which only links into the marketplace. Marketplace access
# is per-person allow-listed (see Course::AssessmentMarketplaceAbilityComponent) and not implied by
# `:create` on assessments, so a manager without it would otherwise be sent to a 403. Mirrors the
# gate on the marketplace sidebar item in Course::AssessmentMarketplaceComponent.
json.canImportAssessments marketplace_enabled && can?(:access_marketplace, current_course)

# True only in the marketplace's snapshot container, viewed by a system admin. Switches on the
# container-only Listing/Version/Source columns and the search toolbar — every other course's
# assessments index must stay exactly as it was.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# frozen_string_literal: true
json.redirectAssessmentUrl course_assessment_path(current_course, @assessment)

if check_import_job?
json.importJobUrl job_path(@programming_question.import_job)
end
json.importJobUrl job_path(@programming_question.import_job) if check_import_job?

if redirect_to_edit
json.id @programming_question.id
Expand Down
Loading