This commit is contained in:
cxt 2015-08-01 10:02:23 +08:00
commit 8de8fe69cc
3 changed files with 43 additions and 38 deletions

View File

@ -1,6 +1,7 @@
class HomeworkCommonController < ApplicationController
require 'net/http'
require 'json'
require "base64"
layout "base_courses"
before_filter :find_course, :only => [:index,:new,:create,:next_step]
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy]
@ -353,7 +354,7 @@ class HomeworkCommonController < ApplicationController
end
def programing_test
test = {language:params[:language],src:params[:src],input:[params[:input]],output:[params[:output]]}
test = {language:params[:language],src:Base64.encode64(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
@ -364,8 +365,8 @@ class HomeworkCommonController < ApplicationController
client.request(request)
end
result = JSON.parse(res.body)
result[:results].each do |re|
@result = re[:status]
result["results"].each do |re|
@result = re["status"]
end
end

View File

@ -48,30 +48,32 @@
</div>
<div class="cl"></div>
<% if homework.homework_type == 2 && homework.homework_detail_programing && @is_teacher%>
<table class="border_ce" cellpadding="0" cellspacing="0">
<tbody>
<tr class="<%= cycle("", "b_grey") %>">
<td class="td_tit">
输入
</td>
<td class="td_tit">
输出
</td>
</tr>
<% homework.homework_tests.each do |test|%>
<% if homework.homework_type == 2 && homework.homework_detail_programing%>
<% if @is_teacher%>
<table class="border_ce" cellpadding="0" cellspacing="0">
<tbody>
<tr class="<%= cycle("", "b_grey") %>">
<td class="td_tit">
<%=test.input%>
输入
</td>
<td class="td_tit">
<%= test.output%>
输出
</td>
</tr>
<% end%>
</tbody>
</table>
<div class="cl"></div>
<% homework.homework_tests.each do |test|%>
<tr class="<%= cycle("", "b_grey") %>">
<td class="td_tit">
<%=test.input%>
</td>
<td class="td_tit">
<%= test.output%>
</td>
</tr>
<% end%>
</tbody>
</table>
<div class="cl"></div>
<% end%>
<div class="mt5">
<span class="tit_fb" style="width: auto;"> 开发语言:</span>

View File

@ -137,29 +137,31 @@
<div class="cl"></div>
<% if @homework.homework_type == 2 && @homework.homework_detail_programing%>
<table class="border_ce" cellpadding="0" cellspacing="0">
<tbody>
<tr class="<%= cycle("", "b_grey") %>">
<td class="td_tit">
输入
</td>
<td class="td_tit">
输出
</td>
</tr>
<% @homework.homework_tests.each do |test|%>
<% if @is_teacher%>
<table class="border_ce" cellpadding="0" cellspacing="0">
<tbody>
<tr class="<%= cycle("", "b_grey") %>">
<td class="td_tit">
<%=test.input%>
输入
</td>
<td class="td_tit">
<%= test.output%>
输出
</td>
</tr>
<% end%>
</tbody>
</table>
<div class="cl"></div>
<% homework.homework_tests.each do |test|%>
<tr class="<%= cycle("", "b_grey") %>">
<td class="td_tit">
<%=test.input%>
</td>
<td class="td_tit">
<%= test.output%>
</td>
</tr>
<% end%>
</tbody>
</table>
<div class="cl"></div>
<% end%>
<div class="mt5">
<span class="tit_fb" style="width: auto;"> 开发语言:</span>