socialforge/app/controllers/myshixuns_controller.rb

40 lines
1.2 KiB
Ruby

class MyshixunsController < ApplicationController
layout 'base_myshixun'
skip_before_filter :verify_authenticity_token, :only => [:training_task_status]
before_filter :require_login, :except => [:training_task_status]
before_filter :find_myshixun, :only => [:show]
# taskId 即返回的game id
# params [:stauts] 0 表示成功,其它则失败
# msg 错误信息
# output 为测试用户编译输出结果
def training_task_status
status = params[:status].to_i
task_id = params[:taskId]
outPut = params[:outPut]
message = Base64.decode64(params[:msg]) unless params[:msg].blank?
game = Game.find(task_id)
if game.status == 0
game.update_attribute(:status, 2)
message = nil
else
game.update_attribute(:status, 0)
end
game_outputs = GameOutputs.create(:code => status, :msg => message, :game_id => task_id, :out_put => outPut)
end
def show
respond_to do |format|
format.html{redirect_to myshixun_game_path(@myshixun.current_task, :myshixun_id => @myshixun)}
end
end
private
# Find myshixun of id params[:id]
def find_myshixun
@myshixun = Myshixun.find(params[:id])
rescue ActiveRecord::RecordNotFound
render_404
end
end