added search intervention. search opens new tab with search in the java course (at least in chrome)
send only 3 interventions per exercise at maximum
This commit is contained in:
@@ -156,11 +156,13 @@ class ExercisesController < ApplicationController
|
||||
def implement
|
||||
redirect_to(@exercise, alert: t('exercises.implement.no_files')) unless @exercise.files.visible.exists?
|
||||
@show_interventions =
|
||||
if UserExerciseIntervention.find_by(exercise: @exercise, user: current_user)
|
||||
if UserExerciseIntervention.where(exercise: @exercise, user: current_user).count >= 3
|
||||
"false"
|
||||
else
|
||||
"true"
|
||||
end
|
||||
@search = Search.new
|
||||
@search.exercise = @exercise
|
||||
@submission = current_user.submissions.where(exercise_id: @exercise.id).order('created_at DESC').first
|
||||
@files = (@submission ? @submission.collect_files : @exercise.files).select(&:visible).sort_by(&:name_with_extension)
|
||||
@paths = collect_paths(@files)
|
||||
|
34
app/controllers/searches_controller.rb
Normal file
34
app/controllers/searches_controller.rb
Normal file
@@ -0,0 +1,34 @@
|
||||
class SearchesController < ApplicationController
|
||||
include CommonBehavior
|
||||
|
||||
def authorize!
|
||||
authorize(@search || @searchs)
|
||||
end
|
||||
private :authorize!
|
||||
|
||||
|
||||
def create
|
||||
@search = Search.new(search_params)
|
||||
@search.user = current_user
|
||||
authorize!
|
||||
|
||||
respond_to do |format|
|
||||
if @search.save
|
||||
path = implement_exercise_path(@search.exercise)
|
||||
respond_with_valid_object(format, path: path, status: :created)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def search_params
|
||||
params[:search].permit(:search, :exercise_id)
|
||||
end
|
||||
private :search_params
|
||||
|
||||
def index
|
||||
@search = policy_scope(ProxyExercise).search(params[:q])
|
||||
@searches = @search.result.order(:title).paginate(page: params[:page])
|
||||
authorize!
|
||||
end
|
||||
|
||||
end
|
Reference in New Issue
Block a user