diff --git a/app/controllers/heartbeat_controller.rb b/app/controllers/heartbeat_controller.rb --- a/app/controllers/heartbeat_controller.rb +++ b/app/controllers/heartbeat_controller.rb @@ -2,11 +2,11 @@ before_filter :admin_authorization, :only => ['index'] def edit - @user = User.find_by_login(params[:id]) - unless @user - render text: "LOGIN_NOT_FOUND" - return - end + #@user = User.find_by_login(params[:id]) + #unless @user + # render text: "LOGIN_NOT_FOUND" + # return + #end #hb = HeartBeat.where(user_id: @user.id, ip_address: request.remote_ip).first #puts "status = #{params[:status]}" @@ -19,9 +19,24 @@ #else # HeartBeat.creae(user_id: @user.id, ip_address: request.remote_ip) #end - HeartBeat.create(user_id: @user.id, ip_address: request.remote_ip, status: params[:status]) + #HeartBeat.create(user_id: @user.id, ip_address: request.remote_ip, status: params[:status]) + + res = GraderConfiguration['right.heartbeat_response'] + res.strip! if res + full = GraderConfiguration['right.heartbeat_response_full'] + full.strip! if full - render text: (GraderConfiguration['right.heartbeat_response'] || 'OK') + if full and full != '' + l = Login.where(ip_address: request.remote_ip).last + @user = l.user + if @user.solve_all_available_problems? + render text: (full || 'OK') + else + render text: (res || 'OK') + end + else + render text: (GraderConfiguration['right.heartbeat_response'] || 'OK') + end end def index