Apply manual rubocop fixes
This commit is contained in:
@@ -6,7 +6,7 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
MEMBER_ACTIONS = %i[destroy edit show update].freeze
|
||||
|
||||
after_action :verify_authorized, except: %i[help welcome]
|
||||
after_action :verify_authorized, except: %i[welcome]
|
||||
around_action :mnemosyne_trace
|
||||
before_action :set_sentry_context, :set_locale, :allow_iframe_requests, :load_embed_options
|
||||
protect_from_forgery(with: :exception, prepend: true)
|
||||
|
@@ -31,7 +31,10 @@ module CodeOcean
|
||||
path: path, status: :created)
|
||||
else
|
||||
filename = "#{@object.path || ''}/#{@object.name || ''}#{@object.file_type.try(:file_extension) || ''}"
|
||||
format.html { redirect_to(options[:path]); flash[:danger] = t('files.error.filename', name: filename) }
|
||||
format.html do
|
||||
flash[:danger] = t('files.error.filename', name: filename)
|
||||
redirect_to(options[:path])
|
||||
end
|
||||
format.json { render(json: @object.errors, status: :unprocessable_entity) }
|
||||
end
|
||||
end
|
||||
|
@@ -3,7 +3,7 @@
|
||||
class CodeharborLinksController < ApplicationController
|
||||
include CommonBehavior
|
||||
before_action :verify_codeharbor_activation
|
||||
before_action :set_codeharbor_link, only: %i[show edit update destroy]
|
||||
before_action :set_codeharbor_link, only: %i[edit update destroy]
|
||||
|
||||
def new
|
||||
base_url = CodeOcean::Config.new(:code_ocean).read[:codeharbor][:url] || ''
|
||||
|
@@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CommentsController < ApplicationController
|
||||
before_action :set_comment, only: %i[show edit update destroy]
|
||||
before_action :set_comment, only: %i[show update destroy]
|
||||
|
||||
# to disable authorization check: comment the line below back in
|
||||
# skip_after_action :verify_authorized
|
||||
|
@@ -60,11 +60,9 @@ module Lti
|
||||
if provider.roles.present?
|
||||
provider.roles.each do |role|
|
||||
case role.downcase
|
||||
when 'administrator'
|
||||
when 'administrator', 'instructor'
|
||||
# We don't want anyone to get admin privileges through LTI
|
||||
result = 'teacher' if result == 'learner'
|
||||
when 'instructor'
|
||||
result = 'teacher' if result == 'learner'
|
||||
else # 'learner'
|
||||
next
|
||||
end
|
||||
@@ -172,8 +170,7 @@ module Lti
|
||||
normalized_lit_score *= 0.0
|
||||
end
|
||||
response = provider.post_replace_result!(normalized_lit_score)
|
||||
{code: response.response_code, message: response.post_response.body, status: response.code_major,
|
||||
score_sent: normalized_lit_score}
|
||||
{code: response.response_code, message: response.post_response.body, status: response.code_major, score_sent: normalized_lit_score}
|
||||
else
|
||||
{status: 'unsupported'}
|
||||
end
|
||||
|
@@ -5,8 +5,7 @@ module RemoteEvaluationParameters
|
||||
|
||||
def remote_evaluation_params
|
||||
if params[:remote_evaluation].present?
|
||||
remote_evaluation_params = params[:remote_evaluation].permit(:validation_token,
|
||||
files_attributes: file_attributes)
|
||||
params[:remote_evaluation].permit(:validation_token, files_attributes: file_attributes)
|
||||
end
|
||||
end
|
||||
private :remote_evaluation_params
|
||||
|
@@ -81,7 +81,7 @@ module SubmissionScoring
|
||||
end
|
||||
end
|
||||
submission.update(score: score)
|
||||
if submission.normalized_score == 1.0
|
||||
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|
|
||||
|
@@ -58,8 +58,8 @@ class ExerciseCollectionsController < ApplicationController
|
||||
end
|
||||
sanitized_params[:exercise_ids] = sanitized_params[:exercise_ids].reject {|v| v.nil? or v == '' }
|
||||
sanitized_params.tap do |p|
|
||||
p[:exercise_collection_items] = p[:exercise_ids].map.with_index do |_id, index|
|
||||
ExerciseCollectionItem.find_or_create_by(exercise_id: _id, exercise_collection_id: @exercise_collection.id, position: index)
|
||||
p[:exercise_collection_items] = p[:exercise_ids].map.with_index do |id, index|
|
||||
ExerciseCollectionItem.find_or_create_by(exercise_id: id, exercise_collection_id: @exercise_collection.id, position: index)
|
||||
end
|
||||
p.delete(:exercise_ids)
|
||||
end
|
||||
|
@@ -61,7 +61,7 @@ raise: false
|
||||
def collect_paths(files)
|
||||
unique_paths = files.map(&:path).reject(&:blank?).uniq
|
||||
subpaths = unique_paths.map do |path|
|
||||
(path.split('/').length + 1).times.map do |n|
|
||||
Array.new((path.split('/').length + 1)) do |n|
|
||||
path.split('/').shift(n).join('/')
|
||||
end
|
||||
end
|
||||
@@ -271,7 +271,7 @@ user_id: current_user.id, user_type: current_user.class.name
|
||||
def implement
|
||||
redirect_to(@exercise, alert: t('exercises.implement.unpublished')) if @exercise.unpublished? && current_user.role != 'admin' && current_user.role != 'teacher' # TODO: TESTESTEST
|
||||
redirect_to(@exercise, alert: t('exercises.implement.no_files')) unless @exercise.files.visible.exists?
|
||||
user_solved_exercise = @exercise.has_user_solved(current_user)
|
||||
user_solved_exercise = @exercise.solved_by?(current_user)
|
||||
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,
|
||||
@@ -280,11 +280,10 @@ exercise: @exercise).size >= max_intervention_count_per_exercise
|
||||
|
||||
if @embed_options[:disable_interventions]
|
||||
@show_rfc_interventions = false
|
||||
@show_break_interventions = false
|
||||
else
|
||||
@show_rfc_interventions = (!user_solved_exercise && !user_got_enough_interventions).to_s
|
||||
@show_break_interventions = false
|
||||
end
|
||||
@show_break_interventions = false
|
||||
|
||||
@hide_rfc_button = @embed_options[:disable_rfc]
|
||||
|
||||
@@ -308,9 +307,7 @@ exercise: @exercise).size >= max_intervention_count_per_exercise
|
||||
lti_json = lti_parameters.lti_parameters['launch_presentation_return_url']
|
||||
|
||||
@course_token =
|
||||
if lti_json.nil?
|
||||
''
|
||||
elsif match = lti_json.match(%r{^.*courses/([a-z0-9\-]+)/sections})
|
||||
if lti_json.present? && (match = lti_json.match(%r{^.*courses/([a-z0-9\-]+)/sections}))
|
||||
match.captures.first
|
||||
else
|
||||
''
|
||||
@@ -470,7 +467,7 @@ working_time_accumulated: working_time_accumulated})
|
||||
authorize(@external_user, :statistics?)
|
||||
if policy(@exercise).detailed_statistics?
|
||||
@submissions = Submission.where(user: @external_user,
|
||||
exercise_id: @exercise.id).in_study_group_of(current_user).order('created_at')
|
||||
exercise_id: @exercise.id).in_study_group_of(current_user).order('created_at')
|
||||
interventions = UserExerciseIntervention.where('user_id = ? AND exercise_id = ?', @external_user.id,
|
||||
@exercise.id)
|
||||
@all_events = (@submissions + interventions).sort_by(&:created_at)
|
||||
@@ -480,11 +477,11 @@ exercise_id: @exercise.id).in_study_group_of(current_user).order('created_at')
|
||||
end
|
||||
@working_times_until = []
|
||||
@all_events.each_with_index do |_, index|
|
||||
@working_times_until.push((format_time_difference(@deltas[0..index].inject(:+)) if index.positive?))
|
||||
@working_times_until.push((format_time_difference(@deltas[0..index].sum) if index.positive?))
|
||||
end
|
||||
else
|
||||
final_submissions = Submission.where(user: @external_user,
|
||||
exercise_id: @exercise.id).in_study_group_of(current_user).final
|
||||
exercise_id: @exercise.id).in_study_group_of(current_user).final
|
||||
@submissions = []
|
||||
%i[before_deadline within_grace_period after_late_deadline].each do |filter|
|
||||
relevant_submission = final_submissions.send(filter).latest
|
||||
@@ -570,7 +567,7 @@ normalized_score: @submission.normalized_score})
|
||||
|
||||
def redirect_after_submit
|
||||
Rails.logger.debug("Redirecting user with score:s #{@submission.normalized_score}")
|
||||
if @submission.normalized_score == 1.0
|
||||
if @submission.normalized_score.to_d == 1.0.to_d
|
||||
# if user is external and has an own rfc, redirect to it and message him to clean up and accept the answer. (we need to check that the user is external,
|
||||
# otherwise an internal user could be shown a false rfc here, since current_user.id is polymorphic, but only makes sense for external users when used with rfcs.)
|
||||
# redirect 10 percent pseudorandomly to the feedback page
|
||||
@@ -603,7 +600,7 @@ normalized_score: @submission.normalized_score})
|
||||
flash.keep(:notice)
|
||||
|
||||
# increase counter 'times_featured' in rfc
|
||||
rfc.increment!(:times_featured)
|
||||
rfc.increment(:times_featured)
|
||||
|
||||
clear_lti_session_data(@submission.exercise_id, @submission.user_id)
|
||||
respond_to do |format|
|
||||
|
@@ -23,7 +23,7 @@ class FlowrController < ApplicationController
|
||||
# for each error get all attributes, filter out uninteresting ones, and build a query
|
||||
insights = errors.map do |error|
|
||||
attributes = error.structured_error_attributes.select do |attribute|
|
||||
is_interesting(attribute) and attribute.match
|
||||
interesting?(attribute) and attribute.match
|
||||
end
|
||||
# once the programming language model becomes available, the language name can be added to the query to
|
||||
# produce more relevant results
|
||||
@@ -35,8 +35,8 @@ class FlowrController < ApplicationController
|
||||
render json: insights, status: :ok
|
||||
end
|
||||
|
||||
def is_interesting(attribute)
|
||||
attribute.error_template_attribute.key.index(/error message|error type/i) != nil
|
||||
def interesting?(attribute)
|
||||
!attribute.error_template_attribute.key.index(/error message|error type/i).nil?
|
||||
end
|
||||
private :is_interesting
|
||||
private :interesting?
|
||||
end
|
||||
|
@@ -6,7 +6,7 @@ class RequestForCommentsController < ApplicationController
|
||||
before_action :require_user!
|
||||
before_action :set_request_for_comment, only: %i[show mark_as_solved set_thank_you_note]
|
||||
before_action :set_study_group_grouping,
|
||||
only: %i[index get_my_comment_requests get_rfcs_with_my_comments get_rfcs_for_exercise]
|
||||
only: %i[index my_comment_requests rfcs_with_my_comments rfcs_for_exercise]
|
||||
|
||||
def authorize!
|
||||
authorize(@request_for_comments || @request_for_comment)
|
||||
@@ -31,7 +31,7 @@ class RequestForCommentsController < ApplicationController
|
||||
end
|
||||
|
||||
# GET /my_request_for_comments
|
||||
def get_my_comment_requests
|
||||
def my_comment_requests
|
||||
@search = RequestForComment
|
||||
.with_last_activity
|
||||
.where(user: current_user)
|
||||
@@ -44,7 +44,7 @@ class RequestForCommentsController < ApplicationController
|
||||
end
|
||||
|
||||
# GET /my_rfc_activity
|
||||
def get_rfcs_with_my_comments
|
||||
def rfcs_with_my_comments
|
||||
@search = RequestForComment
|
||||
.with_last_activity
|
||||
.joins(:comments) # we don't need to outer join here, because we know the user has commented on these
|
||||
@@ -58,7 +58,7 @@ class RequestForCommentsController < ApplicationController
|
||||
end
|
||||
|
||||
# GET /exercises/:id/request_for_comments
|
||||
def get_rfcs_for_exercise
|
||||
def rfcs_for_exercise
|
||||
exercise = Exercise.find(params[:exercise_id])
|
||||
@search = RequestForComment
|
||||
.with_last_activity
|
||||
|
@@ -9,7 +9,7 @@ class SubmissionsController < ApplicationController
|
||||
include Tubesock::Hijack
|
||||
|
||||
before_action :set_submission,
|
||||
only: %i[download download_file render_file run score extract_errors show statistics stop test]
|
||||
only: %i[download download_file render_file run score extract_errors show statistics test]
|
||||
before_action :set_docker_client, only: %i[run test]
|
||||
before_action :set_files, only: %i[download download_file render_file show run]
|
||||
before_action :set_file, only: %i[download_file render_file run]
|
||||
@@ -199,7 +199,7 @@ user_type: current_user.class.name, row: annotation[1][:row], column: annotation
|
||||
socket.send data
|
||||
Rails.logger.debug("Sent the received client data to docker:#{data}")
|
||||
end
|
||||
rescue JSON::ParserError => e
|
||||
rescue JSON::ParserError
|
||||
socket.send data
|
||||
Rails.logger.debug("Rescued parsing error, sent the received client data to docker:#{data}")
|
||||
Sentry.set_extras(data: data)
|
||||
@@ -266,7 +266,7 @@ user_type: current_user.class.name, row: annotation[1][:row], column: annotation
|
||||
end
|
||||
end
|
||||
|
||||
def parse_message(message, output_stream, socket, container = nil, recursive = true)
|
||||
def parse_message(message, output_stream, socket, container = nil, recursive: true)
|
||||
parsed = ''
|
||||
begin
|
||||
parsed = JSON.parse(message)
|
||||
@@ -279,11 +279,11 @@ user_type: current_user.class.name, row: annotation[1][:row], column: annotation
|
||||
socket.send_data JSON.dump(parsed)
|
||||
Rails.logger.info("parse_message sent: #{JSON.dump(parsed)}")
|
||||
end
|
||||
rescue JSON::ParserError => e
|
||||
rescue JSON::ParserError
|
||||
# Check wether the message contains multiple lines, if true try to parse each line
|
||||
if recursive && message.include?("\n")
|
||||
message.split("\n").each do |part|
|
||||
parse_message(part, output_stream, socket, container, false)
|
||||
parse_message(part, output_stream, socket, container, recursive: false)
|
||||
end
|
||||
elsif message.include?('<img') || message.start_with?('{"cmd') || message.include?('"turtlebatch"')
|
||||
# Rails.logger.info('img foung')
|
||||
|
@@ -39,7 +39,7 @@ class UserExerciseFeedbacksController < ApplicationController
|
||||
authorize!
|
||||
if validate_inputs(uef_params)
|
||||
path =
|
||||
if rfc && submission && submission.normalized_score == 1.0
|
||||
if rfc && submission && submission.normalized_score.to_d == 1.0.to_d
|
||||
request_for_comment_path(rfc)
|
||||
else
|
||||
implement_exercise_path(@exercise)
|
||||
@@ -82,7 +82,7 @@ class UserExerciseFeedbacksController < ApplicationController
|
||||
authorize!
|
||||
if @exercise && validate_inputs(uef_params)
|
||||
path =
|
||||
if rfc && submission && submission.normalized_score == 1.0
|
||||
if rfc && submission && submission.normalized_score.to_d == 1.0.to_d
|
||||
request_for_comment_path(rfc)
|
||||
else
|
||||
implement_exercise_path(@exercise)
|
||||
|
Reference in New Issue
Block a user