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.

32 lines
1.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

class ExerciseUser < ApplicationRecord
# reviewed: 已评阅
# subjective_reviewed主观题已评阅
# subjective_score 主观题得分
# objective_score 客观题得分
# score 总分
#
belongs_to :user
belongs_to :exercise
has_many :exercise_user_scores, dependent: :destroy
# 随机组卷中试卷用户关联的试题
has_many :exercise_user_questions, dependent: :destroy
has_many :exercise_questions, through: :exercise_user_questions, dependent: :destroy
scope :commit_exercise_by_status, lambda { |s| where(commit_status: s) }
scope :exercise_user_committed, -> {where("commit_status = ?",1) }
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("reviewed = ?",1)} #已评阅
scope :exercise_unreview, -> {where("reviewed = ?",0)} #未评阅
scope :search_by_exercise, lambda {|ids| where(exercise_id:ids)} #根据试卷来查找
scope :subjective_reviewed, -> {where(subjective_reviewed: true)}
scope :subjective_not_reviewed, -> {where(subjective_reviewed: false)}
# commit_method 0 为默认, 1为学生的手动提交2为倒计时结束后自动提交3为试卷定时截止的自动提交, 4为教师手动的立即截止, 5为老师调分
enum :commit_method => {default: 0, student_manual: 1, countdown_auto: 2, endtime_auto: 3, teacher_manual: 4, adjust_by_teacher: 5}
# 提交状态 commit_status/status 0 未提交, 1 已提交, 2已交卷未答
enum :commit_status => {none_commit: 0, commited: 1, commit_with_no_answer: 2}
end