From 466f3c4cc356afccfce09a055c450b132ac77e02 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 13 Nov 2015 15:47:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E4=B8=80=E5=AF=B9=E4=B8=80=EF=BC=8C=E4=B8=80?= =?UTF-8?q?=E5=AF=B9=E5=A4=9A=EF=BC=8C=E5=A4=9A=E5=AF=B9=E5=A4=9A=E7=AD=89?= =?UTF-8?q?=E5=85=B3=E7=B3=BB=E7=9A=84=E7=A1=AE=E7=AB=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/exercise.rb | 2 +- app/models/exercise_answer.rb | 2 +- ...exercise_choices.rb => exercise_choice.rb} | 2 +- app/models/exercise_question.rb | 2 +- app/models/exercise_standard_answer.rb | 2 +- app/models/user.rb | 6 +- db/migrate/20151113025341_exercise.rb | 2 +- .../20151113025459_exercise_question.rb | 2 +- ...20151113025549_exercise_standard_answer.rb | 4 +- db/migrate/20151113025721_exercise_answer.rb | 4 +- db/migrate/20151113025751_user_exercise.rb | 2 +- db/schema.rb | 56 ++++++++++++++++++- 12 files changed, 70 insertions(+), 16 deletions(-) rename app/models/{exercise_choices.rb => exercise_choice.rb} (81%) diff --git a/app/models/exercise.rb b/app/models/exercise.rb index 752441947..cbf3a6e91 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -3,5 +3,5 @@ class Exercise < ActiveRecord::Base 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 #该文件被哪些用户提交答案过 + has_many :users, :through => :exercise_users #该测试被哪些用户提交答案过 end diff --git a/app/models/exercise_answer.rb b/app/models/exercise_answer.rb index 14b60982a..c62f5bcd5 100644 --- a/app/models/exercise_answer.rb +++ b/app/models/exercise_answer.rb @@ -4,5 +4,5 @@ class ExerciseAnswer < ActiveRecord::Base belongs_to :user belongs_to :exercise_question - belongs_to :exercise_choices + belongs_to :exercise_choice end diff --git a/app/models/exercise_choices.rb b/app/models/exercise_choice.rb similarity index 81% rename from app/models/exercise_choices.rb rename to app/models/exercise_choice.rb index 8e67a8c0a..00d611566 100644 --- a/app/models/exercise_choices.rb +++ b/app/models/exercise_choice.rb @@ -1,4 +1,4 @@ -class ExerciseChoices < ActiveRecord::Base +class ExerciseChoice < ActiveRecord::Base include Redmine::SafeAttributes belongs_to :exercise_question diff --git a/app/models/exercise_question.rb b/app/models/exercise_question.rb index 64ec53e4c..5189b0274 100644 --- a/app/models/exercise_question.rb +++ b/app/models/exercise_question.rb @@ -2,7 +2,7 @@ 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_choices, :order => "#{ExerciseChoice.table_name}.choice_position",:dependent => :destroy has_many :exercise_answers, :dependent => :destroy has_many :exercise_standard_answers, :dependent => :destroy end diff --git a/app/models/exercise_standard_answer.rb b/app/models/exercise_standard_answer.rb index 2b67a83a2..ce3d08fbf 100644 --- a/app/models/exercise_standard_answer.rb +++ b/app/models/exercise_standard_answer.rb @@ -3,5 +3,5 @@ class ExerciseStandardAnswer < ActiveRecord::Base include Redmine::SafeAttributes belongs_to :exercise_question - belongs_to :exercise_choices + belongs_to :exercise_choice end diff --git a/app/models/user.rb b/app/models/user.rb index 9e470380d..d79ae575a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -82,10 +82,10 @@ class User < Principal has_many :answers, :source => :poll, :through => :poll_users, :dependent => :destroy #用户已经完成问答的问卷 # end #在线测验相关关系 - has_many :exercise_users, :dependent => :destroy #答卷中间表 - has_many :exercise_answers, :dependent => :destroy #针对每个题目学生的答案 + has_many :exercise_user, :dependent => :destroy #答卷中间表 + has_many :exercise_answer, :dependent => :destroy #针对每个题目学生的答案 has_many :exercises, :dependent => :destroy #创建的试卷 - has_many :exercises_answers, :source => :exercises, :through => :exercise_users, :dependent => :destroy #用户已经完成问答的试卷 + has_many :exercises_answers, :source => :exercise, :through => :exercise_user, :dependent => :destroy #用户已经完成问答的试卷 #end #作业相关关系 has_many :homework_commons, :dependent => :destroy diff --git a/db/migrate/20151113025341_exercise.rb b/db/migrate/20151113025341_exercise.rb index 696f8d953..b29bfdb91 100644 --- a/db/migrate/20151113025341_exercise.rb +++ b/db/migrate/20151113025341_exercise.rb @@ -1,6 +1,6 @@ class Exercise < ActiveRecord::Migration def up - create_table :exercise do |t| + create_table :exercises do |t| t.string :exercise_name t.text :exercise_description t.integer :course_id diff --git a/db/migrate/20151113025459_exercise_question.rb b/db/migrate/20151113025459_exercise_question.rb index 5e83504c5..1dd0409f9 100644 --- a/db/migrate/20151113025459_exercise_question.rb +++ b/db/migrate/20151113025459_exercise_question.rb @@ -1,6 +1,6 @@ class ExerciseQuestion < ActiveRecord::Migration def up - create_table :exercise_question do |t| + create_table :exercise_questions do |t| t.string :question_title t.integer :question_type t.integer :question_number diff --git a/db/migrate/20151113025549_exercise_standard_answer.rb b/db/migrate/20151113025549_exercise_standard_answer.rb index 17e59eaf8..8ed1a25be 100644 --- a/db/migrate/20151113025549_exercise_standard_answer.rb +++ b/db/migrate/20151113025549_exercise_standard_answer.rb @@ -1,8 +1,8 @@ class ExerciseStandardAnswer < ActiveRecord::Migration def up - create_table :exercise_standard_answer do |t| + create_table :exercise_standard_answers do |t| t.integer :exercise_question_id - t.integer :exercise_choices_id + t.integer :exercise_choice_id t.text :answer_text t.timestamps end diff --git a/db/migrate/20151113025721_exercise_answer.rb b/db/migrate/20151113025721_exercise_answer.rb index 0a34c15ea..9cc9c5bc7 100644 --- a/db/migrate/20151113025721_exercise_answer.rb +++ b/db/migrate/20151113025721_exercise_answer.rb @@ -1,9 +1,9 @@ class ExerciseAnswer < ActiveRecord::Migration def up - create_table :exercise_answer do |t| + create_table :exercise_answers do |t| t.integer :user_id t.integer :exercise_question_id - t.integer :exercise_choices_id + t.integer :exercise_choice_id t.text :answer_text t.timestamps end diff --git a/db/migrate/20151113025751_user_exercise.rb b/db/migrate/20151113025751_user_exercise.rb index a49053146..d5e521401 100644 --- a/db/migrate/20151113025751_user_exercise.rb +++ b/db/migrate/20151113025751_user_exercise.rb @@ -1,6 +1,6 @@ class UserExercise < ActiveRecord::Migration def up - create_table :exercise_user do |t| + create_table :exercise_users do |t| t.integer :user_id t.integer :exercise_id t.integer :score diff --git a/db/schema.rb b/db/schema.rb index 419b30c3e..418382a64 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20151112072948) do +ActiveRecord::Schema.define(:version => 20151113025751) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -572,6 +572,60 @@ ActiveRecord::Schema.define(:version => 20151112072948) do add_index "enumerations", ["id", "type"], :name => "index_enumerations_on_id_and_type" add_index "enumerations", ["project_id"], :name => "index_enumerations_on_project_id" + create_table "exercise_answers", :force => true do |t| + t.integer "user_id" + t.integer "exercise_question_id" + t.integer "exercise_choices_id" + t.text "answer_text" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "exercise_choices", :force => true do |t| + t.integer "exercise_question_id" + t.text "choice_text" + t.integer "choice_position" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "exercise_questions", :force => true do |t| + t.string "question_title" + t.integer "question_type" + t.integer "question_number" + t.integer "exercise_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "exercise_standard_answers", :force => true do |t| + t.integer "exercise_question_id" + t.integer "exercise_choices_id" + t.text "answer_text" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "exercise_users", :force => true do |t| + t.integer "user_id" + t.integer "exercise_id" + t.integer "score" + t.datetime "start_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "exercises", :force => true do |t| + t.string "exercise_name" + t.text "exercise_description" + t.integer "course_id" + t.integer "exercise_status" + t.integer "user_id" + t.integer "time" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "first_pages", :force => true do |t| t.string "web_title" t.string "title"