Merge pull request #1129 from openHPI/updates
Update bundle (with newest rubocop version) and fix offenses
This commit is contained in:
@@ -5,7 +5,7 @@ module RedirectBehavior
|
||||
|
||||
def redirect_after_submit
|
||||
Rails.logger.debug { "Redirecting user with score:s #{@submission.normalized_score}" }
|
||||
if @submission.normalized_score.to_d == 1.0.to_d
|
||||
if @submission.normalized_score.to_d == BigDecimal('1.0')
|
||||
if redirect_to_community_solution?
|
||||
redirect_to_community_solution
|
||||
return
|
||||
|
@@ -59,7 +59,7 @@ raise: false
|
||||
end
|
||||
|
||||
def collect_paths(files)
|
||||
unique_paths = files.map(&:path).reject(&:blank?).uniq
|
||||
unique_paths = files.map(&:path).compact_blank.uniq
|
||||
subpaths = unique_paths.map do |path|
|
||||
Array.new((path.split('/').length + 1)) do |n|
|
||||
path.split('/').shift(n).join('/')
|
||||
|
@@ -24,7 +24,7 @@ class ProxyExercisesController < ApplicationController
|
||||
|
||||
def create
|
||||
myparams = proxy_exercise_params
|
||||
myparams[:exercises] = Exercise.find(myparams[:exercise_ids].reject(&:empty?))
|
||||
myparams[:exercises] = Exercise.find(myparams[:exercise_ids].compact_blank)
|
||||
@proxy_exercise = ProxyExercise.new(myparams)
|
||||
authorize!
|
||||
|
||||
@@ -78,7 +78,7 @@ class ProxyExercisesController < ApplicationController
|
||||
|
||||
def update
|
||||
myparams = proxy_exercise_params
|
||||
myparams[:exercises] = Exercise.find(myparams[:exercise_ids].reject(&:blank?))
|
||||
myparams[:exercises] = Exercise.find(myparams[:exercise_ids].compact_blank)
|
||||
update_and_respond(object: @proxy_exercise, params: myparams)
|
||||
end
|
||||
end
|
||||
|
@@ -23,7 +23,7 @@ class StudyGroupsController < ApplicationController
|
||||
def update
|
||||
myparams = study_group_params
|
||||
myparams[:external_users] =
|
||||
StudyGroupMembership.find(myparams[:study_group_membership_ids].reject(&:empty?)).map(&:user)
|
||||
StudyGroupMembership.find(myparams[:study_group_membership_ids].compact_blank).map(&:user)
|
||||
myparams.delete(:study_group_membership_ids)
|
||||
update_and_respond(object: @study_group, params: myparams)
|
||||
end
|
||||
|
@@ -244,9 +244,7 @@ class SubmissionsController < ApplicationController
|
||||
@submission.files.each do |file|
|
||||
content += "#{file.filepath}=#{file.file_id}\n"
|
||||
end
|
||||
File.open(path, 'w+') do |f|
|
||||
f.write(content)
|
||||
end
|
||||
File.write(path, content)
|
||||
path
|
||||
end
|
||||
|
||||
|
@@ -39,7 +39,7 @@ class UserExerciseFeedbacksController < ApplicationController
|
||||
authorize!
|
||||
if validate_inputs(uef_params)
|
||||
path =
|
||||
if rfc && submission && submission.normalized_score.to_d == 1.0.to_d
|
||||
if rfc && submission && submission.normalized_score.to_d == BigDecimal('1.0')
|
||||
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.to_d == 1.0.to_d
|
||||
if rfc && submission && submission.normalized_score.to_d == BigDecimal('1.0')
|
||||
request_for_comment_path(rfc)
|
||||
else
|
||||
implement_exercise_path(@exercise)
|
||||
|
@@ -41,7 +41,6 @@ module CodeOcean
|
||||
|
||||
validates :feedback_message, if: :teacher_defined_assessment?, presence: true
|
||||
validates :feedback_message, absence: true, unless: :teacher_defined_assessment?
|
||||
validates :file_type_id, presence: true
|
||||
validates :hashed_content, if: :content_present?, presence: true
|
||||
validates :hidden, boolean_presence: true
|
||||
validates :name, presence: true
|
||||
|
@@ -7,8 +7,5 @@ module Creation
|
||||
belongs_to :user, polymorphic: true
|
||||
alias_method :author, :user
|
||||
alias_method :creator, :user
|
||||
|
||||
validates :user_id, presence: true
|
||||
validates :user_type, presence: true
|
||||
end
|
||||
end
|
||||
|
@@ -49,7 +49,7 @@ class Exercise < ApplicationRecord
|
||||
MAX_GROUP_EXERCISE_FEEDBACKS = 20
|
||||
|
||||
def average_percentage
|
||||
if average_score && (maximum_score.to_d != 0.0.to_d) && submissions.exists?(cause: 'submit')
|
||||
if average_score && (maximum_score.to_d != BigDecimal('0.0')) && submissions.exists?(cause: 'submit')
|
||||
(average_score / maximum_score * 100).round(2)
|
||||
else
|
||||
0
|
||||
@@ -580,7 +580,7 @@ cause: %w[submit assess remoteSubmit remoteAssess]}).distinct
|
||||
private :valid_submission_deadlines?
|
||||
|
||||
def needs_more_feedback?(submission)
|
||||
if submission.normalized_score.to_d == 1.0.to_d
|
||||
if submission.normalized_score.to_d == BigDecimal('1.0')
|
||||
user_exercise_feedbacks.final.size <= MAX_GROUP_EXERCISE_FEEDBACKS
|
||||
else
|
||||
user_exercise_feedbacks.intermediate.size <= MAX_GROUP_EXERCISE_FEEDBACKS
|
||||
|
@@ -1,7 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ExternalUser < User
|
||||
validates :consumer_id, presence: true
|
||||
validates :external_id, presence: true
|
||||
|
||||
def displayname
|
||||
|
@@ -175,7 +175,7 @@ class ProxyExercise < ApplicationRecord
|
||||
return 0.0
|
||||
end
|
||||
points_ratio = exercise.maximum_score(user) / max_score
|
||||
if points_ratio.to_d == 0.0.to_d
|
||||
if points_ratio.to_d == BigDecimal('0.0')
|
||||
Rails.logger.debug { "scoring user #{user.id} for exercise #{exercise.id}: points_ratio=#{points_ratio} score: 0" }
|
||||
return 0.0
|
||||
elsif points_ratio > 1.0
|
||||
|
@@ -6,7 +6,7 @@ class Runner < ApplicationRecord
|
||||
|
||||
before_validation :request_id
|
||||
|
||||
validates :execution_environment, :user, :runner_id, presence: true
|
||||
validates :runner_id, presence: true
|
||||
|
||||
attr_accessor :strategy
|
||||
|
||||
|
@@ -45,7 +45,6 @@ class Submission < ApplicationRecord
|
||||
scope :in_study_group_of, ->(user) { where(study_group_id: user.study_groups) unless user.admin? }
|
||||
|
||||
validates :cause, inclusion: {in: CAUSES}
|
||||
validates :exercise_id, presence: true
|
||||
|
||||
# after_save :trigger_working_times_action_cable
|
||||
|
||||
@@ -293,7 +292,7 @@ class Submission < ApplicationRecord
|
||||
end
|
||||
# Prevent floating point precision issues by converting to BigDecimal, e.g., for `0.28 * 25`
|
||||
update(score: score.to_d)
|
||||
if normalized_score.to_d == 1.0.to_d
|
||||
if normalized_score.to_d == BigDecimal('1.0')
|
||||
Thread.new do
|
||||
RequestForComment.where(exercise_id: exercise_id, user_id: user_id, user_type: user_type).find_each do |rfc|
|
||||
rfc.full_score_reached = true
|
||||
|
@@ -4,8 +4,4 @@ class UserExerciseIntervention < ApplicationRecord
|
||||
belongs_to :user, polymorphic: true
|
||||
belongs_to :intervention
|
||||
belongs_to :exercise
|
||||
|
||||
validates :user, presence: true
|
||||
validates :exercise, presence: true
|
||||
validates :intervention, presence: true
|
||||
end
|
||||
|
@@ -5,10 +5,5 @@ class UserProxyExerciseExercise < ApplicationRecord
|
||||
belongs_to :exercise
|
||||
belongs_to :proxy_exercise
|
||||
|
||||
validates :user_id, presence: true
|
||||
validates :user_type, presence: true
|
||||
validates :exercise_id, presence: true
|
||||
validates :proxy_exercise_id, presence: true
|
||||
|
||||
validates :user_id, uniqueness: {scope: %i[proxy_exercise_id user_type]}
|
||||
end
|
||||
|
@@ -40,9 +40,9 @@ module ProformaService
|
||||
end
|
||||
|
||||
def task_files
|
||||
@task_files ||= @task.all_files.reject {|file| file.id == 'ms-placeholder-file' }.map do |task_file|
|
||||
@task_files ||= @task.all_files.reject {|file| file.id == 'ms-placeholder-file' }.to_h do |task_file|
|
||||
[task_file.id, codeocean_file_from_task_file(task_file)]
|
||||
end.to_h
|
||||
end
|
||||
end
|
||||
|
||||
def codeocean_file_from_task_file(file)
|
||||
|
Reference in New Issue
Block a user