Skip to content

Commit 83106db

Browse files
authored
Merge branch 'main' into nursing-internal-table-columns
2 parents 8cb980d + 5c673f6 commit 83106db

File tree

9 files changed

+202
-79
lines changed

9 files changed

+202
-79
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased]
88

99
* Bake `TableColumns` in `nursing-internal`
10+
* Create `v4` of `introduction` order
11+
* Bake `unfolding-casestudy` note exercises in `nursing-internal`
1012
* Add translations for notes titles and eoc sections to `pl-marketing`
1113
* Create `V2` of `BakeChapterGlossary`
1214
* Change `note titles` in `information systems`

lib/kitchen/directions/bake_chapter_introductions/v2.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ def order(options:, introduction_page:, chapter_intro_html:, title:)
5757
chapter_intro_html: chapter_intro_html,
5858
title: title
5959
)
60+
when :v4
61+
v4_introduction_order(
62+
introduction_page: introduction_page,
63+
chapter_intro_html: chapter_intro_html,
64+
title: title
65+
)
6066
end
6167
end
6268

@@ -120,6 +126,27 @@ def v3_introduction_order(introduction_page:, chapter_intro_html:, title:)
120126
)
121127
end
122128

129+
def v4_introduction_order(introduction_page:, chapter_intro_html:, title:)
130+
intro_content = introduction_page.search(
131+
"> :not([data-type='metadata']):not(.splash):not(.has-splash):not(.meet-author)"
132+
).cut
133+
134+
meet_author_note = introduction_page.search('[data-type="note"].meet-author').cut
135+
136+
introduction_page.append(child:
137+
<<~HTML
138+
<div class="intro-body">
139+
#{chapter_intro_html}
140+
#{meet_author_note.paste}
141+
<div class="intro-text">
142+
#{title.paste}
143+
#{intro_content.paste}
144+
</div>
145+
</div>
146+
HTML
147+
)
148+
end
149+
123150
def bake_title(introduction_page:)
124151
introduction_page.search(
125152
'div[data-type="description"], div[data-type="abstract"]'

lib/recipes/neuroscience/recipe.rb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020

2121
BakeUnitTitle.v1(book: book)
2222
BakeChapterTitle.v1(book: book)
23+
BakeChapterIntroductions.v2(
24+
book: book,
25+
options: {
26+
strategy: :add_objectives,
27+
bake_chapter_outline: true,
28+
introduction_order: :v4
29+
}
30+
)
2331

2432
book.chapters.each do |chapter|
2533
BakeNonIntroductionPages.v1(chapter: chapter)
@@ -82,7 +90,6 @@
8290

8391
BakeUnnumberedTables.v1(book: book)
8492
BakeTableColumns.v1(book: book)
85-
BakeChapterIntroductions.v1(book: book)
8693
BakeIframes.v1(book: book)
8794
BakeFootnotes.v1(book: book)
8895
BakeIndex.v1(book: book)

lib/recipes/nursing-internal/recipe.rb

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -84,34 +84,16 @@
8484
BakeChapterReferences.v3(chapter: chapter, metadata_source: metadata)
8585

8686
# Exercises
87-
chapter.search('section.review-questions').injected_questions.each do |question|
88-
BakeInjectedExerciseQuestion.v1(question: question, number: question.count_in(:chapter))
89-
BakeFirstElements.v1(within: question)
90-
end
91-
92-
chapter.search('section.check-understanding').injected_questions.each do |question|
93-
BakeInjectedExerciseQuestion.v1(question: question, number: question.count_in(:chapter))
94-
BakeFirstElements.v1(within: question)
95-
end
96-
97-
chapter.search('section.critical-thinking').injected_questions.each do |question|
98-
BakeInjectedExerciseQuestion.v1(question: question, number: question.count_in(:chapter))
99-
BakeFirstElements.v1(within: question)
100-
end
101-
102-
chapter.search('section.competency-based').injected_questions.each do |question|
103-
BakeInjectedExerciseQuestion.v1(question: question, number: question.count_in(:chapter))
104-
BakeFirstElements.v1(within: question)
105-
end
106-
107-
chapter.search('section.reflection-questions').injected_questions.each do |question|
108-
BakeInjectedExerciseQuestion.v1(question: question, number: question.count_in(:chapter))
109-
BakeFirstElements.v1(within: question)
110-
end
111-
112-
chapter.search('section.what-nurses-do').injected_questions.each do |question|
113-
BakeInjectedExerciseQuestion.v1(question: question, number: question.count_in(:chapter))
114-
BakeFirstElements.v1(within: question)
87+
exercise_sections_or_notes = %w[
88+
section.review-questions section.check-understanding section.critical-thinking
89+
section.competency-based section.reflection-questions section.what-nurses-do
90+
div[data-type="note"].unfolding-casestudy
91+
]
92+
exercise_sections_or_notes.each do |selector|
93+
chapter.search(selector).injected_questions.each do |question|
94+
BakeInjectedExerciseQuestion.v1(question: question, number: question.count_in(:chapter))
95+
BakeFirstElements.v1(within: question)
96+
end
11597
end
11698

11799
# Answer Key
@@ -121,6 +103,11 @@
121103
append_to: answer_key
122104
)
123105

106+
MoveSolutionsFromNumberedNote.v1(
107+
chapter: chapter, append_to: answer_key_inner_container,
108+
note_class: 'unfolding-casestudy'
109+
)
110+
124111
exercises = %w[review-questions check-understanding
125112
reflection-questions critical-thinking
126113
what-nurses-do competency-based]

spec/kitchen_spec/directions/bake_chapter_introductions/v2_spec.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,32 @@
131131
)
132132
end
133133

134+
let(:book_with_meet_author) do
135+
book_containing(html:
136+
<<~HTML
137+
<div data-type="chapter">
138+
<h1 data-type="document-title">Chapter 1 Title</h1>
139+
<div class="introduction" data-type="page" id="testid1">
140+
<div data-type="document-title">Introduction</div>
141+
<figure class="splash">
142+
<div data-type="title">Blood Pressure</div>
143+
<figcaption>A proficiency in anatomy and physiology... (credit: Bryan Mason/flickr)</figcaption>
144+
<span data-type="media" data-alt="This photo shows a nurse taking a woman’s...">
145+
<img src="ccc4ed14-6c87-408b-9934-7a0d279d853a/100_Blood_Pressure.jpg" data-media-type="image/jpg" alt="This photo shows a nurse taking..." />
146+
</span>
147+
</figure>
148+
<div data-type="note" class="meet-author">
149+
<div data-type="title">Understanding the Marketplace</div>
150+
<p>Welcome to Part II of Principles of Marketing...</p>
151+
</div>
152+
<p id="123">Though you may approach a course in anatomy and physiology...</p>
153+
<p id="123">This chapter begins with an overview of anatomy and...</p>
154+
</div>
155+
</div>
156+
HTML
157+
)
158+
end
159+
134160
let(:book_with_intro_module_title_children) do
135161
book_containing(html:
136162
<<~HTML
@@ -213,6 +239,16 @@
213239
end
214240
end
215241

242+
context 'when v2 is called on book with meet author note' do
243+
it 'bakes' do
244+
described_class.v2(
245+
book: book_with_meet_author,
246+
options: { strategy: :default, bake_chapter_outline: true, introduction_order: :v4 }
247+
)
248+
expect(book_with_meet_author.body).to match_snapshot_auto
249+
end
250+
end
251+
216252
context 'when v2 is called with strategy: add_objectives' do
217253
it 'works' do
218254
described_class.v2(

0 commit comments

Comments
 (0)