修改编程作业发送
This commit is contained in:
parent
ffee6d27a6
commit
c1824a6db0
|
@ -236,6 +236,25 @@ class HomeworkCommonController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#发送修改作业的请求
|
||||||
|
question = {title:@homework.name,content:@homework.description}
|
||||||
|
question[:input] = []
|
||||||
|
question[:output] = []
|
||||||
|
@homework.homework_tests.each do |test|
|
||||||
|
question[:input] << test.input
|
||||||
|
question[:output] << test.output
|
||||||
|
end
|
||||||
|
uri = URI("http://192.168.80.21:8080/api/questions/#{@homework_detail_programing.question_id}.json")
|
||||||
|
body = question.to_json
|
||||||
|
res = Net::HTTP.new(uri.host, uri.port).start do |client|
|
||||||
|
request = Net::HTTP::Put.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
|
||||||
end
|
end
|
||||||
|
|
||||||
@homework.save_attachments(params[:attachments])
|
@homework.save_attachments(params[:attachments])
|
||||||
|
|
Loading…
Reference in New Issue