You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/models/exercise_user.rb

16 lines
1018 B

6 years ago
class ExerciseUser < ApplicationRecord
# commit_method 0 为默认, 1为学生的手动提交2为倒计时结束后自动提交3为试卷定时截止的自动提交, 4为教师手动的立即截止, 5为老师调分
6 years ago
belongs_to :user
belongs_to :exercise
has_many :exercise_user_scores, dependent: :destroy
6 years ago
scope :commit_exercise_by_status, lambda { |s| where(commit_status: s) }
scope :exercise_user_committed, -> {where("commit_status != ?",0) }
scope :current_exercise_user, lambda { |user_id,exercise_id| where(user_id: user_id,exercise_id:exercise_id)}
scope :exercise_commit_users, lambda {|user_ids| where(user_id:user_ids)}
scope :exercise_review, -> {where("subjective_score >= ?",0.0)} #已评阅,测试版的不一样是因为测试版的 主观题默认为0。0分没有修改为-1分
scope :exercise_unreview, -> {where("subjective_score < ?",0.0)} #未评阅
scope :search_by_exercise, lambda {|ids| where(exercise_id:ids)} #根据试卷来查找
end