|
|
@ -8,7 +8,6 @@ class StudentWorkController < ApplicationController
|
|
|
|
before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work]
|
|
|
|
before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work]
|
|
|
|
before_filter :author_of_work, :only => [:edit, :update, :destroy]
|
|
|
|
before_filter :author_of_work, :only => [:edit, :update, :destroy]
|
|
|
|
before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list]
|
|
|
|
before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list]
|
|
|
|
protect_from_forgery :except => :set_program_score
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
###
|
|
|
|
def program_test
|
|
|
|
def program_test
|
|
|
@ -360,46 +359,6 @@ class StudentWorkController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#设置编程作业得分
|
|
|
|
|
|
|
|
def set_program_score
|
|
|
|
|
|
|
|
stundet_work = StudentWork.find_by_id params[:student_work_id]
|
|
|
|
|
|
|
|
@course = stundet_work.homework_common.course
|
|
|
|
|
|
|
|
student_score_count = 0
|
|
|
|
|
|
|
|
if stundet_work && params[:results] && params[:results].class.to_s == "Array"
|
|
|
|
|
|
|
|
homework_common = stundet_work.homework_common
|
|
|
|
|
|
|
|
params[:results].each do |result|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
student_work_test.result = result[:status]
|
|
|
|
|
|
|
|
if student_work_test.result == 0
|
|
|
|
|
|
|
|
student_score_count += 1
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
student_work_test.error_msg = params[:compile_error_msg]
|
|
|
|
|
|
|
|
student_work_test.save!
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
unless homework_common.homework_tests.empty?
|
|
|
|
|
|
|
|
stundet_work.student_score = student_score_count * 100.0 / homework_common.homework_tests.count
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if stundet_work.teacher_score.nil?
|
|
|
|
|
|
|
|
if stundet_work.teaching_asistant_score.nil?
|
|
|
|
|
|
|
|
stundet_work.final_score = stundet_work.student_score
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
final_ta_score = BigDecimal.new("#{stundet_work.teaching_asistant_score}") * BigDecimal.new("#{homework_common.homework_detail_programing.ta_proportion}")
|
|
|
|
|
|
|
|
final_s_score = BigDecimal.new("#{stundet_work.student_score}") * (BigDecimal.new('1.0') - BigDecimal.new("#{homework_common.homework_detail_programing.ta_proportion}"))
|
|
|
|
|
|
|
|
final_score = final_ta_score + final_s_score
|
|
|
|
|
|
|
|
stundet_work.final_score = format("%.1f",final_score.to_f)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stundet_work.save!
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
private
|
|
|
|
#获取作业
|
|
|
|
#获取作业
|
|
|
|
def find_homework
|
|
|
|
def find_homework
|
|
|
|