与编程作业服务器联调
This commit is contained in:
parent
24d6c8e17e
commit
11191f6743
|
@ -1,4 +1,5 @@
|
|||
class HomeworkCommonController < ApplicationController
|
||||
require 'net/http'
|
||||
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]
|
||||
|
@ -72,6 +73,8 @@ class HomeworkCommonController < ApplicationController
|
|||
homework_detail_programing.language = "C++"
|
||||
homework_detail_programing.standard_code = params[:standard_code]
|
||||
|
||||
question = {title:homework.name,content:homework.description}
|
||||
uri = URI('http://fast.forge.trustie.net/api/questions.json')
|
||||
if params[:input] && params[:output]
|
||||
params[:input].each do |k,v|
|
||||
if params[:output].include? k
|
||||
|
@ -79,6 +82,10 @@ class HomeworkCommonController < ApplicationController
|
|||
homework_test.input = v
|
||||
homework_test.output = params[:output][k]
|
||||
homework.homework_tests << homework_test
|
||||
question[:input] = homework_test.input
|
||||
question[:output] = homework_test.output
|
||||
|
||||
res = Net::HTTP.post_form(uri, question)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -80,8 +80,14 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
render_attachment_warning_if_needed(stundet_work)
|
||||
|
||||
if @homework.homework_type == 2 #编程作业,学生提交作品后计算系统得分
|
||||
|
||||
if @homework.homework_type == 2 && @homework.homework_detail_programing #编程作业,学生提交作品后计算系统得分
|
||||
url = "http://fast.forge.trustie.net/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json"
|
||||
uri = URI(url)
|
||||
solutions = {
|
||||
src:stundet_work.description,
|
||||
language:1
|
||||
}
|
||||
Net::HTTP.post_form(uri, solutions)
|
||||
end
|
||||
|
||||
if stundet_work.save
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20150708085629) do
|
||||
ActiveRecord::Schema.define(:version => 20150709071731) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -589,6 +589,7 @@ ActiveRecord::Schema.define(:version => 20150708085629) do
|
|||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.float "ta_proportion", :default => 0.1
|
||||
t.integer "question_id"
|
||||
end
|
||||
|
||||
create_table "homework_evaluations", :force => true do |t|
|
||||
|
|
Loading…
Reference in New Issue