@@ -69,15 +69,17 @@ def exec(filename:, book_uuid:)
69
69
end
70
70
raise ArgumentError , 'Could not find "Question Stem" column' if question_stem_index . nil?
71
71
72
- uuid_index ||= headers . index { |header | header == 'uuid' || header == 'page uuid' }
73
- section_index ||= headers . index { |header | header == 'section' }
72
+ uuid_index ||= headers . index do |header |
73
+ header == 'uuid' || header == 'page uuid' || header == 'section uuid'
74
+ end
75
+ section_index ||= headers . index { |header | header == 'section' || header == 'section number' }
74
76
Rails . logger . warn { 'Could not find "UUID" or "Section" columns' } \
75
77
if uuid_index . nil? && section_index . nil?
76
78
77
79
unless section_index . nil?
78
80
book = OpenStax ::Content ::Abl . new . approved_books . find { |book | book . uuid == book_uuid }
79
- book . all_pages . each { |page | page_uuid_by_book_location [ page . book_location ] = page . uuid }
80
81
raise ArgumentError , "Could not find book with UUID #{ book_uuid } in the ABL" if book . nil?
82
+ book . all_pages . each { |page | page_uuid_by_book_location [ page . book_location ] = page . uuid }
81
83
end
82
84
83
85
nickname_index ||= headers . index { |header | header &.include? ( 'nickname' ) }
@@ -168,7 +170,6 @@ def exec(filename:, book_uuid:)
168
170
exercise . questions << question
169
171
170
172
stem = Stem . new ( content : parse ( row [ question_stem_index ] , exercise ) )
171
- stem . stylings << Styling . new ( style : ::Style ::MULTIPLE_CHOICE )
172
173
question . stems << stem
173
174
174
175
unless detailed_solution_index . nil? || row [ detailed_solution_index ] . blank?
@@ -179,7 +180,12 @@ def exec(filename:, book_uuid:)
179
180
question . collaborator_solutions << solution
180
181
end
181
182
182
- next if correct_answer_index . nil? || row [ correct_answer_index ] . blank?
183
+ if correct_answer_index . nil? || row [ correct_answer_index ] . blank?
184
+ stem . stylings << Styling . new ( style : ::Style ::FREE_RESPONSE )
185
+ next
186
+ end
187
+
188
+ stem . stylings << Styling . new ( style : ::Style ::MULTIPLE_CHOICE )
183
189
184
190
correct_answer = row [ correct_answer_index ] . downcase . strip . each_byte . first - 97
185
191
answer_choice_indices . each_with_index do |row_index , answer_index |
0 commit comments