parent
36e0aeb301
commit
bbf087fa67
@ -0,0 +1,7 @@
|
|||||||
|
class Exercise < ActiveRecord::Base
|
||||||
|
include Redmine::SafeAttributes
|
||||||
|
belongs_to :user
|
||||||
|
has_many :exercise_questions, :dependent => :destroy,:order => "#{ExerciseQuestion.table_name}.question_number"
|
||||||
|
has_many :exercise_users, :dependent => :destroy
|
||||||
|
has_many :users, :through => :exercise_users #该文件被哪些用户提交答案过
|
||||||
|
end
|
@ -0,0 +1,8 @@
|
|||||||
|
class ExerciseAnswer < ActiveRecord::Base
|
||||||
|
#学生答题
|
||||||
|
include Redmine::SafeAttributes
|
||||||
|
|
||||||
|
belongs_to :user
|
||||||
|
belongs_to :exercise_question
|
||||||
|
belongs_to :exercise_choices
|
||||||
|
end
|
@ -0,0 +1,7 @@
|
|||||||
|
class ExerciseChoices < ActiveRecord::Base
|
||||||
|
include Redmine::SafeAttributes
|
||||||
|
|
||||||
|
belongs_to :exercise_question
|
||||||
|
has_many :exercise_answers, :dependent => :destroy
|
||||||
|
has_many :exercise_standard_answers, :dependent => :destroy
|
||||||
|
end
|
@ -0,0 +1,8 @@
|
|||||||
|
class ExerciseQuestion < ActiveRecord::Base
|
||||||
|
include Redmine::SafeAttributes
|
||||||
|
|
||||||
|
belongs_to :exercise
|
||||||
|
has_many :exercise_choiceses, :order => "#{ExerciseChoices.table_name}.choice_position",:dependent => :destroy
|
||||||
|
has_many :exercise_answers, :dependent => :destroy
|
||||||
|
has_many :exercise_standard_answers, :dependent => :destroy
|
||||||
|
end
|
@ -0,0 +1,7 @@
|
|||||||
|
class ExerciseStandardAnswer < ActiveRecord::Base
|
||||||
|
#标准答案
|
||||||
|
include Redmine::SafeAttributes
|
||||||
|
|
||||||
|
belongs_to :exercise_question
|
||||||
|
belongs_to :exercise_choices
|
||||||
|
end
|
@ -0,0 +1,6 @@
|
|||||||
|
class ExerciseUser < ActiveRecord::Base
|
||||||
|
include Redmine::SafeAttributes
|
||||||
|
|
||||||
|
belongs_to :user
|
||||||
|
belongs_to :exercise
|
||||||
|
end
|
@ -1,14 +1,15 @@
|
|||||||
class UserExercise < ActiveRecord::Migration
|
class UserExercise < ActiveRecord::Migration
|
||||||
def up
|
def up
|
||||||
create_table :user_exercise do |t|
|
create_table :exercise_user do |t|
|
||||||
t.integer :user_id
|
t.integer :user_id
|
||||||
t.integer :exercise_id
|
t.integer :exercise_id
|
||||||
t.integer :score
|
t.integer :score
|
||||||
|
t.datetime :start_at
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
drop_table :user_exercise
|
drop_table :exercise_user
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in new issue