Skip to content

Commit c8bafaa

Browse files
authored
Merge pull request #426 from openstax/ancillary-tag
Added ancillary column to spreadsheet import
2 parents d05a661 + b1a35d1 commit c8bafaa

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

app/routines/exercises/import/assessments.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def exec(filename:, book_uuid:)
2828

2929
pre_or_post_index = nil
3030

31+
ancillary_index = nil
3132
teks_index = nil
3233
machine_teks_index = nil
3334

@@ -69,7 +70,11 @@ def exec(filename:, book_uuid:)
6970
end
7071
raise ArgumentError, 'Could not find "Question Stem" column' if question_stem_index.nil?
7172

72-
uuid_index ||= headers.index { |header| header&.end_with?('uuid') && !header.include?('book') }
73+
uuid_index ||= headers.index do |header|
74+
header&.end_with?('uuid') && (
75+
header == 'uuid' || header.start_with?('page') || header.start_with?('section')
76+
)
77+
end
7378
section_index ||= headers.index do |header|
7479
header&.start_with?('section') && !header.include?('uuid') && !header.include?('name')
7580
end
@@ -87,6 +92,8 @@ def exec(filename:, book_uuid:)
8792
pre_or_post_index ||= headers.index { |header| header&.start_with?('pre') && header.end_with?('post') }
8893
Rails.logger.warn { 'Could not find "Pre or Post" column' } if pre_or_post_index.nil?
8994

95+
ancillary_index ||= headers.index { |header| header&.start_with?('ancillary') }
96+
9097
teks_index ||= headers.index { |header| header&.include?('teks') && !header.include?('machine') }
9198
machine_teks_index ||= headers.index { |header| header&.include?('machine') && header.include?('teks') }
9299

@@ -144,6 +151,9 @@ def exec(filename:, book_uuid:)
144151
unless pre_or_post_index.nil? || row[pre_or_post_index].blank?
145152
end
146153

154+
exercise.tags << "assessment:practice:https://openstax.org/orn/ancillary/#{row[ancillary_index]}" \
155+
unless ancillary_index.nil? || row[ancillary_index].blank?
156+
147157
unless teks_index.nil? || row[teks_index].blank?
148158
teks = row[teks_index].split(/,|;/).map(&:strip)
149159
teks.each { |tek| exercise.tags << "teks:#{tek}" }
55 Bytes
Binary file not shown.

spec/routines/exercises/import/assessments_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050

5151
expect(exercises[1].publication_group.nickname).to eq 'Q2'
5252
expect(Set.new exercises[1].tags.map(&:to_s)).to eq Set[
53+
'assessment:practice:https://openstax.org/orn/ancillary/e9779614-2fca-43cb-ae53-4af6d20e00ea',
5354
'assessment:practice:https://openstax.org/orn/book:page/62a49025-8cd8-407c-9cfb-c7eba55cf1c6:6c30d0cc-e435-4081-be68-5ff2f558cbec',
5455
'context-cnxmod:6c30d0cc-e435-4081-be68-5ff2f558cbec',
5556
'book-slug:college-success',

0 commit comments

Comments
 (0)