Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ GEM
rspec-mocks (~> 3.13)
rspec-support (~> 3.13)
rspec-support (3.13.4)
rubocop (1.76.2)
rubocop (1.77.0)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
Expand Down Expand Up @@ -942,7 +942,7 @@ CHECKSUMS
rspec-mocks (3.13.5) sha256=e4338a6f285ada9fe56f5893f5457783af8194f5d08884d17a87321d5195ea81
rspec-rails (8.0.1) sha256=0c3700b10ab6d7c648c4cd554023d8c2b5b07e7f01205f7608f0c511cf686505
rspec-support (3.13.4) sha256=184b1814f6a968102b57df631892c7f1990a91c9a3b9e80ef892a0fc2a71a3f7
rubocop (1.76.2) sha256=ae44f172ba0bbe3d623c927111798f85a7879bcc88e544d08f51f62c19f45633
rubocop (1.77.0) sha256=1f360b4575ef7a124be27b0dfffa227a2b2d9420d22d4fd8bf179d702bcc88c0
rubocop-ast (1.45.1) sha256=94042e49adc17f187ba037b33f941ba7398fede77cdf4bffafba95190a473a3e
rubocop-capybara (2.22.1) sha256=ced88caef23efea53f46e098ff352f8fc1068c649606ca75cb74650970f51c0c
rubocop-factory_bot (2.27.1) sha256=9d744b5916778c1848e5fe6777cc69855bd96548853554ec239ba9961b8573fe
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/community_solutions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
# If the first user did not save, the ReadMe file already exists
@files << CodeOcean::File.find_or_create_by!(new_readme_file)
end
all_visible_files = last_contribution.files.select(&:visible)
all_visible_files = last_contribution.files.select(&:visible?)

Check warning on line 35 in app/controllers/community_solutions_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/community_solutions_controller.rb#L35

Added line #L35 was not covered by tests
# Add the ReadMe file first
@files += all_visible_files.select {|f| CodeOcean::File.find_by(id: f.file_id)&.context_type == 'CommunitySolution' }
# Then, add all remaining files and sort them by name with extension
@files += (all_visible_files - @files).sort_by(&:filepath)

# Own Submission as a reference
@own_files = @submission.collect_files.select(&:visible).sort_by(&:filepath)
@own_files = @submission.collect_files.select(&:visible?).sort_by(&:filepath)

Check warning on line 42 in app/controllers/community_solutions_controller.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/community_solutions_controller.rb#L42

Added line #L42 was not covered by tests
# Remove the file_id from the second graph. Otherwise, the comparison and file-tree selection does not work as expected
@own_files.map do |file|
file.file_id = nil
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/exercises_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def implement # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedC
@hide_rfc_button = @embed_options[:disable_rfc]

@submission = current_contributor.submissions.order(created_at: :desc).find_by(exercise: @exercise)
@files = (@submission ? @submission.collect_files : @exercise.files).select(&:visible).sort_by(&:filepath)
@files = (@submission ? @submission.collect_files : @exercise.files).select(&:visible?).sort_by(&:filepath)
@paths = collect_paths(@files)
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def set_files_and_specific_file
end

def set_files
@files = @submission.collect_files.select(&:visible)
@files = @submission.collect_files.select(&:visible?)
end

def set_submission
Expand Down
2 changes: 1 addition & 1 deletion app/models/code_ocean/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def set_default_values
end
private :set_default_values

def visible
def visible?
!hidden
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/exercise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def get_quantiles(quantiles)
SELECT unnest(percentile_cont(#{self.class.sanitize_sql(['array[?]', quantiles])}) within GROUP (ORDER BY working_time))
FROM result
")
if result.count.positive?
if result.any?
quantiles.each_with_index.map {|_q, i| parse_duration(result[i]['unnest']).to_f }
else
quantiles.map {|_q| 0 }
Expand Down Expand Up @@ -512,7 +512,7 @@ def set_default_values
private :set_default_values

def valid_main_file?
if files.count(&:main_file?) > 1
if files.many?(&:main_file?)
errors.add(:files, :at_most_one_main_file)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/testrun_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def self.validate_and_store!(messages)
private_class_method :validate_and_store!

def either_data_or_log
if [data, log].count(&:present?) > 1
if [data, log].many?(&:present?)
errors.add(log, "can't be present if data is also present")
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_form_errors.html.slim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- if object.errors.any?
#error_explanation.alert.alert-warning
h4 = "#{t("shared.errors_#{object.errors.count == 1 ? 'one' : 'other'}", count: object.errors.count, model: object.class.model_name.human)}:"
h4 = "#{t("shared.errors_#{object.errors.one? ? 'one' : 'other'}", count: object.errors.count, model: object.class.model_name.human)}:"
ul
- object.errors.full_messages.each do |message|
li = message
2 changes: 1 addition & 1 deletion app/views/submissions/show.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ json.files @submission.files do |file|
json.extract! file, :id, :file_id
end
unless @embed_options[:disable_download]
json.render_url @submission.collect_files.select(&:visible) do |files|
json.render_url @submission.collect_files.select(&:visible?) do |files|
host = ApplicationController::RENDER_HOST || request.host
url = render_submission_url(@submission, files.filepath, host:)

Expand Down
8 changes: 4 additions & 4 deletions lib/java21_study.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
# frozen_string_literal: true

class Java21Study
def self.get_for(exercise)
def self.get_for?(exercise)
java21_collection = ExerciseCollection.find_by(name: 'java2021', id: 13)

exercise.exercise_collections.include? java21_collection
end

def self.show_tips_intervention?(user, exercise)
java21_exercise = get_for(exercise)
java21_exercise = get_for?(exercise)

Check warning on line 11 in lib/java21_study.rb

View check run for this annotation

Codecov / codecov/patch

lib/java21_study.rb#L11

Added line #L11 was not covered by tests
return false unless java21_exercise # Exercise is not part of the experiment

user_group = UserGroupSeparator.get_intervention_group(user.id)
user_group == :show_tips_intervention
end

def self.show_break_intervention?(user, exercise)
java21_exercise = get_for(exercise)
java21_exercise = get_for?(exercise)
return false unless java21_exercise # Exercise is not part of the experiment

user_group = UserGroupSeparator.get_intervention_group(user.id)
user_group == :show_break_intervention
end

def self.allow_redirect_to_community_solution?(user, exercise)
java21_exercise = get_for(exercise)
java21_exercise = get_for?(exercise)
return false unless java21_exercise # Exercise is not part of the experiment

user_group = UserGroupSeparator.get_community_solution_group(user.id)
Expand Down
2 changes: 1 addition & 1 deletion spec/system/editor_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

it 'displays all visible files in a file tree' do
within('#files') do
exercise.files.select(&:visible).each do |file|
exercise.files.select(&:visible?).each do |file|
expect(page).to have_content(file.name_with_extension)
end
end
Expand Down