diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 58d3c8d12..a6fae032f 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -99,12 +99,13 @@ class HomeworkCommonController < ApplicationController question = {title:homework.name,content:homework.description} question[:input] = [] question[:output] = [] - if params[:input] && params[:output] + if params[:input] && params[:output] && params[:result] params[:input].each do |k,v| if params[:output].include? k homework_test = HomeworkTest.new homework_test.input = v homework_test.output = params[:output][k] + homework_test.result = params[:result][k] homework.homework_tests << homework_test question[:input] << homework_test.input question[:output] << homework_test.output @@ -119,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 @@ -352,7 +353,20 @@ class HomeworkCommonController < ApplicationController end 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 end private diff --git a/app/views/homework_common/_homework_detail_programing_form.html.erb b/app/views/homework_common/_homework_detail_programing_form.html.erb index 1d4c52c71..5e53c4b15 100644 --- a/app/views/homework_common/_homework_detail_programing_form.html.erb +++ b/app/views/homework_common/_homework_detail_programing_form.html.erb @@ -96,8 +96,8 @@
  • - 测试 - + 测试 +
  • @@ -115,8 +115,8 @@
  • - 测试 - + 测试 +
  • @@ -134,7 +134,8 @@ src: $("textarea[name='standard_code']").val(), input: $("input[name='input[" + obj +"]']").val(), output: $("input[name='output[" + obj + "]']").val(), - language: $("select[name='language']").val() + language: $("select[name='language']").val(), + index: obj }, function (data) { diff --git a/app/views/homework_common/programing_test.js.erb b/app/views/homework_common/programing_test.js.erb index e69de29bb..4f5b115db 100644 --- a/app/views/homework_common/programing_test.js.erb +++ b/app/views/homework_common/programing_test.js.erb @@ -0,0 +1,2 @@ +$("#test_send_<%= @index%>").replaceWith("错误"); +$("#test_result_<%= @index%>").val("1"); \ No newline at end of file diff --git a/public/javascripts/course.js b/public/javascripts/course.js index dd2d300d1..c7b01cee1 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -550,8 +550,8 @@ function add_programing_test(obj) { "
  • " + "
  • " + "" + - "测试" + - "" + + "测试" + + "" + "
  • "); } //删除测试结果 diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 7ccb783fe..5c6fd9867 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -88,8 +88,6 @@ a:hover.talk_edit{ color:#ff5722;} .talk_text{ border:1px solid #64bdd9; height:100px;width:550px; background:#fff; margin-left:5px; padding:5px; margin-bottom:10px;} .talk_new ul li{ } .sb{width:70px; height:26px; color:#606060; cursor:pointer;} -a.blue_btn{ background:#64bdd9; display:block; font-size:14px;color:#fff; font-weight:normal; text-align:center; margin-left:10px; margin-bottom:10px; padding:2px 10px;} -a:hover.blue_btn{ background:#329cbd;} a.grey_btn{ background:#d9d9d9; color:#656565;font-size:14px; font-weight:normal; text-align:center; margin-left:10px; margin-bottom:10px; padding:2px 10px;} a:hover.grey_btn{ background:#717171; color:#fff;} /****资源库***/ diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 2a9e71e7d..1bf889cba 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -169,8 +169,10 @@ a:hover.grey_btn{ background:#717171; color:#fff;} .green_btn{ background:#28be6c; color:#fff; font-size:14px; font-weight:normal;padding:2px 8px; text-align:center;} a.green_btn{background:#28be6c;color:#fff;font-size:14px; font-weight:normal; padding:2px 8px; text-align:center;cursor: pointer;} a:hover.green_btn{ background:#14ad5a;} -.blue_btn{ background:#64bdd9; color:#fff; font-size:14px; font-weight:normal;padding:2px 10px; text-align:center;} -a.blue_btn{background:#64bdd9;color:#fff;font-size:14px; font-weight:normal; padding:2px 10px; text-align:center;} +.blue_btn{ background:#64bdd9; color:#fff; font-size:14px; font-weight:normal;padding:2px 8px; text-align:center;} +a.blue_btn{background:#64bdd9;color:#fff;font-size:14px; font-weight:normal; padding:2px 8px; text-align:center;} +.red_btn{ background:red; color:#fff; font-size:14px; font-weight:normal;padding:2px 8px; text-align:center;} +a.red_btn{background:red; color:#fff;font-size:14px; font-weight:normal; padding:2px 8px; text-align:center;} a.orange_btn_homework{background:#d63502;color:#fff;font-size:14px; font-weight:normal; padding:2px 10px; text-align:center;} a:hover.blue_btn{ background:#329cbd;cursor: pointer;} a.orange_btn{ background:#ff5722;color:#fff;font-size:14px; font-weight:normal; padding:2px 10px; text-align:center; }