编程作业有多个输入输出测试集一样时只有第一个会进行编译结果的赋值

This commit is contained in:
sw 2015-08-01 16:38:58 +08:00
parent d1569c18ba
commit 9a7a1def66
1 changed files with 2 additions and 2 deletions

View File

@ -387,8 +387,8 @@ class StudentWorkController < ApplicationController
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
if homework_test
homework_tests = homework_common.homework_tests.where("input = '#{result[:input]}' AND output = '#{result[:output]}'")
homework_tests.each do |homework_test|
student_work_test = StudentWorkTest.new
student_work_test.student_work = stundet_work
student_work_test.homework_test = homework_test