Apply automatic rubocop fixes
This commit is contained in:
@@ -7,7 +7,7 @@ module CodeOcean
|
||||
class FileNameValidator < ActiveModel::Validator
|
||||
def validate(record)
|
||||
existing_files = File.where(name: record.name, path: record.path, file_type_id: record.file_type_id,
|
||||
context_id: record.context_id, context_type: record.context_type).to_a
|
||||
context_id: record.context_id, context_type: record.context_type).to_a
|
||||
if !existing_files.empty? && (!record.context.is_a?(Exercise) || record.context.new_record?)
|
||||
record.errors[:base] << 'Duplicate'
|
||||
end
|
||||
|
@@ -500,14 +500,14 @@ class Exercise < ApplicationRecord
|
||||
feedback_message_nodes = task_node.xpath('p:tests/p:test/p:test-configuration/c:feedback-message/text()')
|
||||
files.build({
|
||||
name: file_name_split.first,
|
||||
content: file.xpath('text()').first.content,
|
||||
read_only: false,
|
||||
hidden: file_class == 'internal',
|
||||
role: role,
|
||||
feedback_message: role == 'teacher_defined_test' ? feedback_message_nodes.first.content : nil,
|
||||
file_type: FileType.find_by(
|
||||
file_extension: ".#{file_name_split.second}"
|
||||
),
|
||||
content: file.xpath('text()').first.content,
|
||||
read_only: false,
|
||||
hidden: file_class == 'internal',
|
||||
role: role,
|
||||
feedback_message: role == 'teacher_defined_test' ? feedback_message_nodes.first.content : nil,
|
||||
file_type: FileType.find_by(
|
||||
file_extension: ".#{file_name_split.second}"
|
||||
),
|
||||
})
|
||||
end
|
||||
self.execution_environment_id = 1
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user