根据编译返回结果,自动刷新页面是否成功
This commit is contained in:
parent
f163cdac51
commit
c507a97ac6
|
@ -120,16 +120,16 @@ class HomeworkCommonController < ApplicationController
|
||||||
# http.request(req)
|
# http.request(req)
|
||||||
# end
|
# end
|
||||||
|
|
||||||
# uri = URI('http://192.168.80.21:8080/api/questions.json')
|
uri = URI('http://192.168.80.21:8080/api/questions.json')
|
||||||
# body = question.to_json
|
body = question.to_json
|
||||||
# res = Net::HTTP.new(uri.host, uri.port).start do |client|
|
res = Net::HTTP.new(uri.host, uri.port).start do |client|
|
||||||
# request = Net::HTTP::Post.new(uri.path)
|
request = Net::HTTP::Post.new(uri.path)
|
||||||
# request.body = body
|
request.body = body
|
||||||
# request["Content-Type"] = "application/json"
|
request["Content-Type"] = "application/json"
|
||||||
# client.request(request)
|
client.request(request)
|
||||||
# end
|
end
|
||||||
# result = JSON.parse(res.body)
|
result = JSON.parse(res.body)
|
||||||
# homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0
|
homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0
|
||||||
|
|
||||||
homework.homework_detail_programing = homework_detail_programing
|
homework.homework_detail_programing = homework_detail_programing
|
||||||
else
|
else
|
||||||
|
@ -355,18 +355,16 @@ class HomeworkCommonController < ApplicationController
|
||||||
def programing_test
|
def programing_test
|
||||||
test = {language:params[:language],src:params[:src],input:[params[:input]],output:[params[:output]]}
|
test = {language:params[:language],src:params[:src],input:[params[:input]],output:[params[:output]]}
|
||||||
@index = params[:index]
|
@index = params[:index]
|
||||||
# uri = URI('http://192.168.80.21:8080/api/realtime.json')
|
uri = URI('http://192.168.80.21:8080/api/realtime.json')
|
||||||
# body = test.to_json
|
body = test.to_json
|
||||||
# res = Net::HTTP.new(uri.host, uri.port).start do |client|
|
res = Net::HTTP.new(uri.host, uri.port).start do |client|
|
||||||
# request = Net::HTTP::Post.new(uri.path)
|
request = Net::HTTP::Post.new(uri.path)
|
||||||
# request.body = body
|
request.body = body
|
||||||
# request["Content-Type"] = "application/json"
|
request["Content-Type"] = "application/json"
|
||||||
# client.request(request)
|
client.request(request)
|
||||||
# end
|
end
|
||||||
# result = JSON.parse(res.body)
|
result = JSON.parse(res.body)
|
||||||
# homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0
|
@result = result[:result][0][:status]
|
||||||
#
|
|
||||||
# homework.homework_detail_programing = homework_detail_programing
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
$("#test_send_<%= @index%>").replaceWith("<span class='red_btn fl ml5 mt1'>错误</span>");
|
$("#test_send_<%= @index%>").replaceWith("<span class='<%= @result == 0 ? 'green_btn' : 'red_btn'%> fl ml5 mt1'><%= @result == 0 ? '正确' : '错误'%></span>");
|
||||||
$("#test_result_<%= @index%>").val("1");
|
$("#test_result_<%= @index%>").val("<%= @result%>");
|
Loading…
Reference in New Issue