Apply automatic rubocop fixes
This commit is contained in:
@ -15,7 +15,7 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
def current_user
|
||||
::NewRelic::Agent.add_custom_attributes(external_user_id: session[:external_user_id],
|
||||
session_user_id: session[:user_id])
|
||||
session_user_id: session[:user_id])
|
||||
@current_user ||= ExternalUser.find_by(id: session[:external_user_id]) || login_from_session || login_from_other_sources || nil
|
||||
end
|
||||
|
||||
|
@ -49,7 +49,7 @@ path: path, status: :created)
|
||||
def file_params
|
||||
if params[:code_ocean_file].present?
|
||||
params[:code_ocean_file].permit(file_attributes).merge(context_type: 'Submission',
|
||||
role: 'user_defined_file')
|
||||
role: 'user_defined_file')
|
||||
end
|
||||
end
|
||||
private :file_params
|
||||
|
@ -8,7 +8,7 @@ class CodeharborLinksController < ApplicationController
|
||||
def new
|
||||
base_url = CodeOcean::Config.new(:code_ocean).read[:codeharbor][:url] || ''
|
||||
@codeharbor_link = CodeharborLink.new(push_url: "#{base_url}/import_exercise",
|
||||
check_uuid_url: "#{base_url}/import_uuid_check")
|
||||
check_uuid_url: "#{base_url}/import_uuid_check")
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -86,7 +86,7 @@ class CommentsController < ApplicationController
|
||||
# params.require(:comment).permit(:user_id, :file_id, :row, :column, :text)
|
||||
# fuer production mode, damit böse menschen keine falsche user_id uebergeben:
|
||||
params.require(:comment).permit(:file_id, :row, :column, :text, :request_id).merge(user_id: current_user.id,
|
||||
user_type: current_user.class.name)
|
||||
user_type: current_user.class.name)
|
||||
end
|
||||
|
||||
def send_mail_to_author(comment, request_for_comment)
|
||||
|
@ -84,7 +84,7 @@ module SubmissionScoring
|
||||
if submission.normalized_score.to_d == 1.0.to_d
|
||||
Thread.new do
|
||||
RequestForComment.where(exercise_id: submission.exercise_id, user_id: submission.user_id,
|
||||
user_type: submission.user_type).each do |rfc|
|
||||
user_type: submission.user_type).each do |rfc|
|
||||
rfc.full_score_reached = true
|
||||
rfc.save
|
||||
end
|
||||
|
@ -103,8 +103,8 @@ class ExecutionEnvironmentsController < ApplicationController
|
||||
def execution_environment_params
|
||||
if params[:execution_environment].present?
|
||||
params[:execution_environment].permit(:docker_image, :exposed_ports, :editor_mode, :file_extension, :file_type_id, :help, :indent_size, :memory_limit, :name, :network_enabled, :permitted_execution_time, :pool_size, :run_command, :test_command, :testing_framework).merge(
|
||||
user_id: current_user.id, user_type: current_user.class.name
|
||||
)
|
||||
user_id: current_user.id, user_type: current_user.class.name
|
||||
)
|
||||
end
|
||||
end
|
||||
private :execution_environment_params
|
||||
|
@ -111,7 +111,7 @@ raise: false
|
||||
|
||||
def export_external_check
|
||||
codeharbor_check = ExerciseService::CheckExternal.call(uuid: @exercise.uuid,
|
||||
codeharbor_link: current_user.codeharbor_link)
|
||||
codeharbor_link: current_user.codeharbor_link)
|
||||
render json: {
|
||||
message: codeharbor_check[:message],
|
||||
actions: render_to_string(
|
||||
@ -139,7 +139,7 @@ codeharbor_link: current_user.codeharbor_link)
|
||||
status: 'success',
|
||||
message: t('exercises.export_codeharbor.successfully_exported', id: @exercise.id, title: @exercise.title),
|
||||
actions: render_to_string(partial: 'export_actions',
|
||||
locals: {exercise: @exercise, exported: true, error: error}),
|
||||
locals: {exercise: @exercise, exported: true, error: error}),
|
||||
}
|
||||
@exercise.save
|
||||
else
|
||||
@ -147,7 +147,7 @@ locals: {exercise: @exercise, exported: true, error: error}),
|
||||
status: 'fail',
|
||||
message: t('exercises.export_codeharbor.export_failed', id: @exercise.id, title: @exercise.title, error: error),
|
||||
actions: render_to_string(partial: 'export_actions',
|
||||
locals: {exercise: @exercise, exported: true, error: error}),
|
||||
locals: {exercise: @exercise, exported: true, error: error}),
|
||||
}
|
||||
end
|
||||
end
|
||||
@ -203,8 +203,8 @@ locals: {exercise: @exercise, exported: true, error: error}),
|
||||
def exercise_params
|
||||
if params[:exercise].present?
|
||||
params[:exercise].permit(:description, :execution_environment_id, :file_id, :instructions, :submission_deadline, :late_submission_deadline, :public, :unpublished, :hide_file_tree, :allow_file_creation, :allow_auto_completion, :title, :expected_difficulty, :tips, files_attributes: file_attributes, tag_ids: []).merge(
|
||||
user_id: current_user.id, user_type: current_user.class.name
|
||||
)
|
||||
user_id: current_user.id, user_type: current_user.class.name
|
||||
)
|
||||
end
|
||||
end
|
||||
private :exercise_params
|
||||
@ -275,7 +275,7 @@ user_id: current_user.id, user_type: current_user.class.name
|
||||
count_interventions_today = UserExerciseIntervention.where(user: current_user).where('created_at >= ?',
|
||||
Time.zone.now.beginning_of_day).count
|
||||
user_got_intervention_in_exercise = UserExerciseIntervention.where(user: current_user,
|
||||
exercise: @exercise).size >= max_intervention_count_per_exercise
|
||||
exercise: @exercise).size >= max_intervention_count_per_exercise
|
||||
(user_got_enough_interventions = count_interventions_today >= max_intervention_count_per_day) || user_got_intervention_in_exercise
|
||||
|
||||
if @embed_options[:disable_interventions]
|
||||
@ -525,7 +525,7 @@ working_time_accumulated: working_time_accumulated})
|
||||
|
||||
def transmit_lti_score
|
||||
::NewRelic::Agent.add_custom_attributes({submission: @submission.id,
|
||||
normalized_score: @submission.normalized_score})
|
||||
normalized_score: @submission.normalized_score})
|
||||
response = send_score(@submission)
|
||||
|
||||
if response[:status] == 'success'
|
||||
|
@ -80,7 +80,7 @@ class ExternalUsersController < ApplicationController
|
||||
tags = ProxyExercise.new.get_user_knowledge_and_max_knowledge(@user, @user.participations.uniq.compact)
|
||||
tags[:user_topic_knowledge].each_pair do |tag, value|
|
||||
statistics.append({key: tag.name.to_s, value: (100.0 / tags[:max_topic_knowledge][tag] * value).round,
|
||||
id: tag.id})
|
||||
id: tag.id})
|
||||
end
|
||||
statistics.sort_by! {|item| -item[:value] }
|
||||
|
||||
|
@ -26,8 +26,8 @@ class FileTypesController < ApplicationController
|
||||
def file_type_params
|
||||
if params[:file_type].present?
|
||||
params[:file_type].permit(:binary, :editor_mode, :executable, :file_extension, :name, :indent_size, :renderable).merge(
|
||||
user_id: current_user.id, user_type: current_user.class.name
|
||||
)
|
||||
user_id: current_user.id, user_type: current_user.class.name
|
||||
)
|
||||
end
|
||||
end
|
||||
private :file_type_params
|
||||
|
@ -12,7 +12,7 @@ class ProxyExercisesController < ApplicationController
|
||||
|
||||
def clone
|
||||
proxy_exercise = @proxy_exercise.duplicate(public: false, token: nil, exercises: @proxy_exercise.exercises,
|
||||
user: current_user)
|
||||
user: current_user)
|
||||
proxy_exercise.send(:generate_token)
|
||||
if proxy_exercise.save
|
||||
redirect_to(proxy_exercise, notice: t('shared.object_cloned', model: ProxyExercise.model_name.human))
|
||||
@ -44,7 +44,7 @@ user: current_user)
|
||||
def proxy_exercise_params
|
||||
if params[:proxy_exercise].present?
|
||||
params[:proxy_exercise].permit(:description, :title, :public, exercise_ids: []).merge(user_id: current_user.id,
|
||||
user_type: current_user.class.name)
|
||||
user_type: current_user.class.name)
|
||||
end
|
||||
end
|
||||
private :proxy_exercise_params
|
||||
|
@ -145,8 +145,8 @@ class RequestForCommentsController < ApplicationController
|
||||
def request_for_comment_params
|
||||
# The study_group_id might not be present in the session (e.g. for internal users), resulting in session[:study_group_id] = nil which is intended.
|
||||
params.require(:request_for_comment).permit(:exercise_id, :file_id, :question, :requested_at, :solved, :submission_id).merge(
|
||||
user_id: current_user.id, user_type: current_user.class.name
|
||||
)
|
||||
user_id: current_user.id, user_type: current_user.class.name
|
||||
)
|
||||
end
|
||||
|
||||
# The index page requires the grouping of the study groups
|
||||
|
@ -47,7 +47,7 @@ module_name: File.basename(filename, File.extname(filename)).underscore}
|
||||
params[:annotations_arr]&.each do |annotation|
|
||||
# comment = Comment.new(annotation[1].permit(:user_id, :file_id, :user_type, :row, :column, :text, :created_at, :updated_at))
|
||||
comment = Comment.new(user_id: annotation[1][:user_id], file_id: annotation[1][:file_id],
|
||||
user_type: current_user.class.name, row: annotation[1][:row], column: annotation[1][:column], text: annotation[1][:text])
|
||||
user_type: current_user.class.name, row: annotation[1][:row], column: annotation[1][:column], text: annotation[1][:text])
|
||||
source_file = CodeOcean::File.find(annotation[1][:file_id])
|
||||
|
||||
# retrieve target file
|
||||
|
@ -57,7 +57,7 @@ class SubscriptionsController < ApplicationController
|
||||
current_user_class_name = current_user.try(:class).try(:name)
|
||||
if params[:subscription].present?
|
||||
params[:subscription].permit(:request_for_comment_id, :subscription_type).merge(user_id: current_user_id,
|
||||
user_type: current_user_class_name, deleted: false)
|
||||
user_type: current_user_class_name, deleted: false)
|
||||
end
|
||||
end
|
||||
private :subscription_params
|
||||
|
@ -25,9 +25,9 @@ class UserMailer < ApplicationMailer
|
||||
@comment_text = comment.text
|
||||
@rfc_link = request_for_comment_url(request_for_comment)
|
||||
mail(
|
||||
subject: t('mailers.user_mailer.got_new_comment.subject',
|
||||
subject: t('mailers.user_mailer.got_new_comment.subject',
|
||||
commenting_user_displayname: @commenting_user_displayname), to: request_for_comment.user.email
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
def got_new_comment_for_subscription(comment, subscription, from_user)
|
||||
@ -37,9 +37,9 @@ subject: t('mailers.user_mailer.got_new_comment.subject',
|
||||
@rfc_link = request_for_comment_url(subscription.request_for_comment)
|
||||
@unsubscribe_link = unsubscribe_subscription_url(subscription)
|
||||
mail(
|
||||
subject: t('mailers.user_mailer.got_new_comment_for_subscription.subject',
|
||||
subject: t('mailers.user_mailer.got_new_comment_for_subscription.subject',
|
||||
author_displayname: @author_displayname), to: subscription.user.email
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
def send_thank_you_note(request_for_comments, receiver)
|
||||
|
@ -14,8 +14,8 @@ class ExerciseTip < ApplicationRecord
|
||||
def tip_chain?
|
||||
# Ensure each referenced parent exercise tip is set for this exercise
|
||||
unless ExerciseTip.exists?(
|
||||
exercise: exercise, id: parent_exercise_tip
|
||||
)
|
||||
exercise: exercise, id: parent_exercise_tip
|
||||
)
|
||||
errors.add :parent_exercise_tip,
|
||||
I18n.t('activerecord.errors.messages.together',
|
||||
attribute: I18n.t('activerecord.attributes.exercise_tip.tip'))
|
||||
|
@ -58,7 +58,7 @@ class ProxyExercise < ApplicationRecord
|
||||
exercises.where('expected_difficulty > 1').sample # difficulty should be > 1 to prevent dummy exercise from being chosen.
|
||||
end
|
||||
user.user_proxy_exercise_exercises << UserProxyExerciseExercise.create(user: user,
|
||||
exercise: matching_exercise, proxy_exercise: self, reason: @reason.to_json)
|
||||
exercise: matching_exercise, proxy_exercise: self, reason: @reason.to_json)
|
||||
matching_exercise
|
||||
end
|
||||
end
|
||||
|
@ -11,6 +11,6 @@ class StructuredErrorAttribute < ApplicationRecord
|
||||
value = result.captures[0]
|
||||
end
|
||||
create(structured_error: structured_error, error_template_attribute: attribute, value: value,
|
||||
match: !result.nil?)
|
||||
match: !result.nil?)
|
||||
end
|
||||
end
|
||||
|
@ -17,7 +17,7 @@ class DockerContainerPool
|
||||
container
|
||||
rescue StandardError => e
|
||||
Sentry.set_extras({container: container.inspect, execution_environment: execution_environment.inspect,
|
||||
config: config.inspect})
|
||||
config: config.inspect})
|
||||
Sentry.capture_exception(e)
|
||||
nil
|
||||
end
|
||||
@ -26,7 +26,7 @@ config: config.inspect})
|
||||
Faraday.get("#{config[:location]}/docker_container_pool/return_container/#{container.id}")
|
||||
rescue StandardError => e
|
||||
Sentry.set_extras({container: container.inspect, execution_environment: execution_environment.inspect,
|
||||
config: config.inspect})
|
||||
config: config.inspect})
|
||||
Sentry.capture_exception(e)
|
||||
nil
|
||||
end
|
||||
@ -39,7 +39,7 @@ config: config.inspect})
|
||||
Docker::Container.get(container_id) if container_id.present?
|
||||
rescue StandardError => e
|
||||
Sentry.set_extras({container_id: container_id.inspect, execution_environment: execution_environment.inspect,
|
||||
config: config.inspect})
|
||||
config: config.inspect})
|
||||
Sentry.capture_exception(e)
|
||||
nil
|
||||
end
|
||||
|
@ -142,7 +142,7 @@ namespace :detect_exercise_anomalies do
|
||||
user = u[:user_type] == InternalUser.name ? InternalUser.find(u[:user_id]) : ExternalUser.find(u[:user_id])
|
||||
host = CodeOcean::Application.config.action_mailer.default_url_options[:host]
|
||||
feedback_link = Rails.application.routes.url_helpers.url_for(action: :new,
|
||||
controller: :user_exercise_feedbacks, exercise_id: exercise.id, host: host)
|
||||
controller: :user_exercise_feedbacks, exercise_id: exercise.id, host: host)
|
||||
UserMailer.exercise_anomaly_needs_feedback(user, exercise, feedback_link).deliver
|
||||
end
|
||||
log("Asked #{users_to_notify.size} users for feedback.", 2)
|
||||
|
@ -353,7 +353,7 @@ describe DockerClient, docker: true do
|
||||
end
|
||||
|
||||
describe '#send_command' do
|
||||
let(:block) { proc { nil } }
|
||||
let(:block) { proc {} }
|
||||
let(:container) { described_class.create_container(execution_environment) }
|
||||
let(:send_command) { docker_client.send(:send_command, command, container, &block) }
|
||||
|
||||
|
Reference in New Issue
Block a user