修改回调函数

This commit is contained in:
sw 2015-07-16 14:26:43 +08:00
parent b6e123e476
commit 17e6102005
1 changed files with 10 additions and 4 deletions

View File

@ -124,7 +124,7 @@ class StudentWorkController < ApplicationController
url = "http://test.gitlab.trustie.net/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json"
uri = URI(url)
solutions = {
id:stundet_work.id,
stundet_work_id:stundet_work.id,
src:stundet_work.description,
language:1
}
@ -372,9 +372,15 @@ class StudentWorkController < ApplicationController
#设置编程作业得分
def set_program_score
stundet_work = StudentWork.find_by_id params[:id]
if stundet_work
stundet_work.update_column("student_score",params[:status] == 0 ? 100 : 0)
stundet_work = StudentWork.find_by_id params[:student_work_id]
if stundet_work && params[:result] && 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
if homework_test
StudentWorkTest.create(:student_work_id => stundet_work.id,:homework_test_id => homework_test.id,:result => result[:status])
end
end
end
end