Sha256: baad97ec3889a5db9c04de59bd26a5e36ee3709b39ce90b7b93d138737c2ebff

Contents?: true

Size: 1.34 KB

Versions: 7

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

module Kitchen::Directions::MoveSolutionsToAnswerKey
  module Strategies
    class ContemporaryMath
      def bake(chapter:, append_to:)
        # Hacky numbering fix
        chapter.notes('$.your-turn').exercises.each do |exercise|
          solution = exercise.solution
          next unless solution

          number = exercise.ancestor(:note).count_in(:chapter)
          solution.first('a.os-number').inner_html = number.to_s
          solution.first('span.os-divider').inner_html = '. '
        end

        Kitchen::Directions::MoveSolutionsFromNumberedNote.v1(
          chapter: chapter, append_to: append_to, note_class: 'your-turn'
        )

        # Bake section exercises
        chapter.non_introduction_pages.each do |page|
          number = "#{chapter.count_in(:book)}.#{page.count_in(:chapter)}"
          Kitchen::Directions::MoveSolutionsFromExerciseSection.v1(
            chapter: page, append_to: append_to, section_class: 'section-exercises',
            title_number: number
          )
        end

        # Bake other exercise sections
        classes = %w[chapter-review chapter-test]
        classes.each do |klass|
          Kitchen::Directions::MoveSolutionsFromExerciseSection.v1(
            chapter: chapter, append_to: append_to, section_class: klass
          )
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
openstax_kitchen-14.0.0 lib/kitchen/directions/move_solutions_to_answer_key/strategies/contemporary_math.rb
openstax_kitchen-13.0.0 lib/kitchen/directions/move_solutions_to_answer_key/strategies/contemporary_math.rb
openstax_kitchen-12.2.0 lib/kitchen/directions/move_solutions_to_answer_key/strategies/contemporary_math.rb
openstax_kitchen-12.1.0 lib/kitchen/directions/move_solutions_to_answer_key/strategies/contemporary_math.rb
openstax_kitchen-12.0.0 lib/kitchen/directions/move_solutions_to_answer_key/strategies/contemporary_math.rb
openstax_kitchen-11.2.0 lib/kitchen/directions/move_solutions_to_answer_key/strategies/contemporary_math.rb
openstax_kitchen-11.1.0 lib/kitchen/directions/move_solutions_to_answer_key/strategies/contemporary_math.rb