5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/kitchen/directions/bake_chapter_solutions/v1.rb', line 5
def bake(chapter:, metadata_source:, uuid_prefix: '', classes: %w[free-response])
solutions_clipboard = Kitchen::Clipboard.new
classes.each do |klass|
chapter.search("section.#{klass}").each do |question|
exercises = question.exercises
next if exercises.none?
exercises.each do |exercise|
solution = exercise.solution
next unless solution.present?
solution.cut(to: solutions_clipboard)
end
end
end
content = solutions_clipboard.paste
Kitchen::Directions::CompositePageContainer.v1(
container_key: 'solutions',
uuid_key: "#{uuid_prefix}solutions",
metadata_source: metadata_source,
content: content,
append_to: chapter
)
end
|