submission.rb 495 B

123456789101112131415161718
  1. class Submission < ApplicationRecord
  2. belongs_to :assignment
  3. validates :title, presence: true, length: { maximum: 255 }
  4. has_many :group_participations, as: :group, dependent: :destroy
  5. has_many :users, through: :group_participations
  6. has_many :data_files, as: :repository
  7. def can_download_files?(user)
  8. users.include?(user) || self.assignment.course.users.merge(CourseParticipation.teachers).include?(user)
  9. end
  10. def can_upload_files?(user)
  11. users.include?(user)
  12. end
  13. end