diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index f48633a53..e3424707f 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -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 diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb index 6847da2c7..4a804ae60 100644 --- a/app/views/homework_common/index.html.erb +++ b/app/views/homework_common/index.html.erb @@ -48,30 +48,32 @@
- <% if homework.homework_type == 2 && homework.homework_detail_programing && @is_teacher%> - - - "> - - - - <% homework.homework_tests.each do |test|%> + <% if homework.homework_type == 2 && homework.homework_detail_programing%> + <% if @is_teacher%> +
- 输入 - - 输出 -
+ "> - <% end%> - -
- <%=test.input%> + 输入 - <%= test.output%> + 输出
-
+ <% homework.homework_tests.each do |test|%> + "> + + <%=test.input%> + + + <%= test.output%> + + + <% end%> + + +
+ <% end%>
开发语言: diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index 92f6f93e0..3783d67d3 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -137,29 +137,31 @@
<% if @homework.homework_type == 2 && @homework.homework_detail_programing%> - - - "> - - - - <% @homework.homework_tests.each do |test|%> + <% if @is_teacher%> +
- 输入 - - 输出 -
+ "> - <% end%> - -
- <%=test.input%> + 输入 - <%= test.output%> + 输出
-
+ <% homework.homework_tests.each do |test|%> + "> + + <%=test.input%> + + + <%= test.output%> + + + <% end%> + + +
+ <% end%>
开发语言: