Sha256: 92a9e1107f9ee71f9fdc2f6ff30f4c963b6a64be3b321bd83336dd004eeb7d1c

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

module Mumuki::Laboratory::Controllers::ResultsRendering
  extend ActiveSupport::Concern

  included do
    include ProgressBarHelper

    before_action :set_guide_previously_done!
  end

  def render_results_json(assignment, results = {})
    render json: results.merge(
      guide_finished_by_solution: guide_finished_by_solution?,
      class_for_progress_list_item: class_for_progress_list_item(@exercise, true),
      html: render_results_html(assignment),
      title_html: render_results_title_html(assignment),
      button_html: render_results_button_html(assignment))
  end

  def render_results_html(assignment)
    render_to_string partial: 'exercise_solutions/results',
                     locals: {assignment: assignment}
  end

  def render_results_title_html(assignment)
    render_to_string partial: 'exercise_solutions/results_title',
                     locals: {assignment: assignment}
  end

  def render_results_button_html(assignment)
    render_to_string partial: 'exercise_solutions/kids_results_button',
                     locals: {assignment: assignment}
  end

  def guide_finished_by_solution?
    !@guide_previously_done && @exercise.guide_done_for?(current_user)
  end

  def set_guide_previously_done!
    @guide_previously_done = @exercise.guide_done_for?(current_user)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mumuki-laboratory-5.1.1 lib/mumuki/laboratory/controllers/results_rendering.rb
mumuki-laboratory-5.1.0 lib/mumuki/laboratory/controllers/results_rendering.rb