Module: Kitchen::Directions::BakeAllNumberedExerciseTypes

Defined in:
lib/kitchen/directions/bake_all_numbered_exercise_types.rb

Class Method Summary collapse

Class Method Details

.v1(within:, exercise_options: {}, question_options: {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/kitchen/directions/bake_all_numbered_exercise_types.rb', line 6

def self.v1(within:, exercise_options: {}, question_options: {})
  exercise_counter = 1
  within.search_with(ExerciseElementEnumerator, InjectedQuestionElementEnumerator)\
        .each do |exercise|
    next if exercise.has_class?('unnumbered')

    if exercise.instance_of?(ExerciseElement)
      exercise_options[:exercise] = exercise
      exercise_options[:number] = exercise_counter
      BakeNumberedExercise.v1(exercise_options)
    else
      question_options[:number] = exercise_counter
      question_options[:question] = exercise
      BakeInjectedExerciseQuestion.v1(question_options)
    end
    exercise_counter += 1
  end
end