From 4606cf7c28dc83628ec0bafa95c18348fe7ba79b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 15 Jul 2015 14:57:47 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9A=E4=B8=AA=E8=BE=93=E5=85=A5=E8=BE=93?= =?UTF-8?q?=E5=87=BA=202=E3=80=81=E7=BC=96=E7=A8=8B=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E5=8F=82=E6=95=B0=E8=8E=B7=E5=8F=96=E6=94=B9?= =?UTF-8?q?=E4=B8=BAparams=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 13 +++++++------ app/controllers/student_work_controller.rb | 5 ++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index dce5bdf6c..a8ccf2b9a 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -75,6 +75,8 @@ class HomeworkCommonController < ApplicationController question = {title:homework.name,content:homework.description} uri = URI('http://test.gitlab.trustie.net/api/questions.json') + question[:input] = [] + question[:output] = [] if params[:input] && params[:output] params[:input].each do |k,v| if params[:output].include? k @@ -82,15 +84,14 @@ class HomeworkCommonController < ApplicationController homework_test.input = v homework_test.output = params[:output][k] homework.homework_tests << homework_test - question[:input] = homework_test.input - question[:output] = homework_test.output - - res = Net::HTTP.post_form(uri, question) - result = JSON.parse(res.body) - homework_detail_programing.question_id = result["id"] if result["status"] && result["status"] == 0 + question[:input] << homework_test.input + question[:output] << homework_test.output end end end + res = Net::HTTP.post_form(uri, question) + 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 diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index da4e01d8a..cf712bfc9 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -323,10 +323,9 @@ class StudentWorkController < ApplicationController #设置编程作业得分 def set_program_score - res = JSON.parse(response.body) - stundet_work = StudentWork.find_by_id res["id"] + stundet_work = StudentWork.find_by_id params[:id] if stundet_work - stundet_work.update_column("student_score",res["status"]) + stundet_work.update_column("student_score",params[:status] == 0 ? 100 : 0) end end