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 class HomeworkCommonController < ApplicationController
require 'net/http' require 'net/http'
require 'json' require 'json'
require "base64"
layout "base_courses" layout "base_courses"
before_filter :find_course, :only => [:index,:new,:create,:next_step] 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] 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 end
def programing_test 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] @index = params[:index]
uri = URI('http://192.168.80.21:8080/api/realtime.json') uri = URI('http://192.168.80.21:8080/api/realtime.json')
body = test.to_json body = test.to_json
@ -364,8 +365,8 @@ class HomeworkCommonController < ApplicationController
client.request(request) client.request(request)
end end
result = JSON.parse(res.body) result = JSON.parse(res.body)
result[:results].each do |re| result["results"].each do |re|
@result = re[:status] @result = re["status"]
end end
end end

View File

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

View File

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