Skip to content

Commit

Permalink
Check that handout/writeup exists before checking path (#2001)
Browse files Browse the repository at this point in the history
Move present? check to front
  • Loading branch information
damianhxy authored Nov 4, 2023
1 parent 5ce46a0 commit 21cb413
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/models/assessment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def writeup_is_url?

def writeup_is_file?
# Ensure that writeup lies within the assessment folder
Archive.in_dir?(writeup_path, folder_path) && is_file?(writeup)
writeup.present? && Archive.in_dir?(writeup_path, folder_path) && is_file?(writeup)
end

def handout_is_url?
Expand All @@ -292,7 +292,7 @@ def handout_is_url?

def handout_is_file?
# Ensure that handout lies within the assessment folder
Archive.in_dir?(handout_path, folder_path) && is_file?(handout)
handout.present? && Archive.in_dir?(handout_path, folder_path) && is_file?(handout)
end

# raw_score
Expand Down Expand Up @@ -543,7 +543,7 @@ def max_score!
end

def is_file?(name)
name.present? && File.file?(path(name))
File.file?(path(name))
end

def verify_dates_order
Expand Down

0 comments on commit 21cb413

Please sign in to comment.