socialforge/app/models/student_work.rb

20 lines
673 B
Ruby
Raw Normal View History

#学生提交作品表
class StudentWork < ActiveRecord::Base
attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :project_id
belongs_to :homework_common
belongs_to :user
2015-05-19 10:56:41 +08:00
has_many :student_works_evaluation_distributions, :dependent => :destroy
has_many :student_works_scores, :dependent => :destroy
belongs_to :project
2015-08-28 12:04:49 +08:00
has_many :student_work_tests, order: 'id desc'
before_destroy :delete_praise
acts_as_attachable
def delete_praise
PraiseTread.where("praise_tread_object_id = #{self.id} AND praise_tread_object_type = 'StudentWork'").destroy_all
end
end