From 6ac97f2c349b825c06342883718ce00097103961 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 21 May 2015 10:54:02 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E8=BF=81=E7=A7=BB=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9B=9E=E6=BB=9A=E6=96=B9=E6=B3=95=202?= =?UTF-8?q?=E3=80=81=E4=BD=9C=E5=93=81=E8=A1=A8=E5=A2=9E=E5=8A=A0=E6=89=80?= =?UTF-8?q?=E5=B1=9E=E9=A1=B9=E7=9B=AE=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/project.rb | 2 +- app/models/student_work.rb | 1 + db/migrate/20150519012744_create_homework_commons.rb | 6 +++++- .../20150519014600_create_homework_detail_manuals.rb | 6 +++++- .../20150519014639_create_homework_detail_programings.rb | 6 +++++- db/migrate/20150519020031_create_homework_tests.rb | 6 +++++- db/migrate/20150519022200_create_student_works.rb | 7 ++++++- ...023821_create_student_works_evaluation_distributions.rb | 6 +++++- db/migrate/20150519030544_create_student_works_scores.rb | 6 +++++- db/schema.rb | 1 + 10 files changed, 39 insertions(+), 8 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index f257058ea..a60f43157 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -30,7 +30,7 @@ class Project < ActiveRecord::Base # Specific overidden Activities - belongs_to :homework_attach + has_many :student_works has_many :time_entry_activities has_many :members, :include => [:principal, :roles], :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}" has_many :memberships, :class_name => 'Member' diff --git a/app/models/student_work.rb b/app/models/student_work.rb index e46e70a2b..c8e69a4a3 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -6,6 +6,7 @@ class StudentWork < ActiveRecord::Base belongs_to :user has_many :student_works_evaluation_distributions, :dependent => :destroy has_many :student_works_scores, :dependent => :destroy + belongs_to :project acts_as_attachable end diff --git a/db/migrate/20150519012744_create_homework_commons.rb b/db/migrate/20150519012744_create_homework_commons.rb index 75c68e49f..eaf39bfa0 100644 --- a/db/migrate/20150519012744_create_homework_commons.rb +++ b/db/migrate/20150519012744_create_homework_commons.rb @@ -1,5 +1,5 @@ class CreateHomeworkCommons < ActiveRecord::Migration - def change + def up create_table :homework_commons do |t| t.string :name t.integer :user_id @@ -13,4 +13,8 @@ class CreateHomeworkCommons < ActiveRecord::Migration t.timestamps end end + + def down + drop_table :homework_commons + end end diff --git a/db/migrate/20150519014600_create_homework_detail_manuals.rb b/db/migrate/20150519014600_create_homework_detail_manuals.rb index 955d4a852..29548cab2 100644 --- a/db/migrate/20150519014600_create_homework_detail_manuals.rb +++ b/db/migrate/20150519014600_create_homework_detail_manuals.rb @@ -1,5 +1,5 @@ class CreateHomeworkDetailManuals < ActiveRecord::Migration - def change + def up create_table :homework_detail_manuals do |t| t.float :ta_proportion t.integer :comment_status @@ -12,4 +12,8 @@ class CreateHomeworkDetailManuals < ActiveRecord::Migration t.timestamps end end + + def down + drop_table :homework_detail_manuals + end end diff --git a/db/migrate/20150519014639_create_homework_detail_programings.rb b/db/migrate/20150519014639_create_homework_detail_programings.rb index 4a1e248d3..707da164c 100644 --- a/db/migrate/20150519014639_create_homework_detail_programings.rb +++ b/db/migrate/20150519014639_create_homework_detail_programings.rb @@ -1,5 +1,5 @@ class CreateHomeworkDetailProgramings < ActiveRecord::Migration - def change + def up create_table :homework_detail_programings do |t| t.string :language t.text :standard_code, :limit => 4294967295 @@ -8,4 +8,8 @@ class CreateHomeworkDetailProgramings < ActiveRecord::Migration t.timestamps end end + + def down + drop_table :homework_detail_programings + end end diff --git a/db/migrate/20150519020031_create_homework_tests.rb b/db/migrate/20150519020031_create_homework_tests.rb index 92b63a412..8106c51f5 100644 --- a/db/migrate/20150519020031_create_homework_tests.rb +++ b/db/migrate/20150519020031_create_homework_tests.rb @@ -1,5 +1,5 @@ class CreateHomeworkTests < ActiveRecord::Migration - def change + def up create_table :homework_tests do |t| t.text :input t.text :output @@ -8,4 +8,8 @@ class CreateHomeworkTests < ActiveRecord::Migration t.timestamps end end + + def down + drop_table :homework_tests + end end diff --git a/db/migrate/20150519022200_create_student_works.rb b/db/migrate/20150519022200_create_student_works.rb index e5a94b275..adcc21b0b 100644 --- a/db/migrate/20150519022200_create_student_works.rb +++ b/db/migrate/20150519022200_create_student_works.rb @@ -1,5 +1,5 @@ class CreateStudentWorks < ActiveRecord::Migration - def change + def up create_table :student_works do |t| t.string :name t.text :description @@ -9,8 +9,13 @@ class CreateStudentWorks < ActiveRecord::Migration t.float :teacher_score, default: 0 t.float :student_score, default: 0 t.float :teaching_asistant_score, default: 0 + t.integer :project_id, default: 0 t.timestamps end end + + def down + drop_table :student_works + end end diff --git a/db/migrate/20150519023821_create_student_works_evaluation_distributions.rb b/db/migrate/20150519023821_create_student_works_evaluation_distributions.rb index 8f7ae2e25..a46b9f0f1 100644 --- a/db/migrate/20150519023821_create_student_works_evaluation_distributions.rb +++ b/db/migrate/20150519023821_create_student_works_evaluation_distributions.rb @@ -1,5 +1,5 @@ class CreateStudentWorksEvaluationDistributions < ActiveRecord::Migration - def change + def up create_table :student_works_evaluation_distributions do |t| t.integer :student_work_id t.integer :user_id @@ -7,4 +7,8 @@ class CreateStudentWorksEvaluationDistributions < ActiveRecord::Migration t.timestamps end end + + def down + drop_table :student_works_evaluation_distributions + end end diff --git a/db/migrate/20150519030544_create_student_works_scores.rb b/db/migrate/20150519030544_create_student_works_scores.rb index 1a43df966..0c4721276 100644 --- a/db/migrate/20150519030544_create_student_works_scores.rb +++ b/db/migrate/20150519030544_create_student_works_scores.rb @@ -1,5 +1,5 @@ class CreateStudentWorksScores < ActiveRecord::Migration - def change + def up create_table :student_works_scores do |t| t.integer :student_work_id t.integer :user_id @@ -9,4 +9,8 @@ class CreateStudentWorksScores < ActiveRecord::Migration t.timestamps end end + + def down + drop_table :student_works_scores + end end diff --git a/db/schema.rb b/db/schema.rb index 489dd03dd..4c6be4b35 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1207,6 +1207,7 @@ ActiveRecord::Schema.define(:version => 20150519030544) do t.float "teacher_score", :default => 0.0 t.float "student_score", :default => 0.0 t.float "teaching_asistant_score", :default => 0.0 + t.integer "project_id", :default => 0 t.datetime "created_at", :null => false t.datetime "updated_at", :null => false end