Sha256: 56b0b263d6fdc2de766affdf84d84607e5034a1244cc511f7202c00ecb5f525e

Contents?: true

Size: 1.25 KB

Versions: 29

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

module Kitchen
  module Directions
    module BakeCheckpoint
      def self.v1(checkpoint:, number:)
        checkpoint.wrap_children(class: 'os-note-body')

        checkpoint.prepend(child:
          <<~HTML
            <div class="os-title">
              <span class="os-title-label">#{I18n.t(:checkpoint)} </span>
              <span class="os-number">#{number}</span>
              <span class="os-divider"> </span>
            </div>
          HTML
        )

        exercise = checkpoint.exercises.first!
        exercise.search("[data-type='commentary']").trash

        problem = exercise.problem
        problem.wrap_children(class: 'os-problem-container')

        solution = exercise.solution
        exercise.add_class('unnumbered') unless solution.present?
        return unless solution.present?

        solution.id = "#{exercise.id}-solution"
        exercise.add_class('os-hasSolution')

        solution.replace_children(with:
          <<~HTML
            <span class="os-divider"> </span>
            <a class="os-number" href="##{exercise.id}">#{number}</a>
            <div class="os-solution-container">#{solution.children}</div>
          HTML
        )

        exercise.add_class('unnumbered')
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
openstax_kitchen-19.0.0 lib/kitchen/directions/bake_checkpoint.rb
openstax_kitchen-18.0.0 lib/kitchen/directions/bake_checkpoint.rb
openstax_kitchen-17.1.0 lib/kitchen/directions/bake_checkpoint.rb
openstax_kitchen-17.0.0 lib/kitchen/directions/bake_checkpoint.rb
openstax_kitchen-16.0.0 lib/kitchen/directions/bake_checkpoint.rb
openstax_kitchen-15.0.0 lib/kitchen/directions/bake_checkpoint.rb
openstax_kitchen-14.0.0 lib/kitchen/directions/bake_checkpoint.rb
openstax_kitchen-13.0.0 lib/kitchen/directions/bake_checkpoint.rb
openstax_kitchen-12.2.0 lib/kitchen/directions/bake_checkpoint.rb
openstax_kitchen-12.1.0 lib/kitchen/directions/bake_checkpoint.rb
openstax_kitchen-12.0.0 lib/kitchen/directions/bake_checkpoint.rb
openstax_kitchen-11.2.0 lib/kitchen/directions/bake_checkpoint.rb
openstax_kitchen-11.1.0 lib/kitchen/directions/bake_checkpoint.rb
openstax_kitchen-11.0.0 lib/kitchen/directions/bake_checkpoint.rb
openstax_kitchen-10.0.0 lib/kitchen/directions/bake_checkpoint.rb
openstax_kitchen-9.2.0 lib/kitchen/directions/bake_checkpoint.rb
openstax_kitchen-9.1.0 lib/kitchen/directions/bake_checkpoint.rb
openstax_kitchen-9.0.0 lib/kitchen/directions/bake_checkpoint.rb
openstax_kitchen-8.0.1 lib/kitchen/directions/bake_checkpoint.rb
openstax_kitchen-8.0.0 lib/kitchen/directions/bake_checkpoint.rb