Sha256: 664717a697775bd00cb4991a6b39311b8374ae92262722e3b02c562f6f0abc88

Contents?: true

Size: 1.35 KB

Versions: 11

Compression:

Stored size: 1.35 KB

Contents

class ExercisesController < ApplicationController
  include Mumuki::Laboratory::Controllers::Content
  include Mumuki::Laboratory::Controllers::ExerciseSeed

  before_action :set_guide!, only: :show
  before_action :set_assignment!, only: :show, if: :current_user?
  before_action :validate_accessible!, only: :show
  before_action :start!, only: :show

  def show
    @solution = @exercise.new_solution if current_user?
    enable_embedded_rendering
  end

  def show_by_slug
    redirect_to Guide.by_slug_parts!(params).exercises.find_by!(bibliotheca_id: params[:bibliotheca_id])
  end

  private

  def subject
    @exercise ||= Exercise.find_by(id: params[:id])
  end

  def accessible_subject
    subject.navigable_parent
  end

  def start!
    @exercise.navigable_parent.start! current_user
  end

  def set_assignment!
    @assignment = @exercise.assignment_for(current_user)
    @files = @assignment.files
    @current_content = @assignment.current_content
    @default_content = @assignment.default_content
  end

  def set_guide!
    raise Mumuki::Laboratory::NotFoundError if @exercise.nil?
    @guide = @exercise.guide
  end

  def exercise_params
    params.require(:exercise).
      permit(:name, :description, :locale, :test,
             :extra, :language_id, :hint, :tag_list,
             :guide_id, :number,
             :layout, :expectations_yaml)
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
mumuki-laboratory-5.13.0 app/controllers/exercises_controller.rb
mumuki-laboratory-5.12.1 app/controllers/exercises_controller.rb
mumuki-laboratory-5.12.0 app/controllers/exercises_controller.rb
mumuki-laboratory-5.11.0 app/controllers/exercises_controller.rb
mumuki-laboratory-5.10.4 app/controllers/exercises_controller.rb
mumuki-laboratory-5.10.3 app/controllers/exercises_controller.rb
mumuki-laboratory-5.10.2 app/controllers/exercises_controller.rb
mumuki-laboratory-5.10.1 app/controllers/exercises_controller.rb
mumuki-laboratory-5.10.0 app/controllers/exercises_controller.rb
mumuki-laboratory-5.9.1 app/controllers/exercises_controller.rb
mumuki-laboratory-5.9.0 app/controllers/exercises_controller.rb