Update bundle (with newest rubocop version) and fix offenses
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user