Sha256: f6ddf2cac627625ad4a60bab555a4495529a8ec5dd4c326bd2b3454b9a019f63

Contents?: true

Size: 1.36 KB

Versions: 19

Compression:

Stored size: 1.36 KB

Contents

class ExercisesController < ApplicationController
  before_action :set_guide!, only: :show
  before_action :set_default_content!, only: :show, if: :current_user?
  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?
  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_default_content!
    @files = @exercise.files_for(current_user)
    @current_content = @exercise.current_content_for(current_user)
    @default_content = @exercise.default_content_for(current_user)
  end

  def set_assignment!
    @assignment = @exercise.assignment_for(current_user)
  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

19 entries across 19 versions & 1 rubygems

Version Path
mumuki-laboratory-5.4.0 app/controllers/exercises_controller.rb
mumuki-laboratory-5.3.0 app/controllers/exercises_controller.rb
mumuki-laboratory-5.2.1 app/controllers/exercises_controller.rb
mumuki-laboratory-5.2.0 app/controllers/exercises_controller.rb
mumuki-laboratory-5.1.1 app/controllers/exercises_controller.rb
mumuki-laboratory-5.1.0 app/controllers/exercises_controller.rb
mumuki-laboratory-5.0.12 app/controllers/exercises_controller.rb
mumuki-laboratory-5.0.11 app/controllers/exercises_controller.rb
mumuki-laboratory-5.0.10 app/controllers/exercises_controller.rb
mumuki-laboratory-5.0.9 app/controllers/exercises_controller.rb
mumuki-laboratory-5.0.8 app/controllers/exercises_controller.rb
mumuki-laboratory-5.0.7 app/controllers/exercises_controller.rb
mumuki-laboratory-5.0.6 app/controllers/exercises_controller.rb
mumuki-laboratory-5.0.5 app/controllers/exercises_controller.rb
mumuki-laboratory-5.0.4 app/controllers/exercises_controller.rb
mumuki-laboratory-5.0.3 app/controllers/exercises_controller.rb
mumuki-laboratory-5.0.2 app/controllers/exercises_controller.rb
mumuki-laboratory-5.0.1 app/controllers/exercises_controller.rb
mumuki-laboratory-5.0.0 app/controllers/exercises_controller.rb