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