openstax_kitchen 14.0.0 → 15.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -3
- data/Gemfile.lock +2 -2
- 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_example.rb +1 -1
- data/lib/kitchen/directions/bake_index/v1.xhtml.erb +5 -9
- 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 +3 -0
- data/lib/kitchen/directions/bake_unnumbered_exercise.rb +16 -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/default_strategy_for_answer_key_solutions.rb +35 -0
- data/lib/kitchen/directions/move_solutions_to_answer_key/answer_key_inner_container.rb +29 -0
- data/lib/kitchen/patches/renderable.rb +1 -1
- data/lib/kitchen/version.rb +1 -1
- data/lib/locales/es.yml +6 -1
- metadata +8 -10
- data/lib/kitchen/directions/book_answer_key_container/eob_answer_key_outer_container.xhtml.erb +0 -9
- 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 -47
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,11 +6,24 @@ 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
|
+
|
|
9
22
|
## [14.0.0] - 2021-10-22
|
|
10
23
|
|
|
11
|
-
Fix `BakeAutotitledExercise` V2 to stop breaking for exercises without solutions (patch)
|
|
12
|
-
Add `BakeAutotitledExercise` V2 (minor)
|
|
13
|
-
Fix `BakeChapterGlossary::V1` to stop adding an empty wrapper if there is no content (patch)
|
|
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)
|
|
14
27
|
* Create `BakeNoteExercise` and `BakeNoteInjectedQuestion` and support exercises in `BakeUnclassifiedNotes` (minor)
|
|
15
28
|
* Add baking section with class `column header` to `BakeAppendix` (patch)
|
|
16
29
|
* Expand `BakeAnnotationClasses` to book from chapter to bake also paragraphs from Preface (major)
|
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
|
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
|
|
@@ -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>
|
|
@@ -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>
|
|
@@ -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
|
|
@@ -2,13 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
module Kitchen::Directions::BakeNumberedExercise
|
|
4
4
|
class V1
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
# rubocop:disable Metrics/ParameterLists
|
|
6
|
+
def bake(exercise:, number:, suppress_solution_if:,
|
|
7
|
+
note_suppressed_solutions:, cases:, solution_stays_put:)
|
|
7
8
|
problem = exercise.problem
|
|
8
9
|
solution = exercise.solution
|
|
9
10
|
|
|
11
|
+
in_appendix = exercise.has_ancestor?(:page) && exercise.ancestor(:page).has_class?('appendix')
|
|
12
|
+
|
|
10
13
|
# Store label information
|
|
11
|
-
|
|
14
|
+
if in_appendix
|
|
15
|
+
label_number = number
|
|
16
|
+
title_label = "<span class=\"os-title-label\">#{I18n.t('exercise')}</span>"
|
|
17
|
+
problem_divider = ''
|
|
18
|
+
else
|
|
19
|
+
label_number = "#{exercise.ancestor(:chapter).count_in(:book)}.#{number}"
|
|
20
|
+
title_label = ''
|
|
21
|
+
problem_divider = "<span class='os-divider'>. </span>"
|
|
22
|
+
end
|
|
23
|
+
|
|
12
24
|
exercise.target_label(label_text: 'exercise', custom_content: label_number, cases: cases)
|
|
13
25
|
|
|
14
26
|
problem_number = "<span class='os-number'>#{number}</span>"
|
|
@@ -26,25 +38,54 @@ module Kitchen::Directions::BakeNumberedExercise
|
|
|
26
38
|
solution.trash
|
|
27
39
|
exercise.add_class('os-hasSolution-trashed') if note_suppressed_solutions
|
|
28
40
|
else
|
|
29
|
-
problem_number =
|
|
30
|
-
|
|
41
|
+
problem_number = \
|
|
42
|
+
if solution_stays_put || in_appendix
|
|
43
|
+
"<span class='os-number'>#{number}</span>"
|
|
44
|
+
else
|
|
45
|
+
"<a class='os-number' href='##{exercise.id}-solution'>#{number}</a>"
|
|
46
|
+
end
|
|
47
|
+
bake_solution(
|
|
48
|
+
exercise: exercise,
|
|
49
|
+
number: number,
|
|
50
|
+
solution_stays_put: solution_stays_put,
|
|
51
|
+
in_appendix: in_appendix
|
|
52
|
+
)
|
|
31
53
|
end
|
|
32
54
|
end
|
|
33
55
|
|
|
34
56
|
problem.replace_children(with:
|
|
35
57
|
<<~HTML
|
|
58
|
+
#{title_label}
|
|
36
59
|
#{problem_number}
|
|
37
|
-
|
|
60
|
+
#{problem_divider}
|
|
38
61
|
<div class="os-problem-container">#{problem.children}</div>
|
|
39
62
|
HTML
|
|
40
63
|
)
|
|
41
64
|
end
|
|
65
|
+
# rubocop:enable Metrics/ParameterLists
|
|
42
66
|
|
|
43
|
-
def bake_solution(exercise:, number:, divider: '. ')
|
|
67
|
+
def bake_solution(exercise:, number:, solution_stays_put:, divider: '. ', in_appendix: false)
|
|
44
68
|
solution = exercise.solution
|
|
69
|
+
if solution_stays_put
|
|
70
|
+
solution.wrap_children(class: 'os-solution-container')
|
|
71
|
+
solution.prepend(child:
|
|
72
|
+
<<~HTML
|
|
73
|
+
<h4 class="solution-title" data-type="title">
|
|
74
|
+
<span class="os-text">#{I18n.t(:solution)}</span>
|
|
75
|
+
</h4>
|
|
76
|
+
HTML
|
|
77
|
+
)
|
|
78
|
+
return
|
|
79
|
+
end
|
|
80
|
+
|
|
45
81
|
solution.id = "#{exercise.id}-solution"
|
|
46
82
|
exercise.add_class('os-hasSolution')
|
|
47
83
|
|
|
84
|
+
if in_appendix
|
|
85
|
+
solution.wrap_children(class: 'os-solution-container')
|
|
86
|
+
return
|
|
87
|
+
end
|
|
88
|
+
|
|
48
89
|
solution.replace_children(with:
|
|
49
90
|
<<~HTML
|
|
50
91
|
<a class='os-number' href='##{exercise.id}'>#{number}</a>
|
|
@@ -65,6 +65,9 @@ module Kitchen
|
|
|
65
65
|
elsif table.text_heavy?
|
|
66
66
|
custom_table = CustomBody.new(table: table, klass: 'text-heavy')
|
|
67
67
|
custom_table.modify_body(has_fake_title: false)
|
|
68
|
+
elsif table.unstyled?
|
|
69
|
+
custom_table = CustomBody.new(table: table, klass: 'unstyled')
|
|
70
|
+
custom_table.modify_body(has_fake_title: false)
|
|
68
71
|
end
|
|
69
72
|
end
|
|
70
73
|
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Kitchen
|
|
4
|
+
module Directions
|
|
5
|
+
module BakeUnnumberedExercise
|
|
6
|
+
def self.v1(exercise:)
|
|
7
|
+
exercise.problem.wrap_children(class: 'os-problem-container')
|
|
8
|
+
return unless exercise.solution
|
|
9
|
+
|
|
10
|
+
exercise.solutions.each do |solution|
|
|
11
|
+
solution.wrap_children(class: 'os-solution-container')
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<div class="os-eob os-<%= @solutions_or_solution %>-container" data-type="<%= @composite_element %>" data-uuid-key=".<%= @uuid_key %>">
|
|
2
|
+
<<%= @main_title_tag %> data-type="document-title">
|
|
3
|
+
<span class="os-text"><%= @title %></span>
|
|
4
|
+
</<%= @main_title_tag %>>
|
|
5
|
+
<div data-type="metadata" style="display: none;">
|
|
6
|
+
<h1 data-type="document-title" itemprop="name"><%= @title %></h1>
|
|
7
|
+
<%= @metadata.paste %>
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
@@ -4,10 +4,14 @@ module Kitchen::Directions::BookAnswerKeyContainer
|
|
|
4
4
|
class V1
|
|
5
5
|
renderable
|
|
6
6
|
|
|
7
|
-
def bake(book:, solutions_plural:
|
|
7
|
+
def bake(book:, solutions_plural:)
|
|
8
|
+
@composite_element = 'composite-chapter'
|
|
8
9
|
@metadata = book.metadata.children_to_keep.copy
|
|
9
10
|
@solutions_or_solution = solutions_plural ? 'solutions' : 'solution'
|
|
10
|
-
|
|
11
|
+
@title = I18n.t(:answer_key_title)
|
|
12
|
+
@main_title_tag = 'h1'
|
|
13
|
+
@uuid_key = @solutions_or_solution
|
|
14
|
+
book.body.append(child: render(file: 'eob_answer_key_container.xhtml.erb'))
|
|
11
15
|
book.body.first("div.os-eob.os-#{@solutions_or_solution}-container")
|
|
12
16
|
end
|
|
13
17
|
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Kitchen::Directions::DefaultStrategyForAnswerKeySolutions
|
|
4
|
+
def self.v1(strategy_options:, chapter:, append_to:)
|
|
5
|
+
V1.new(
|
|
6
|
+
strategy_options
|
|
7
|
+
).bake(
|
|
8
|
+
chapter: chapter,
|
|
9
|
+
append_to: append_to
|
|
10
|
+
)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class V1
|
|
14
|
+
def bake(chapter:, append_to:)
|
|
15
|
+
bake_section(chapter: chapter, append_to: append_to)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
protected
|
|
19
|
+
|
|
20
|
+
def bake_section(chapter:, append_to:)
|
|
21
|
+
@selectors.each do |selector|
|
|
22
|
+
chapter.search("#{selector} div[data-type='solution']").each do |solution|
|
|
23
|
+
append_to.append(child: solution.cut.to_s) unless @condition.present? && !@condition
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# This method helps to obtain more strategy-specific params through
|
|
29
|
+
# "strategy_options: {blah1: 1, blah2: 2}"
|
|
30
|
+
def initialize(strategy_options)
|
|
31
|
+
@selectors = strategy_options[:selectors] || (raise 'missing selectors for strategy')
|
|
32
|
+
@condition = strategy_options[:condition]
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Kitchen::Directions::AnswerKeyInnerContainer
|
|
4
|
+
def self.v1(chapter:, metadata_source:, append_to:, solutions_plural: true)
|
|
5
|
+
V1.new.bake(
|
|
6
|
+
chapter: chapter,
|
|
7
|
+
metadata_source: metadata_source,
|
|
8
|
+
append_to: append_to,
|
|
9
|
+
solutions_plural: solutions_plural
|
|
10
|
+
)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class V1
|
|
14
|
+
renderable
|
|
15
|
+
|
|
16
|
+
def bake(chapter:, metadata_source:, append_to:, solutions_plural:)
|
|
17
|
+
@solutions_or_solution = solutions_plural ? 'solutions' : 'solution'
|
|
18
|
+
@uuid_key = "#{@solutions_or_solution}#{chapter.count_in(:book)}"
|
|
19
|
+
@metadata = metadata_source.children_to_keep.copy
|
|
20
|
+
@composite_element = 'composite-page'
|
|
21
|
+
@title = "#{I18n.t(:chapter)} #{chapter.count_in(:book)}"
|
|
22
|
+
@main_title_tag = 'h2'
|
|
23
|
+
|
|
24
|
+
append_to.append(
|
|
25
|
+
child: render(file: '../book_answer_key_container/eob_answer_key_container.xhtml.erb')
|
|
26
|
+
).first("div[data-uuid-key='.#{@uuid_key}']")
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
data/lib/kitchen/version.rb
CHANGED
data/lib/locales/es.yml
CHANGED
|
@@ -21,17 +21,22 @@ es:
|
|
|
21
21
|
eoc_exercises_title: Ejercicios
|
|
22
22
|
eoc_composite_metadata_title: Revisión Del Capítulo
|
|
23
23
|
eoc_solutions_title: Soluciones
|
|
24
|
-
eoc_key_concepts: Conceptos Clave
|
|
25
24
|
eoc_suggested_reading: Sugerencias Para Estudios Adicionales
|
|
26
25
|
eob_index_symbols_group: Símbolos
|
|
27
26
|
review_exercises: Ejercicios De Repaso
|
|
28
27
|
section_exercises: ! 'Sección %{number} Ejercicios'
|
|
28
|
+
iframe_link_text: Haga Clic Para Ver El Contenido
|
|
29
|
+
handbook_outline_title: Esquema
|
|
30
|
+
context_lead_text: 'Referirse a '
|
|
29
31
|
eoc:
|
|
30
32
|
glossary: Términos Clave
|
|
31
33
|
key-equations: Ecuaciones Clave
|
|
32
34
|
summary: Resumen
|
|
33
35
|
further-research: Investigación Adicional
|
|
36
|
+
key-concepts: Conceptos Clave
|
|
34
37
|
references: Referencias
|
|
38
|
+
solutions: Soluciones
|
|
39
|
+
section-exercises: ! 'Sección %{number} Ejercicios'
|
|
35
40
|
folio:
|
|
36
41
|
preface: Prefacio
|
|
37
42
|
access_for_free: Acceso gratis en openstax.org
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: openstax_kitchen
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 15.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- JP Slavinsky
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-11-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -244,6 +244,8 @@ files:
|
|
|
244
244
|
- lib/kitchen/debug/print_recipe_error.rb
|
|
245
245
|
- lib/kitchen/directions/.rubocop.yml
|
|
246
246
|
- lib/kitchen/directions/bake_accessibility_fixes.rb
|
|
247
|
+
- lib/kitchen/directions/bake_all_chapter_solutions_types.rb
|
|
248
|
+
- lib/kitchen/directions/bake_all_numbered_exercise_types.rb
|
|
247
249
|
- lib/kitchen/directions/bake_annotation_classes/main.rb
|
|
248
250
|
- lib/kitchen/directions/bake_annotation_classes/v1.rb
|
|
249
251
|
- lib/kitchen/directions/bake_appendix.rb
|
|
@@ -331,9 +333,10 @@ files:
|
|
|
331
333
|
- lib/kitchen/directions/bake_unit_page_title/v1.rb
|
|
332
334
|
- lib/kitchen/directions/bake_unit_title/main.rb
|
|
333
335
|
- lib/kitchen/directions/bake_unit_title/v1.rb
|
|
336
|
+
- lib/kitchen/directions/bake_unnumbered_exercise.rb
|
|
334
337
|
- lib/kitchen/directions/bake_unnumbered_figure.rb
|
|
335
338
|
- lib/kitchen/directions/bake_unnumbered_tables.rb
|
|
336
|
-
- lib/kitchen/directions/book_answer_key_container/
|
|
339
|
+
- lib/kitchen/directions/book_answer_key_container/eob_answer_key_container.xhtml.erb
|
|
337
340
|
- lib/kitchen/directions/book_answer_key_container/main.rb
|
|
338
341
|
- lib/kitchen/directions/book_answer_key_container/v1.rb
|
|
339
342
|
- lib/kitchen/directions/chapter_review_container/chapter_review.xhtml.erb
|
|
@@ -341,6 +344,7 @@ files:
|
|
|
341
344
|
- lib/kitchen/directions/chapter_review_container/v1.rb
|
|
342
345
|
- lib/kitchen/directions/composite_page_container/main.rb
|
|
343
346
|
- lib/kitchen/directions/composite_page_container/v1.rb
|
|
347
|
+
- lib/kitchen/directions/default_strategy_for_answer_key_solutions.rb
|
|
344
348
|
- lib/kitchen/directions/eoc_section_title_link_snippet.rb
|
|
345
349
|
- lib/kitchen/directions/move_custom_section_to_eoc_container/main.rb
|
|
346
350
|
- lib/kitchen/directions/move_custom_section_to_eoc_container/v1.rb
|
|
@@ -348,16 +352,10 @@ files:
|
|
|
348
352
|
- lib/kitchen/directions/move_exercises_to_eoc/v1.rb
|
|
349
353
|
- lib/kitchen/directions/move_exercises_to_eoc/v2.rb
|
|
350
354
|
- lib/kitchen/directions/move_exercises_to_eoc/v3.rb
|
|
351
|
-
- lib/kitchen/directions/move_solutions_to_answer_key/
|
|
355
|
+
- lib/kitchen/directions/move_solutions_to_answer_key/answer_key_inner_container.rb
|
|
352
356
|
- lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_exercise_section.rb
|
|
353
357
|
- lib/kitchen/directions/move_solutions_to_answer_key/move_solutions_from_numbered_note.rb
|
|
354
358
|
- lib/kitchen/directions/move_solutions_to_answer_key/solution_area_snippet.rb
|
|
355
|
-
- lib/kitchen/directions/move_solutions_to_answer_key/strategies/calculus.rb
|
|
356
|
-
- lib/kitchen/directions/move_solutions_to_answer_key/strategies/contemporary_math.rb
|
|
357
|
-
- lib/kitchen/directions/move_solutions_to_answer_key/strategies/default.rb
|
|
358
|
-
- lib/kitchen/directions/move_solutions_to_answer_key/strategies/precalculus.rb
|
|
359
|
-
- lib/kitchen/directions/move_solutions_to_answer_key/strategies/uphysics.rb
|
|
360
|
-
- lib/kitchen/directions/move_solutions_to_answer_key/v1.rb
|
|
361
359
|
- lib/kitchen/directions/move_title_text_into_span.rb
|
|
362
360
|
- lib/kitchen/document.rb
|
|
363
361
|
- lib/kitchen/element.rb
|
data/lib/kitchen/directions/book_answer_key_container/eob_answer_key_outer_container.xhtml.erb
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<div class="os-eob os-<%= @solutions_or_solution %>-container" data-type="composite-chapter" data-uuid-key=".<%= @solutions_or_solution %>">
|
|
2
|
-
<h1 data-type="document-title">
|
|
3
|
-
<span class="os-text"><%= I18n.t(:answer_key_title) %></span>
|
|
4
|
-
</h1>
|
|
5
|
-
<div data-type="metadata" style="display: none;">
|
|
6
|
-
<h1 data-type="document-title" itemprop="name"><%= I18n.t(:answer_key_title) %></h1>
|
|
7
|
-
<%= @metadata.paste %>
|
|
8
|
-
</div>
|
|
9
|
-
</div>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Kitchen
|
|
4
|
-
module Directions
|
|
5
|
-
module MoveSolutionsToAnswerKey
|
|
6
|
-
def self.v1(chapter:, metadata_source:, strategy:, append_to:, strategy_options: {}, solutions_plural: true)
|
|
7
|
-
V1.new.bake(
|
|
8
|
-
chapter: chapter,
|
|
9
|
-
metadata_source: metadata_source,
|
|
10
|
-
strategy: strategy,
|
|
11
|
-
append_to: append_to,
|
|
12
|
-
strategy_options: strategy_options,
|
|
13
|
-
solutions_plural: solutions_plural
|
|
14
|
-
)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Kitchen::Directions::MoveSolutionsToAnswerKey
|
|
4
|
-
module Strategies
|
|
5
|
-
class Calculus
|
|
6
|
-
def bake(chapter:, append_to:)
|
|
7
|
-
checkpoint_solutions = chapter.search('div.checkpoint div[data-type="solution"]').cut
|
|
8
|
-
append_solution_area(I18n.t(:checkpoint), checkpoint_solutions, append_to)
|
|
9
|
-
|
|
10
|
-
chapter.search('section.section-exercises').each do |section|
|
|
11
|
-
section_solutions = section.search('div[data-type="solution"]').cut
|
|
12
|
-
section_title = I18n.t(
|
|
13
|
-
:section_exercises,
|
|
14
|
-
number: "#{chapter.count_in(:book)}.#{section.count_in(:chapter)}"
|
|
15
|
-
)
|
|
16
|
-
append_solution_area(section_title, section_solutions, append_to)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
chapter.search('section.review-exercises').each do |section|
|
|
20
|
-
section_solutions = section.search('div[data-type="solution"]').cut
|
|
21
|
-
append_solution_area(I18n.t(:review_exercises), section_solutions, append_to)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
protected
|
|
26
|
-
|
|
27
|
-
def append_solution_area(title, clipboard, append_to)
|
|
28
|
-
append_to.append(child:
|
|
29
|
-
<<~HTML
|
|
30
|
-
<div class="os-solution-area">
|
|
31
|
-
<h3 data-type="title">
|
|
32
|
-
<span class="os-title-label">#{title}</span>
|
|
33
|
-
</h3>
|
|
34
|
-
#{clipboard.paste}
|
|
35
|
-
</div>
|
|
36
|
-
HTML
|
|
37
|
-
)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Kitchen::Directions::MoveSolutionsToAnswerKey
|
|
4
|
-
module Strategies
|
|
5
|
-
class ContemporaryMath
|
|
6
|
-
def bake(chapter:, append_to:)
|
|
7
|
-
# Hacky numbering fix
|
|
8
|
-
chapter.notes('$.your-turn').exercises.each do |exercise|
|
|
9
|
-
solution = exercise.solution
|
|
10
|
-
next unless solution
|
|
11
|
-
|
|
12
|
-
number = exercise.ancestor(:note).count_in(:chapter)
|
|
13
|
-
solution.first('a.os-number').inner_html = number.to_s
|
|
14
|
-
solution.first('span.os-divider').inner_html = '. '
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
Kitchen::Directions::MoveSolutionsFromNumberedNote.v1(
|
|
18
|
-
chapter: chapter, append_to: append_to, note_class: 'your-turn'
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
# Bake section exercises
|
|
22
|
-
chapter.non_introduction_pages.each do |page|
|
|
23
|
-
number = "#{chapter.count_in(:book)}.#{page.count_in(:chapter)}"
|
|
24
|
-
Kitchen::Directions::MoveSolutionsFromExerciseSection.v1(
|
|
25
|
-
chapter: page, append_to: append_to, section_class: 'section-exercises',
|
|
26
|
-
title_number: number
|
|
27
|
-
)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
# Bake other exercise sections
|
|
31
|
-
classes = %w[chapter-review chapter-test]
|
|
32
|
-
classes.each do |klass|
|
|
33
|
-
Kitchen::Directions::MoveSolutionsFromExerciseSection.v1(
|
|
34
|
-
chapter: chapter, append_to: append_to, section_class: klass
|
|
35
|
-
)
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Kitchen::Directions::MoveSolutionsToAnswerKey
|
|
4
|
-
module Strategies
|
|
5
|
-
class Default
|
|
6
|
-
def bake(chapter:, append_to:)
|
|
7
|
-
bake_section(chapter: chapter, append_to: append_to)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
protected
|
|
11
|
-
|
|
12
|
-
def bake_section(chapter:, append_to:)
|
|
13
|
-
@selectors.each do |selector|
|
|
14
|
-
chapter.search("#{selector} div[data-type='solution']").each do |solution|
|
|
15
|
-
append_to.append(child: solution.cut.to_s)
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# This method helps to obtain more strategy-specific params through
|
|
21
|
-
# "strategy_options: {blah1: 1, blah2: 2}"
|
|
22
|
-
def initialize(strategy_options)
|
|
23
|
-
@selectors = strategy_options[:selectors] || (raise 'missing selectors for strategy')
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Kitchen::Directions::MoveSolutionsToAnswerKey
|
|
4
|
-
module Strategies
|
|
5
|
-
class Precalculus
|
|
6
|
-
def bake(chapter:, append_to:)
|
|
7
|
-
try_note_solutions(chapter: chapter, append_to: append_to)
|
|
8
|
-
|
|
9
|
-
# Bake section exercises
|
|
10
|
-
chapter.non_introduction_pages.each do |page|
|
|
11
|
-
number = "#{chapter.count_in(:book)}.#{page.count_in(:chapter)}"
|
|
12
|
-
Kitchen::Directions::MoveSolutionsFromExerciseSection.v1(
|
|
13
|
-
chapter: page, append_to: append_to, section_class: 'section-exercises',
|
|
14
|
-
title_number: number
|
|
15
|
-
)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# Bake other types of exercises
|
|
19
|
-
classes = %w[review-exercises practice-test]
|
|
20
|
-
classes.each do |klass|
|
|
21
|
-
Kitchen::Directions::MoveSolutionsFromExerciseSection.v1(
|
|
22
|
-
chapter: chapter, append_to: append_to, section_class: klass
|
|
23
|
-
)
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
protected
|
|
28
|
-
|
|
29
|
-
def try_note_solutions(chapter:, append_to:)
|
|
30
|
-
append_to.append(child:
|
|
31
|
-
<<~HTML
|
|
32
|
-
<div class="os-module-reset-solution-area os-try-solution-area">
|
|
33
|
-
<h3 data-type="title">
|
|
34
|
-
<span class="os-title-label">#{I18n.t(:"notes.try")}</span>
|
|
35
|
-
</h3>
|
|
36
|
-
</div>
|
|
37
|
-
HTML
|
|
38
|
-
)
|
|
39
|
-
chapter.pages.each do |page|
|
|
40
|
-
solutions = Kitchen::Clipboard.new
|
|
41
|
-
page.notes('$.try').each do |note|
|
|
42
|
-
note.exercises.each do |exercise|
|
|
43
|
-
solution = exercise.solution
|
|
44
|
-
solution&.cut(to: solutions)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
next if solutions.items.empty?
|
|
48
|
-
|
|
49
|
-
title_snippet = Kitchen::Directions::EocSectionTitleLinkSnippet.v1(
|
|
50
|
-
page: page,
|
|
51
|
-
wrapper: 'div'
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
append_to.first('div.os-try-solution-area').append(child:
|
|
55
|
-
Kitchen::Directions::SolutionAreaSnippet.v1(
|
|
56
|
-
title: title_snippet, solutions_clipboard: solutions
|
|
57
|
-
)
|
|
58
|
-
)
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Kitchen::Directions::MoveSolutionsToAnswerKey
|
|
4
|
-
module Strategies
|
|
5
|
-
class UPhysics
|
|
6
|
-
def bake(chapter:, append_to:)
|
|
7
|
-
Kitchen::Directions::MoveSolutionsFromNumberedNote.v1(
|
|
8
|
-
chapter: chapter, append_to: append_to, note_class: 'check-understanding'
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
classes = %w[review-conceptual-questions review-problems review-additional-problems
|
|
12
|
-
review-challenge]
|
|
13
|
-
classes.each do |klass|
|
|
14
|
-
Kitchen::Directions::MoveSolutionsFromExerciseSection.v1(
|
|
15
|
-
chapter: chapter, append_to: append_to, section_class: klass
|
|
16
|
-
)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Kitchen::Directions::MoveSolutionsToAnswerKey
|
|
4
|
-
class V1
|
|
5
|
-
# rubocop:disable Metrics/ParameterLists
|
|
6
|
-
# This direction may need refactoring to simplify parameters
|
|
7
|
-
def bake(chapter:, metadata_source:, strategy:, append_to:, strategy_options: {},
|
|
8
|
-
solutions_plural: true)
|
|
9
|
-
strategy =
|
|
10
|
-
case strategy
|
|
11
|
-
when :calculus
|
|
12
|
-
Strategies::Calculus.new
|
|
13
|
-
when :contemporary_math
|
|
14
|
-
Strategies::ContemporaryMath.new
|
|
15
|
-
when :uphysics
|
|
16
|
-
Strategies::UPhysics.new
|
|
17
|
-
when :precalculus
|
|
18
|
-
Strategies::Precalculus.new
|
|
19
|
-
when :default
|
|
20
|
-
Strategies::Default.new(strategy_options)
|
|
21
|
-
else
|
|
22
|
-
raise 'No such strategy'
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
solutions_or_solution = solutions_plural ? 'solutions' : 'solution'
|
|
26
|
-
uuid_key = ".#{solutions_or_solution}#{chapter.count_in(:book)}"
|
|
27
|
-
append_to.append(child:
|
|
28
|
-
<<~HTML
|
|
29
|
-
<div class="os-eob os-#{solutions_or_solution}-container" data-type="composite-page" \
|
|
30
|
-
data-uuid-key="#{uuid_key}">
|
|
31
|
-
<h2 data-type="document-title">
|
|
32
|
-
<span class="os-text">#{I18n.t(:chapter)} #{chapter.count_in(:book)}</span>
|
|
33
|
-
</h2>
|
|
34
|
-
<div data-type="metadata" style="display: none;">
|
|
35
|
-
<h1 data-type="document-title" itemprop="name">#{I18n.t(:chapter)} #{chapter.count_in(:book)}</h1>
|
|
36
|
-
#{metadata_source.children_to_keep.copy.paste}
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
39
|
-
HTML
|
|
40
|
-
)
|
|
41
|
-
strategy.bake(
|
|
42
|
-
chapter: chapter, append_to: append_to.first("div[data-uuid-key='#{uuid_key}']")
|
|
43
|
-
)
|
|
44
|
-
end
|
|
45
|
-
# rubocop:enable Metrics/ParameterLists
|
|
46
|
-
end
|
|
47
|
-
end
|