added interventions back to code. added post method to be able to save interventions

This commit is contained in:
Thomas Hille
2017-02-28 15:26:36 +01:00
parent 3d7f5bdf1a
commit bfc96328c4
5 changed files with 30 additions and 10 deletions

View File

@ -6,7 +6,7 @@ class ExercisesController < ApplicationController
before_action :handle_file_uploads, only: [:create, :update]
before_action :set_execution_environments, only: [:create, :edit, :new, :update]
before_action :set_exercise, only: MEMBER_ACTIONS + [:clone, :implement, :working_times, :run, :statistics, :submit, :reload]
before_action :set_exercise, only: MEMBER_ACTIONS + [:clone, :implement, :working_times, :intervention, :run, :statistics, :submit, :reload]
before_action :set_external_user, only: [:statistics]
before_action :set_file_types, only: [:create, :edit, :new, :update]
@ -167,11 +167,20 @@ class ExercisesController < ApplicationController
end
def working_times
working_time_accumulated = @exercise.accumulated_working_time_for_only(current_user.id)
working_time_accumulated = @exercise.accumulated_working_time_for_only(current_user)
working_time_75_percentile = @exercise.get_quantiles([0.75]).first
render(json: {working_time_75_percentile: working_time_75_percentile, working_time_accumulated: working_time_accumulated})
end
def intervention
uei = UserExerciseIntervention.new(
user: current_user, exercise: @exercise, intervention: Intervention.first,
accumulated_worktime: @exercise.accumulated_working_time_for_only(current_user))
puts "user: #{current_user}, intervention: #{Intervention.first} #{uei.save}"
render(json: {success: 'true'})
end
def index
@search = policy_scope(Exercise).search(params[:q])
@exercises = @search.result.includes(:execution_environment, :user).order(:title).paginate(page: params[:page])