修改作业逻辑梳理

This commit is contained in:
sw 2015-07-06 10:44:27 +08:00
parent 5e90684677
commit e734abe613
1 changed files with 11 additions and 19 deletions

View File

@ -133,19 +133,8 @@ class HomeworkCommonController < ApplicationController
end
@homework.late_penalty = params[:late_penalty]
end
@homework.course_id = @course.id
# @homework.course_id = @course.id
@homework_detail_programing = @homework.homework_detail_programing
if @homework.homework_type == 2 #编程作业
@homework_detail_programing.language = "C++"
@homework_detail_programing.standard_code = params[:standard_code]
homework_tests = @homework.homework_tests
#需要删除的测试
ids = homework_tests.map(&:id) - params[:input].keys.map(&:to_i)
ids.each do |id|
homework_test = HomeworkTest.find id
homework_test.destroy if homework_test
end
#匿评作业相关属性
if @homework.homework_type == 1
@homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6
@ -171,6 +160,16 @@ class HomeworkCommonController < ApplicationController
@homework_detail_manual.absence_penalty = 0
end
if @homework.homework_type == 2 #编程作业
@homework_detail_programing.language = "C++"
@homework_detail_programing.standard_code = params[:standard_code]
homework_tests = @homework.homework_tests
#需要删除的测试
ids = homework_tests.map(&:id) - params[:input].keys.map(&:to_i)
ids.each do |id|
homework_test = HomeworkTest.find id
homework_test.destroy if homework_test
end
if params[:input] && params[:output]
params[:input].each do |k,v|
if params[:output].include? k
@ -188,13 +187,6 @@ class HomeworkCommonController < ApplicationController
end
end
end
else
#匿评作业相关属性
@homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6
@homework_detail_manual.evaluation_start = params[:evaluation_start]
@homework_detail_manual.evaluation_end = params[:evaluation_end]
@homework_detail_manual.evaluation_num = params[:evaluation_num]
@homework_detail_manual.absence_penalty = params[:absence_penalty]
end
@homework.save_attachments(params[:attachments])