Sha256: 64ed11dd983f8cf4a09e4f8da886255d28791eb322aae2145c255871982cf951

Contents?: true

Size: 993 Bytes

Versions: 5

Compression:

Stored size: 993 Bytes

Contents

# frozen_string_literal: true

module Kitchen::Directions::BakeChapterSolutions
  class V1
    renderable

    def bake(chapter:, metadata_source:, uuid_prefix: '')
      @metadata = metadata_source.children_to_keep.copy
      @klass = 'solutions'
      @title = I18n.t(:eoc_solutions_title)
      @uuid_prefix = uuid_prefix

      solutions_clipboard = Kitchen::Clipboard.new

      chapter.search('section.free-response').each do |free_response_question|
        exercises = free_response_question.exercises
        # must run AFTER .free-response notes are baked

        next if exercises.none?

        exercises.each do |exercise|
          solution = exercise.solution
          next unless solution.present?

          solution.cut(to: solutions_clipboard)
        end
      end

      @content = solutions_clipboard.paste

      @in_composite_chapter = false

      chapter.append(child: render(file:
        '../../templates/eoc_section_title_template.xhtml.erb'))
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
openstax_kitchen-8.0.1 lib/kitchen/directions/bake_chapter_solutions/v1.rb
openstax_kitchen-8.0.0 lib/kitchen/directions/bake_chapter_solutions/v1.rb
openstax_kitchen-7.0.0 lib/kitchen/directions/bake_chapter_solutions/v1.rb
openstax_kitchen-6.1.0 lib/kitchen/directions/bake_chapter_solutions/v1.rb
openstax_kitchen-6.0.0 lib/kitchen/directions/bake_chapter_solutions/v1.rb