From c1824a6db01d24ba120556bf1543fae7755f529a Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 22 Jul 2015 17:47:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=96=E7=A8=8B=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 54963b0fd..333f86da1 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -236,6 +236,25 @@ class HomeworkCommonController < ApplicationController 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 @homework.save_attachments(params[:attachments])