Sha256: a43aa34521cc0a978e47c0201b09bea4ab4484c81873db4b6a32d1963af4404f

Contents?: true

Size: 1.06 KB

Versions: 13

Compression:

Stored size: 1.06 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))
  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 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

13 entries across 13 versions & 1 rubygems

Version Path
mumuki-laboratory-5.0.12 lib/mumuki/laboratory/controllers/results_rendering.rb
mumuki-laboratory-5.0.11 lib/mumuki/laboratory/controllers/results_rendering.rb
mumuki-laboratory-5.0.10 lib/mumuki/laboratory/controllers/results_rendering.rb
mumuki-laboratory-5.0.9 lib/mumuki/laboratory/controllers/results_rendering.rb
mumuki-laboratory-5.0.8 lib/mumuki/laboratory/controllers/results_rendering.rb
mumuki-laboratory-5.0.7 lib/mumuki/laboratory/controllers/results_rendering.rb
mumuki-laboratory-5.0.6 lib/mumuki/laboratory/controllers/results_rendering.rb
mumuki-laboratory-5.0.5 lib/mumuki/laboratory/controllers/results_rendering.rb
mumuki-laboratory-5.0.4 lib/mumuki/laboratory/controllers/results_rendering.rb
mumuki-laboratory-5.0.3 lib/mumuki/laboratory/controllers/results_rendering.rb
mumuki-laboratory-5.0.2 lib/mumuki/laboratory/controllers/results_rendering.rb
mumuki-laboratory-5.0.1 lib/mumuki/laboratory/controllers/results_rendering.rb
mumuki-laboratory-5.0.0 lib/mumuki/laboratory/controllers/results_rendering.rb