Skip to content

Commit 4be2162

Browse files
authored
Merge pull request #415 from openstax/skip-blank-rows
CORE-817 When importing exercises, skip blank rows
2 parents 023fba7 + 1772ff0 commit 4be2162

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

app/routines/exercises/import/assessments.rb

+8-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,16 @@ def exec(filename:, book_uuid:)
5555
detailed_solution_index ||= headers.index { |header| header&.end_with?('solution') }
5656
raise ArgumentError, 'Could not find "Detailed Solution" column' if detailed_solution_index.nil?
5757

58-
exercise = Exercise.new
58+
row_number = row_index + 1
5959

6060
page_uuid = row[uuid_index]
61+
if page_uuid.blank?
62+
Rails.logger.info { "Skipped row ##{row_number} with blank page UUID" }
63+
next
64+
end
65+
66+
exercise = Exercise.new
67+
6168
exercise.tags = [
6269
"assessment:#{row[pre_or_post_index].downcase == 'pre' ? 'preparedness' : 'practice'
6370
}:https://openstax.org/orn/book:page/#{book_uuid}:#{page_uuid}",
@@ -93,8 +100,6 @@ def exec(filename:, book_uuid:)
93100
question.collaborator_solutions << solution
94101
end
95102

96-
row_number = row_index + 1
97-
98103
begin
99104
exercise.save!
100105
exercise.publication.publish.save!

0 commit comments

Comments
 (0)