|
|
|
@ -14,8 +14,8 @@ class StudentWorkController < ApplicationController
|
|
|
|
|
def program_test
|
|
|
|
|
is_test = params[:is_test] == 'true'
|
|
|
|
|
resultObj = {status: 0, results: [], error_msg: '', time: Time.now.strftime('%Y-%m-%d %T')}
|
|
|
|
|
unless is_test
|
|
|
|
|
student_work = find_or_save_student_work
|
|
|
|
|
|
|
|
|
|
student_work = find_or_save_student_work(is_test)
|
|
|
|
|
|
|
|
|
|
unless student_work
|
|
|
|
|
resultObj[:status] = 100
|
|
|
|
@ -43,24 +43,7 @@ class StudentWorkController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
if @homework.homework_type == 2 && @homework.homework_detail_programing
|
|
|
|
|
result = test_realtime(student_work, params[:src])
|
|
|
|
|
logger.debug result
|
|
|
|
|
resultObj[:status] = result["status"]
|
|
|
|
|
resultObj[:results] = result["results"]
|
|
|
|
|
resultObj[:error_msg] = result["error_msg"]
|
|
|
|
|
results = result["results"]
|
|
|
|
|
if result["status"].to_i == -2 #编译错误
|
|
|
|
|
results = [result["error_msg"]]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
resultObj[:status] = result["status"].to_i
|
|
|
|
|
resultObj[:time] = Time.now.strftime('%Y-%m-%d %T')
|
|
|
|
|
resultObj[:index] = 0
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
render :json => resultObj
|
|
|
|
@ -640,13 +623,14 @@ class StudentWorkController < ApplicationController
|
|
|
|
|
xls_report.string
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def find_or_save_student_work
|
|
|
|
|
def find_or_save_student_work(is_test)
|
|
|
|
|
student_work = @homework.student_works.where(user_id: User.current.id).first
|
|
|
|
|
if student_work.nil?
|
|
|
|
|
@homework.student_works.build(
|
|
|
|
|
name: params[:title],
|
|
|
|
|
description: params[:src],
|
|
|
|
|
user_id: User.current.id
|
|
|
|
|
user_id: User.current.id,
|
|
|
|
|
is_test: is_test
|
|
|
|
|
)
|
|
|
|
|
unless @homework.save
|
|
|
|
|
else
|
|
|
|
|