回调函数页面返回

回调函数不能存储结果
This commit is contained in:
sw 2015-07-17 15:31:49 +08:00
parent fa2dfd0692
commit c18481e89c
2 changed files with 9 additions and 3 deletions

View File

@ -380,12 +380,17 @@ class StudentWorkController < ApplicationController
#设置编程作业得分
def set_program_score
stundet_work = StudentWork.find_by_id params[:student_work_id]
if stundet_work && params[:result] && params[:results].class.to_s == "Array"
@course = stundet_work.homework_common.course
if stundet_work && params[:results] && params[:results].class.to_s == "Array"
homework_common = stundet_work.homework_common
params[:results].each do |result|
homework_test = homework_common.homework_tests.where("input = #{result[:input]} AND output = #{result[:output]}").first
homework_test = homework_common.homework_tests.where("input = '#{result[:input]}' AND output = '#{result[:output]}'").first
if homework_test
StudentWorkTest.create(:student_work_id => stundet_work.id,:homework_test_id => homework_test.id,:result => result[:status])
student_work_test = StudentWorkTest.new
student_work_test.student_work = stundet_work
student_work_test.homework_test = homework_test
student_work_test.result = result[:status]
student_work_test.save
end
end
end

View File

@ -0,0 +1 @@
成功