openstax_kitchen 12.1.0 → 15.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +42 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +3 -3
- data/codecov.yaml +4 -0
- data/lib/kitchen/directions/bake_all_chapter_solutions_types.rb +30 -0
- data/lib/kitchen/directions/bake_all_numbered_exercise_types.rb +26 -0
- data/lib/kitchen/directions/bake_annotation_classes/main.rb +2 -2
- data/lib/kitchen/directions/bake_annotation_classes/v1.rb +3 -3
- data/lib/kitchen/directions/bake_appendix.rb +1 -0
- data/lib/kitchen/directions/bake_autotitled_exercise/main.rb +4 -0
- data/lib/kitchen/directions/bake_autotitled_exercise/v2.rb +33 -0
- data/lib/kitchen/directions/bake_chapter_glossary/v1.rb +3 -1
- data/lib/kitchen/directions/bake_chapter_references/v1.rb +1 -1
- data/lib/kitchen/directions/bake_chapter_solutions/v1.rb +1 -1
- data/lib/kitchen/directions/bake_chapter_summary.rb +1 -1
- data/lib/kitchen/directions/bake_example.rb +1 -1
- data/lib/kitchen/directions/bake_figure.rb +1 -15
- data/lib/kitchen/directions/bake_iframes/v1.rb +2 -0
- data/lib/kitchen/directions/bake_index/v1.xhtml.erb +5 -9
- data/lib/kitchen/directions/bake_injected_exercise/add_injected_exercise_id.rb +16 -0
- data/lib/kitchen/directions/{bake_injected_exercise_question.rb → bake_injected_exercise/bake_injected_exercise_question.rb} +0 -0
- data/lib/kitchen/directions/bake_learning_objectives.rb +13 -0
- data/lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb +1 -14
- data/lib/kitchen/directions/bake_notes/bake_note_exercise.rb +54 -0
- data/lib/kitchen/directions/bake_notes/bake_note_injected_question.rb +15 -0
- data/lib/kitchen/directions/bake_notes/bake_numbered_notes/main.rb +0 -31
- data/lib/kitchen/directions/bake_notes/bake_numbered_notes/v1.rb +2 -2
- data/lib/kitchen/directions/bake_notes/bake_numbered_notes/v2.rb +2 -2
- data/lib/kitchen/directions/bake_notes/bake_numbered_notes/v3.rb +2 -2
- data/lib/kitchen/directions/bake_notes/bake_unclassified_notes.rb +5 -3
- data/lib/kitchen/directions/bake_numbered_exercise/main.rb +8 -3
- data/lib/kitchen/directions/bake_numbered_exercise/v1.rb +48 -7
- data/lib/kitchen/directions/bake_numbered_table/bake_table_body.rb +6 -0
- data/lib/kitchen/directions/bake_references/main.rb +6 -9
- data/lib/kitchen/directions/bake_references/v1.rb +9 -8
- data/lib/kitchen/directions/bake_references/v2.rb +9 -10
- data/lib/kitchen/directions/bake_references/v3.rb +32 -0
- data/lib/kitchen/directions/bake_unnumbered_exercise.rb +16 -0
- data/lib/kitchen/directions/bake_unnumbered_figure.rb +26 -0
- data/lib/kitchen/directions/bake_unnumbered_tables.rb +1 -0
- data/lib/kitchen/directions/book_answer_key_container/eob_answer_key_container.xhtml.erb +9 -0
- data/lib/kitchen/directions/book_answer_key_container/v1.rb +6 -2
- data/lib/kitchen/directions/{eoc_composite_page_container → composite_page_container}/main.rb +1 -1
- data/lib/kitchen/directions/composite_page_container/v1.rb +28 -0
- data/lib/kitchen/directions/default_strategy_for_answer_key_solutions.rb +35 -0
- data/lib/kitchen/directions/move_custom_section_to_eoc_container/v1.rb +1 -1
- data/lib/kitchen/directions/move_solutions_to_answer_key/answer_key_inner_container.rb +29 -0
- data/lib/kitchen/element_base.rb +2 -18
- data/lib/kitchen/element_enumerator_base.rb +35 -0
- data/lib/kitchen/figure_element.rb +12 -4
- data/lib/kitchen/note_element.rb +7 -1
- data/lib/kitchen/patches/renderable.rb +1 -1
- data/lib/kitchen/section_element.rb +27 -0
- data/lib/kitchen/section_element_enumerator.rb +20 -0
- data/lib/kitchen/selectors/base.rb +3 -0
- data/lib/kitchen/selectors/standard_1.rb +1 -0
- data/lib/kitchen/table_element.rb +8 -0
- data/lib/kitchen/templates/composite_page_template.xhtml.erb +10 -0
- data/lib/kitchen/version.rb +1 -1
- data/lib/locales/en.yml +4 -0
- data/lib/locales/es.yml +9 -1
- data/lib/locales/pl.yml +3 -0
- metadata +20 -14
- data/lib/kitchen/directions/book_answer_key_container/eob_answer_key_outer_container.xhtml.erb +0 -9
- data/lib/kitchen/directions/eoc_composite_page_container/v1.rb +0 -19
- data/lib/kitchen/directions/move_solutions_to_answer_key/main.rb +0 -18
- data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/calculus.rb +0 -41
- data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/contemporary_math.rb +0 -40
- data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/default.rb +0 -27
- data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/precalculus.rb +0 -63
- data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/uphysics.rb +0 -21
- data/lib/kitchen/directions/move_solutions_to_answer_key/v1.rb +0 -45
- data/lib/kitchen/templates/eoc_section_template.xhtml.erb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 074dfc264ca97aab5805a3ab189b49fe1e97a1108366b592b5599a70e15f1345
|
4
|
+
data.tar.gz: fee3491d899d7983e55e5c6eb22010b49d23e8dd43e54ca97950a7be2fbda93f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9a5936f931cf6b1c3485543adf375426d71b444109c68fc80b0a06ef6f953e4ac43cd40b27941c06dec0541e02dd2b3387074aa8a956821cdca781f97607f1d
|
7
|
+
data.tar.gz: 13d5bf302fe8144acef670f017bc8393847292d37f4a4dae68922cbf56c52da41c18719ec586ca1b5b1a135dc0c303e168f5515903e2b667299347cba909e7d4
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,48 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [15.0.0] - 2021-11-05
|
10
|
+
|
11
|
+
* Add unstyled tables to `BakeTableBody` (minor)
|
12
|
+
* Add to `BakeNumberedExercises` rules for baking exercises in appendecies (minor)
|
13
|
+
* Add `BakeUnnumberedExercise` direction (minor)
|
14
|
+
* Change whitespace for `BakeIndex` and `BakeExample` (major)
|
15
|
+
* Add `BakeAllNumberedExerciseTypes` direction for easier baking of compound sections (minor)
|
16
|
+
* Add `solution_stays_put` option for `BakeNumberedExercise` (minor)
|
17
|
+
* Add `BakeAllChapterSolutionsTypes` direction to move injected solutions and regular ones to EOC (minor)
|
18
|
+
* Refactor: moves all `Answer key strategies` that are book-specific to the
|
19
|
+
recipes side and keeps the `Default Strategy`in kitchen (major)
|
20
|
+
* Adds missing spanish translations (minor)
|
21
|
+
|
22
|
+
## [14.0.0] - 2021-10-22
|
23
|
+
|
24
|
+
* Fix `BakeAutotitledExercise` V2 to stop breaking for exercises without solutions (patch)
|
25
|
+
* Add `BakeAutotitledExercise` V2 (minor)
|
26
|
+
* Fix `BakeChapterGlossary::V1` to stop adding an empty wrapper if there is no content (patch)
|
27
|
+
* Create `BakeNoteExercise` and `BakeNoteInjectedQuestion` and support exercises in `BakeUnclassifiedNotes` (minor)
|
28
|
+
* Add baking section with class `column header` to `BakeAppendix` (patch)
|
29
|
+
* Expand `BakeAnnotationClasses` to book from chapter to bake also paragraphs from Preface (major)
|
30
|
+
* Create separate direction `BakeUnnumberedFigure`, clean `BakeFigure` to not match unnumbered figures , rename and update `figure_to_bake?` method to `figure_to_number?` to support only numbered figures except subfigures (major)
|
31
|
+
|
32
|
+
## [13.0.0] - 2021-10-6
|
33
|
+
|
34
|
+
* Add `BakeLearningObjectives` v3 (minor)
|
35
|
+
* Fix `BakeIframes` to skip already-baked iframes (patch)
|
36
|
+
* Add `SectionElement` and `SectionElementEnumerator` classes (minor)
|
37
|
+
* Refactor `EocCompositePageContainer` to be used by `EOB` sections as well (major)
|
38
|
+
* Refactor `bake_references` `v1, v2 and v3` to use `CompositePageContainer` (major)
|
39
|
+
|
40
|
+
## [12.2.0] - 2021-10-1
|
41
|
+
|
42
|
+
* Add `context_lead_text` to translations (minor)
|
43
|
+
* Make `ElementBase#search_with` callable from an `ElementEnumerator` (minor)
|
44
|
+
* Support top-titled tables in `BakeUnnumberedTables` (minor)
|
45
|
+
* Stop `NoteElement#title` from breaking for empty notes (patch)
|
46
|
+
* Add text heavy tables to `BakeTableBody` (minor)
|
47
|
+
* Modify `BakeAutotitledNotes` to bake unnumbered exercises with solution (minor)
|
48
|
+
* Create `AddInjectedExerciseId` to separate creating ids from `BakeInjectedExerciseQuestion` (minor)
|
49
|
+
* Rework `AddInjectedExerciseId` to use loop inside module (minor)
|
50
|
+
|
9
51
|
## [12.1.0] - 2021-09-24
|
10
52
|
|
11
53
|
* Fix `BakeExample#titles_to_rename` to exclude exercise titles (patch)
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
openstax_kitchen (
|
4
|
+
openstax_kitchen (15.0.0)
|
5
5
|
activesupport
|
6
6
|
i18n
|
7
7
|
nokogiri
|
@@ -27,7 +27,7 @@ GEM
|
|
27
27
|
concurrent-ruby (1.1.9)
|
28
28
|
diff-lcs (1.3)
|
29
29
|
docile (1.4.0)
|
30
|
-
i18n (1.8.
|
30
|
+
i18n (1.8.11)
|
31
31
|
concurrent-ruby (~> 1.0)
|
32
32
|
inch (0.8.0)
|
33
33
|
pry
|
@@ -107,7 +107,7 @@ GEM
|
|
107
107
|
concurrent-ruby (~> 1.0)
|
108
108
|
unicode-display_width (1.7.0)
|
109
109
|
yard (0.9.24)
|
110
|
-
zeitwerk (2.
|
110
|
+
zeitwerk (2.5.1)
|
111
111
|
|
112
112
|
PLATFORMS
|
113
113
|
ruby
|
data/codecov.yaml
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen
|
4
|
+
module Directions
|
5
|
+
module BakeAllChapterSolutionsTypes
|
6
|
+
def self.v1(chapter:, within:, metadata_source:, uuid_prefix: '')
|
7
|
+
solutions_clipboard = Kitchen::Clipboard.new
|
8
|
+
|
9
|
+
within.search_with(ExerciseElementEnumerator, InjectedQuestionElementEnumerator)\
|
10
|
+
.each do |exercise|
|
11
|
+
|
12
|
+
solution = exercise.solution
|
13
|
+
next unless solution.present?
|
14
|
+
|
15
|
+
solution.cut(to: solutions_clipboard)
|
16
|
+
end
|
17
|
+
|
18
|
+
content = solutions_clipboard.paste
|
19
|
+
|
20
|
+
Kitchen::Directions::CompositePageContainer.v1(
|
21
|
+
container_key: 'solutions',
|
22
|
+
uuid_key: "#{uuid_prefix}solutions",
|
23
|
+
metadata_source: metadata_source,
|
24
|
+
content: content,
|
25
|
+
append_to: chapter
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen
|
4
|
+
module Directions
|
5
|
+
module BakeAllNumberedExerciseTypes
|
6
|
+
def self.v1(within:, exercise_options: {}, question_options: {})
|
7
|
+
exercise_counter = 1
|
8
|
+
within.search_with(ExerciseElementEnumerator, InjectedQuestionElementEnumerator)\
|
9
|
+
.each do |exercise|
|
10
|
+
next if exercise.has_class?('unnumbered')
|
11
|
+
|
12
|
+
if exercise.instance_of?(ExerciseElement)
|
13
|
+
exercise_options[:exercise] = exercise
|
14
|
+
exercise_options[:number] = exercise_counter
|
15
|
+
BakeNumberedExercise.v1(exercise_options)
|
16
|
+
else
|
17
|
+
question_options[:number] = exercise_counter
|
18
|
+
question_options[:question] = exercise
|
19
|
+
BakeInjectedExerciseQuestion.v1(question_options)
|
20
|
+
end
|
21
|
+
exercise_counter += 1
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
module Kitchen::Directions::BakeAnnotationClasses
|
4
4
|
class V1
|
5
|
-
def bake(
|
6
|
-
|
5
|
+
def bake(book:)
|
6
|
+
book.search('p.annotation').each do |annotation|
|
7
7
|
annotation.wrap_children('span', class: 'os-text')
|
8
8
|
annotation.prepend(child:
|
9
9
|
<<~HTML
|
@@ -19,7 +19,7 @@ module Kitchen::Directions::BakeAnnotationClasses
|
|
19
19
|
auditory-icon
|
20
20
|
kinesthetic-icon]
|
21
21
|
annotation_icon_classes.each do |annotation_icon_class|
|
22
|
-
|
22
|
+
book.search("p.#{annotation_icon_class}").each do |annotation_with_icon_class|
|
23
23
|
annotation_with_icon_class.search('div.os-icons').first.append(child:
|
24
24
|
<<~HTML
|
25
25
|
<span class = "#{annotation_icon_class}"></span>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen::Directions::BakeAutotitledExercise
|
4
|
+
# Differences from V1:
|
5
|
+
# 1. Title is an <h3><span>, not <h4>, & above the problem instead of within it
|
6
|
+
# 2. Title is generated in the recipe and passed to the method
|
7
|
+
class V2
|
8
|
+
def bake(exercise:, title:)
|
9
|
+
exercise.add_class('unnumbered')
|
10
|
+
exercise.titles.first&.trash
|
11
|
+
|
12
|
+
# bake problem
|
13
|
+
exercise.prepend(child:
|
14
|
+
<<~HTML
|
15
|
+
<h3 class="os-title" data-type="title">
|
16
|
+
<span class="os-title-label">#{title}</span>
|
17
|
+
</h3>
|
18
|
+
HTML
|
19
|
+
)
|
20
|
+
exercise.problem.wrap_children(class: 'os-problem-container')
|
21
|
+
return unless exercise.solution
|
22
|
+
|
23
|
+
exercise.solution.wrap_children(class: 'os-solution-container')
|
24
|
+
exercise.solution.prepend(child:
|
25
|
+
<<~HTML
|
26
|
+
<h4 class="solution-title" data-type="title">
|
27
|
+
<span class="os-text">#{I18n.t(:solution)}</span>
|
28
|
+
</h4>
|
29
|
+
HTML
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -41,7 +41,9 @@ module Kitchen::Directions::BakeChapterGlossary
|
|
41
41
|
|
42
42
|
content = @glossary.sort.map { |definition| definition.element.paste }.join
|
43
43
|
|
44
|
-
|
44
|
+
return if content.empty?
|
45
|
+
|
46
|
+
Kitchen::Directions::CompositePageContainer.v1(
|
45
47
|
container_key: 'glossary',
|
46
48
|
uuid_key: "#{uuid_prefix}glossary",
|
47
49
|
metadata_source: metadata_source,
|
@@ -11,7 +11,7 @@ module Kitchen::Directions::BakeChapterReferences
|
|
11
11
|
|
12
12
|
content = chapter.pages.references.cut.paste
|
13
13
|
|
14
|
-
Kitchen::Directions::
|
14
|
+
Kitchen::Directions::CompositePageContainer.v1(
|
15
15
|
container_key: klass,
|
16
16
|
uuid_key: "#{uuid_prefix}#{klass}",
|
17
17
|
metadata_source: metadata_source,
|
@@ -23,7 +23,7 @@ module Kitchen::Directions::BakeChapterSolutions
|
|
23
23
|
|
24
24
|
content = solutions_clipboard.paste
|
25
25
|
|
26
|
-
Kitchen::Directions::
|
26
|
+
Kitchen::Directions::CompositePageContainer.v1(
|
27
27
|
container_key: 'solutions',
|
28
28
|
uuid_key: "#{uuid_prefix}solutions",
|
29
29
|
metadata_source: metadata_source,
|
@@ -39,7 +39,7 @@ module Kitchen
|
|
39
39
|
solution.replace_children(with:
|
40
40
|
<<~HTML
|
41
41
|
<h4 data-type="solution-title">
|
42
|
-
<span class="os-title-label">#{I18n.t(:solution)}
|
42
|
+
<span class="os-title-label">#{I18n.t(:solution)}</span>
|
43
43
|
#{solution_number}
|
44
44
|
</h4>
|
45
45
|
<div class="os-solution-container">#{solution.children}</div>
|
@@ -4,27 +4,13 @@ module Kitchen
|
|
4
4
|
module Directions
|
5
5
|
module BakeFigure
|
6
6
|
def self.v1(figure:, number:, cases: false)
|
7
|
-
|
8
|
-
|
7
|
+
warn 'warning! exclude unnumbered figures from `BakeFigure` loop' if figure.unnumbered?
|
9
8
|
figure.wrap(%(<div class="os-figure#{' has-splash' if figure.has_class?('splash')}">))
|
10
9
|
|
11
|
-
if figure.has_class?('unnumbered') && (figure.caption || figure.has_class?('splash'))
|
12
|
-
caption = figure.caption&.cut
|
13
|
-
figure.append(sibling:
|
14
|
-
<<~HTML
|
15
|
-
<div class="os-caption-container">
|
16
|
-
#{"<span class=\"os-caption\">#{caption.children}</span>" if caption}
|
17
|
-
</div>
|
18
|
-
HTML
|
19
|
-
)
|
20
|
-
return
|
21
|
-
end
|
22
|
-
|
23
10
|
# Store label information
|
24
11
|
figure.target_label(label_text: 'figure', custom_content: number, cases: cases)
|
25
12
|
|
26
13
|
title = figure.title&.cut
|
27
|
-
|
28
14
|
caption = figure.caption&.cut
|
29
15
|
figure.append(sibling:
|
30
16
|
<<~HTML
|
@@ -7,6 +7,8 @@ module Kitchen::Directions::BakeIframes
|
|
7
7
|
return unless iframes.any?
|
8
8
|
|
9
9
|
iframes.each do |iframe|
|
10
|
+
next if iframe.has_class?('os-is-iframe')
|
11
|
+
|
10
12
|
iframe.wrap('<div class="os-has-iframe" data-type="alternatives">')
|
11
13
|
iframe.add_class('os-is-iframe')
|
12
14
|
link_ref = iframe[:src]
|
@@ -11,16 +11,12 @@
|
|
11
11
|
<span class="group-label"><%= section.name %></span>
|
12
12
|
<% section.items.each do |item| %>
|
13
13
|
<div class="os-index-item">
|
14
|
-
|
15
|
-
|
14
|
+
<%- item.terms.each_with_index do |term, ii| -%>
|
15
|
+
<%- if ii == 0 -%>
|
16
16
|
<span class="os-term" group-by="<%= term.group_by %>"><%= term.text %></span>
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
<a class="os-term-section-link" href="#<%= term.id %>">
|
21
|
-
<span class="os-term-section"><%= term.page_title %></span>
|
22
|
-
</a>
|
23
|
-
<% end %>
|
17
|
+
<%- else -%><span class="os-index-link-separator">, </span><% end %>
|
18
|
+
<a class="os-term-section-link" href="#<%= term.id %>"><span class="os-term-section"><%= term.page_title %></span></a><!--
|
19
|
+
--><%- end %>
|
24
20
|
</div>
|
25
21
|
<% end %>
|
26
22
|
</div>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen
|
4
|
+
module Directions
|
5
|
+
# Ids should be added before exercises are moved to EOC,
|
6
|
+
# since they're using part of the ancestor page id.
|
7
|
+
#
|
8
|
+
# In some books exercises are numbered after moving.
|
9
|
+
# That's why this step has to be separated from BakeInjectedExerciseQuestion
|
10
|
+
module AddInjectedExerciseId
|
11
|
+
def self.v1(book:)
|
12
|
+
book.pages.injected_questions.each(&:id)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
File without changes
|
@@ -30,6 +30,19 @@ module Kitchen
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
# Wraps & moves abstract under the corresponding chapter objective in the intro page
|
35
|
+
def self.v3(chapter:)
|
36
|
+
abstracts = chapter.abstracts.map do |abstract|
|
37
|
+
abstract.wrap('<div class="learning-objective">')
|
38
|
+
abstract.parent
|
39
|
+
end
|
40
|
+
|
41
|
+
chapter.introduction_page.search('div.os-chapter-objective') \
|
42
|
+
.each_with_index do |objective, index|
|
43
|
+
objective.append(child: abstracts[index].cut.paste)
|
44
|
+
end
|
45
|
+
end
|
33
46
|
end
|
34
47
|
end
|
35
48
|
end
|
@@ -30,20 +30,7 @@ module Kitchen
|
|
30
30
|
HTML
|
31
31
|
)
|
32
32
|
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.bake_unclassified_exercises(note:)
|
37
|
-
note.exercises.each do |exercise|
|
38
|
-
exercise.problem.wrap_children('div', class: 'os-problem-container')
|
39
|
-
|
40
|
-
exercise.problem.prepend(child:
|
41
|
-
<<~HTML
|
42
|
-
<span class="os-title-label">#{I18n.t(:"exercises.exercise")} </span>
|
43
|
-
<span class="os-number">#{exercise.count_in(:note)}</span>
|
44
|
-
HTML
|
45
|
-
)
|
46
|
-
end
|
33
|
+
BakeNoteExercise.v2(note: note) if bake_exercises
|
47
34
|
end
|
48
35
|
end
|
49
36
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen
|
4
|
+
module Directions
|
5
|
+
module BakeNoteExercise
|
6
|
+
def self.v1(note:, exercise:, divider: ' ', suppress_solution: false)
|
7
|
+
exercise.add_class('unnumbered')
|
8
|
+
number = note.first('.os-number').text.gsub(/#/, '')
|
9
|
+
|
10
|
+
# bake problem
|
11
|
+
exercise.problem.wrap_children('div', class: 'os-problem-container')
|
12
|
+
exercise.search('[data-type="commentary"]').each(&:trash)
|
13
|
+
return unless exercise.solution
|
14
|
+
|
15
|
+
# bake solution in place
|
16
|
+
if suppress_solution
|
17
|
+
exercise.add_class('os-hasSolution')
|
18
|
+
exercise.solution.trash
|
19
|
+
else
|
20
|
+
BakeNumberedExercise.bake_solution_v1(
|
21
|
+
exercise: exercise,
|
22
|
+
number: number,
|
23
|
+
divider: divider
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.v2(note:)
|
29
|
+
note.exercises.each do |exercise|
|
30
|
+
exercise.problem.wrap_children('div', class: 'os-problem-container')
|
31
|
+
|
32
|
+
unless exercise.has_class?('unnumbered')
|
33
|
+
exercise.problem.prepend(child:
|
34
|
+
<<~HTML
|
35
|
+
<span class="os-title-label">#{I18n.t(:"exercises.exercise")} </span>
|
36
|
+
<span class="os-number">#{exercise.count_in(:note)}</span>
|
37
|
+
HTML
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
next unless exercise.solution
|
42
|
+
|
43
|
+
exercise.solution.wrap_children('div', class: 'os-solution-container')
|
44
|
+
|
45
|
+
exercise.solution.prepend(child:
|
46
|
+
<<~HTML
|
47
|
+
<span class="os-title-label">#{I18n.t(:"exercises.solution")}</span>
|
48
|
+
HTML
|
49
|
+
)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kitchen
|
4
|
+
module Directions
|
5
|
+
module BakeNoteInjectedQuestion
|
6
|
+
def self.v1(note:, question:)
|
7
|
+
question.add_class('unnumbered')
|
8
|
+
number = note.first('.os-number').text.gsub(/#/, '')
|
9
|
+
Kitchen::Directions::BakeInjectedExerciseQuestion.v1(
|
10
|
+
question: question, number: number, only_number_solution: true
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -17,37 +17,6 @@ module Kitchen
|
|
17
17
|
def self.v3(book:, classes:, suppress_solution: true)
|
18
18
|
V3.new.bake(book: book, classes: classes, suppress_solution: suppress_solution)
|
19
19
|
end
|
20
|
-
|
21
|
-
# Used by V1, V2, V3
|
22
|
-
def self.bake_note_exercise(note:, exercise:, divider: ' ', suppress_solution: false)
|
23
|
-
exercise.add_class('unnumbered')
|
24
|
-
number = note.first('.os-number').text.gsub(/#/, '')
|
25
|
-
|
26
|
-
# bake problem
|
27
|
-
exercise.problem.wrap_children('div', class: 'os-problem-container')
|
28
|
-
exercise.search('[data-type="commentary"]').each(&:trash)
|
29
|
-
return unless exercise.solution
|
30
|
-
|
31
|
-
# bake solution in place
|
32
|
-
if suppress_solution
|
33
|
-
exercise.add_class('os-hasSolution')
|
34
|
-
exercise.solution.trash
|
35
|
-
else
|
36
|
-
BakeNumberedExercise.bake_solution_v1(
|
37
|
-
exercise: exercise,
|
38
|
-
number: number,
|
39
|
-
divider: divider
|
40
|
-
)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def self.bake_note_injected_question(note:, question:)
|
45
|
-
question.add_class('unnumbered')
|
46
|
-
number = note.first('.os-number').text.gsub(/#/, '')
|
47
|
-
Kitchen::Directions::BakeInjectedExerciseQuestion.v1(
|
48
|
-
question: question, number: number, only_number_solution: true
|
49
|
-
)
|
50
|
-
end
|
51
20
|
end
|
52
21
|
end
|
53
22
|
end
|
@@ -8,10 +8,10 @@ module Kitchen::Directions
|
|
8
8
|
book.chapters.pages.notes("$.#{klass}").each do |note|
|
9
9
|
bake_note(note: note, cases: cases)
|
10
10
|
note.exercises.each do |exercise|
|
11
|
-
|
11
|
+
BakeNoteExercise.v1(note: note, exercise: exercise)
|
12
12
|
end
|
13
13
|
note.injected_questions.each do |question|
|
14
|
-
|
14
|
+
BakeNoteInjectedQuestion.v1(note: note, question: question)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -17,10 +17,10 @@ module Kitchen::Directions
|
|
17
17
|
HTML
|
18
18
|
)
|
19
19
|
note.exercises.each do |exercise|
|
20
|
-
|
20
|
+
BakeNoteExercise.v1(note: note, exercise: exercise, divider: '. ')
|
21
21
|
end
|
22
22
|
note.injected_questions.each do |question|
|
23
|
-
|
23
|
+
BakeNoteInjectedQuestion.v1(note: note, question: question)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -25,12 +25,12 @@ module Kitchen::Directions
|
|
25
25
|
|
26
26
|
note.title&.trash
|
27
27
|
note.exercises.each do |exercise|
|
28
|
-
|
28
|
+
BakeNoteExercise.v1(
|
29
29
|
note: note, exercise: exercise, divider: '. ', suppress_solution: suppress_solution
|
30
30
|
)
|
31
31
|
end
|
32
32
|
note.injected_questions.each do |question|
|
33
|
-
|
33
|
+
BakeNoteInjectedQuestion.v1(note: note, question: question)
|
34
34
|
end
|
35
35
|
|
36
36
|
note.search("div[data-type='solution']").each&.trash if suppress_solution
|
@@ -3,15 +3,15 @@
|
|
3
3
|
module Kitchen
|
4
4
|
module Directions
|
5
5
|
module BakeUnclassifiedNotes
|
6
|
-
def self.v1(book:)
|
6
|
+
def self.v1(book:, bake_exercises: false)
|
7
7
|
book.notes.each do |note|
|
8
8
|
next unless note.classes.empty?
|
9
9
|
|
10
|
-
bake_note(note: note)
|
10
|
+
bake_note(note: note, bake_exercises: bake_exercises)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.bake_note(note:)
|
14
|
+
def self.bake_note(note:, bake_exercises:)
|
15
15
|
note.wrap_children(class: 'os-note-body')
|
16
16
|
|
17
17
|
title = note.title&.cut
|
@@ -24,6 +24,8 @@ module Kitchen
|
|
24
24
|
</h3>
|
25
25
|
HTML
|
26
26
|
)
|
27
|
+
|
28
|
+
BakeNoteExercise.v2(note: note) if bake_exercises
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
@@ -3,14 +3,19 @@
|
|
3
3
|
module Kitchen
|
4
4
|
module Directions
|
5
5
|
module BakeNumberedExercise
|
6
|
+
# rubocop:disable Metrics/ParameterLists
|
7
|
+
# :/
|
6
8
|
def self.v1(exercise:, number:, suppress_solution_if: false,
|
7
|
-
note_suppressed_solutions: false, cases: false)
|
9
|
+
note_suppressed_solutions: false, cases: false, solution_stays_put: false)
|
8
10
|
V1.new.bake(exercise: exercise, number: number, suppress_solution_if: suppress_solution_if,
|
9
|
-
note_suppressed_solutions: note_suppressed_solutions, cases: cases
|
11
|
+
note_suppressed_solutions: note_suppressed_solutions, cases: cases,
|
12
|
+
solution_stays_put: solution_stays_put)
|
10
13
|
end
|
14
|
+
# rubocop:enable Metrics/ParameterLists
|
11
15
|
|
12
16
|
def self.bake_solution_v1(exercise:, number:, divider: '. ')
|
13
|
-
V1.new.bake_solution(exercise: exercise, number: number, divider: divider
|
17
|
+
V1.new.bake_solution(exercise: exercise, number: number, divider: divider,
|
18
|
+
solution_stays_put: false)
|
14
19
|
end
|
15
20
|
end
|
16
21
|
end
|