|
|
|
@ -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
|
|
|
|
|