老师点击测试自动刷新,每组测试对标准代码的返回结果存储
This commit is contained in:
parent
3e5af49281
commit
f163cdac51
|
@ -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
|
||||
|
|
|
@ -96,8 +96,8 @@
|
|||
<li>
|
||||
<a class="icon_add ml10 " href="javascript:void(0);" title="添加测试" onclick="add_programing_test($(this).parent().parent())"></a>
|
||||
<a class="icon_remove" href="javascript:void(0);" title="删除测试" onclick="remove_programing_test($(this).parent().parent())"></a>
|
||||
<a class="green_btn fl ml5 mt1" onclick="programing_test('<%= homework_test.id%>')">测试</a>
|
||||
<input type="hidden" class="fl h26 w190 mb10" id="test_result_<%= homework_test.id%>" name="result[<%= homework_test.id%>]" />
|
||||
<a class="blue_btn fl ml5 mt1" onclick="programing_test('<%= homework_test.id%>')" id="test_send_<%= homework_test.id%>">测试</a>
|
||||
<input type="hidden" id="test_result_<%= homework_test.id%>" name="result[<%= homework_test.id%>]" />
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
|
@ -115,8 +115,8 @@
|
|||
<li>
|
||||
<a class="icon_add ml10 " href="javascript:void(0);" title="添加测试" onclick="add_programing_test($(this).parent().parent())"></a>
|
||||
<a class="icon_remove" href="javascript:void(0);" title="删除测试" onclick="remove_programing_test($(this).parent().parent())"></a>
|
||||
<a class="green_btn fl ml5 mt1" onclick="programing_test('0')">测试</a>
|
||||
<input type="hidden" class="fl h26 w190 mb10" id="test_result_0" name="result[0]" />
|
||||
<a class="blue_btn fl ml5 mt1" onclick="programing_test('0')" id="test_send_0">测试</a>
|
||||
<input type="hidden" id="test_result_0" name="result[0]" />
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
|
@ -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) {
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
$("#test_send_<%= @index%>").replaceWith("<span class='red_btn fl ml5 mt1'>错误</span>");
|
||||
$("#test_result_<%= @index%>").val("1");
|
|
@ -550,8 +550,8 @@ function add_programing_test(obj) {
|
|||
"</li><li ><label class='fl f14 ml10'> 输出: </label><input type='text' class='fl h26 w190 mb10' name='output[" + now +"]' />" +
|
||||
"</li><li><a class='icon_add ml10' href='javascript:void(0);' title='添加测试' onclick='add_programing_test($(this).parent().parent())'></a>" +
|
||||
"<a class='icon_remove' href='javascript:void(0);' title='删除测试' onclick='remove_programing_test($(this).parent().parent())'></a>" +
|
||||
"<a class='green_btn fl ml5 mt1' onclick='programing_test("+ now +")'>测试</a>" +
|
||||
"<input type='hidden' id='test_result_" + now +"' name='result[" + now +"]' />" +
|
||||
"<a class='blue_btn fl ml5 mt1' onclick='programing_test("+ now +")' id='test_send_" + now + "'>测试</a>" +
|
||||
"<input type='hidden' id='test_result_" + now +"' name='result[" + now +"]'/>" +
|
||||
"</li><div class='cl'></div></div>");
|
||||
}
|
||||
//删除测试结果
|
||||
|
|
|
@ -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;}
|
||||
/****资源库***/
|
||||
|
|
|
@ -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; }
|
||||
|
|
Loading…
Reference in New Issue