diff --git a/lib/kitchen/directions/bake_hidden_solutions_web.rb b/lib/kitchen/directions/bake_hidden_solutions_web.rb new file mode 100644 index 000000000..2f6eabeb7 --- /dev/null +++ b/lib/kitchen/directions/bake_hidden_solutions_web.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Kitchen::Directions + module BakeHiddenSolutionsWeb + def self.v1(book_pages:) + book_pages.exercises('$.unnumbered').each do |exercise| + # wrap content, add [Show/Hide Solution] element + solution = exercise.solutions&.first + next unless solution + + show_hide_translated = 'Show/Hide Solution' # TODO: I18n.t(:problem) - why is this broken? + solution[:'aria-label'] = show_hide_translated + children = solution.element_children.cut + solution.append(child: + <<~HTML + [#{show_hide_translated}] + + HTML + ) + solution.name = 'details' + end + end + end +end diff --git a/lib/locales/en.yml b/lib/locales/en.yml index 7c160ed53..1c0028fe7 100644 --- a/lib/locales/en.yml +++ b/lib/locales/en.yml @@ -32,6 +32,7 @@ en: handbook_outline_title: Outline context_lead_text: 'Refer to ' lo_label_text: 'LO ' + show_hide_solution: 'Show/Hide Solution' eoc: glossary: Key Terms key-equations: Key Equations diff --git a/lib/recipes/web-generic/recipe.rb b/lib/recipes/web-generic/recipe.rb index 4df4d0a3c..91d47240e 100644 --- a/lib/recipes/web-generic/recipe.rb +++ b/lib/recipes/web-generic/recipe.rb @@ -19,6 +19,7 @@ BakeExerciseWithTitle.v1(within: example) end end + BakeHiddenSolutionsWeb.v1(book_pages: book_pages) # Restore WebPostBakeRestore.v1(book_pages: book_pages) diff --git a/spec/kitchen_spec/directions/bake_hidden_solutions_web_spec.rb b/spec/kitchen_spec/directions/bake_hidden_solutions_web_spec.rb new file mode 100644 index 000000000..0b528459a --- /dev/null +++ b/spec/kitchen_spec/directions/bake_hidden_solutions_web_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Kitchen::Directions::BakeHiddenSolutionsWeb do + let(:content) do + book_containing(html: + <<~HTML +
+
+
+ solution content +
+
+ HTML + ) + end + + it 'works' do + described_class.v1(book_pages: content) + expect(content).to match_snapshot_auto + end +end diff --git a/spec/recipes_spec/books/web-test/expected_output.xhtml b/spec/recipes_spec/books/web-test/expected_output.xhtml index 3687e59ce..d8738efa2 100644 --- a/spec/recipes_spec/books/web-test/expected_output.xhtml +++ b/spec/recipes_spec/books/web-test/expected_output.xhtml @@ -1146,19 +1146,22 @@ Dr. William Moebs earned a BS and PhD (1959 and 1965) from the University of Mic

Determine what the key terms refer to in the following study. We want to know the average (mean) amount of money first year college students spend at ABC College on school supplies that do not include books. We randomly surveyed 100 first year students at the college. Three of those students spent $150, $200, and $225, respectively.

-
-

- Solution -

-
-

The population is all first year students attending ABC College this term.

-

The sample could be all students enrolled in one section of a beginning statistics course at ABC College (although this sample may not represent the entire population).

-

The parameter is the average (mean) amount of money spent (excluding books) by first year college students at ABC College this term.

-

The statistic is the average (mean) amount of money spent (excluding books) by first year college students in the sample.

-

The variable could be the amount of money spent (excluding books) by one first year student. Let X = the amount of money spent (excluding books) by one first year student attending ABC College.

-

The data are the dollar amounts spent by the first year students. Examples of the data are $150, $200, and $225.

-
-
+
+ [Show/Hide Solution] + +

Using Metric Prefixes

Restate the mass 1.93×1013kg1.93×1013kg using a metric prefix such that the resulting numerical value is bigger than one but less than 1000.

diff --git a/spec/snapshots/Kitchen_Directions_BakeHiddenSolutionsWeb_works.snap b/spec/snapshots/Kitchen_Directions_BakeHiddenSolutionsWeb_works.snap new file mode 100644 index 000000000..e588677be --- /dev/null +++ b/spec/snapshots/Kitchen_Directions_BakeHiddenSolutionsWeb_works.snap @@ -0,0 +1,13 @@ + + +
+
+
+ + [Show/Hide Solution] + +
+
+ + + \ No newline at end of file