|
|
|
@ -24,7 +24,7 @@ class StudentWork < ActiveRecord::Base
|
|
|
|
|
scope :all_commit, lambda{where("work_status != 0")}
|
|
|
|
|
|
|
|
|
|
before_destroy :delete_praise
|
|
|
|
|
before_save :set_program_score, :set_src
|
|
|
|
|
before_save :set_program_score
|
|
|
|
|
|
|
|
|
|
after_save :update_avg_sum_score
|
|
|
|
|
# after_create :act_as_message
|
|
|
|
@ -34,25 +34,26 @@ class StudentWork < ActiveRecord::Base
|
|
|
|
|
PraiseTread.where("praise_tread_object_id = #{self.id} AND praise_tread_object_type = 'StudentWork'").destroy_all
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def last_test
|
|
|
|
|
student_work_tests.order('id desc').first
|
|
|
|
|
end
|
|
|
|
|
# def last_test
|
|
|
|
|
# student_work_tests.order('id desc').first
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
def set_program_score
|
|
|
|
|
if self.homework_common.is_program_homework? #编程作业,学生提交作品后计算系统得分
|
|
|
|
|
#根据最后一次测试计算得分
|
|
|
|
|
unless last_test
|
|
|
|
|
self.system_score = 0
|
|
|
|
|
else
|
|
|
|
|
self.system_score = last_test.test_score self.homework_common.homework_tests.size
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
# if self.homework_common.is_program_homework? #编程作业,学生提交作品后计算系统得分
|
|
|
|
|
# #根据最后一次测试计算得分
|
|
|
|
|
# unless last_test
|
|
|
|
|
# self.system_score = 0
|
|
|
|
|
# else
|
|
|
|
|
# self.system_score = last_test.test_score self.homework_common.homework_tests.size
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
|
set_final_score self.homework_common,self
|
|
|
|
|
end
|
|
|
|
|
def set_src
|
|
|
|
|
self.description = last_test.src if last_test
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# def set_src
|
|
|
|
|
# self.description = last_test.src if last_test
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
#成绩计算
|
|
|
|
|
def set_final_score homework,student_work
|
|
|
|
@ -217,8 +218,8 @@ class StudentWork < ActiveRecord::Base
|
|
|
|
|
|
|
|
|
|
# status == 0 : delay
|
|
|
|
|
def act_as_message
|
|
|
|
|
if self.work_status != 0 && self.created_at > self.homework_common.end_time
|
|
|
|
|
self.course_messages << CourseMessage.new(:user_id => self.user_id, :course_id => self.homework_common.course_id, :viewed => false, :status => false)
|
|
|
|
|
end
|
|
|
|
|
# if self.work_status != 0 && self.created_at > self.homework_common.end_time
|
|
|
|
|
# self.course_messages << CourseMessage.new(:user_id => self.user_id, :course_id => self.homework_common.course_id, :viewed => false, :status => false)
|
|
|
|
|
# end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|