From d8dc7786ca2a8adda01992f91e6f8c3096e4cb50 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 11 Nov 2015 10:25:24 +0800 Subject: [PATCH 001/191] =?UTF-8?q?fork=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/repositories/fork.html.erb | 0 lib/gitlab-cli/lib/gitlab/client/projects.rb | 6 ++++++ 2 files changed, 6 insertions(+) create mode 100644 app/views/repositories/fork.html.erb diff --git a/app/views/repositories/fork.html.erb b/app/views/repositories/fork.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/lib/gitlab-cli/lib/gitlab/client/projects.rb b/lib/gitlab-cli/lib/gitlab/client/projects.rb index 04ea682aa..476e88b72 100644 --- a/lib/gitlab-cli/lib/gitlab/client/projects.rb +++ b/lib/gitlab-cli/lib/gitlab/client/projects.rb @@ -222,6 +222,12 @@ class Gitlab::Client delete("/projects/#{project}/hooks/#{id}") end + # Forks a project into the user namespace of the authenticated user. + # @param [Integer] - The ID of the project to be forked + def fork(id) + post("/projects/fork/#{id}") + end + # Mark this project as forked from the other # # @example From cc0afa7d9b735ee5056cc5b60049435703c10900 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 11 Nov 2015 12:43:59 +0800 Subject: [PATCH 002/191] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E8=BF=81=E7=A7=BB=E7=89=88=E6=9C=AC=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/sync_sigle_rep.rake | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/tasks/sync_sigle_rep.rake b/lib/tasks/sync_sigle_rep.rake index 591dcce84..4ed360426 100644 --- a/lib/tasks/sync_sigle_rep.rake +++ b/lib/tasks/sync_sigle_rep.rake @@ -27,4 +27,30 @@ namespace :sync_rep do end end end + + task :delete_rep => :environment do + projects = Project.where("user_id !=?",12) + projects.each do |project| + # 针对类型为Git并且只有一个版本库的项目 + if project.repositories && project.repositories.count == 1 && project.repositories.first.type == "Repository::Git" + rep = project.repositories.first + count = Repository.find_by_sql("SELECT * FROM `repositories` where identifier = '#{rep.identifier}'").count + puts count + unless count > 1 + rep.identifier + puts "################################" + puts project.id + puts rep.id + s = Trustie::Gitlab::Sync.new + s.sync_project(project, path: rep.identifier, import_url: rep.url) + rep.type = 'Repository::Gitlab' + rep.save + puts "*************************************" + puts project.id + puts rep.id + puts rep.identifier + end + end + end + end end \ No newline at end of file From 5a153637b7629e37f89b407279d92d1b09671b17 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 13 Nov 2015 11:43:44 +0800 Subject: [PATCH 003/191] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9C=A8=E7=BA=BF?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=BF=81=E7=A7=BB=E9=97=AE=E5=8D=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20151113025341_exercise.rb | 18 ++++++++++++++++++ db/migrate/20151113025459_exercise_question.rb | 14 ++++++++++++++ db/migrate/20151113025524_exercise_choices.rb | 14 ++++++++++++++ .../20151113025549_exercise_standard_answer.rb | 14 ++++++++++++++ db/migrate/20151113025721_exercise_answer.rb | 15 +++++++++++++++ db/migrate/20151113025751_user_exercise.rb | 14 ++++++++++++++ 6 files changed, 89 insertions(+) create mode 100644 db/migrate/20151113025341_exercise.rb create mode 100644 db/migrate/20151113025459_exercise_question.rb create mode 100644 db/migrate/20151113025524_exercise_choices.rb create mode 100644 db/migrate/20151113025549_exercise_standard_answer.rb create mode 100644 db/migrate/20151113025721_exercise_answer.rb create mode 100644 db/migrate/20151113025751_user_exercise.rb diff --git a/db/migrate/20151113025341_exercise.rb b/db/migrate/20151113025341_exercise.rb new file mode 100644 index 000000000..8fdcf0a9e --- /dev/null +++ b/db/migrate/20151113025341_exercise.rb @@ -0,0 +1,18 @@ +class Exercise < ActiveRecord::Migration + def up + create_table :exercise do |t| + t.string :exercise_name + t.text :exercise_description + t.integer :course_id + t.integer :exercise_status + t.integer :user_id + t.datetime :start_at + t.datetime :end_at + t.timestamps + end + end + + def down + drop_table :exercise + end +end diff --git a/db/migrate/20151113025459_exercise_question.rb b/db/migrate/20151113025459_exercise_question.rb new file mode 100644 index 000000000..3ab084f13 --- /dev/null +++ b/db/migrate/20151113025459_exercise_question.rb @@ -0,0 +1,14 @@ +class ExerciseQuestion < ActiveRecord::Migration + def up + create_table :exercise_question do |t| + t.string :question_title + t.integer :question_type + t.integer :exercise_id + t.timestamps + end + end + + def down + drop_table :exercise_question + end +end diff --git a/db/migrate/20151113025524_exercise_choices.rb b/db/migrate/20151113025524_exercise_choices.rb new file mode 100644 index 000000000..782cb5f7d --- /dev/null +++ b/db/migrate/20151113025524_exercise_choices.rb @@ -0,0 +1,14 @@ +class ExerciseChoices < ActiveRecord::Migration + def up + create_table :exercise_choices do |t| + t.integer :exercise_question_id + t.text :choice_text + t.integer :choice_position + t.timestamps + end + end + + def down + drop_table :exercise_choices + end +end diff --git a/db/migrate/20151113025549_exercise_standard_answer.rb b/db/migrate/20151113025549_exercise_standard_answer.rb new file mode 100644 index 000000000..17e59eaf8 --- /dev/null +++ b/db/migrate/20151113025549_exercise_standard_answer.rb @@ -0,0 +1,14 @@ +class ExerciseStandardAnswer < ActiveRecord::Migration + def up + create_table :exercise_standard_answer do |t| + t.integer :exercise_question_id + t.integer :exercise_choices_id + t.text :answer_text + t.timestamps + end + end + + def down + drop_table :exercise_standard_answer + end +end diff --git a/db/migrate/20151113025721_exercise_answer.rb b/db/migrate/20151113025721_exercise_answer.rb new file mode 100644 index 000000000..0a34c15ea --- /dev/null +++ b/db/migrate/20151113025721_exercise_answer.rb @@ -0,0 +1,15 @@ +class ExerciseAnswer < ActiveRecord::Migration + def up + create_table :exercise_answer do |t| + t.integer :user_id + t.integer :exercise_question_id + t.integer :exercise_choices_id + t.text :answer_text + t.timestamps + end + end + + def down + drop_table :exercise_answer + end +end diff --git a/db/migrate/20151113025751_user_exercise.rb b/db/migrate/20151113025751_user_exercise.rb new file mode 100644 index 000000000..b0a003d1d --- /dev/null +++ b/db/migrate/20151113025751_user_exercise.rb @@ -0,0 +1,14 @@ +class UserExercise < ActiveRecord::Migration + def up + create_table :user_exercise do |t| + t.integer :user_id + t.integer :exercise_id + t.integer :score + t.timestamps + end + end + + def down + drop_table :user_exercise + end +end From bbf087fa67452482f07bae27d4bf75ab0fcccdc2 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 13 Nov 2015 14:40:14 +0800 Subject: [PATCH 004/191] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E7=9A=84?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A5=E5=8F=8Amodel=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=85=B3=E7=B3=BB=E7=9A=84=E7=A1=AE=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/exercise.rb | 7 +++++++ app/models/exercise_answer.rb | 8 ++++++++ app/models/exercise_choices.rb | 7 +++++++ app/models/exercise_question.rb | 8 ++++++++ app/models/exercise_standard_answer.rb | 7 +++++++ app/models/exercise_user.rb | 6 ++++++ app/models/user.rb | 6 ++++++ db/migrate/20151113025341_exercise.rb | 3 +-- db/migrate/20151113025459_exercise_question.rb | 1 + db/migrate/20151113025751_user_exercise.rb | 5 +++-- 10 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 app/models/exercise.rb create mode 100644 app/models/exercise_answer.rb create mode 100644 app/models/exercise_choices.rb create mode 100644 app/models/exercise_question.rb create mode 100644 app/models/exercise_standard_answer.rb create mode 100644 app/models/exercise_user.rb diff --git a/app/models/exercise.rb b/app/models/exercise.rb new file mode 100644 index 000000000..752441947 --- /dev/null +++ b/app/models/exercise.rb @@ -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 diff --git a/app/models/exercise_answer.rb b/app/models/exercise_answer.rb new file mode 100644 index 000000000..14b60982a --- /dev/null +++ b/app/models/exercise_answer.rb @@ -0,0 +1,8 @@ +class ExerciseAnswer < ActiveRecord::Base + #学生答题 + include Redmine::SafeAttributes + + belongs_to :user + belongs_to :exercise_question + belongs_to :exercise_choices +end diff --git a/app/models/exercise_choices.rb b/app/models/exercise_choices.rb new file mode 100644 index 000000000..8e67a8c0a --- /dev/null +++ b/app/models/exercise_choices.rb @@ -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 diff --git a/app/models/exercise_question.rb b/app/models/exercise_question.rb new file mode 100644 index 000000000..64ec53e4c --- /dev/null +++ b/app/models/exercise_question.rb @@ -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 diff --git a/app/models/exercise_standard_answer.rb b/app/models/exercise_standard_answer.rb new file mode 100644 index 000000000..2b67a83a2 --- /dev/null +++ b/app/models/exercise_standard_answer.rb @@ -0,0 +1,7 @@ +class ExerciseStandardAnswer < ActiveRecord::Base + #标准答案 + include Redmine::SafeAttributes + + belongs_to :exercise_question + belongs_to :exercise_choices +end diff --git a/app/models/exercise_user.rb b/app/models/exercise_user.rb new file mode 100644 index 000000000..2d5da5d95 --- /dev/null +++ b/app/models/exercise_user.rb @@ -0,0 +1,6 @@ +class ExerciseUser < ActiveRecord::Base + include Redmine::SafeAttributes + + belongs_to :user + belongs_to :exercise +end diff --git a/app/models/user.rb b/app/models/user.rb index edc29c015..9e470380d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -81,6 +81,12 @@ class User < Principal has_many :poll, :dependent => :destroy #用户创建的问卷 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 :exercises, :dependent => :destroy #创建的试卷 + has_many :exercises_answers, :source => :exercises, :through => :exercise_users, :dependent => :destroy #用户已经完成问答的试卷 + #end #作业相关关系 has_many :homework_commons, :dependent => :destroy has_many :student_works, :dependent => :destroy diff --git a/db/migrate/20151113025341_exercise.rb b/db/migrate/20151113025341_exercise.rb index 8fdcf0a9e..696f8d953 100644 --- a/db/migrate/20151113025341_exercise.rb +++ b/db/migrate/20151113025341_exercise.rb @@ -6,8 +6,7 @@ class Exercise < ActiveRecord::Migration t.integer :course_id t.integer :exercise_status t.integer :user_id - t.datetime :start_at - t.datetime :end_at + t.integer :time t.timestamps end end diff --git a/db/migrate/20151113025459_exercise_question.rb b/db/migrate/20151113025459_exercise_question.rb index 3ab084f13..5e83504c5 100644 --- a/db/migrate/20151113025459_exercise_question.rb +++ b/db/migrate/20151113025459_exercise_question.rb @@ -3,6 +3,7 @@ class ExerciseQuestion < ActiveRecord::Migration create_table :exercise_question do |t| t.string :question_title t.integer :question_type + t.integer :question_number t.integer :exercise_id t.timestamps end diff --git a/db/migrate/20151113025751_user_exercise.rb b/db/migrate/20151113025751_user_exercise.rb index b0a003d1d..a49053146 100644 --- a/db/migrate/20151113025751_user_exercise.rb +++ b/db/migrate/20151113025751_user_exercise.rb @@ -1,14 +1,15 @@ class UserExercise < ActiveRecord::Migration def up - create_table :user_exercise do |t| + create_table :exercise_user do |t| t.integer :user_id t.integer :exercise_id t.integer :score + t.datetime :start_at t.timestamps end end def down - drop_table :user_exercise + drop_table :exercise_user end end 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 005/191] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BB=A5=E5=8F=8A=E4=B8=80=E5=AF=B9=E4=B8=80=EF=BC=8C?= =?UTF-8?q?=E4=B8=80=E5=AF=B9=E5=A4=9A=EF=BC=8C=E5=A4=9A=E5=AF=B9=E5=A4=9A?= =?UTF-8?q?=E7=AD=89=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" From 70c5b27a437df83d823f1442fa5e945b7cd2ff56 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 13 Nov 2015 16:40:39 +0800 Subject: [PATCH 006/191] =?UTF-8?q?=E7=9B=B8=E5=85=B3=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 39 +++++++++++++++++++++++++ app/helpers/exercise_helper.rb | 3 ++ app/models/course.rb | 1 + app/views/exercise/index.html.erb | 1 + app/views/exercise/new.html.erb | 0 app/views/exercise/show.html.erb | 1 + app/views/layouts/base_courses.html.erb | 5 ++++ config/routes.rb | 9 ++++++ 8 files changed, 59 insertions(+) create mode 100644 app/controllers/exercise_controller.rb create mode 100644 app/helpers/exercise_helper.rb create mode 100644 app/views/exercise/index.html.erb create mode 100644 app/views/exercise/new.html.erb create mode 100644 app/views/exercise/show.html.erb diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb new file mode 100644 index 000000000..96a965f79 --- /dev/null +++ b/app/controllers/exercise_controller.rb @@ -0,0 +1,39 @@ +class ExerciseController < ApplicationController + layout "base_courses" + + before_filter :find_course, :only => [:index,:new,:create] + def index + + end + + def show + + end + + def new + + end + + def create + + end + + def edit + + end + + def update + + end + + def destroy + + end + + private + def find_course + @course = Course.find params[:course_id] + rescue Exception => e + render_404 + end +end \ No newline at end of file diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb new file mode 100644 index 000000000..7fc7b1421 --- /dev/null +++ b/app/helpers/exercise_helper.rb @@ -0,0 +1,3 @@ +# encoding: utf-8 +module ExerciseHelper +end \ No newline at end of file diff --git a/app/models/course.rb b/app/models/course.rb index 7288c3b3b..913449d22 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -39,6 +39,7 @@ class Course < ActiveRecord::Base has_many :course_activities # 课程消息 has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy + has_many :exercises, :dependent => :destroy acts_as_taggable acts_as_nested_set :order => 'name', :dependent => :destroy diff --git a/app/views/exercise/index.html.erb b/app/views/exercise/index.html.erb new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/app/views/exercise/index.html.erb @@ -0,0 +1 @@ +111111111111 \ No newline at end of file diff --git a/app/views/exercise/new.html.erb b/app/views/exercise/new.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/exercise/show.html.erb b/app/views/exercise/show.html.erb new file mode 100644 index 000000000..b23c1c517 --- /dev/null +++ b/app/views/exercise/show.html.erb @@ -0,0 +1 @@ +111111 \ No newline at end of file diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 39de4faeb..ac8727e21 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -157,6 +157,11 @@ <%= link_to "(#{course_poll_count})", poll_index_path(:polls_type => "Course", :polls_group_id => @course.id), :class => "subnav_num c_orange" %> <%= link_to( "+#{l(:label_new_poll)}", new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => 'subnav_green c_white') if is_teacher %> +
diff --git a/config/routes.rb b/config/routes.rb index 6cf872180..9c557c9a5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -96,6 +96,15 @@ RedmineApp::Application.routes.draw do end end + #show、index、new、create、edit、update、destroy路由自动生成 + resources :exercise do + member do #生成路径为 /exercise/:id/方法名 + end + + collection do #生成路径为 /exercise/方法名 + end + end + resources :homework_common, :except => [:show]do member do get 'start_anonymous_comment' From e6cd104ead1f32ae3d73cec883173328002bd205 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 13 Nov 2015 17:23:52 +0800 Subject: [PATCH 007/191] =?UTF-8?q?index=E7=95=8C=E9=9D=A2=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E8=AF=95=E5=8D=B7=E7=BB=9F=E8=AE=A1=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 18 +++++- app/models/exercise.rb | 1 + app/views/exercise/_exercise.html.erb | 61 +++++++++++++++++++++ app/views/exercise/_exercises_list.html.erb | 25 +++++++++ app/views/exercise/index.html.erb | 5 +- config/routes.rb | 2 + 6 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 app/views/exercise/_exercise.html.erb create mode 100644 app/views/exercise/_exercises_list.html.erb diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 96a965f79..bed3d9061 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -3,9 +3,18 @@ class ExerciseController < ApplicationController before_filter :find_course, :only => [:index,:new,:create] def index - + @is_teacher = User.current.allowed_to?(:as_teacher,@course) + if @is_teacher + exercises = @course.exercises + else + exercises = @course.exercises.where(:exercise_status => 1) + end + @exercises = paginateHelper exercises,20 #分页 + respond_to do |format| + format.html + end end - + def show end @@ -30,6 +39,11 @@ class ExerciseController < ApplicationController end + #统计结果 + def statistics_result + + end + private def find_course @course = Course.find params[:course_id] diff --git a/app/models/exercise.rb b/app/models/exercise.rb index cbf3a6e91..e4295971e 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -1,4 +1,5 @@ class Exercise < ActiveRecord::Base + #exercise_status: 1,新建;2,发布;3,关闭 include Redmine::SafeAttributes belongs_to :user has_many :exercise_questions, :dependent => :destroy,:order => "#{ExerciseQuestion.table_name}.question_number" diff --git a/app/views/exercise/_exercise.html.erb b/app/views/exercise/_exercise.html.erb new file mode 100644 index 000000000..e469c471c --- /dev/null +++ b/app/views/exercise/_exercise.html.erb @@ -0,0 +1,61 @@ +<%# has_commit = has_commit_poll?(poll.id ,User.current)%> +<% exercise_name = exercise.exercise_name.empty? ? l(:label_poll_new) : exercise.exercise_name%> +<% if @is_teacher%> +
  • +
    + <%# if has_commit %> + <%#= link_to poll_name, poll_result_poll_path(poll.id), :class => "polls_title polls_title_w fl c_dblue"%> + <%# else %> + <%#= link_to poll_name, exercise_path(poll.id), :class => "polls_title polls_title_w fl c_dblue" %> + <%# end %> + <%= link_to exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_w fl c_dblue" %> +
    +
  • + + <% if exercise.exercise_status == 1%> +
  • 统计结果
  • + <% else %> +
  • <%= link_to l(:label_statistical_results), statistics_result_exercise_path(exercise.id), :class => "pollsbtn fl ml10"%>
  • + <% end%> + + <% if exercise.exercise_status == 1 %> +
  • 发布试卷
  • + <% elsif exercise.exercise_status == 2%> +
  • 取消发布
  • + <% else%> +
  • 发布试卷
  • + <% end%> + + <%= link_to(l(:button_delete), exercise,:method => :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml5 mr10") %> + + <% if exercise.exercise_status == 1 %> +
  • <%= link_to l(:button_edit), edit_exercise_path(exercise.id), :class => "polls_de fr ml5"%>
  • + <% else%> +
  • 编辑
  • + <% end%> + + <% if exercise.exercise_status == 2 %> +
  • 关闭
  • + <% else %> +
  • 关闭
  • + <% end%> + + <% if exercise.exercise_status == 1%> +
  • 导出
  • + <% elsif exercise.exercise_status == 2 || exercise.exercise_status == 3 %> +
  • <%= link_to "导出", export_exercise_exercise_path(exercise.id,:format => "xls"), :class => "polls_de fr ml5"%>
  • + <% end%> + + +
  • <%= format_date exercise.created_at.to_date%>
  • +<% else%> + <% if exercise.exercise_status == 2%> + <%# if has_commit%> + + <%#else%> + <%= link_to exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_st fl c_dblue"%> + <%#end%> + <% end%> +
  • <%= format_date exercise.created_at.to_date%>
  • +<% end%> \ No newline at end of file diff --git a/app/views/exercise/_exercises_list.html.erb b/app/views/exercise/_exercises_list.html.erb new file mode 100644 index 000000000..16fa24b0e --- /dev/null +++ b/app/views/exercise/_exercises_list.html.erb @@ -0,0 +1,25 @@ +
    +

    所有试卷 + (<%= @obj_count%>) +

    + <% if @is_teacher%> + <%#= link_to "导入", other_poll_poll_index_path(:polls_group_id => @course.id), :remote=>true,:class => "newbtn"%> + <%= link_to "新建试卷 ", new_exercise_path(:course_id => @course.id), :class => "newbtn" %> + <% end%> +
    +
    +
    + + <% @exercises.each do |exercise|%> +
      + <%= render :partial => 'exercise', :locals => {:exercise => exercise} %> +
    +
    + <% end%> + +
      + <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> +
    + +
    +
    \ No newline at end of file diff --git a/app/views/exercise/index.html.erb b/app/views/exercise/index.html.erb index 52cfcc97f..1a8d15181 100644 --- a/app/views/exercise/index.html.erb +++ b/app/views/exercise/index.html.erb @@ -1 +1,4 @@ -111111111111 \ No newline at end of file +<%= stylesheet_link_tag 'polls', :media => 'all' %> +
    + <%= render :partial => 'exercises_list'%> +
    \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 9c557c9a5..f1c41f65f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -99,6 +99,8 @@ RedmineApp::Application.routes.draw do #show、index、new、create、edit、update、destroy路由自动生成 resources :exercise do member do #生成路径为 /exercise/:id/方法名 + get 'statistics_result' + get 'export_exercise' end collection do #生成路径为 /exercise/方法名 From a40e5c5b54cc416db6d5ed4bd33b8395a5b6b0cc Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 13 Nov 2015 17:30:14 +0800 Subject: [PATCH 008/191] =?UTF-8?q?frok=E5=8A=9F=E8=83=BD=E5=BC=80?= =?UTF-8?q?=E5=8F=91--=E6=9D=83=E9=99=90=E8=BF=98=E6=9C=AA=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 70 +++++++++++++++++++- app/helpers/repositories_helper.rb | 12 ++++ app/models/repository.rb | 10 ++- app/views/repositories/_breadcrumbs.html.erb | 4 +- app/views/repositories/fork.html.erb | 0 app/views/repositories/forked.html.erb | 10 +++ app/views/repositories/show.html.erb | 2 +- config/routes.rb | 2 + 8 files changed, 103 insertions(+), 7 deletions(-) delete mode 100644 app/views/repositories/fork.html.erb create mode 100644 app/views/repositories/forked.html.erb diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 1f252cc24..82f469259 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -31,10 +31,10 @@ class RepositoriesController < ApplicationController default_search_scope :changesets before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo] - before_filter :find_repository, :only => [:edit, :update, :destroy, :committers] + before_filter :find_repository, :only => [:edit, :update, :destroy, :committers, :forked] before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo,:to_gitlab] before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue] - before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab] + before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked] accept_rss_auth :revisions # hidden repositories filter // 隐藏代码过滤器 before_filter :check_hidden_repo, :only => [:show, :stats, :revisions, :revision, :diff ] @@ -63,6 +63,72 @@ class RepositoriesController < ApplicationController end + def forked + # REDO: 那些人有权限forked项目 + # g = Gitlab.client + # gproject = g.post ("/projects/fork/#{@project.gpid}") + if gproject + copy_project(@project, gproject) + end + # render :layout => 'base_projects' + end + + # copy a project for fork + def copy_project(project, gproject) + project = Project.new + project.name = @project.name + project.is_public = @project.is_public + project.status = @project.status + project.hidden_repo = @project.hidden_repo + project.user_id = User.current.id + project.project_type = 0 + project.project_new_type = @project.project_new_type + project.gpid = gproject.id + if project.save + r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first + m = Member.new(:user => User.current, :roles => [r]) + project_info = ProjectInfo.new(:user_id => User.current.id, :project_id => project.id) + user_grades = UserGrade.create(:user_id => User.current.id, :project_id => project.id) + Rails.logger.debug "UserGrade created: #{user_grades.to_json}" + project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :project_type => @project.project_type,:grade => 0) + Rails.logger.debug "ProjectStatus created: #{project_status.to_json}" + project.members << m + project.project_infos << project_info + repository = Repository.create(:project_id => project.id, :url =>'ddd222', :type => 'Repository::Gitlab', :identifier => 'ddd222', :is_default => true) + copy_repository(project, gproject) + respond_to do |format| + format.html { + flash[:notice] = l(:notice_successful_create) + if params[:continue] + attrs = {:parent_id => project.parent_id}.reject {|k,v| v.nil?} + redirect_to new_project_url(attrs, :course => '0') + else + redirect_to settings_project_url(project) + end + } + format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => project.id) } + format.js + end + else + respond_to do |format| + format.html { render :action => 'forked', :layout => 'base_projects'} + format.api { render_validation_errors(@project) } + end + end + end + + def copy_repository(project, gproject) + # 避免 + if is_sigle_identifier?(project.owner, gproject.name) + + end + repository = Repository.factory('Git') + repository.project_id = project.id + repository.type = 'Repository::Gitlab' + repository.url = gproject.name + repository.identifier = gproject.name + repository = repository.save + end def newrepo scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index f32bef51b..05403114d 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -27,6 +27,18 @@ module RepositoriesHelper REPO_IP_ADDRESS = Setting.host_repository REPO_GITLAB_ADDRESS = "git.trustie.net" + # 某个成员不能拥有同名版本库,不同的成员可以创建同名版本库 + def is_sigle_identifier?(user, iden) + projects = Project.where("user_id =?",user) + identifiers = [] + projects.each do |project| + # 只针对gitlab类型的,git类型的后期清掉 + repository = Repository.where("project_id =? and type =?", project.id, "Repository::Gitlab").first + identifiers << repository.identifier + end + identifiers + end + def format_revision(revision) if revision.respond_to? :format_identifier revision.format_identifier diff --git a/app/models/repository.rb b/app/models/repository.rb index 94b7905c6..f50f37f31 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -40,7 +40,8 @@ class Repository < ActiveRecord::Base validates_length_of :identifier, :maximum => IDENTIFIER_MAX_LENGTH, :allow_blank => true validates_presence_of :identifier#, :unless => Proc.new { |r| r.is_default? || r.set_as_default? } #validates_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true - validates_uniqueness_of :identifier, :allow_blank => true + # 改成同一用户不能有两个相同名字的版本库 + # validates_uniqueness_of :identifier, :allow_blank => true validates_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph) # donwcase letters, digits, dashes, underscores but not digits only validates_format_of :identifier, :with => /^[a-z0-9_\-]+$/, :allow_blank => true @@ -52,7 +53,8 @@ class Repository < ActiveRecord::Base 'password', 'path_encoding', 'log_encoding', - 'is_default' + 'is_default', + 'type' safe_attributes 'url', :if => lambda {|repository, user| repository.new_record?} @@ -63,6 +65,10 @@ class Repository < ActiveRecord::Base end def repo_create_validation + # 之所以可以这样改,是因为Fork的时候不需要从Trustie创建版本库,只需从Gitlab关联即可 + if self.class.name.demodulize == "Repository" + return + end unless Setting.enabled_scm.include?(self.class.name.demodulize) errors.add(:type, :invalid) end diff --git a/app/views/repositories/_breadcrumbs.html.erb b/app/views/repositories/_breadcrumbs.html.erb index 84111afeb..2c675cc1e 100644 --- a/app/views/repositories/_breadcrumbs.html.erb +++ b/app/views/repositories/_breadcrumbs.html.erb @@ -1,12 +1,12 @@
    + <%=link_to @project.owner, user_path(@project.owner), :class => "repository-title-dec" %> + / <%= link_to @repository.identifier.present? ? h(@repository.identifier) : 'root', {:action => 'show', :id => @project, :repository_id => @repository.identifier_param, :path => nil, :rev => @rev }, :class => "repository-title-dec" %> - / - <%=link_to @project.owner, user_path(@project.owner), :class => "repository-title-dec" %>
    diff --git a/app/views/repositories/fork.html.erb b/app/views/repositories/fork.html.erb deleted file mode 100644 index e69de29bb..000000000 diff --git a/app/views/repositories/forked.html.erb b/app/views/repositories/forked.html.erb new file mode 100644 index 000000000..2860b9898 --- /dev/null +++ b/app/views/repositories/forked.html.erb @@ -0,0 +1,10 @@ +
    +

    <%= render :partial => 'breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %>

    +
    +<%= form_for('forked',:url => {:controller => 'repositories', :action => 'forked'},:method => "post") do |f| %> + + +<% end %> +<%= @project.id %> +<%= @repository.id %> +<%= User.current %> diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 9601e5188..f210add24 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -25,7 +25,7 @@ -
    Fork 0
    +
    <% if @changesets && !@changesets.empty? %> diff --git a/config/routes.rb b/config/routes.rb index 6cf872180..6d754ffaf 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -551,6 +551,7 @@ RedmineApp::Application.routes.draw do # get 'create', :via=>[:get, :post] end end + match 'wiki/index', :via => :get resources :wiki, :except => [:index, :new, :create], :as => 'wiki_page' do member do @@ -647,6 +648,7 @@ RedmineApp::Application.routes.draw do get 'projects/:id/repository/changes(/*path(.:ext))', :to => 'repositories#changes' + get 'projects/:id/repository/forked', :to => 'repositories#forked' get 'projects/:id/repository/revisions', :to => 'repositories#revisions' get 'projects/:id/repository/revisions/:rev', :to => 'repositories#revision' get 'projects/:id/repository/revision', :to => 'repositories#revision' From ee8d9d7b4ecef7c35dc6efb9270642c66177fc5a Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 13 Nov 2015 17:47:29 +0800 Subject: [PATCH 009/191] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/schema.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 418382a64..19bd05677 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -575,7 +575,7 @@ ActiveRecord::Schema.define(:version => 20151113025751) do create_table "exercise_answers", :force => true 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.datetime "created_at", :null => false t.datetime "updated_at", :null => false @@ -600,7 +600,7 @@ ActiveRecord::Schema.define(:version => 20151113025751) do create_table "exercise_standard_answers", :force => true do |t| t.integer "exercise_question_id" - t.integer "exercise_choices_id" + t.integer "exercise_choice_id" t.text "answer_text" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false From b6d785bda00eab0e786a26278de19c8cc4fee739 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 13 Nov 2015 19:10:44 +0800 Subject: [PATCH 010/191] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=96=87=E7=AB=A0=E6=A0=B7=E5=BC=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/org_document_comments/edit.html.erb | 14 +++++++++----- app/views/organizations/new.html.erb | 2 +- public/images/org_default.jpg | Bin 1897 -> 0 bytes public/images/org_default.png | Bin 0 -> 4471 bytes 4 files changed, 10 insertions(+), 6 deletions(-) delete mode 100644 public/images/org_default.jpg create mode 100644 public/images/org_default.png diff --git a/app/views/org_document_comments/edit.html.erb b/app/views/org_document_comments/edit.html.erb index ffb04a4f9..498ac46a6 100644 --- a/app/views/org_document_comments/edit.html.erb +++ b/app/views/org_document_comments/edit.html.erb @@ -12,18 +12,21 @@ } } -
    +
    编辑文章
    +
    +
    <%= form_tag url_for(:controller => 'org_document_comments',:action => 'update', :id => @org_document.id),:method => 'put', :id => 'new_org_document_form' do |f| %>
    - +
    -
    +
    +
    - <%= kindeditor_tag 'org_document_comment[content]',@org_document.content, :editor_id => 'org_document_description_editor', :height => "150px" %> + <%= kindeditor_tag 'org_document_comment[content]',@org_document.content, :editor_id => 'org1_document_description_editor', :height => "150px" %>
    @@ -40,4 +43,5 @@
    -<% end %> \ No newline at end of file +<% end %> +
    \ No newline at end of file diff --git a/app/views/organizations/new.html.erb b/app/views/organizations/new.html.erb index 08311d51b..1ab3ad933 100644 --- a/app/views/organizations/new.html.erb +++ b/app/views/organizations/new.html.erb @@ -31,7 +31,7 @@
  • - (打钩为公开,不打钩则不公开,若不公开,仅项目成员可见该项目。) + (打钩为公开,不打钩则不公开,若不公开,仅组织成员可见该组织。)
  • diff --git a/public/images/org_default.jpg b/public/images/org_default.jpg deleted file mode 100644 index ad1b4f007d0c6141a10715ce46f447630e3ce376..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1897 zcmbVMdr%W+5WmYoMM0Bb02^w&UPJ^Xm&=PJ8X+Wsq6GvLL9G~)10p6DFNY-9VzFw` zYN=8jTkErfD5%6LP{vk}D)_)^3yRP2i8ETo(V|wdq?ZUjW*q8M%0Kjz(B62CpszgzXO`tatS-8MJ zm{GgliedsG3QUZ$TlI!KoPx9P9Fs+b+&|EWz$T*#nITOOCRjCiuIZyf5>G8moMtG@ zGboHm)FgPKU1>L4%{Zlp?dJIwo6@dAJm5-t?N*}*>@lJ8REXNm3a2Mbg*60;!%~4b z!XU&jSSAx-5~)mvjfX`-OoR&QR~CUulv0^e6bbhWLbH*^Y-Nfzwx5gsQz89H6%-T* z3d90}%t0}QLgB^`i6Ur=2%Ez~>Fp5~8-D;ni`xvO$x4|B3+zVJXA$|73ZWx?k%HNp zknj@tt<^G{-FbPeZBz>WDvY;U+on0JIGTdnhGpR#=lNgU8M=S&T%1EzEs9FS6C*q-h~;j3o&(?5VHP^cH@NRES9> zLa|QxB5%1gMjIm$V;ZqGRv{EikbYm||EU>D2ZOqs>r9%I)9zz+gxVu%ey0ln!Z zpO=)dGiz&hfep<$&O7nXmnQFvZC+RLTk)0CrALpCd%%n!degg(6frLE?P)^~f7-lp z_JXTLWFt{iUz5vSzy{eYw)+$AP|n+z(vt7JCO-9!pZ$1sO=6u6+^Ei)P^NmAxT1nU z28F;m9qS+Lsi~OZKP+evZ)tRGzpsD9>Xo%svJ2K9>l-FDs~4BIZ~gB5r^+Wo#GMyK zBWGq79y(C_MY;4sP>a{n^U8@W2kT^3kAk$HrLBpj-8q&$hNK zKAAMPXj?*DdHb);;{vkpjxf~J&7ECRGWf{WlZnIchuiz)wQn9e+i|}k z&Z8#oLcfssGt%O^RN&ljyIgs1+ry3E-Y&=8!wwp+8Z;}=IIFXOM}J&)Q- zuNJ1QYnTED2B+Qx9**Xa86B+Z&2u)Yw*PSb)K^f~ja5Bet8)G>W`5n(x4d!UL+MV% OokfMWGD?bF=l=tIZIm|v diff --git a/public/images/org_default.png b/public/images/org_default.png new file mode 100644 index 0000000000000000000000000000000000000000..3f3cfc575550c44e2261bc7aa9affdd3f5bb6506 GIT binary patch literal 4471 zcmaJ_c|25Y`zIwkB_&j2645Yb%wjNvktkyuV~=45W0_%QWGP!n)Fe~Lo-JFElqEu0 zvP&T(WlKc1Bx}F%JoWtEKc4qJpL5Q=oa=k-*M07DqD`>+f_xHu92^{i24^v5>=wIo z@$6#XIa?|W+09{wo)yEK>ca3N&`2EGM5+@BVBke?C7F>3!~maGk_HC{mkSwZ#jr9u zujWkkQX=foDEWJNv(X$J8e0C|1ZNKt1K>n*B~#GA`RY0#fJ{UKE#XGWM&7z4H}cs) z8p%8mi*pY2a7GbFA(FA{?Q@b~hh(AE6Wz`yvavHLsIU?AWx5{3sF__tD4 zMkWAVDvbnyE2$_tD?=av1VRY{gCh_S5CEzSfr6FUCqfYdQ-dSaph&>)1IU&}Bf6-W zVb1)P#U7!7ZVZOE8W`;7=cnYSqC};+f*~jrYKI3Ds>r5Lqz6zK1b;;e{rDda7!uu? zM)qcqsT9BtM}ia8mw^VdHT~NJFK;8Ge;8Bfza7PP8Q7oT4TdNwgT1_V?D~tE&M+hW zzZ(BaO~(azlfY&qI@Oov%#Mf4@jqa;@BX)-9YVG?YQ{7&J17KC4At4!i$q}er=qR%hsVER;RvX*G903!iaNuN zgdQA)($iK&s-RR55TvrMs`ekO0fo*WP@GAB8jec!{F4DD zZd3-9?nd8AV#K_rt~%XBTDTr$~M>x-Oc>{ln(5RZAd#{4qYwi=$cynR2 z!7+H8iL{g6oU8cQ+i@47%S@>+K854hHWyP?=H+$t77`YAUg|#Fk(!i8T>R3LJy_=Y zPE5fO@IoY4kZd|WjA@7yUQR{P%^c37fB*4g`}#j;B*F?{)D>TTg2P*$@Eq?yMW;8Xy)`r@1rD8h*qFC-*XZ1dE8`b}=D z(hQ#%qF-EmQ#9mM{k=ra2Kmj`#JfqQiReNfyT}-Lv2BGAcK1@LV?{*;f1%d)&uob& zWmfz03rSaRNyjwr3I)l5eenV;~G09033XOg;u+mhT<#ku$IX;!Qj(}SER zTRyM~BP4O9K3FAKxYxj9ZC=XP15LI$5PcRO`}==vZ_F=SxsOGpBr0qfU9SXHA6Beq zMFcE=9!YfQYr{L1mt_|Xe!#Z2 z$zJ-k;sRge(iA1%%j$k$`P_rmsGLD(N|bnxIri+?ADG?T#AW_zcB`2R_kF(ZH&Jie zE7ceAes_0onU!p^qd67toMDQUIMtKL;Tmo`GJk;)&3YB;(c#XDnw8sHY6mAO**~LA z#x%KOJti8gI!8jh?!Bp3Hh<|X^y!ON!oBeDa5>}j+4=dsk~;ZUuU@@*L|wKy_~&R; zD~u+S*yrg(j>8>%Uefet_<%G_4n%TUYXw!=T~1f``}Q)DU$O6^d~T$cBsQnarBkA) zDw6+DGo>AMf_d%kaNVZiy(G%LvE858wCuwB{C)auV=1BG>gvcPF!=O9U*DbvzmGvv zk#6undwm;!+~<|Y7O9oZX)e02b4u*1&yY>sXF?x3)CD^_)~g4z&0zFo>4n8CC|9w| zY?sakyQtbBM4g_myWpcT*UdDq(vp>MAA>g(wI<|mefaQUd8)h4_bdMM97)S!Y{Ana zKU5!<#1a-3c3n#sn3!BO%479Kh=h*9s=mG}3Hi0PYFTmte(ruHsXgJuxr7Dutf(c* zP49?f3c~A+NU7H50@pyx{Fg6|6BlGl3WlW8q4@^UcMqn17sWP5ckkgp_`t4ee=eZF z_?fL)?ySa>@^Z>ZjWxRJ+8JJymzNi4SMO!b#i1q(1}RY>BN6O?n6@awKeVm5xd-^V zCNimI*Idr0yugPw34L}B4jEU!O)pf>*GkH1oQR4O)Ya1i=2aztinMx&3~*Z9X}I~A#4oOPp8qfmLa){6d_sq2lF zNPhQPGl;U|nKoIg+F~agJE4$Mo+es`8!z@AyVK2L3G2alrPmH`Qg(&A{ZwcR+4$jA z$a$0*itqrG^vv8y!H|}op_lh~LPxYD;$^sLmZ*oVi%Krd!Y^8RAo%jGwxeb|@<(Ln zyU+Bp7sV!9Sh|{TOz-2Pj&s(P`j6LY&gqVM0E=3?M72H;C13cD$=&*nKk+)XhjvG1-c6+&6Y+v1fy0VWj?Ca{9C!{O;1l8_&^6A~RUHc-z5HlC*(OHv= z0b`B4WiZRjeDT*0ftA$5t?vcinah=Wk`RAdQv+n%xbIkQXDw#z;kIDo&+NI8SO<|} z*<=0tncU>X0cWF4v|G0%GjGeW*U9Lcfh4Brf%~pJXn! z=ay4G6iVmYt+SWw=-9wK+pZ+8SV1IYfQQ=&o$n(STlg|W$+ldew?)UO1Drg4H6@d| z7AUu6RZS}!dDm8RTWnJF>FZ+J%1mEQ!zgdhZi(kjGTM*!Nf$=*f%dnobY*B!&+5Px zLq!#`i%mVR#ID9bR4nOpb91@7B3Kh)l5ZvR4es8y`J!ke@%(J*Aa1h@R7l{s82q=*$OkA;r)|u9}l>8fzG~iinlX)F-dgA zQKe#Q3=i~Sc=~pyV`RZ5oUx3rBi<1&#pu)Sm4QJs-cwy^pG5{tqj+*T^9Re%*WdW% zO|rQL@V9l7DGG#Lq%|xg_}|Uv(ETB@RNyAifqvCc0>BI6<)sBKm#iF#n8h2h8dJxJ z3A{S{PMmEt#d2kVzU!c?h=yS{wYR9Ahk&Vf1mEXJjV5XT;Crmr+17y8%W@2mi#g!Z zwvaBH*ir~Egy7=O%0;-bGTWP3SJk@PTD_yaZ^=m{&S$k%y}0gKc?YLCB zyY9Apn9Fjp6Zx?cn$q~@iJy*>3GHYwyYBKB?Oe@yVc=8g8WDd7gJi{& zHqn!vWaB(v%yy@#Pwh!C{^i`)6DM-+=GaVRVaws~=g+K9m&Eu4sG{Xi^1S64y#9iX zeX|}ey&a)Eo$?uiI;Y||!k=Q8Oo@C*4N>UmWc7&{_h#3w)KSa!Y3|f@Y6)N3jnx>1 z!&u9Eg)+n8dxa&=G4a;xZw{nq+|A;T?C>AwM(B&Kw`b*8VKto&3Y!vp2dv6>vESC( zKTPwawhtYD$9w7aSQwv*{bbToJaUkHHf%X~;Orw_Zq>3wmbLfm>-2zW(BTQKlj4U8 zv1MHXtcfqB$1G`LI=Skv%@kw}FGUXq4SqV+rTjT@3)9fEN7ir;tVg6ps-k>zh1t?F zzvl)v{NxqQW4IIQpPN~zM+L3(!m<4DTl-&)C1u%|#?xBTcuAQm?q$`g4IQek%n^uQ zy=uHvgWjFPMU`7WuVLUwweB8#U>8t6*lp=+WwaGD=NE)D?07t$yyhD3lli9N*P(op zYedO>k)hcmd3gbgs7}fo@gj$ym3Y`$)k(R!pJV)ApUQ_NA8?0KY47$ePNcwUE;K1P zI(=d)o=VjWtl|;UPiDt%lsmgpD77}~4h;=EA zr)hCC*I-?K{>GeE)#8AbQS#!TYX&o_f9TzknaHV6rfC-QqYY6X=vz+XwLu%ZISxlo z(z@QcCFgXUcs3%SDzf;y+k9@6&Ht^#T* z1d5h_76&wFyMWD=3#%N! z4#r6ih78_!549M}v7F>D-7Ltu?5p7;f*A;oR($6+Jd5ZX2HodNtJ7=lkV#=0v^-i{e7x{JHpR zEt6aND2lc_DjJxUmL?wFZ^vImvrn*o*4F$hjBBsVI z9J4m(@o@)b-i!Q&1v$+dYJP%qO)Ay$a_H%RoW1>xOxX+V4D;Kv(-T!kE5B2PCOvu! zHeWU=hlV{ocECrhbL0G_CD$4kc)y*)kCTU0S|(D(6<2~MRm-Nf?J9b|YsnXC3vGgX zE%8eRI_=l$Ox@SM*4^K1pTS9~)hg84Z093WF0I`TZ57>c;N<4m3L^Asm~@`n`4wWI Lhs6}@I9~ZbFKHr^ literal 0 HcmV?d00001 From ddbc9003c2a308fe5839259216fba08edff1919c Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 13 Nov 2015 20:24:30 +0800 Subject: [PATCH 011/191] =?UTF-8?q?=E6=AF=8F=E4=B8=AA=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E5=88=9B=E5=BB=BA=E5=90=8C=E5=90=8D=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=BA=93=20=E4=B8=8D=E5=90=8C=E7=9A=84=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=8F=AF=E4=BB=A5=E5=88=9B=E5=BB=BA=E4=B8=8D=E5=90=8C?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=20=E6=9B=B4=E6=96=B0fork=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 68 +++++++++++++--------- app/helpers/repositories_helper.rb | 10 ++-- config/locales/projects/zh.yml | 2 + 3 files changed, 48 insertions(+), 32 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 82f469259..d1d8a961a 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -64,13 +64,18 @@ class RepositoriesController < ApplicationController end def forked - # REDO: 那些人有权限forked项目 - # g = Gitlab.client - # gproject = g.post ("/projects/fork/#{@project.gpid}") - if gproject - copy_project(@project, gproject) + # 被forked的标识如果不满足单个用户唯一性,则不执行fork + if is_sigle_identifier?(User.current, @repository.identifier) + # REDO: 那些人有权限forked项目 + g = Gitlab.client + gproject = g.post ("/projects/fork/#{@project.gpid}?user_id=#{User.current.id}") + if gproject + copy_project(@project, gproject) + end + else + flash[:notice] = l(:project_gitlab_fork_double_message) + redirect_to settings_project_url(@project, :tab => 'repositories') end - # render :layout => 'base_projects' end # copy a project for fork @@ -79,6 +84,7 @@ class RepositoriesController < ApplicationController project.name = @project.name project.is_public = @project.is_public project.status = @project.status + project.description = @project.description project.hidden_repo = @project.hidden_repo project.user_id = User.current.id project.project_type = 0 @@ -94,7 +100,6 @@ class RepositoriesController < ApplicationController Rails.logger.debug "ProjectStatus created: #{project_status.to_json}" project.members << m project.project_infos << project_info - repository = Repository.create(:project_id => project.id, :url =>'ddd222', :type => 'Repository::Gitlab', :identifier => 'ddd222', :is_default => true) copy_repository(project, gproject) respond_to do |format| format.html { @@ -119,15 +124,16 @@ class RepositoriesController < ApplicationController def copy_repository(project, gproject) # 避免 - if is_sigle_identifier?(project.owner, gproject.name) - + if is_sigle_identifier?(project.user_id, gproject.name) + repository = Repository.factory('Git') + repository.project_id = project.id + repository.type = 'Repository::Gitlab' + repository.url = gproject.name + repository.identifier = gproject.name + repository = repository.save + else + flash[:notice] = l(:project_gitlab_create_double_message) end - repository = Repository.factory('Git') - repository.project_id = project.id - repository.type = 'Repository::Gitlab' - repository.url = gproject.name - repository.identifier = gproject.name - repository = repository.save end def newrepo @@ -181,21 +187,27 @@ update } def create - attrs = pickup_extra_info - @repository = Repository.factory('Git') - @repository.safe_attributes = params[:repository] - if attrs[:attrs_extra].keys.any? - @repository.merge_extra_info(attrs[:attrs_extra]) - end - @repository.project = @project - @repository.type = 'Repository::Gitlab' - @repository.url = @repository.identifier - if request.post? && @repository.save - s = Trustie::Gitlab::Sync.new - s.create_project(@project, @repository) + # 判断版本库创建者是否有同名版本库,避免版本库路径一致问题 + unless is_sigle_identifier?(@project.user_id, params[:repository].first[1]) + flash[:notice] = l(:project_gitlab_create_double_message) redirect_to settings_project_url(@project, :tab => 'repositories') else - redirect_to settings_project_url(@project, :tab => 'repositories',:repository_error_message=>@repository.errors.full_messages) + attrs = pickup_extra_info + @repository = Repository.factory('Git') + @repository.safe_attributes = params[:repository] + if attrs[:attrs_extra].keys.any? + @repository.merge_extra_info(attrs[:attrs_extra]) + end + @repository.project = @project + @repository.type = 'Repository::Gitlab' + @repository.url = @repository.identifier + if request.post? && @repository.save + s = Trustie::Gitlab::Sync.new + s.create_project(@project, @repository) + redirect_to settings_project_url(@project, :tab => 'repositories') + else + redirect_to settings_project_url(@project, :tab => 'repositories',:repository_error_message=>@repository.errors.full_messages) + end end end diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 05403114d..ddabb5356 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -28,15 +28,17 @@ module RepositoriesHelper REPO_GITLAB_ADDRESS = "git.trustie.net" # 某个成员不能拥有同名版本库,不同的成员可以创建同名版本库 - def is_sigle_identifier?(user, iden) - projects = Project.where("user_id =?",user) + def is_sigle_identifier?(user_id, iden) + projects = Project.where("user_id =?",user_id) identifiers = [] projects.each do |project| # 只针对gitlab类型的,git类型的后期清掉 repository = Repository.where("project_id =? and type =?", project.id, "Repository::Gitlab").first - identifiers << repository.identifier + if repository + identifiers << repository.identifier + end end - identifiers + identifiers.include?(iden) ? false :true end def format_revision(revision) diff --git a/config/locales/projects/zh.yml b/config/locales/projects/zh.yml index 1a18e5a14..aebdebd2c 100644 --- a/config/locales/projects/zh.yml +++ b/config/locales/projects/zh.yml @@ -89,6 +89,8 @@ zh: project_module_repository: 版本库 project_module_create_repository: 创建版本库 project_gitlab_create_repository: 新版本库 + project_gitlab_create_double_message: 亲,您已经创建了一个同名的版本库,换个特别点的名字同名的概率就会变小哦~ + project_gitlab_fork_double_message: 亲,您已经有了一个相同名字的版本库,所以不能fork改版本库~ label_project_more: 更多 From f32cae9012bf14b1b336e861f1c942cce93a8c7a Mon Sep 17 00:00:00 2001 From: huang Date: Sat, 14 Nov 2015 10:54:46 +0800 Subject: [PATCH 012/191] =?UTF-8?q?fork=20fileter=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index d1d8a961a..750a2d1b6 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -31,7 +31,7 @@ class RepositoriesController < ApplicationController default_search_scope :changesets before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo] - before_filter :find_repository, :only => [:edit, :update, :destroy, :committers, :forked] + before_filter :find_repository, :only => [:edit, :update, :destroy, :committers] before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo,:to_gitlab] before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue] before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked] @@ -545,8 +545,8 @@ update def find_repository @repository = Repository.find(params[:id]) @project = @repository.project - rescue ActiveRecord::RecordNotFound - render_404 + rescue ActiveRecord::RecordNotFound + render_404 end REV_PARAM_RE = %r{\A[a-f0-9]*\Z}i From 50dfe5ce8bf0469bf78e597246b700d01187fe29 Mon Sep 17 00:00:00 2001 From: huang Date: Sat, 14 Nov 2015 15:20:29 +0800 Subject: [PATCH 013/191] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=8E=A5=E5=8F=A3=20?= =?UTF-8?q?=E9=A1=B9=E7=9B=AEowner=E4=B8=BA=E5=BD=93=E5=89=8D=E7=94=A8?= =?UTF-8?q?=E6=88=B7=EF=BC=8C=E5=90=8C=E6=AD=A5gitlab=E7=AB=AF=E7=94=A8?= =?UTF-8?q?=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 750a2d1b6..a7069e87e 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -68,7 +68,7 @@ class RepositoriesController < ApplicationController if is_sigle_identifier?(User.current, @repository.identifier) # REDO: 那些人有权限forked项目 g = Gitlab.client - gproject = g.post ("/projects/fork/#{@project.gpid}?user_id=#{User.current.id}") + gproject = g.post ("/projects/fork/#{@project.gpid}?user_id=#{User.current.gid}") if gproject copy_project(@project, gproject) end From 9350841d50ffaad5f980d9d5f4597963bfe4f51b Mon Sep 17 00:00:00 2001 From: houxiang Date: Mon, 16 Nov 2015 10:44:36 +0800 Subject: [PATCH 014/191] change by hx --- app/controllers/repositories_controller.rb | 2 +- db/schema.rb | 3532 ++++++++++---------- lib/gitlab-cli/bin/gitlab | 0 lib/grack/bin/console | 0 lib/grack/bin/testserver | 0 5 files changed, 1767 insertions(+), 1767 deletions(-) mode change 100644 => 100755 lib/gitlab-cli/bin/gitlab mode change 100644 => 100755 lib/grack/bin/console mode change 100644 => 100755 lib/grack/bin/testserver diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 1f252cc24..21ee6e1de 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -275,7 +275,7 @@ update @entry = @repository.entry(@path, @rev) (show_error_not_found; return) unless @entry g = Gitlab.client - @commits = g.commits(@project.gpid, page:params[:pamge]) + @commits = g.commits(@project.gpid, page:params[:page]) @commit = g.commit(@project.gpid,@rev) # @changesets = g.get ("/projects/#{@project.gpid}/repository/commits?#{@rev}") #@changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i) diff --git a/db/schema.rb b/db/schema.rb index b7e1bfa1c..a51b811bb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,1766 +1,1766 @@ -# encoding: UTF-8 -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). -# -# It's strongly recommended to check this file into your version control system. - -ActiveRecord::Schema.define(:version => 20151102090519) do - - create_table "activities", :force => true do |t| - t.integer "act_id", :null => false - t.string "act_type", :null => false - t.integer "user_id", :null => false - t.integer "activity_container_id" - t.string "activity_container_type", :default => "" - t.datetime "created_at" - end - - add_index "activities", ["act_id", "act_type"], :name => "index_activities_on_act_id_and_act_type" - add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type" - add_index "activities", ["user_id"], :name => "index_activities_on_user_id" - - create_table "activity_notifies", :force => true do |t| - t.integer "activity_container_id" - t.string "activity_container_type" - t.integer "activity_id" - t.string "activity_type" - t.integer "notify_to" - t.datetime "created_on" - t.integer "is_read" - end - - add_index "activity_notifies", ["activity_container_id", "activity_container_type"], :name => "index_an_activity_container_id" - add_index "activity_notifies", ["created_on"], :name => "index_an_created_on" - add_index "activity_notifies", ["notify_to"], :name => "index_an_notify_to" - - create_table "api_keys", :force => true do |t| - t.string "access_token" - t.datetime "expires_at" - t.integer "user_id" - t.boolean "active", :default => true - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "api_keys", ["access_token"], :name => "index_api_keys_on_access_token" - add_index "api_keys", ["user_id"], :name => "index_api_keys_on_user_id" - - create_table "applied_projects", :force => true do |t| - t.integer "project_id", :null => false - t.integer "user_id", :null => false - end - - create_table "apply_project_masters", :force => true do |t| - t.integer "user_id" - t.string "apply_type" - t.integer "apply_id" - t.integer "status" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "attachments", :force => true do |t| - t.integer "container_id" - t.string "container_type", :limit => 30 - t.string "filename", :default => "", :null => false - t.string "disk_filename", :default => "", :null => false - t.integer "filesize", :default => 0, :null => false - t.string "content_type", :default => "" - t.string "digest", :limit => 40, :default => "", :null => false - t.integer "downloads", :default => 0, :null => false - t.integer "author_id", :default => 0, :null => false - t.datetime "created_on" - t.string "description" - t.string "disk_directory" - t.integer "attachtype", :default => 1 - t.integer "is_public", :default => 1 - t.integer "copy_from" - t.integer "quotes" - end - - add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id" - add_index "attachments", ["container_id", "container_type"], :name => "index_attachments_on_container_id_and_container_type" - add_index "attachments", ["created_on"], :name => "index_attachments_on_created_on" - - create_table "attachmentstypes", :force => true do |t| - t.integer "typeId", :null => false - t.string "typeName", :limit => 50 - end - - create_table "auth_sources", :force => true do |t| - t.string "type", :limit => 30, :default => "", :null => false - t.string "name", :limit => 60, :default => "", :null => false - t.string "host", :limit => 60 - t.integer "port" - t.string "account" - t.string "account_password", :default => "" - t.string "base_dn" - t.string "attr_login", :limit => 30 - t.string "attr_firstname", :limit => 30 - t.string "attr_lastname", :limit => 30 - t.string "attr_mail", :limit => 30 - t.boolean "onthefly_register", :default => false, :null => false - t.boolean "tls", :default => false, :null => false - t.string "filter" - t.integer "timeout" - end - - add_index "auth_sources", ["id", "type"], :name => "index_auth_sources_on_id_and_type" - - create_table "biding_projects", :force => true do |t| - t.integer "project_id" - t.integer "bid_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "bids", :force => true do |t| - t.string "name" - t.string "budget", :null => false - t.integer "author_id" - t.date "deadline" - t.text "description" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.integer "commit" - t.integer "reward_type" - t.integer "homework_type" - t.integer "parent_id" - t.string "password" - t.integer "is_evaluation" - t.integer "proportion", :default => 60 - t.integer "comment_status", :default => 0 - t.integer "evaluation_num", :default => 3 - t.integer "open_anonymous_evaluation", :default => 1 - end - - create_table "blog_comments", :force => true do |t| - t.integer "blog_id", :null => false - t.integer "parent_id" - t.string "title", :default => "", :null => false - t.text "content" - t.integer "author_id" - t.integer "comments_count", :default => 0, :null => false - t.integer "last_comment_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.boolean "locked", :default => false - t.integer "sticky", :default => 0 - t.integer "reply_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "blogs", :force => true do |t| - t.string "name", :default => "", :null => false - t.text "description" - t.integer "position", :default => 1 - t.integer "article_count", :default => 0, :null => false - t.integer "comments_count", :default => 0, :null => false - t.integer "last_comments_id" - t.integer "parent_id" - t.integer "author_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "boards", :force => true do |t| - t.integer "project_id", :null => false - t.string "name", :default => "", :null => false - t.string "description" - t.integer "position", :default => 1 - t.integer "topics_count", :default => 0, :null => false - t.integer "messages_count", :default => 0, :null => false - t.integer "last_message_id" - t.integer "parent_id" - t.integer "course_id" - end - - add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id" - add_index "boards", ["project_id"], :name => "boards_project_id" - - create_table "bug_to_osps", :force => true do |t| - t.integer "osp_id" - t.integer "relative_memo_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "changes", :force => true do |t| - t.integer "changeset_id", :null => false - t.string "action", :limit => 1, :default => "", :null => false - t.text "path", :null => false - t.text "from_path" - t.string "from_revision" - t.string "revision" - t.string "branch" - end - - add_index "changes", ["changeset_id"], :name => "changesets_changeset_id" - - create_table "changeset_parents", :id => false, :force => true do |t| - t.integer "changeset_id", :null => false - t.integer "parent_id", :null => false - end - - add_index "changeset_parents", ["changeset_id"], :name => "changeset_parents_changeset_ids" - add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids" - - create_table "changesets", :force => true do |t| - t.integer "repository_id", :null => false - t.string "revision", :null => false - t.string "committer" - t.datetime "committed_on", :null => false - t.text "comments" - t.date "commit_date" - t.string "scmid" - t.integer "user_id" - end - - add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on" - add_index "changesets", ["repository_id", "revision"], :name => "changesets_repos_rev", :unique => true - add_index "changesets", ["repository_id", "scmid"], :name => "changesets_repos_scmid" - add_index "changesets", ["repository_id"], :name => "index_changesets_on_repository_id" - add_index "changesets", ["user_id"], :name => "index_changesets_on_user_id" - - create_table "changesets_issues", :id => false, :force => true do |t| - t.integer "changeset_id", :null => false - t.integer "issue_id", :null => false - end - - add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true - - create_table "code_review_assignments", :force => true do |t| - t.integer "issue_id" - t.integer "change_id" - t.integer "attachment_id" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.string "action_type" - t.integer "changeset_id" - end - - create_table "code_review_project_settings", :force => true do |t| - t.integer "project_id" - t.integer "tracker_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "updated_by" - t.boolean "hide_code_review_tab", :default => false - t.integer "auto_relation", :default => 1 - t.integer "assignment_tracker_id" - t.text "auto_assign" - t.integer "lock_version", :default => 0, :null => false - t.boolean "tracker_in_review_dialog", :default => false - end - - create_table "code_review_user_settings", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.integer "mail_notification", :default => 0, :null => false - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "code_reviews", :force => true do |t| - t.integer "project_id" - t.integer "change_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "line" - t.integer "updated_by_id" - t.integer "lock_version", :default => 0, :null => false - t.integer "status_changed_from" - t.integer "status_changed_to" - t.integer "issue_id" - t.string "action_type" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.integer "attachment_id" - t.integer "file_count", :default => 0, :null => false - t.boolean "diff_all" - end - - create_table "comments", :force => true do |t| - t.string "commented_type", :limit => 30, :default => "", :null => false - t.integer "commented_id", :default => 0, :null => false - t.integer "author_id", :default => 0, :null => false - t.text "comments" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - add_index "comments", ["author_id"], :name => "index_comments_on_author_id" - add_index "comments", ["commented_id", "commented_type"], :name => "index_comments_on_commented_id_and_commented_type" - - create_table "contest_notifications", :force => true do |t| - t.text "title" - t.text "content" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "contesting_projects", :force => true do |t| - t.integer "project_id" - t.string "contest_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "contesting_softapplications", :force => true do |t| - t.integer "softapplication_id" - t.integer "contest_id" - t.integer "user_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - end - - create_table "contestnotifications", :force => true do |t| - t.integer "contest_id" - t.string "title" - t.string "summary" - t.text "description" - t.integer "author_id" - t.integer "notificationcomments_count" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "contests", :force => true do |t| - t.string "name" - t.string "budget", :default => "" - t.integer "author_id" - t.date "deadline" - t.string "description" - t.integer "commit" - t.string "password" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - create_table "course_activities", :force => true do |t| - t.integer "user_id" - t.integer "course_id" - t.integer "course_act_id" - t.string "course_act_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "course_attachments", :force => true do |t| - t.string "filename" - t.string "disk_filename" - t.integer "filesize" - t.string "content_type" - t.string "digest" - t.integer "downloads" - t.string "author_id" - t.string "integer" - t.string "description" - t.string "disk_directory" - t.integer "attachtype" - t.integer "is_public" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "container_id", :default => 0 - end - - create_table "course_groups", :force => true do |t| - t.string "name" - t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "course_infos", :force => true do |t| - t.integer "course_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "course_messages", :force => true do |t| - t.integer "user_id" - t.integer "course_id" - t.integer "course_message_id" - t.string "course_message_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "content" - t.integer "status" - end - - create_table "course_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "course_id" - t.float "grade", :default => 0.0 - t.integer "course_ac_para", :default => 0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "courses", :force => true do |t| - t.integer "tea_id" - t.string "name" - t.integer "state" - t.string "code" - t.integer "time" - t.string "extra" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "location" - t.string "term" - t.string "string" - t.string "password" - t.string "setup_time" - t.string "endup_time" - t.string "class_period" - t.integer "school_id" - t.text "description" - t.integer "status", :default => 1 - t.integer "attachmenttype", :default => 2 - t.integer "lft" - t.integer "rgt" - t.integer "is_public", :limit => 1, :default => 1 - t.integer "inherit_members", :limit => 1, :default => 1 - t.integer "open_student", :default => 0 - t.integer "outline", :default => 0 - end - - create_table "custom_fields", :force => true do |t| - t.string "type", :limit => 30, :default => "", :null => false - t.string "name", :limit => 30, :default => "", :null => false - t.string "field_format", :limit => 30, :default => "", :null => false - t.text "possible_values" - t.string "regexp", :default => "" - t.integer "min_length", :default => 0, :null => false - t.integer "max_length", :default => 0, :null => false - t.boolean "is_required", :default => false, :null => false - t.boolean "is_for_all", :default => false, :null => false - t.boolean "is_filter", :default => false, :null => false - t.integer "position", :default => 1 - t.boolean "searchable", :default => false - t.text "default_value" - t.boolean "editable", :default => true - t.boolean "visible", :default => true, :null => false - t.boolean "multiple", :default => false - end - - add_index "custom_fields", ["id", "type"], :name => "index_custom_fields_on_id_and_type" - - create_table "custom_fields_projects", :id => false, :force => true do |t| - t.integer "custom_field_id", :default => 0, :null => false - t.integer "project_id", :default => 0, :null => false - end - - add_index "custom_fields_projects", ["custom_field_id", "project_id"], :name => "index_custom_fields_projects_on_custom_field_id_and_project_id", :unique => true - - create_table "custom_fields_trackers", :id => false, :force => true do |t| - t.integer "custom_field_id", :default => 0, :null => false - t.integer "tracker_id", :default => 0, :null => false - end - - add_index "custom_fields_trackers", ["custom_field_id", "tracker_id"], :name => "index_custom_fields_trackers_on_custom_field_id_and_tracker_id", :unique => true - - create_table "custom_values", :force => true do |t| - t.string "customized_type", :limit => 30, :default => "", :null => false - t.integer "customized_id", :default => 0, :null => false - t.integer "custom_field_id", :default => 0, :null => false - t.text "value" - end - - add_index "custom_values", ["custom_field_id"], :name => "index_custom_values_on_custom_field_id" - add_index "custom_values", ["customized_type", "customized_id"], :name => "custom_values_customized" - - create_table "delayed_jobs", :force => true do |t| - t.integer "priority", :default => 0, :null => false - t.integer "attempts", :default => 0, :null => false - t.text "handler", :null => false - t.text "last_error" - t.datetime "run_at" - t.datetime "locked_at" - t.datetime "failed_at" - t.string "locked_by" - t.string "queue" - t.datetime "created_at" - t.datetime "updated_at" - end - - add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" - - create_table "discuss_demos", :force => true do |t| - t.string "title" - t.text "body" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "documents", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.integer "category_id", :default => 0, :null => false - t.string "title", :limit => 60, :default => "", :null => false - t.text "description" - t.datetime "created_on" - t.integer "user_id", :default => 0 - t.integer "is_public", :default => 1 - end - - add_index "documents", ["category_id"], :name => "index_documents_on_category_id" - add_index "documents", ["created_on"], :name => "index_documents_on_created_on" - add_index "documents", ["project_id"], :name => "documents_project_id" - - create_table "dts", :primary_key => "Num", :force => true do |t| - t.string "Defect", :limit => 50 - t.string "Category", :limit => 50 - t.string "File" - t.string "Method" - t.string "Module", :limit => 20 - t.string "Variable", :limit => 50 - t.integer "StartLine" - t.integer "IPLine" - t.string "IPLineCode", :limit => 200 - t.string "Judge", :limit => 15 - t.integer "Review", :limit => 1 - t.string "Description" - t.text "PreConditions", :limit => 2147483647 - t.text "TraceInfo", :limit => 2147483647 - t.text "Code", :limit => 2147483647 - t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "id", :null => false - end - - create_table "enabled_modules", :force => true do |t| - t.integer "project_id" - t.string "name", :null => false - t.integer "course_id" - end - - add_index "enabled_modules", ["project_id"], :name => "enabled_modules_project_id" - - create_table "enumerations", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.integer "position", :default => 1 - t.boolean "is_default", :default => false, :null => false - t.string "type" - t.boolean "active", :default => true, :null => false - t.integer "project_id" - t.integer "parent_id" - t.string "position_name", :limit => 30 - end - - 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 "first_pages", :force => true do |t| - t.string "web_title" - t.string "title" - t.text "description" - t.string "page_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "sort_type" - t.integer "image_width", :default => 107 - t.integer "image_height", :default => 63 - t.integer "show_course", :default => 1 - t.integer "show_contest", :default => 1 - end - - create_table "forge_activities", :force => true do |t| - t.integer "user_id" - t.integer "project_id" - t.integer "forge_act_id" - t.string "forge_act_type" - t.integer "org_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "forge_activities", ["forge_act_id"], :name => "index_forge_activities_on_forge_act_id" - - create_table "forge_messages", :force => true do |t| - t.integer "user_id" - t.integer "project_id" - t.integer "forge_message_id" - t.string "forge_message_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "secret_key" - t.integer "status" - end - - create_table "forums", :force => true do |t| - t.string "name", :null => false - t.text "description" - t.integer "topic_count", :default => 0 - t.integer "memo_count", :default => 0 - t.integer "last_memo_id", :default => 0 - t.integer "creator_id", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "sticky" - t.integer "locked" - end - - create_table "groups_users", :id => false, :force => true do |t| - t.integer "group_id", :null => false - t.integer "user_id", :null => false - end - - add_index "groups_users", ["group_id", "user_id"], :name => "groups_users_ids", :unique => true - - create_table "homework_attaches", :force => true do |t| - t.integer "bid_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "reward" - t.string "name" - t.text "description" - t.integer "state" - t.integer "project_id", :default => 0 - t.float "score", :default => 0.0 - t.integer "is_teacher_score", :default => 0 - end - - add_index "homework_attaches", ["bid_id"], :name => "index_homework_attaches_on_bid_id" - - create_table "homework_commons", :force => true do |t| - t.string "name" - t.integer "user_id" - t.text "description" - t.date "publish_time" - t.date "end_time" - t.integer "homework_type", :default => 1 - t.string "late_penalty" - t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "teacher_priority", :default => 1 - t.integer "anonymous_comment", :default => 0 - end - - create_table "homework_detail_manuals", :force => true do |t| - t.float "ta_proportion" - t.integer "comment_status" - t.date "evaluation_start" - t.date "evaluation_end" - t.integer "evaluation_num" - t.integer "absence_penalty", :default => 1 - t.integer "homework_common_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "homework_detail_programings", :force => true do |t| - t.string "language" - t.text "standard_code", :limit => 2147483647 - t.integer "homework_common_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.float "ta_proportion", :default => 0.1 - t.integer "question_id" - end - - create_table "homework_evaluations", :force => true do |t| - t.string "user_id" - t.string "homework_attach_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "homework_for_courses", :force => true do |t| - t.integer "course_id" - t.integer "bid_id" - end - - add_index "homework_for_courses", ["bid_id"], :name => "index_homework_for_courses_on_bid_id" - add_index "homework_for_courses", ["course_id"], :name => "index_homework_for_courses_on_course_id" - - create_table "homework_tests", :force => true do |t| - t.text "input" - t.text "output" - t.integer "homework_common_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "result" - t.text "error_msg" - end - - create_table "homework_users", :force => true do |t| - t.string "homework_attach_id" - t.string "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "invite_lists", :force => true do |t| - t.integer "project_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "mail" - end - - create_table "issue_categories", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "name", :limit => 30, :default => "", :null => false - t.integer "assigned_to_id" - end - - add_index "issue_categories", ["assigned_to_id"], :name => "index_issue_categories_on_assigned_to_id" - add_index "issue_categories", ["project_id"], :name => "issue_categories_project_id" - - create_table "issue_relations", :force => true do |t| - t.integer "issue_from_id", :null => false - t.integer "issue_to_id", :null => false - t.string "relation_type", :default => "", :null => false - t.integer "delay" - end - - add_index "issue_relations", ["issue_from_id", "issue_to_id"], :name => "index_issue_relations_on_issue_from_id_and_issue_to_id", :unique => true - add_index "issue_relations", ["issue_from_id"], :name => "index_issue_relations_on_issue_from_id" - add_index "issue_relations", ["issue_to_id"], :name => "index_issue_relations_on_issue_to_id" - - create_table "issue_statuses", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.boolean "is_closed", :default => false, :null => false - t.boolean "is_default", :default => false, :null => false - t.integer "position", :default => 1 - t.integer "default_done_ratio" - end - - add_index "issue_statuses", ["is_closed"], :name => "index_issue_statuses_on_is_closed" - add_index "issue_statuses", ["is_default"], :name => "index_issue_statuses_on_is_default" - add_index "issue_statuses", ["position"], :name => "index_issue_statuses_on_position" - - create_table "issues", :force => true do |t| - t.integer "tracker_id", :null => false - t.integer "project_id", :null => false - t.string "subject", :default => "", :null => false - t.text "description" - t.date "due_date" - t.integer "category_id" - t.integer "status_id", :null => false - t.integer "assigned_to_id" - t.integer "priority_id", :null => false - t.integer "fixed_version_id" - t.integer "author_id", :null => false - t.integer "lock_version", :default => 0, :null => false - t.datetime "created_on" - t.datetime "updated_on" - t.date "start_date" - t.integer "done_ratio", :default => 0, :null => false - t.float "estimated_hours" - t.integer "parent_id" - t.integer "root_id" - t.integer "lft" - t.integer "rgt" - t.boolean "is_private", :default => false, :null => false - t.datetime "closed_on" - t.integer "project_issues_index" - end - - add_index "issues", ["assigned_to_id"], :name => "index_issues_on_assigned_to_id" - add_index "issues", ["author_id"], :name => "index_issues_on_author_id" - add_index "issues", ["category_id"], :name => "index_issues_on_category_id" - add_index "issues", ["created_on"], :name => "index_issues_on_created_on" - add_index "issues", ["fixed_version_id"], :name => "index_issues_on_fixed_version_id" - add_index "issues", ["priority_id"], :name => "index_issues_on_priority_id" - add_index "issues", ["project_id"], :name => "issues_project_id" - add_index "issues", ["root_id", "lft", "rgt"], :name => "index_issues_on_root_id_and_lft_and_rgt" - add_index "issues", ["status_id"], :name => "index_issues_on_status_id" - add_index "issues", ["tracker_id"], :name => "index_issues_on_tracker_id" - - create_table "join_in_competitions", :force => true do |t| - t.integer "user_id" - t.integer "competition_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "join_in_contests", :force => true do |t| - t.integer "user_id" - t.integer "bid_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "journal_details", :force => true do |t| - t.integer "journal_id", :default => 0, :null => false - t.string "property", :limit => 30, :default => "", :null => false - t.string "prop_key", :limit => 30, :default => "", :null => false - t.text "old_value" - t.text "value" - end - - add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" - - create_table "journal_replies", :id => false, :force => true do |t| - t.integer "journal_id" - t.integer "user_id" - t.integer "reply_id" - end - - add_index "journal_replies", ["journal_id"], :name => "index_journal_replies_on_journal_id" - add_index "journal_replies", ["reply_id"], :name => "index_journal_replies_on_reply_id" - add_index "journal_replies", ["user_id"], :name => "index_journal_replies_on_user_id" - - create_table "journals", :force => true do |t| - t.integer "journalized_id", :default => 0, :null => false - t.string "journalized_type", :limit => 30, :default => "", :null => false - t.integer "user_id", :default => 0, :null => false - t.text "notes" - t.datetime "created_on", :null => false - t.boolean "private_notes", :default => false, :null => false - end - - add_index "journals", ["created_on"], :name => "index_journals_on_created_on" - add_index "journals", ["journalized_id", "journalized_type"], :name => "journals_journalized_id" - add_index "journals", ["journalized_id"], :name => "index_journals_on_journalized_id" - add_index "journals", ["user_id"], :name => "index_journals_on_user_id" - - create_table "journals_for_messages", :force => true do |t| - t.integer "jour_id" - t.string "jour_type" - t.integer "user_id" - t.text "notes" - t.integer "status" - t.integer "reply_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.string "m_parent_id" - t.boolean "is_readed" - t.integer "m_reply_count" - t.integer "m_reply_id" - t.integer "is_comprehensive_evaluation" - end - - create_table "kindeditor_assets", :force => true do |t| - t.string "asset" - t.integer "file_size" - t.string "file_type" - t.integer "owner_id" - t.string "asset_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "owner_type", :default => 0 - end - - create_table "member_roles", :force => true do |t| - t.integer "member_id", :null => false - t.integer "role_id", :null => false - t.integer "inherited_from" - end - - add_index "member_roles", ["member_id"], :name => "index_member_roles_on_member_id" - add_index "member_roles", ["role_id"], :name => "index_member_roles_on_role_id" - - create_table "members", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.integer "project_id", :default => 0 - t.datetime "created_on" - t.boolean "mail_notification", :default => false, :null => false - t.integer "course_id", :default => -1 - t.integer "course_group_id", :default => 0 - end - - add_index "members", ["project_id"], :name => "index_members_on_project_id" - add_index "members", ["user_id", "project_id", "course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true - add_index "members", ["user_id"], :name => "index_members_on_user_id" - - create_table "memo_messages", :force => true do |t| - t.integer "user_id" - t.integer "forum_id" - t.integer "memo_id" - t.string "memo_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "memos", :force => true do |t| - t.integer "forum_id", :null => false - t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :null => false - t.integer "author_id", :null => false - t.integer "replies_count", :default => 0 - t.integer "last_reply_id" - t.boolean "lock", :default => false - t.boolean "sticky", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "viewed_count", :default => 0 - end - - create_table "message_alls", :force => true do |t| - t.integer "user_id" - t.integer "message_id" - t.string "message_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "messages", :force => true do |t| - t.integer "board_id", :null => false - t.integer "parent_id" - t.string "subject", :default => "", :null => false - t.text "content" - t.integer "author_id" - t.integer "replies_count", :default => 0, :null => false - t.integer "last_reply_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - t.boolean "locked", :default => false - t.integer "sticky", :default => 0 - t.integer "reply_id" - end - - add_index "messages", ["author_id"], :name => "index_messages_on_author_id" - add_index "messages", ["board_id"], :name => "messages_board_id" - add_index "messages", ["created_on"], :name => "index_messages_on_created_on" - add_index "messages", ["last_reply_id"], :name => "index_messages_on_last_reply_id" - add_index "messages", ["parent_id"], :name => "messages_parent_id" - - create_table "news", :force => true do |t| - t.integer "project_id" - t.string "title", :limit => 60, :default => "", :null => false - t.string "summary", :default => "" - t.text "description" - t.integer "author_id", :default => 0, :null => false - t.datetime "created_on" - t.integer "comments_count", :default => 0, :null => false - t.integer "course_id" - end - - add_index "news", ["author_id"], :name => "index_news_on_author_id" - add_index "news", ["created_on"], :name => "index_news_on_created_on" - add_index "news", ["project_id"], :name => "news_project_id" - - create_table "no_uses", :force => true do |t| - t.integer "user_id", :null => false - t.string "no_use_type" - t.integer "no_use_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "notificationcomments", :force => true do |t| - t.string "notificationcommented_type" - t.integer "notificationcommented_id" - t.integer "author_id" - t.text "notificationcomments" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "onclick_times", :force => true do |t| - t.integer "user_id" - t.datetime "onclick_time" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "open_id_authentication_associations", :force => true do |t| - t.integer "issued" - t.integer "lifetime" - t.string "handle" - t.string "assoc_type" - t.binary "server_url" - t.binary "secret" - end - - create_table "open_id_authentication_nonces", :force => true do |t| - t.integer "timestamp", :null => false - t.string "server_url" - t.string "salt", :null => false - end - - create_table "open_source_projects", :force => true do |t| - t.string "name" - t.text "description" - t.integer "commit_count", :default => 0 - t.integer "code_line", :default => 0 - t.integer "users_count", :default => 0 - t.date "last_commit_time" - t.string "url" - t.date "date_collected" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "option_numbers", :force => true do |t| - t.integer "user_id" - t.integer "memo" - t.integer "messages_for_issues" - t.integer "issues_status" - t.integer "replay_for_message" - t.integer "replay_for_memo" - t.integer "follow" - t.integer "tread" - t.integer "praise_by_one" - t.integer "praise_by_two" - t.integer "praise_by_three" - t.integer "tread_by_one" - t.integer "tread_by_two" - t.integer "tread_by_three" - t.integer "changeset" - t.integer "document" - t.integer "attachment" - t.integer "issue_done_ratio" - t.integer "post_issue" - t.integer "score_type" - t.integer "total_score" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "project_id" - end - - create_table "org_members", :force => true do |t| - t.integer "user_id" - t.integer "organization_id" - t.string "role" - end - - create_table "organizations", :force => true do |t| - t.string "name" - t.text "description" - t.integer "creator_id" - t.integer "home_id" - t.string "domain" - t.boolean "is_public" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "phone_app_versions", :force => true do |t| - t.string "version" - t.text "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "poll_answers", :force => true do |t| - t.integer "poll_question_id" - t.text "answer_text" - t.integer "answer_position" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "poll_questions", :force => true do |t| - t.string "question_title" - t.integer "question_type" - t.integer "is_necessary" - t.integer "poll_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "question_number" - end - - create_table "poll_users", :force => true do |t| - t.integer "user_id" - t.integer "poll_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "poll_votes", :force => true do |t| - t.integer "user_id" - t.integer "poll_question_id" - t.integer "poll_answer_id" - t.text "vote_text" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "polls", :force => true do |t| - t.string "polls_name" - t.string "polls_type" - t.integer "polls_group_id" - t.integer "polls_status" - t.integer "user_id" - t.datetime "published_at" - t.datetime "closed_at" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.text "polls_description" - t.integer "show_result", :default => 1 - end - - create_table "praise_tread_caches", :force => true do |t| - t.integer "object_id", :null => false - t.string "object_type" - t.integer "praise_num" - t.integer "tread_num" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "praise_treads", :force => true do |t| - t.integer "user_id", :null => false - t.integer "praise_tread_object_id" - t.string "praise_tread_object_type" - t.integer "praise_or_tread" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "principal_activities", :force => true do |t| - t.integer "user_id" - t.integer "principal_id" - t.integer "principal_act_id" - t.string "principal_act_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "project_infos", :force => true do |t| - t.integer "project_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "project_scores", :force => true do |t| - t.string "project_id" - t.integer "score" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "issue_num", :default => 0 - t.integer "issue_journal_num", :default => 0 - t.integer "news_num", :default => 0 - t.integer "documents_num", :default => 0 - t.integer "changeset_num", :default => 0 - t.integer "board_message_num", :default => 0 - end - - create_table "project_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "project_id" - t.integer "project_type" - t.float "grade", :default => 0.0 - t.integer "course_ac_para", :default => 0 - end - - add_index "project_statuses", ["grade"], :name => "index_project_statuses_on_grade" - - create_table "projecting_softapplictions", :force => true do |t| - t.integer "user_id" - t.integer "softapplication_id" - t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "projects", :force => true do |t| - t.string "name", :default => "", :null => false - t.text "description" - t.string "homepage", :default => "" - t.boolean "is_public", :default => true, :null => false - t.integer "parent_id" - t.datetime "created_on" - t.datetime "updated_on" - t.string "identifier" - t.integer "status", :default => 1, :null => false - t.integer "lft" - t.integer "rgt" - t.boolean "inherit_members", :default => false, :null => false - t.integer "project_type" - t.boolean "hidden_repo", :default => false, :null => false - t.integer "attachmenttype", :default => 1 - t.integer "user_id" - t.integer "dts_test", :default => 0 - t.string "enterprise_name" - t.integer "organization_id" - t.integer "project_new_type" - t.integer "gpid" - end - - add_index "projects", ["lft"], :name => "index_projects_on_lft" - add_index "projects", ["rgt"], :name => "index_projects_on_rgt" - - create_table "projects_trackers", :id => false, :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.integer "tracker_id", :default => 0, :null => false - end - - add_index "projects_trackers", ["project_id", "tracker_id"], :name => "projects_trackers_unique", :unique => true - add_index "projects_trackers", ["project_id"], :name => "projects_trackers_project_id" - - create_table "queries", :force => true do |t| - t.integer "project_id" - t.string "name", :default => "", :null => false - t.text "filters" - t.integer "user_id", :default => 0, :null => false - t.boolean "is_public", :default => false, :null => false - t.text "column_names" - t.text "sort_criteria" - t.string "group_by" - t.string "type" - end - - add_index "queries", ["project_id"], :name => "index_queries_on_project_id" - add_index "queries", ["user_id"], :name => "index_queries_on_user_id" - - create_table "relative_memo_to_open_source_projects", :force => true do |t| - t.integer "osp_id" - t.integer "relative_memo_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "relative_memos", :force => true do |t| - t.integer "osp_id" - t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :limit => 16777215, :null => false - t.integer "author_id" - t.integer "replies_count", :default => 0 - t.integer "last_reply_id" - t.boolean "lock", :default => false - t.boolean "sticky", :default => false - t.boolean "is_quote", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "viewed_count_crawl", :default => 0 - t.integer "viewed_count_local", :default => 0 - t.string "url" - t.string "username" - t.string "userhomeurl" - t.date "date_collected" - t.string "topic_resource" - end - - create_table "repositories", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "url", :default => "", :null => false - t.string "login", :limit => 60, :default => "" - t.string "password", :default => "" - t.string "root_url", :default => "" - t.string "type" - t.string "path_encoding", :limit => 64 - t.string "log_encoding", :limit => 64 - t.text "extra_info" - t.string "identifier" - t.boolean "is_default", :default => false - t.boolean "hidden", :default => false - end - - add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" - - create_table "rich_rich_files", :force => true do |t| - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "rich_file_file_name" - t.string "rich_file_content_type" - t.integer "rich_file_file_size" - t.datetime "rich_file_updated_at" - t.string "owner_type" - t.integer "owner_id" - t.text "uri_cache" - t.string "simplified_type", :default => "file" - end - - create_table "roles", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.integer "position", :default => 1 - t.boolean "assignable", :default => true - t.integer "builtin", :default => 0, :null => false - t.text "permissions" - t.string "issues_visibility", :limit => 30, :default => "default", :null => false - end - - create_table "schools", :force => true do |t| - t.string "name" - t.string "province" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "logo_link" - t.string "pinyin" - end - - create_table "seems_rateable_cached_ratings", :force => true do |t| - t.integer "cacheable_id", :limit => 8 - t.string "cacheable_type" - t.float "avg", :null => false - t.integer "cnt", :null => false - t.string "dimension" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "seems_rateable_rates", :force => true do |t| - t.integer "rater_id", :limit => 8 - t.integer "rateable_id" - t.string "rateable_type" - t.float "stars", :null => false - t.string "dimension" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "is_teacher_score", :default => 0 - end - - create_table "settings", :force => true do |t| - t.string "name", :default => "", :null => false - t.text "value" - t.datetime "updated_on" - end - - add_index "settings", ["name"], :name => "index_settings_on_name" - - create_table "shares", :force => true do |t| - t.date "created_on" - t.string "url" - t.string "title" - t.integer "share_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "project_id" - t.integer "user_id" - t.string "description" - end - - create_table "softapplications", :force => true do |t| - t.string "name" - t.text "description" - t.integer "app_type_id" - t.string "app_type_name" - t.string "android_min_version_available" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "contest_id" - t.integer "softapplication_id" - t.integer "is_public" - t.string "application_developers" - t.string "deposit_project_url" - t.string "deposit_project" - t.integer "project_id" - end - - create_table "student_work_tests", :force => true do |t| - t.integer "student_work_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "status", :default => 9 - t.text "results" - t.text "src" - end - - create_table "student_works", :force => true do |t| - t.string "name" - t.text "description", :limit => 2147483647 - t.integer "homework_common_id" - t.integer "user_id" - t.float "final_score" - t.float "teacher_score" - t.float "student_score" - t.float "teaching_asistant_score" - t.integer "project_id", :default => 0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "late_penalty", :default => 0 - t.integer "absence_penalty", :default => 0 - t.float "system_score", :default => 0.0 - t.boolean "is_test", :default => false - end - - create_table "student_works_evaluation_distributions", :force => true do |t| - t.integer "student_work_id" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "student_works_scores", :force => true do |t| - t.integer "student_work_id" - t.integer "user_id" - t.integer "score" - t.text "comment" - t.integer "reviewer_role" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "students_for_courses", :force => true do |t| - t.integer "student_id" - t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "students_for_courses", ["course_id"], :name => "index_students_for_courses_on_course_id" - add_index "students_for_courses", ["student_id"], :name => "index_students_for_courses_on_student_id" - - create_table "system_messages", :force => true do |t| - t.integer "user_id" - t.string "content" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.text "description" - t.string "subject" - end - - create_table "taggings", :force => true do |t| - t.integer "tag_id" - t.integer "taggable_id" - t.string "taggable_type" - t.integer "tagger_id" - t.string "tagger_type" - t.string "context", :limit => 128 - t.datetime "created_at" - end - - add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" - add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context" - add_index "taggings", ["taggable_type"], :name => "index_taggings_on_taggable_type" - - create_table "tags", :force => true do |t| - t.string "name" - end - - create_table "teachers", :force => true do |t| - t.string "tea_name" - t.string "location" - t.integer "couurse_time" - t.integer "course_code" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "extra" - end - - create_table "time_entries", :force => true do |t| - t.integer "project_id", :null => false - t.integer "user_id", :null => false - t.integer "issue_id" - t.float "hours", :null => false - t.string "comments" - t.integer "activity_id", :null => false - t.date "spent_on", :null => false - t.integer "tyear", :null => false - t.integer "tmonth", :null => false - t.integer "tweek", :null => false - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false - end - - add_index "time_entries", ["activity_id"], :name => "index_time_entries_on_activity_id" - add_index "time_entries", ["created_on"], :name => "index_time_entries_on_created_on" - add_index "time_entries", ["issue_id"], :name => "time_entries_issue_id" - add_index "time_entries", ["project_id"], :name => "time_entries_project_id" - add_index "time_entries", ["user_id"], :name => "index_time_entries_on_user_id" - - create_table "tokens", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.string "action", :limit => 30, :default => "", :null => false - t.string "value", :limit => 40, :default => "", :null => false - t.datetime "created_on", :null => false - end - - add_index "tokens", ["user_id"], :name => "index_tokens_on_user_id" - add_index "tokens", ["value"], :name => "tokens_value", :unique => true - - create_table "trackers", :force => true do |t| - t.string "name", :limit => 30, :default => "", :null => false - t.boolean "is_in_chlog", :default => false, :null => false - t.integer "position", :default => 1 - t.boolean "is_in_roadmap", :default => true, :null => false - t.integer "fields_bits", :default => 0 - end - - create_table "user_activities", :force => true do |t| - t.string "act_type" - t.integer "act_id" - t.string "container_type" - t.integer "container_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "user_id" - end - - create_table "user_extensions", :force => true do |t| - t.integer "user_id", :null => false - t.date "birthday" - t.string "brief_introduction" - t.integer "gender" - t.string "location" - t.string "occupation" - t.integer "work_experience" - t.integer "zip_code" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "technical_title" - t.integer "identity" - t.string "student_id" - t.string "teacher_realname" - t.string "student_realname" - t.string "location_city" - t.integer "school_id" - t.string "description", :default => "" - end - - create_table "user_feedback_messages", :force => true do |t| - t.integer "user_id" - t.integer "journals_for_message_id" - t.string "journals_for_message_type" - t.integer "viewed" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_grades", :force => true do |t| - t.integer "user_id", :null => false - t.integer "project_id", :null => false - t.float "grade", :default => 0.0 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "user_grades", ["grade"], :name => "index_user_grades_on_grade" - add_index "user_grades", ["project_id"], :name => "index_user_grades_on_project_id" - add_index "user_grades", ["user_id"], :name => "index_user_grades_on_user_id" - - create_table "user_levels", :force => true do |t| - t.integer "user_id" - t.integer "level" - end - - create_table "user_preferences", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.text "others" - t.boolean "hide_mail", :default => false - t.string "time_zone" - end - - add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id" - - create_table "user_score_details", :force => true do |t| - t.integer "current_user_id" - t.integer "target_user_id" - t.string "score_type" - t.string "score_action" - t.integer "user_id" - t.integer "old_score" - t.integer "new_score" - t.integer "current_user_level" - t.integer "target_user_level" - t.integer "score_changeable_obj_id" - t.string "score_changeable_obj_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_scores", :force => true do |t| - t.integer "user_id", :null => false - t.integer "collaboration" - t.integer "influence" - t.integer "skill" - t.integer "active" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "user_statuses", :force => true do |t| - t.integer "changesets_count" - t.integer "watchers_count" - t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.float "grade", :default => 0.0 - end - - add_index "user_statuses", ["changesets_count"], :name => "index_user_statuses_on_changesets_count" - add_index "user_statuses", ["grade"], :name => "index_user_statuses_on_grade" - add_index "user_statuses", ["watchers_count"], :name => "index_user_statuses_on_watchers_count" - - create_table "users", :force => true do |t| - t.string "login", :default => "", :null => false - t.string "hashed_password", :limit => 40, :default => "", :null => false - t.string "firstname", :limit => 30, :default => "", :null => false - t.string "lastname", :default => "", :null => false - t.string "mail", :limit => 60, :default => "", :null => false - t.boolean "admin", :default => false, :null => false - t.integer "status", :default => 1, :null => false - t.datetime "last_login_on" - t.string "language", :limit => 5, :default => "" - t.integer "auth_source_id" - t.datetime "created_on" - t.datetime "updated_on" - t.string "type" - t.string "identity_url" - t.string "mail_notification", :default => "", :null => false - t.string "salt", :limit => 64 - t.integer "gid" - end - - add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id" - add_index "users", ["id", "type"], :name => "index_users_on_id_and_type" - add_index "users", ["type"], :name => "index_users_on_type" - - create_table "versions", :force => true do |t| - t.integer "project_id", :default => 0, :null => false - t.string "name", :default => "", :null => false - t.string "description", :default => "" - t.date "effective_date" - t.datetime "created_on" - t.datetime "updated_on" - t.string "wiki_page_title" - t.string "status", :default => "open" - t.string "sharing", :default => "none", :null => false - end - - add_index "versions", ["project_id"], :name => "versions_project_id" - add_index "versions", ["sharing"], :name => "index_versions_on_sharing" - - create_table "visitors", :force => true do |t| - t.integer "user_id" - t.integer "master_id" - t.datetime "updated_on" - t.datetime "created_on" - end - - add_index "visitors", ["master_id"], :name => "index_visitors_master_id" - add_index "visitors", ["updated_on"], :name => "index_visitors_updated_on" - add_index "visitors", ["user_id"], :name => "index_visitors_user_id" - - create_table "watchers", :force => true do |t| - t.string "watchable_type", :default => "", :null => false - t.integer "watchable_id", :default => 0, :null => false - t.integer "user_id" - end - - add_index "watchers", ["user_id", "watchable_type"], :name => "watchers_user_id_type" - add_index "watchers", ["user_id"], :name => "index_watchers_on_user_id" - add_index "watchers", ["watchable_id", "watchable_type"], :name => "index_watchers_on_watchable_id_and_watchable_type" - - create_table "web_footer_companies", :force => true do |t| - t.string "name" - t.string "logo_size" - t.string "url" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "web_footer_oranizers", :force => true do |t| - t.string "name" - t.text "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "wiki_content_versions", :force => true do |t| - t.integer "wiki_content_id", :null => false - t.integer "page_id", :null => false - t.integer "author_id" - t.binary "data", :limit => 2147483647 - t.string "compression", :limit => 6, :default => "" - t.string "comments", :default => "" - t.datetime "updated_on", :null => false - t.integer "version", :null => false - end - - add_index "wiki_content_versions", ["updated_on"], :name => "index_wiki_content_versions_on_updated_on" - add_index "wiki_content_versions", ["wiki_content_id"], :name => "wiki_content_versions_wcid" - - create_table "wiki_contents", :force => true do |t| - t.integer "page_id", :null => false - t.integer "author_id" - t.text "text", :limit => 2147483647 - t.string "comments", :default => "" - t.datetime "updated_on", :null => false - t.integer "version", :null => false - end - - add_index "wiki_contents", ["author_id"], :name => "index_wiki_contents_on_author_id" - add_index "wiki_contents", ["page_id"], :name => "wiki_contents_page_id" - - create_table "wiki_pages", :force => true do |t| - t.integer "wiki_id", :null => false - t.string "title", :null => false - t.datetime "created_on", :null => false - t.boolean "protected", :default => false, :null => false - t.integer "parent_id" - end - - add_index "wiki_pages", ["parent_id"], :name => "index_wiki_pages_on_parent_id" - add_index "wiki_pages", ["wiki_id", "title"], :name => "wiki_pages_wiki_id_title" - add_index "wiki_pages", ["wiki_id"], :name => "index_wiki_pages_on_wiki_id" - - create_table "wiki_redirects", :force => true do |t| - t.integer "wiki_id", :null => false - t.string "title" - t.string "redirects_to" - t.datetime "created_on", :null => false - end - - add_index "wiki_redirects", ["wiki_id", "title"], :name => "wiki_redirects_wiki_id_title" - add_index "wiki_redirects", ["wiki_id"], :name => "index_wiki_redirects_on_wiki_id" - - create_table "wikis", :force => true do |t| - t.integer "project_id", :null => false - t.string "start_page", :null => false - t.integer "status", :default => 1, :null => false - end - - add_index "wikis", ["project_id"], :name => "wikis_project_id" - - create_table "workflows", :force => true do |t| - t.integer "tracker_id", :default => 0, :null => false - t.integer "old_status_id", :default => 0, :null => false - t.integer "new_status_id", :default => 0, :null => false - t.integer "role_id", :default => 0, :null => false - t.boolean "assignee", :default => false, :null => false - t.boolean "author", :default => false, :null => false - t.string "type", :limit => 30 - t.string "field_name", :limit => 30 - t.string "rule", :limit => 30 - end - - add_index "workflows", ["new_status_id"], :name => "index_workflows_on_new_status_id" - add_index "workflows", ["old_status_id"], :name => "index_workflows_on_old_status_id" - add_index "workflows", ["role_id", "tracker_id", "old_status_id"], :name => "wkfs_role_tracker_old_status" - add_index "workflows", ["role_id"], :name => "index_workflows_on_role_id" - - create_table "works_categories", :force => true do |t| - t.string "category" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - create_table "zip_packs", :force => true do |t| - t.integer "user_id" - t.integer "homework_id" - t.string "file_digest" - t.string "file_path" - t.integer "pack_times", :default => 1 - t.integer "pack_size", :default => 0 - t.text "file_digests" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - -end +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended to check this file into your version control system. + +ActiveRecord::Schema.define(:version => 20151102090519) do + + create_table "activities", :force => true do |t| + t.integer "act_id", :null => false + t.string "act_type", :null => false + t.integer "user_id", :null => false + t.integer "activity_container_id" + t.string "activity_container_type", :default => "" + t.datetime "created_at" + end + + add_index "activities", ["act_id", "act_type"], :name => "index_activities_on_act_id_and_act_type" + add_index "activities", ["user_id", "act_type"], :name => "index_activities_on_user_id_and_act_type" + add_index "activities", ["user_id"], :name => "index_activities_on_user_id" + + create_table "activity_notifies", :force => true do |t| + t.integer "activity_container_id" + t.string "activity_container_type" + t.integer "activity_id" + t.string "activity_type" + t.integer "notify_to" + t.datetime "created_on" + t.integer "is_read" + end + + add_index "activity_notifies", ["activity_container_id", "activity_container_type"], :name => "index_an_activity_container_id" + add_index "activity_notifies", ["created_on"], :name => "index_an_created_on" + add_index "activity_notifies", ["notify_to"], :name => "index_an_notify_to" + + create_table "api_keys", :force => true do |t| + t.string "access_token" + t.datetime "expires_at" + t.integer "user_id" + t.boolean "active", :default => true + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "api_keys", ["access_token"], :name => "index_api_keys_on_access_token" + add_index "api_keys", ["user_id"], :name => "index_api_keys_on_user_id" + + create_table "applied_projects", :force => true do |t| + t.integer "project_id", :null => false + t.integer "user_id", :null => false + end + + create_table "apply_project_masters", :force => true do |t| + t.integer "user_id" + t.string "apply_type" + t.integer "apply_id" + t.integer "status" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "attachments", :force => true do |t| + t.integer "container_id" + t.string "container_type", :limit => 30 + t.string "filename", :default => "", :null => false + t.string "disk_filename", :default => "", :null => false + t.integer "filesize", :default => 0, :null => false + t.string "content_type", :default => "" + t.string "digest", :limit => 40, :default => "", :null => false + t.integer "downloads", :default => 0, :null => false + t.integer "author_id", :default => 0, :null => false + t.datetime "created_on" + t.string "description" + t.string "disk_directory" + t.integer "attachtype", :default => 1 + t.integer "is_public", :default => 1 + t.integer "copy_from" + t.integer "quotes" + end + + add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id" + add_index "attachments", ["container_id", "container_type"], :name => "index_attachments_on_container_id_and_container_type" + add_index "attachments", ["created_on"], :name => "index_attachments_on_created_on" + + create_table "attachmentstypes", :force => true do |t| + t.integer "typeId", :null => false + t.string "typeName", :limit => 50 + end + + create_table "auth_sources", :force => true do |t| + t.string "type", :limit => 30, :default => "", :null => false + t.string "name", :limit => 60, :default => "", :null => false + t.string "host", :limit => 60 + t.integer "port" + t.string "account" + t.string "account_password", :default => "" + t.string "base_dn" + t.string "attr_login", :limit => 30 + t.string "attr_firstname", :limit => 30 + t.string "attr_lastname", :limit => 30 + t.string "attr_mail", :limit => 30 + t.boolean "onthefly_register", :default => false, :null => false + t.boolean "tls", :default => false, :null => false + t.string "filter" + t.integer "timeout" + end + + add_index "auth_sources", ["id", "type"], :name => "index_auth_sources_on_id_and_type" + + create_table "biding_projects", :force => true do |t| + t.integer "project_id" + t.integer "bid_id" + t.integer "user_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + end + + create_table "bids", :force => true do |t| + t.string "name" + t.string "budget", :null => false + t.integer "author_id" + t.date "deadline" + t.text "description" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + t.integer "commit" + t.integer "reward_type" + t.integer "homework_type" + t.integer "parent_id" + t.string "password" + t.integer "is_evaluation" + t.integer "proportion", :default => 60 + t.integer "comment_status", :default => 0 + t.integer "evaluation_num", :default => 3 + t.integer "open_anonymous_evaluation", :default => 1 + end + + create_table "blog_comments", :force => true do |t| + t.integer "blog_id", :null => false + t.integer "parent_id" + t.string "title", :default => "", :null => false + t.text "content" + t.integer "author_id" + t.integer "comments_count", :default => 0, :null => false + t.integer "last_comment_id" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + t.boolean "locked", :default => false + t.integer "sticky", :default => 0 + t.integer "reply_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "blogs", :force => true do |t| + t.string "name", :default => "", :null => false + t.text "description" + t.integer "position", :default => 1 + t.integer "article_count", :default => 0, :null => false + t.integer "comments_count", :default => 0, :null => false + t.integer "last_comments_id" + t.integer "parent_id" + t.integer "author_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "boards", :force => true do |t| + t.integer "project_id", :null => false + t.string "name", :default => "", :null => false + t.string "description" + t.integer "position", :default => 1 + t.integer "topics_count", :default => 0, :null => false + t.integer "messages_count", :default => 0, :null => false + t.integer "last_message_id" + t.integer "parent_id" + t.integer "course_id" + end + + add_index "boards", ["last_message_id"], :name => "index_boards_on_last_message_id" + add_index "boards", ["project_id"], :name => "boards_project_id" + + create_table "bug_to_osps", :force => true do |t| + t.integer "osp_id" + t.integer "relative_memo_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "changes", :force => true do |t| + t.integer "changeset_id", :null => false + t.string "action", :limit => 1, :default => "", :null => false + t.text "path", :null => false + t.text "from_path" + t.string "from_revision" + t.string "revision" + t.string "branch" + end + + add_index "changes", ["changeset_id"], :name => "changesets_changeset_id" + + create_table "changeset_parents", :id => false, :force => true do |t| + t.integer "changeset_id", :null => false + t.integer "parent_id", :null => false + end + + add_index "changeset_parents", ["changeset_id"], :name => "changeset_parents_changeset_ids" + add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids" + + create_table "changesets", :force => true do |t| + t.integer "repository_id", :null => false + t.string "revision", :null => false + t.string "committer" + t.datetime "committed_on", :null => false + t.text "comments" + t.date "commit_date" + t.string "scmid" + t.integer "user_id" + end + + add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on" + add_index "changesets", ["repository_id", "revision"], :name => "changesets_repos_rev", :unique => true + add_index "changesets", ["repository_id", "scmid"], :name => "changesets_repos_scmid" + add_index "changesets", ["repository_id"], :name => "index_changesets_on_repository_id" + add_index "changesets", ["user_id"], :name => "index_changesets_on_user_id" + + create_table "changesets_issues", :id => false, :force => true do |t| + t.integer "changeset_id", :null => false + t.integer "issue_id", :null => false + end + + add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true + + create_table "code_review_assignments", :force => true do |t| + t.integer "issue_id" + t.integer "change_id" + t.integer "attachment_id" + t.string "file_path" + t.string "rev" + t.string "rev_to" + t.string "action_type" + t.integer "changeset_id" + end + + create_table "code_review_project_settings", :force => true do |t| + t.integer "project_id" + t.integer "tracker_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "updated_by" + t.boolean "hide_code_review_tab", :default => false + t.integer "auto_relation", :default => 1 + t.integer "assignment_tracker_id" + t.text "auto_assign" + t.integer "lock_version", :default => 0, :null => false + t.boolean "tracker_in_review_dialog", :default => false + end + + create_table "code_review_user_settings", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.integer "mail_notification", :default => 0, :null => false + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "code_reviews", :force => true do |t| + t.integer "project_id" + t.integer "change_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "line" + t.integer "updated_by_id" + t.integer "lock_version", :default => 0, :null => false + t.integer "status_changed_from" + t.integer "status_changed_to" + t.integer "issue_id" + t.string "action_type" + t.string "file_path" + t.string "rev" + t.string "rev_to" + t.integer "attachment_id" + t.integer "file_count", :default => 0, :null => false + t.boolean "diff_all" + end + + create_table "comments", :force => true do |t| + t.string "commented_type", :limit => 30, :default => "", :null => false + t.integer "commented_id", :default => 0, :null => false + t.integer "author_id", :default => 0, :null => false + t.text "comments" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + end + + add_index "comments", ["author_id"], :name => "index_comments_on_author_id" + add_index "comments", ["commented_id", "commented_type"], :name => "index_comments_on_commented_id_and_commented_type" + + create_table "contest_notifications", :force => true do |t| + t.text "title" + t.text "content" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "contesting_projects", :force => true do |t| + t.integer "project_id" + t.string "contest_id" + t.integer "user_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + end + + create_table "contesting_softapplications", :force => true do |t| + t.integer "softapplication_id" + t.integer "contest_id" + t.integer "user_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + end + + create_table "contestnotifications", :force => true do |t| + t.integer "contest_id" + t.string "title" + t.string "summary" + t.text "description" + t.integer "author_id" + t.integer "notificationcomments_count" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "contests", :force => true do |t| + t.string "name" + t.string "budget", :default => "" + t.integer "author_id" + t.date "deadline" + t.string "description" + t.integer "commit" + t.string "password" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + end + + create_table "course_activities", :force => true do |t| + t.integer "user_id" + t.integer "course_id" + t.integer "course_act_id" + t.string "course_act_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "course_attachments", :force => true do |t| + t.string "filename" + t.string "disk_filename" + t.integer "filesize" + t.string "content_type" + t.string "digest" + t.integer "downloads" + t.string "author_id" + t.string "integer" + t.string "description" + t.string "disk_directory" + t.integer "attachtype" + t.integer "is_public" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "container_id", :default => 0 + end + + create_table "course_groups", :force => true do |t| + t.string "name" + t.integer "course_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "course_infos", :force => true do |t| + t.integer "course_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "course_messages", :force => true do |t| + t.integer "user_id" + t.integer "course_id" + t.integer "course_message_id" + t.string "course_message_type" + t.integer "viewed" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "content" + t.integer "status" + end + + create_table "course_statuses", :force => true do |t| + t.integer "changesets_count" + t.integer "watchers_count" + t.integer "course_id" + t.float "grade", :default => 0.0 + t.integer "course_ac_para", :default => 0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "courses", :force => true do |t| + t.integer "tea_id" + t.string "name" + t.integer "state" + t.string "code" + t.integer "time" + t.string "extra" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "location" + t.string "term" + t.string "string" + t.string "password" + t.string "setup_time" + t.string "endup_time" + t.string "class_period" + t.integer "school_id" + t.text "description" + t.integer "status", :default => 1 + t.integer "attachmenttype", :default => 2 + t.integer "lft" + t.integer "rgt" + t.integer "is_public", :limit => 1, :default => 1 + t.integer "inherit_members", :limit => 1, :default => 1 + t.integer "open_student", :default => 0 + t.integer "outline", :default => 0 + end + + create_table "custom_fields", :force => true do |t| + t.string "type", :limit => 30, :default => "", :null => false + t.string "name", :limit => 30, :default => "", :null => false + t.string "field_format", :limit => 30, :default => "", :null => false + t.text "possible_values" + t.string "regexp", :default => "" + t.integer "min_length", :default => 0, :null => false + t.integer "max_length", :default => 0, :null => false + t.boolean "is_required", :default => false, :null => false + t.boolean "is_for_all", :default => false, :null => false + t.boolean "is_filter", :default => false, :null => false + t.integer "position", :default => 1 + t.boolean "searchable", :default => false + t.text "default_value" + t.boolean "editable", :default => true + t.boolean "visible", :default => true, :null => false + t.boolean "multiple", :default => false + end + + add_index "custom_fields", ["id", "type"], :name => "index_custom_fields_on_id_and_type" + + create_table "custom_fields_projects", :id => false, :force => true do |t| + t.integer "custom_field_id", :default => 0, :null => false + t.integer "project_id", :default => 0, :null => false + end + + add_index "custom_fields_projects", ["custom_field_id", "project_id"], :name => "index_custom_fields_projects_on_custom_field_id_and_project_id", :unique => true + + create_table "custom_fields_trackers", :id => false, :force => true do |t| + t.integer "custom_field_id", :default => 0, :null => false + t.integer "tracker_id", :default => 0, :null => false + end + + add_index "custom_fields_trackers", ["custom_field_id", "tracker_id"], :name => "index_custom_fields_trackers_on_custom_field_id_and_tracker_id", :unique => true + + create_table "custom_values", :force => true do |t| + t.string "customized_type", :limit => 30, :default => "", :null => false + t.integer "customized_id", :default => 0, :null => false + t.integer "custom_field_id", :default => 0, :null => false + t.text "value" + end + + add_index "custom_values", ["custom_field_id"], :name => "index_custom_values_on_custom_field_id" + add_index "custom_values", ["customized_type", "customized_id"], :name => "custom_values_customized" + + create_table "delayed_jobs", :force => true do |t| + t.integer "priority", :default => 0, :null => false + t.integer "attempts", :default => 0, :null => false + t.text "handler", :null => false + t.text "last_error" + t.datetime "run_at" + t.datetime "locked_at" + t.datetime "failed_at" + t.string "locked_by" + t.string "queue" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" + + create_table "discuss_demos", :force => true do |t| + t.string "title" + t.text "body" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "documents", :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.integer "category_id", :default => 0, :null => false + t.string "title", :limit => 60, :default => "", :null => false + t.text "description" + t.datetime "created_on" + t.integer "user_id", :default => 0 + t.integer "is_public", :default => 1 + end + + add_index "documents", ["category_id"], :name => "index_documents_on_category_id" + add_index "documents", ["created_on"], :name => "index_documents_on_created_on" + add_index "documents", ["project_id"], :name => "documents_project_id" + + create_table "dts", :primary_key => "Num", :force => true do |t| + t.string "Defect", :limit => 50 + t.string "Category", :limit => 50 + t.string "File" + t.string "Method" + t.string "Module", :limit => 20 + t.string "Variable", :limit => 50 + t.integer "StartLine" + t.integer "IPLine" + t.string "IPLineCode", :limit => 200 + t.string "Judge", :limit => 15 + t.integer "Review", :limit => 1 + t.string "Description" + t.text "PreConditions", :limit => 2147483647 + t.text "TraceInfo", :limit => 2147483647 + t.text "Code", :limit => 2147483647 + t.integer "project_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "id", :null => false + end + + create_table "enabled_modules", :force => true do |t| + t.integer "project_id" + t.string "name", :null => false + t.integer "course_id" + end + + add_index "enabled_modules", ["project_id"], :name => "enabled_modules_project_id" + + create_table "enumerations", :force => true do |t| + t.string "name", :limit => 30, :default => "", :null => false + t.integer "position", :default => 1 + t.boolean "is_default", :default => false, :null => false + t.string "type" + t.boolean "active", :default => true, :null => false + t.integer "project_id" + t.integer "parent_id" + t.string "position_name", :limit => 30 + end + + 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 "first_pages", :force => true do |t| + t.string "web_title" + t.string "title" + t.text "description" + t.string "page_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "sort_type" + t.integer "image_width", :default => 107 + t.integer "image_height", :default => 63 + t.integer "show_course", :default => 1 + t.integer "show_contest", :default => 1 + end + + create_table "forge_activities", :force => true do |t| + t.integer "user_id" + t.integer "project_id" + t.integer "forge_act_id" + t.string "forge_act_type" + t.integer "org_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "forge_activities", ["forge_act_id"], :name => "index_forge_activities_on_forge_act_id" + + create_table "forge_messages", :force => true do |t| + t.integer "user_id" + t.integer "project_id" + t.integer "forge_message_id" + t.string "forge_message_type" + t.integer "viewed" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "secret_key" + t.integer "status" + end + + create_table "forums", :force => true do |t| + t.string "name", :null => false + t.text "description" + t.integer "topic_count", :default => 0 + t.integer "memo_count", :default => 0 + t.integer "last_memo_id", :default => 0 + t.integer "creator_id", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "sticky" + t.integer "locked" + end + + create_table "groups_users", :id => false, :force => true do |t| + t.integer "group_id", :null => false + t.integer "user_id", :null => false + end + + add_index "groups_users", ["group_id", "user_id"], :name => "groups_users_ids", :unique => true + + create_table "homework_attaches", :force => true do |t| + t.integer "bid_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + t.string "name" + t.text "description" + t.integer "state" + t.integer "project_id", :default => 0 + t.float "score", :default => 0.0 + t.integer "is_teacher_score", :default => 0 + end + + add_index "homework_attaches", ["bid_id"], :name => "index_homework_attaches_on_bid_id" + + create_table "homework_commons", :force => true do |t| + t.string "name" + t.integer "user_id" + t.text "description" + t.date "publish_time" + t.date "end_time" + t.integer "homework_type", :default => 1 + t.string "late_penalty" + t.integer "course_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "teacher_priority", :default => 1 + t.integer "anonymous_comment", :default => 0 + end + + create_table "homework_detail_manuals", :force => true do |t| + t.float "ta_proportion" + t.integer "comment_status" + t.date "evaluation_start" + t.date "evaluation_end" + t.integer "evaluation_num" + t.integer "absence_penalty", :default => 1 + t.integer "homework_common_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "homework_detail_programings", :force => true do |t| + t.string "language" + t.text "standard_code", :limit => 2147483647 + t.integer "homework_common_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.float "ta_proportion", :default => 0.1 + t.integer "question_id" + end + + create_table "homework_evaluations", :force => true do |t| + t.string "user_id" + t.string "homework_attach_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "homework_for_courses", :force => true do |t| + t.integer "course_id" + t.integer "bid_id" + end + + add_index "homework_for_courses", ["bid_id"], :name => "index_homework_for_courses_on_bid_id" + add_index "homework_for_courses", ["course_id"], :name => "index_homework_for_courses_on_course_id" + + create_table "homework_tests", :force => true do |t| + t.text "input" + t.text "output" + t.integer "homework_common_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "result" + t.text "error_msg" + end + + create_table "homework_users", :force => true do |t| + t.string "homework_attach_id" + t.string "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "invite_lists", :force => true do |t| + t.integer "project_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "mail" + end + + create_table "issue_categories", :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.string "name", :limit => 30, :default => "", :null => false + t.integer "assigned_to_id" + end + + add_index "issue_categories", ["assigned_to_id"], :name => "index_issue_categories_on_assigned_to_id" + add_index "issue_categories", ["project_id"], :name => "issue_categories_project_id" + + create_table "issue_relations", :force => true do |t| + t.integer "issue_from_id", :null => false + t.integer "issue_to_id", :null => false + t.string "relation_type", :default => "", :null => false + t.integer "delay" + end + + add_index "issue_relations", ["issue_from_id", "issue_to_id"], :name => "index_issue_relations_on_issue_from_id_and_issue_to_id", :unique => true + add_index "issue_relations", ["issue_from_id"], :name => "index_issue_relations_on_issue_from_id" + add_index "issue_relations", ["issue_to_id"], :name => "index_issue_relations_on_issue_to_id" + + create_table "issue_statuses", :force => true do |t| + t.string "name", :limit => 30, :default => "", :null => false + t.boolean "is_closed", :default => false, :null => false + t.boolean "is_default", :default => false, :null => false + t.integer "position", :default => 1 + t.integer "default_done_ratio" + end + + add_index "issue_statuses", ["is_closed"], :name => "index_issue_statuses_on_is_closed" + add_index "issue_statuses", ["is_default"], :name => "index_issue_statuses_on_is_default" + add_index "issue_statuses", ["position"], :name => "index_issue_statuses_on_position" + + create_table "issues", :force => true do |t| + t.integer "tracker_id", :null => false + t.integer "project_id", :null => false + t.string "subject", :default => "", :null => false + t.text "description" + t.date "due_date" + t.integer "category_id" + t.integer "status_id", :null => false + t.integer "assigned_to_id" + t.integer "priority_id", :null => false + t.integer "fixed_version_id" + t.integer "author_id", :null => false + t.integer "lock_version", :default => 0, :null => false + t.datetime "created_on" + t.datetime "updated_on" + t.date "start_date" + t.integer "done_ratio", :default => 0, :null => false + t.float "estimated_hours" + t.integer "parent_id" + t.integer "root_id" + t.integer "lft" + t.integer "rgt" + t.boolean "is_private", :default => false, :null => false + t.datetime "closed_on" + t.integer "project_issues_index" + end + + add_index "issues", ["assigned_to_id"], :name => "index_issues_on_assigned_to_id" + add_index "issues", ["author_id"], :name => "index_issues_on_author_id" + add_index "issues", ["category_id"], :name => "index_issues_on_category_id" + add_index "issues", ["created_on"], :name => "index_issues_on_created_on" + add_index "issues", ["fixed_version_id"], :name => "index_issues_on_fixed_version_id" + add_index "issues", ["priority_id"], :name => "index_issues_on_priority_id" + add_index "issues", ["project_id"], :name => "issues_project_id" + add_index "issues", ["root_id", "lft", "rgt"], :name => "index_issues_on_root_id_and_lft_and_rgt" + add_index "issues", ["status_id"], :name => "index_issues_on_status_id" + add_index "issues", ["tracker_id"], :name => "index_issues_on_tracker_id" + + create_table "join_in_competitions", :force => true do |t| + t.integer "user_id" + t.integer "competition_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "join_in_contests", :force => true do |t| + t.integer "user_id" + t.integer "bid_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "journal_details", :force => true do |t| + t.integer "journal_id", :default => 0, :null => false + t.string "property", :limit => 30, :default => "", :null => false + t.string "prop_key", :limit => 30, :default => "", :null => false + t.text "old_value" + t.text "value" + end + + add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" + + create_table "journal_replies", :id => false, :force => true do |t| + t.integer "journal_id" + t.integer "user_id" + t.integer "reply_id" + end + + add_index "journal_replies", ["journal_id"], :name => "index_journal_replies_on_journal_id" + add_index "journal_replies", ["reply_id"], :name => "index_journal_replies_on_reply_id" + add_index "journal_replies", ["user_id"], :name => "index_journal_replies_on_user_id" + + create_table "journals", :force => true do |t| + t.integer "journalized_id", :default => 0, :null => false + t.string "journalized_type", :limit => 30, :default => "", :null => false + t.integer "user_id", :default => 0, :null => false + t.text "notes" + t.datetime "created_on", :null => false + t.boolean "private_notes", :default => false, :null => false + end + + add_index "journals", ["created_on"], :name => "index_journals_on_created_on" + add_index "journals", ["journalized_id", "journalized_type"], :name => "journals_journalized_id" + add_index "journals", ["journalized_id"], :name => "index_journals_on_journalized_id" + add_index "journals", ["user_id"], :name => "index_journals_on_user_id" + + create_table "journals_for_messages", :force => true do |t| + t.integer "jour_id" + t.string "jour_type" + t.integer "user_id" + t.text "notes" + t.integer "status" + t.integer "reply_id" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + t.string "m_parent_id" + t.boolean "is_readed" + t.integer "m_reply_count" + t.integer "m_reply_id" + t.integer "is_comprehensive_evaluation" + end + + create_table "kindeditor_assets", :force => true do |t| + t.string "asset" + t.integer "file_size" + t.string "file_type" + t.integer "owner_id" + t.string "asset_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "owner_type", :default => 0 + end + + create_table "member_roles", :force => true do |t| + t.integer "member_id", :null => false + t.integer "role_id", :null => false + t.integer "inherited_from" + end + + add_index "member_roles", ["member_id"], :name => "index_member_roles_on_member_id" + add_index "member_roles", ["role_id"], :name => "index_member_roles_on_role_id" + + create_table "members", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.integer "project_id", :default => 0 + t.datetime "created_on" + t.boolean "mail_notification", :default => false, :null => false + t.integer "course_id", :default => -1 + t.integer "course_group_id", :default => 0 + end + + add_index "members", ["project_id"], :name => "index_members_on_project_id" + add_index "members", ["user_id", "project_id", "course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true + add_index "members", ["user_id"], :name => "index_members_on_user_id" + + create_table "memo_messages", :force => true do |t| + t.integer "user_id" + t.integer "forum_id" + t.integer "memo_id" + t.string "memo_type" + t.integer "viewed" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "memos", :force => true do |t| + t.integer "forum_id", :null => false + t.integer "parent_id" + t.string "subject", :null => false + t.text "content", :null => false + t.integer "author_id", :null => false + t.integer "replies_count", :default => 0 + t.integer "last_reply_id" + t.boolean "lock", :default => false + t.boolean "sticky", :default => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "viewed_count", :default => 0 + end + + create_table "message_alls", :force => true do |t| + t.integer "user_id" + t.integer "message_id" + t.string "message_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "messages", :force => true do |t| + t.integer "board_id", :null => false + t.integer "parent_id" + t.string "subject", :default => "", :null => false + t.text "content" + t.integer "author_id" + t.integer "replies_count", :default => 0, :null => false + t.integer "last_reply_id" + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + t.boolean "locked", :default => false + t.integer "sticky", :default => 0 + t.integer "reply_id" + end + + add_index "messages", ["author_id"], :name => "index_messages_on_author_id" + add_index "messages", ["board_id"], :name => "messages_board_id" + add_index "messages", ["created_on"], :name => "index_messages_on_created_on" + add_index "messages", ["last_reply_id"], :name => "index_messages_on_last_reply_id" + add_index "messages", ["parent_id"], :name => "messages_parent_id" + + create_table "news", :force => true do |t| + t.integer "project_id" + t.string "title", :limit => 60, :default => "", :null => false + t.string "summary", :default => "" + t.text "description" + t.integer "author_id", :default => 0, :null => false + t.datetime "created_on" + t.integer "comments_count", :default => 0, :null => false + t.integer "course_id" + end + + add_index "news", ["author_id"], :name => "index_news_on_author_id" + add_index "news", ["created_on"], :name => "index_news_on_created_on" + add_index "news", ["project_id"], :name => "news_project_id" + + create_table "no_uses", :force => true do |t| + t.integer "user_id", :null => false + t.string "no_use_type" + t.integer "no_use_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "notificationcomments", :force => true do |t| + t.string "notificationcommented_type" + t.integer "notificationcommented_id" + t.integer "author_id" + t.text "notificationcomments" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "onclick_times", :force => true do |t| + t.integer "user_id" + t.datetime "onclick_time" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "open_id_authentication_associations", :force => true do |t| + t.integer "issued" + t.integer "lifetime" + t.string "handle" + t.string "assoc_type" + t.binary "server_url" + t.binary "secret" + end + + create_table "open_id_authentication_nonces", :force => true do |t| + t.integer "timestamp", :null => false + t.string "server_url" + t.string "salt", :null => false + end + + create_table "open_source_projects", :force => true do |t| + t.string "name" + t.text "description" + t.integer "commit_count", :default => 0 + t.integer "code_line", :default => 0 + t.integer "users_count", :default => 0 + t.date "last_commit_time" + t.string "url" + t.date "date_collected" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "option_numbers", :force => true do |t| + t.integer "user_id" + t.integer "memo" + t.integer "messages_for_issues" + t.integer "issues_status" + t.integer "replay_for_message" + t.integer "replay_for_memo" + t.integer "follow" + t.integer "tread" + t.integer "praise_by_one" + t.integer "praise_by_two" + t.integer "praise_by_three" + t.integer "tread_by_one" + t.integer "tread_by_two" + t.integer "tread_by_three" + t.integer "changeset" + t.integer "document" + t.integer "attachment" + t.integer "issue_done_ratio" + t.integer "post_issue" + t.integer "score_type" + t.integer "total_score" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "project_id" + end + + create_table "org_members", :force => true do |t| + t.integer "user_id" + t.integer "organization_id" + t.string "role" + end + + create_table "organizations", :force => true do |t| + t.string "name" + t.text "description" + t.integer "creator_id" + t.integer "home_id" + t.string "domain" + t.boolean "is_public" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "phone_app_versions", :force => true do |t| + t.string "version" + t.text "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "poll_answers", :force => true do |t| + t.integer "poll_question_id" + t.text "answer_text" + t.integer "answer_position" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "poll_questions", :force => true do |t| + t.string "question_title" + t.integer "question_type" + t.integer "is_necessary" + t.integer "poll_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "question_number" + end + + create_table "poll_users", :force => true do |t| + t.integer "user_id" + t.integer "poll_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "poll_votes", :force => true do |t| + t.integer "user_id" + t.integer "poll_question_id" + t.integer "poll_answer_id" + t.text "vote_text" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "polls", :force => true do |t| + t.string "polls_name" + t.string "polls_type" + t.integer "polls_group_id" + t.integer "polls_status" + t.integer "user_id" + t.datetime "published_at" + t.datetime "closed_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.text "polls_description" + t.integer "show_result", :default => 1 + end + + create_table "praise_tread_caches", :force => true do |t| + t.integer "object_id", :null => false + t.string "object_type" + t.integer "praise_num" + t.integer "tread_num" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "praise_treads", :force => true do |t| + t.integer "user_id", :null => false + t.integer "praise_tread_object_id" + t.string "praise_tread_object_type" + t.integer "praise_or_tread" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "principal_activities", :force => true do |t| + t.integer "user_id" + t.integer "principal_id" + t.integer "principal_act_id" + t.string "principal_act_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "project_infos", :force => true do |t| + t.integer "project_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "project_scores", :force => true do |t| + t.string "project_id" + t.integer "score" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "issue_num", :default => 0 + t.integer "issue_journal_num", :default => 0 + t.integer "news_num", :default => 0 + t.integer "documents_num", :default => 0 + t.integer "changeset_num", :default => 0 + t.integer "board_message_num", :default => 0 + end + + create_table "project_statuses", :force => true do |t| + t.integer "changesets_count" + t.integer "watchers_count" + t.integer "project_id" + t.integer "project_type" + t.float "grade", :default => 0.0 + t.integer "course_ac_para", :default => 0 + end + + add_index "project_statuses", ["grade"], :name => "index_project_statuses_on_grade" + + create_table "projecting_softapplictions", :force => true do |t| + t.integer "user_id" + t.integer "softapplication_id" + t.integer "project_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "projects", :force => true do |t| + t.string "name", :default => "", :null => false + t.text "description" + t.string "homepage", :default => "" + t.boolean "is_public", :default => true, :null => false + t.integer "parent_id" + t.datetime "created_on" + t.datetime "updated_on" + t.string "identifier" + t.integer "status", :default => 1, :null => false + t.integer "lft" + t.integer "rgt" + t.boolean "inherit_members", :default => false, :null => false + t.integer "project_type" + t.boolean "hidden_repo", :default => false, :null => false + t.integer "attachmenttype", :default => 1 + t.integer "user_id" + t.integer "dts_test", :default => 0 + t.string "enterprise_name" + t.integer "organization_id" + t.integer "project_new_type" + t.integer "gpid" + end + + add_index "projects", ["lft"], :name => "index_projects_on_lft" + add_index "projects", ["rgt"], :name => "index_projects_on_rgt" + + create_table "projects_trackers", :id => false, :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.integer "tracker_id", :default => 0, :null => false + end + + add_index "projects_trackers", ["project_id", "tracker_id"], :name => "projects_trackers_unique", :unique => true + add_index "projects_trackers", ["project_id"], :name => "projects_trackers_project_id" + + create_table "queries", :force => true do |t| + t.integer "project_id" + t.string "name", :default => "", :null => false + t.text "filters" + t.integer "user_id", :default => 0, :null => false + t.boolean "is_public", :default => false, :null => false + t.text "column_names" + t.text "sort_criteria" + t.string "group_by" + t.string "type" + end + + add_index "queries", ["project_id"], :name => "index_queries_on_project_id" + add_index "queries", ["user_id"], :name => "index_queries_on_user_id" + + create_table "relative_memo_to_open_source_projects", :force => true do |t| + t.integer "osp_id" + t.integer "relative_memo_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "relative_memos", :force => true do |t| + t.integer "osp_id" + t.integer "parent_id" + t.string "subject", :null => false + t.text "content", :limit => 16777215, :null => false + t.integer "author_id" + t.integer "replies_count", :default => 0 + t.integer "last_reply_id" + t.boolean "lock", :default => false + t.boolean "sticky", :default => false + t.boolean "is_quote", :default => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "viewed_count_crawl", :default => 0 + t.integer "viewed_count_local", :default => 0 + t.string "url" + t.string "username" + t.string "userhomeurl" + t.date "date_collected" + t.string "topic_resource" + end + + create_table "repositories", :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.string "url", :default => "", :null => false + t.string "login", :limit => 60, :default => "" + t.string "password", :default => "" + t.string "root_url", :default => "" + t.string "type" + t.string "path_encoding", :limit => 64 + t.string "log_encoding", :limit => 64 + t.text "extra_info" + t.string "identifier" + t.boolean "is_default", :default => false + t.boolean "hidden", :default => false + end + + add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" + + create_table "rich_rich_files", :force => true do |t| + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "rich_file_file_name" + t.string "rich_file_content_type" + t.integer "rich_file_file_size" + t.datetime "rich_file_updated_at" + t.string "owner_type" + t.integer "owner_id" + t.text "uri_cache" + t.string "simplified_type", :default => "file" + end + + create_table "roles", :force => true do |t| + t.string "name", :limit => 30, :default => "", :null => false + t.integer "position", :default => 1 + t.boolean "assignable", :default => true + t.integer "builtin", :default => 0, :null => false + t.text "permissions" + t.string "issues_visibility", :limit => 30, :default => "default", :null => false + end + + create_table "schools", :force => true do |t| + t.string "name" + t.string "province" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "logo_link" + t.string "pinyin" + end + + create_table "seems_rateable_cached_ratings", :force => true do |t| + t.integer "cacheable_id", :limit => 8 + t.string "cacheable_type" + t.float "avg", :null => false + t.integer "cnt", :null => false + t.string "dimension" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "seems_rateable_rates", :force => true do |t| + t.integer "rater_id", :limit => 8 + t.integer "rateable_id" + t.string "rateable_type" + t.float "stars", :null => false + t.string "dimension" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "is_teacher_score", :default => 0 + end + + create_table "settings", :force => true do |t| + t.string "name", :default => "", :null => false + t.text "value" + t.datetime "updated_on" + end + + add_index "settings", ["name"], :name => "index_settings_on_name" + + create_table "shares", :force => true do |t| + t.date "created_on" + t.string "url" + t.string "title" + t.integer "share_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "project_id" + t.integer "user_id" + t.string "description" + end + + create_table "softapplications", :force => true do |t| + t.string "name" + t.text "description" + t.integer "app_type_id" + t.string "app_type_name" + t.string "android_min_version_available" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "contest_id" + t.integer "softapplication_id" + t.integer "is_public" + t.string "application_developers" + t.string "deposit_project_url" + t.string "deposit_project" + t.integer "project_id" + end + + create_table "student_work_tests", :force => true do |t| + t.integer "student_work_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "status", :default => 9 + t.text "results" + t.text "src" + end + + create_table "student_works", :force => true do |t| + t.string "name" + t.text "description", :limit => 2147483647 + t.integer "homework_common_id" + t.integer "user_id" + t.float "final_score" + t.float "teacher_score" + t.float "student_score" + t.float "teaching_asistant_score" + t.integer "project_id", :default => 0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "late_penalty", :default => 0 + t.integer "absence_penalty", :default => 0 + t.float "system_score", :default => 0.0 + t.boolean "is_test", :default => false + end + + create_table "student_works_evaluation_distributions", :force => true do |t| + t.integer "student_work_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "student_works_scores", :force => true do |t| + t.integer "student_work_id" + t.integer "user_id" + t.integer "score" + t.text "comment" + t.integer "reviewer_role" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "students_for_courses", :force => true do |t| + t.integer "student_id" + t.integer "course_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "students_for_courses", ["course_id"], :name => "index_students_for_courses_on_course_id" + add_index "students_for_courses", ["student_id"], :name => "index_students_for_courses_on_student_id" + + create_table "system_messages", :force => true do |t| + t.integer "user_id" + t.string "content" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.text "description" + t.string "subject" + end + + create_table "taggings", :force => true do |t| + t.integer "tag_id" + t.integer "taggable_id" + t.string "taggable_type" + t.integer "tagger_id" + t.string "tagger_type" + t.string "context", :limit => 128 + t.datetime "created_at" + end + + add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" + add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context" + add_index "taggings", ["taggable_type"], :name => "index_taggings_on_taggable_type" + + create_table "tags", :force => true do |t| + t.string "name" + end + + create_table "teachers", :force => true do |t| + t.string "tea_name" + t.string "location" + t.integer "couurse_time" + t.integer "course_code" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "extra" + end + + create_table "time_entries", :force => true do |t| + t.integer "project_id", :null => false + t.integer "user_id", :null => false + t.integer "issue_id" + t.float "hours", :null => false + t.string "comments" + t.integer "activity_id", :null => false + t.date "spent_on", :null => false + t.integer "tyear", :null => false + t.integer "tmonth", :null => false + t.integer "tweek", :null => false + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false + end + + add_index "time_entries", ["activity_id"], :name => "index_time_entries_on_activity_id" + add_index "time_entries", ["created_on"], :name => "index_time_entries_on_created_on" + add_index "time_entries", ["issue_id"], :name => "time_entries_issue_id" + add_index "time_entries", ["project_id"], :name => "time_entries_project_id" + add_index "time_entries", ["user_id"], :name => "index_time_entries_on_user_id" + + create_table "tokens", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.string "action", :limit => 30, :default => "", :null => false + t.string "value", :limit => 40, :default => "", :null => false + t.datetime "created_on", :null => false + end + + add_index "tokens", ["user_id"], :name => "index_tokens_on_user_id" + add_index "tokens", ["value"], :name => "tokens_value", :unique => true + + create_table "trackers", :force => true do |t| + t.string "name", :limit => 30, :default => "", :null => false + t.boolean "is_in_chlog", :default => false, :null => false + t.integer "position", :default => 1 + t.boolean "is_in_roadmap", :default => true, :null => false + t.integer "fields_bits", :default => 0 + end + + create_table "user_activities", :force => true do |t| + t.string "act_type" + t.integer "act_id" + t.string "container_type" + t.integer "container_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "user_id" + end + + create_table "user_extensions", :force => true do |t| + t.integer "user_id", :null => false + t.date "birthday" + t.string "brief_introduction" + t.integer "gender" + t.string "location" + t.string "occupation" + t.integer "work_experience" + t.integer "zip_code" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "technical_title" + t.integer "identity" + t.string "student_id" + t.string "teacher_realname" + t.string "student_realname" + t.string "location_city" + t.integer "school_id" + t.string "description", :default => "" + end + + create_table "user_feedback_messages", :force => true do |t| + t.integer "user_id" + t.integer "journals_for_message_id" + t.string "journals_for_message_type" + t.integer "viewed" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "user_grades", :force => true do |t| + t.integer "user_id", :null => false + t.integer "project_id", :null => false + t.float "grade", :default => 0.0 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "user_grades", ["grade"], :name => "index_user_grades_on_grade" + add_index "user_grades", ["project_id"], :name => "index_user_grades_on_project_id" + add_index "user_grades", ["user_id"], :name => "index_user_grades_on_user_id" + + create_table "user_levels", :force => true do |t| + t.integer "user_id" + t.integer "level" + end + + create_table "user_preferences", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.text "others" + t.boolean "hide_mail", :default => false + t.string "time_zone" + end + + add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id" + + create_table "user_score_details", :force => true do |t| + t.integer "current_user_id" + t.integer "target_user_id" + t.string "score_type" + t.string "score_action" + t.integer "user_id" + t.integer "old_score" + t.integer "new_score" + t.integer "current_user_level" + t.integer "target_user_level" + t.integer "score_changeable_obj_id" + t.string "score_changeable_obj_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "user_scores", :force => true do |t| + t.integer "user_id", :null => false + t.integer "collaboration" + t.integer "influence" + t.integer "skill" + t.integer "active" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "user_statuses", :force => true do |t| + t.integer "changesets_count" + t.integer "watchers_count" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.float "grade", :default => 0.0 + end + + add_index "user_statuses", ["changesets_count"], :name => "index_user_statuses_on_changesets_count" + add_index "user_statuses", ["grade"], :name => "index_user_statuses_on_grade" + add_index "user_statuses", ["watchers_count"], :name => "index_user_statuses_on_watchers_count" + + create_table "users", :force => true do |t| + t.string "login", :default => "", :null => false + t.string "hashed_password", :limit => 40, :default => "", :null => false + t.string "firstname", :limit => 30, :default => "", :null => false + t.string "lastname", :default => "", :null => false + t.string "mail", :limit => 60, :default => "", :null => false + t.boolean "admin", :default => false, :null => false + t.integer "status", :default => 1, :null => false + t.datetime "last_login_on" + t.string "language", :limit => 5, :default => "" + t.integer "auth_source_id" + t.datetime "created_on" + t.datetime "updated_on" + t.string "type" + t.string "identity_url" + t.string "mail_notification", :default => "", :null => false + t.string "salt", :limit => 64 + t.integer "gid" + end + + add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id" + add_index "users", ["id", "type"], :name => "index_users_on_id_and_type" + add_index "users", ["type"], :name => "index_users_on_type" + + create_table "versions", :force => true do |t| + t.integer "project_id", :default => 0, :null => false + t.string "name", :default => "", :null => false + t.string "description", :default => "" + t.date "effective_date" + t.datetime "created_on" + t.datetime "updated_on" + t.string "wiki_page_title" + t.string "status", :default => "open" + t.string "sharing", :default => "none", :null => false + end + + add_index "versions", ["project_id"], :name => "versions_project_id" + add_index "versions", ["sharing"], :name => "index_versions_on_sharing" + + create_table "visitors", :force => true do |t| + t.integer "user_id" + t.integer "master_id" + t.datetime "updated_on" + t.datetime "created_on" + end + + add_index "visitors", ["master_id"], :name => "index_visitors_master_id" + add_index "visitors", ["updated_on"], :name => "index_visitors_updated_on" + add_index "visitors", ["user_id"], :name => "index_visitors_user_id" + + create_table "watchers", :force => true do |t| + t.string "watchable_type", :default => "", :null => false + t.integer "watchable_id", :default => 0, :null => false + t.integer "user_id" + end + + add_index "watchers", ["user_id", "watchable_type"], :name => "watchers_user_id_type" + add_index "watchers", ["user_id"], :name => "index_watchers_on_user_id" + add_index "watchers", ["watchable_id", "watchable_type"], :name => "index_watchers_on_watchable_id_and_watchable_type" + + create_table "web_footer_companies", :force => true do |t| + t.string "name" + t.string "logo_size" + t.string "url" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "web_footer_oranizers", :force => true do |t| + t.string "name" + t.text "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "wiki_content_versions", :force => true do |t| + t.integer "wiki_content_id", :null => false + t.integer "page_id", :null => false + t.integer "author_id" + t.binary "data", :limit => 2147483647 + t.string "compression", :limit => 6, :default => "" + t.string "comments", :default => "" + t.datetime "updated_on", :null => false + t.integer "version", :null => false + end + + add_index "wiki_content_versions", ["updated_on"], :name => "index_wiki_content_versions_on_updated_on" + add_index "wiki_content_versions", ["wiki_content_id"], :name => "wiki_content_versions_wcid" + + create_table "wiki_contents", :force => true do |t| + t.integer "page_id", :null => false + t.integer "author_id" + t.text "text", :limit => 2147483647 + t.string "comments", :default => "" + t.datetime "updated_on", :null => false + t.integer "version", :null => false + end + + add_index "wiki_contents", ["author_id"], :name => "index_wiki_contents_on_author_id" + add_index "wiki_contents", ["page_id"], :name => "wiki_contents_page_id" + + create_table "wiki_pages", :force => true do |t| + t.integer "wiki_id", :null => false + t.string "title", :null => false + t.datetime "created_on", :null => false + t.boolean "protected", :default => false, :null => false + t.integer "parent_id" + end + + add_index "wiki_pages", ["parent_id"], :name => "index_wiki_pages_on_parent_id" + add_index "wiki_pages", ["wiki_id", "title"], :name => "wiki_pages_wiki_id_title" + add_index "wiki_pages", ["wiki_id"], :name => "index_wiki_pages_on_wiki_id" + + create_table "wiki_redirects", :force => true do |t| + t.integer "wiki_id", :null => false + t.string "title" + t.string "redirects_to" + t.datetime "created_on", :null => false + end + + add_index "wiki_redirects", ["wiki_id", "title"], :name => "wiki_redirects_wiki_id_title" + add_index "wiki_redirects", ["wiki_id"], :name => "index_wiki_redirects_on_wiki_id" + + create_table "wikis", :force => true do |t| + t.integer "project_id", :null => false + t.string "start_page", :null => false + t.integer "status", :default => 1, :null => false + end + + add_index "wikis", ["project_id"], :name => "wikis_project_id" + + create_table "workflows", :force => true do |t| + t.integer "tracker_id", :default => 0, :null => false + t.integer "old_status_id", :default => 0, :null => false + t.integer "new_status_id", :default => 0, :null => false + t.integer "role_id", :default => 0, :null => false + t.boolean "assignee", :default => false, :null => false + t.boolean "author", :default => false, :null => false + t.string "type", :limit => 30 + t.string "field_name", :limit => 30 + t.string "rule", :limit => 30 + end + + add_index "workflows", ["new_status_id"], :name => "index_workflows_on_new_status_id" + add_index "workflows", ["old_status_id"], :name => "index_workflows_on_old_status_id" + add_index "workflows", ["role_id", "tracker_id", "old_status_id"], :name => "wkfs_role_tracker_old_status" + add_index "workflows", ["role_id"], :name => "index_workflows_on_role_id" + + create_table "works_categories", :force => true do |t| + t.string "category" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "zip_packs", :force => true do |t| + t.integer "user_id" + t.integer "homework_id" + t.string "file_digest" + t.string "file_path" + t.integer "pack_times", :default => 1 + t.integer "pack_size", :default => 0 + t.text "file_digests" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + +end diff --git a/lib/gitlab-cli/bin/gitlab b/lib/gitlab-cli/bin/gitlab old mode 100644 new mode 100755 diff --git a/lib/grack/bin/console b/lib/grack/bin/console old mode 100644 new mode 100755 diff --git a/lib/grack/bin/testserver b/lib/grack/bin/testserver old mode 100644 new mode 100755 From 55d3b8abb3dcb64696f2866da4f7634b3e49ed28 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 16 Nov 2015 17:19:53 +0800 Subject: [PATCH 015/191] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E8=BF=87=E7=A8=8B=E4=B8=AD=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/sync_sigle_rep.rake | 30 ------------------------------ lib/trustie/gitlab/sync.rb | 6 ------ 2 files changed, 36 deletions(-) diff --git a/lib/tasks/sync_sigle_rep.rake b/lib/tasks/sync_sigle_rep.rake index 4ed360426..e68e37ee8 100644 --- a/lib/tasks/sync_sigle_rep.rake +++ b/lib/tasks/sync_sigle_rep.rake @@ -12,45 +12,15 @@ namespace :sync_rep do puts count unless count > 1 rep.identifier - puts "################################" - puts project.id - puts rep.id s = Trustie::Gitlab::Sync.new s.sync_project(project, path: rep.identifier, import_url: rep.url) rep.type = 'Repository::Gitlab' rep.save - puts "*************************************" - puts project.id - puts rep.id - puts rep.identifier end end end end task :delete_rep => :environment do - projects = Project.where("user_id !=?",12) - projects.each do |project| - # 针对类型为Git并且只有一个版本库的项目 - if project.repositories && project.repositories.count == 1 && project.repositories.first.type == "Repository::Git" - rep = project.repositories.first - count = Repository.find_by_sql("SELECT * FROM `repositories` where identifier = '#{rep.identifier}'").count - puts count - unless count > 1 - rep.identifier - puts "################################" - puts project.id - puts rep.id - s = Trustie::Gitlab::Sync.new - s.sync_project(project, path: rep.identifier, import_url: rep.url) - rep.type = 'Repository::Gitlab' - rep.save - puts "*************************************" - puts project.id - puts rep.id - puts rep.identifier - end - end - end end end \ No newline at end of file diff --git a/lib/trustie/gitlab/sync.rb b/lib/trustie/gitlab/sync.rb index ac01a44ec..1f6f7c146 100644 --- a/lib/trustie/gitlab/sync.rb +++ b/lib/trustie/gitlab/sync.rb @@ -73,11 +73,6 @@ module Trustie # import url http://xianbo_trustie2:1234@repository.trustie.net/xianbo/trustie2.git # can use password - puts "@@@@@@@@@@@@@@@@@@@@@@@" - puts path - puts project.description - puts gid - puts import_url gproject = self.g.create_project(path, path: path, description: project.description, @@ -91,7 +86,6 @@ module Trustie import_url: import_url, visibility_level: project.is_public? ? UserLevel::PUBLIC : UserLevel::PRIVATE ) - puts "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" project.gpid = gproject.id project.save! puts "Successfully created #{project.name}" From bd6a1a9d4931c6e14fa5b2fee516ac00c62a968c Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 16 Nov 2015 17:21:26 +0800 Subject: [PATCH 016/191] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E4=B8=AD=E7=9A=84=E9=A1=B9=E7=9B=AE=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E7=9A=84=E5=9B=9E=E5=A4=8D=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/issues_controller.rb | 21 +++++++++++++++++-- .../org_document_comments_controller.rb | 1 + app/views/issues/add_journal_in_org.js.erb | 3 +++ .../org_document_comments/add_reply.js.erb | 4 ++-- .../organizations/_org_activities.html.erb | 12 +++++------ .../organizations/_org_project_issue.html.erb | 18 +++++++++++++++- .../organizations/_show_org_document.html.erb | 14 ++++++------- app/views/organizations/show.html.erb | 3 ++- config/routes.rb | 1 + 9 files changed, 58 insertions(+), 19 deletions(-) create mode 100644 app/views/issues/add_journal_in_org.js.erb diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index e529dd3b9..edf055370 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -20,11 +20,11 @@ class IssuesController < ApplicationController default_search_scope :issues before_filter :authorize1, :only => [:show] - before_filter :find_issue, :only => [:show, :edit, :update,:add_journal] + before_filter :find_issue, :only => [:show, :edit, :update,:add_journal, :add_journal_in_org] before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy] before_filter :find_project, :only => [:new, :create, :update_form] #before_filter :authorize, :except => [:index, :show] - before_filter :authorize, :except => [:index,:add_journal] + before_filter :authorize, :except => [:index,:add_journal, :add_journal_in_org] before_filter :find_optional_project, :only => [:index] before_filter :check_for_default_issue_status, :only => [:new, :create] @@ -397,6 +397,23 @@ class IssuesController < ApplicationController end end + def add_journal_in_org + if User.current.logged? + jour = Journal.new + jour.user_id = User.current.id + jour.notes = params[:notes] + jour.journalized = @issue + jour.save + org_activity = OrgActivity.where("org_act_type='Issue' and org_act_id =#{@issue.id}").first + org_activity.updated_at = jour.created_on + org_activity.save + @user_activity_id = params[:user_activity_id] + respond_to do |format| + format.js + end + end + end + private def find_project diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index 60522dc3f..13a188e72 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -41,6 +41,7 @@ class OrgDocumentCommentsController < ApplicationController def add_reply @document = OrgDocumentComment.find(params[:id]).root + @act = OrgActivity.find(params[:id]) @comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id]) @comment.content = params[:org_content] @document.children << @comment diff --git a/app/views/issues/add_journal_in_org.js.erb b/app/views/issues/add_journal_in_org.js.erb new file mode 100644 index 000000000..ad7a85540 --- /dev/null +++ b/app/views/issues/add_journal_in_org.js.erb @@ -0,0 +1,3 @@ +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'organizations/org_project_issue', :locals => {:activity => @issue,:user_activity_id =>@user_activity_id}) %>"); + +init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); \ No newline at end of file diff --git a/app/views/org_document_comments/add_reply.js.erb b/app/views/org_document_comments/add_reply.js.erb index 5d54af2bf..40ed2eeb2 100644 --- a/app/views/org_document_comments/add_reply.js.erb +++ b/app/views/org_document_comments/add_reply.js.erb @@ -1,3 +1,3 @@ -$("#organization_document_<%= @document.id %>").replaceWith("<%= escape_javascript(render :partial => 'organizations/show_org_document', :locals => {:document => @document}) %>"); -init_activity_KindEditor_data(<%= @document.id %>,"","87%"); \ No newline at end of file +$("#organization_document_<%= @act.id %>").replaceWith("<%= escape_javascript(render :partial => 'organizations/show_org_document', :locals => {:document => @document, :act => @act}) %>"); +init_activity_KindEditor_data(<%= @act.id %>,"","87%"); \ No newline at end of file diff --git a/app/views/organizations/_org_activities.html.erb b/app/views/organizations/_org_activities.html.erb index cb69738b6..148bb9efe 100644 --- a/app/views/organizations/_org_activities.html.erb +++ b/app/views/organizations/_org_activities.html.erb @@ -1,5 +1,10 @@ <% unless org_activities.nil? %> <% org_activities.each do |act| %> + <% if act.container_type == 'Organization' %> <% if act.org_act_type == 'CreateOrganization' %>
    @@ -17,12 +22,7 @@
    <% end %> <% if act.org_act_type == 'OrgDocumentComment' && act.org_act_id != @organization.home_id %> - - <%= render :partial => 'show_org_document', :locals => {:document => act.org_act} %> + <%= render :partial => 'show_org_document', :locals => {:document => act.org_act, :act => act} %> <% end %> <% end %> <% if act.container_type == 'Project' %> diff --git a/app/views/organizations/_org_project_issue.html.erb b/app/views/organizations/_org_project_issue.html.erb index 573429752..e29994967 100644 --- a/app/views/organizations/_org_project_issue.html.erb +++ b/app/views/organizations/_org_project_issue.html.erb @@ -130,7 +130,23 @@
  • <% end %> - +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
    +
    +
    + <%= form_for('new_form',:url => add_journal_in_org_issue_path(activity.id),:method => "post", :remote => true) do |f|%> + + +
    + +
    +

    + <% end%> +
    +
    +
    +
    +
    diff --git a/app/views/organizations/_show_org_document.html.erb b/app/views/organizations/_show_org_document.html.erb index 4177c3688..e352288ab 100644 --- a/app/views/organizations/_show_org_document.html.erb +++ b/app/views/organizations/_show_org_document.html.erb @@ -91,16 +91,16 @@ <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33", :alt => "用户头像"), user_path(User.current) %>
    -
    - <%= form_for('new_form', :url => add_reply_org_document_comment_path(:id => document.id), :method => "post", :remote => true) do |f| %> - - +
    + <%= form_for('new_form', :url => add_reply_org_document_comment_path(:id => document.id, :act_id => act.id), :method => "post", :remote => true) do |f| %> + + -
    - +
    +
    -

    +

    <% end %>
    diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb index a85ffa687..1ccb2f0e5 100644 --- a/app/views/organizations/show.html.erb +++ b/app/views/organizations/show.html.erb @@ -30,7 +30,8 @@ init_activity_KindEditor_data(<%= @organization.home_id%>, null, "87%"); }); - <%= render :partial => 'show_org_document', :locals => {:document => OrgDocumentComment.find(@organization.home_id), :home_id => @organization.home_id} %> + <% act = OrgActivity.where("org_act_type = 'OrgDocumentComment' and org_act_id =?", @organization.home_id).first %> + <%= render :partial => 'show_org_document', :locals => {:document => OrgDocumentComment.find(@organization.home_id), :home_id => @organization.home_id, :act => act} %> <% end %> <%= render :partial => 'organizations/org_activities', diff --git a/config/routes.rb b/config/routes.rb index 69134e666..24d159f04 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -634,6 +634,7 @@ RedmineApp::Application.routes.draw do end member do post 'add_journal' + post 'add_journal_in_org' end resources :time_entries, :controller => 'timelog' do collection do From 5400b907e6a491cea534d9e7575c6a29e423f3e9 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 17 Nov 2015 09:33:40 +0800 Subject: [PATCH 017/191] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E6=B5=8B=E9=AA=8C?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 19 ++- app/views/exercise/_exercise.html.erb | 2 +- app/views/exercise/_student_exercise.html.erb | 46 ++++++ .../exercise/student_exercise_list.html.erb | 138 ++++++++++++++++++ config/routes.rb | 1 + ...4_add_publish_time_end_time_to_exercise.rb | 6 + db/schema.rb | 4 +- 7 files changed, 213 insertions(+), 3 deletions(-) create mode 100644 app/views/exercise/_student_exercise.html.erb create mode 100644 app/views/exercise/student_exercise_list.html.erb create mode 100644 db/migrate/20151116065904_add_publish_time_end_time_to_exercise.rb diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index bed3d9061..296c744b6 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -1,7 +1,7 @@ class ExerciseController < ApplicationController layout "base_courses" - before_filter :find_course, :only => [:index,:new,:create] + before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list] def index @is_teacher = User.current.allowed_to?(:as_teacher,@course) if @is_teacher @@ -44,6 +44,23 @@ class ExerciseController < ApplicationController end + def student_exercise_list + @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? + @exercise = Exercise.find params[:id] + @all_exercises = @course.exercises.order("created_at desc") + @exercise_count = @exercise.exercise_users.where('score is not NULL').count + if @is_teacher || (!@exercise.exercise_users.where(:user_id => User.current.id).empty? && Time.parse(@exercise.end_time.to_s).strftime("%Y-%m-%d-%H-%M-%S") <= Time.now.strftime("%Y-%m-%d-%H-%M-%S")) + @exercise_users_list = @exercise.exercise_users.where('score is not NULL') + elsif !@exercise.exercise_users.where(:user_id => User.current.id).empty? && Time.parse(@exercise.end_time.to_s).strftime("%Y-%m-%d-%H-%M-%S") > Time.now.strftime("%Y-%m-%d-%H-%M-%S") + @exercise_users_list = @exercise.exercise_users.where("user_id = ? and score is not NULL",User.current.id) + else + @exercise_users_list = [] + end + respond_to do |format| + format.html + end + end + private def find_course @course = Course.find params[:course_id] diff --git a/app/views/exercise/_exercise.html.erb b/app/views/exercise/_exercise.html.erb index e469c471c..15a684a62 100644 --- a/app/views/exercise/_exercise.html.erb +++ b/app/views/exercise/_exercise.html.erb @@ -15,7 +15,7 @@ <% if exercise.exercise_status == 1%>
  • 统计结果
  • <% else %> -
  • <%= link_to l(:label_statistical_results), statistics_result_exercise_path(exercise.id), :class => "pollsbtn fl ml10"%>
  • +
  • <%= link_to l(:label_statistical_results), student_exercise_list_exercise_path(exercise.id,:course_id => @course.id), :class => "pollsbtn fl ml10"%>
  • <% end%> <% if exercise.exercise_status == 1 %> diff --git a/app/views/exercise/_student_exercise.html.erb b/app/views/exercise/_student_exercise.html.erb new file mode 100644 index 000000000..b133baa04 --- /dev/null +++ b/app/views/exercise/_student_exercise.html.erb @@ -0,0 +1,46 @@ +
    + + 测验 + + (<%= @exercise_count%>人已交) + + <% if !@is_teacher && @exercise_users_list.empty?%> + 您尚未提交 + <% elsif !@is_teacher && !@exercise_users_list.empty?%> + 您已提交 + <% end %> + + <%if @is_teacher || @exercise.exercise_status == 3%> +
    + + +
    + <%#= select_tag(:student_work_in_group,options_for_select(course_group_list(@course),@group), {:class => "classSplit"}) unless course_group_list(@course).empty? %> + <% end%> + +
    +
    + +
    + <%= render :partial => "evaluation_un_title"%> +
    +
    + +<% @stundet_works.each do |student_work|%> + <% if @is_evaluation%> + <%= render :partial => "evaluation_work", :locals => {:student_work => student_work}%> + <% else%> + <%= render :partial => "evaluation_un_work", :locals => {:student_work => student_work}%> + <% end%> +
    +
    + <% if student_work.user == User.current && !@is_evaluation %> + <% if @homework.homework_type == 2%> + <%=render :partial => 'programing_work_show', :locals=> {:work => student_work, :score =>student_work_score(student_work,User.current),:student_work_scores => student_work.student_works_scores.order("updated_at desc")} %> + <% else %> + <%=render :partial => 'show' , :locals=> {:work => student_work, :score =>student_work_score(student_work,User.current),:student_work_scores => student_work.student_works_scores.order("updated_at desc")} %> + <% end %> + <% end %> +
    +
    +<% end%> \ No newline at end of file diff --git a/app/views/exercise/student_exercise_list.html.erb b/app/views/exercise/student_exercise_list.html.erb new file mode 100644 index 000000000..8653836ca --- /dev/null +++ b/app/views/exercise/student_exercise_list.html.erb @@ -0,0 +1,138 @@ + + +
    +
    +
    + + +
    +
    + +
    +
    + + <% if @exercise.exercise_status == 1 %> + 未发布 + <% elsif @exercise.exercise_status == 2 %> + 已发布 + <% elsif @exercise.exercise_status == 3 %> + 已截止 + <% end%> + [ 隐藏测验信息 ] +
    +
    发布者:<%= @exercise.user.show_name %>
    +
    +
    <%= @exercise.exercise_description.html_safe %>
    +
    + + +
    +
    +
    截止时间:<%= format_time @exercise.end_time %>
    + <% if @exercise.exercise_status == 1 %> +
    发布时间:<%= format_time @exercise.publish_time %>
    + <% end %> + <% end_time = @exercise.end_time.to_time.to_i %> + <% if end_time > Time.now.to_i %> +
    提交剩余时间: <%= (end_time - Time.now.to_i) / (24*60*60) %> 天 + <%= ((end_time - Time.now.to_i) % (24*60*60)) / (60*60)%> 小时 + <%= (((end_time - Time.now.to_i) % (24*60*60)) % (60*60)) / 60%>
    + <% else %> +
    提交已截止
    + <% end %> +
    +
    +
    +
    + +
    +
    +
    + <%= render :partial => "exercise/student_exercise"%> +
    +
    +
    + +
    +
    +
    +
    \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 3f1ca2ba0..f1073381f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -150,6 +150,7 @@ RedmineApp::Application.routes.draw do resources :exercise do member do #生成路径为 /exercise/:id/方法名 get 'statistics_result' + get 'student_exercise_list' get 'export_exercise' end diff --git a/db/migrate/20151116065904_add_publish_time_end_time_to_exercise.rb b/db/migrate/20151116065904_add_publish_time_end_time_to_exercise.rb new file mode 100644 index 000000000..90aec321f --- /dev/null +++ b/db/migrate/20151116065904_add_publish_time_end_time_to_exercise.rb @@ -0,0 +1,6 @@ +class AddPublishTimeEndTimeToExercise < ActiveRecord::Migration + def change + add_column :exercises, :publish_time, :timestamp + add_column :exercises, :end_time, :timestamp + end +end diff --git a/db/schema.rb b/db/schema.rb index 272db1944..3feb43adb 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 => 20151113025751) do +ActiveRecord::Schema.define(:version => 20151116065904) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -624,6 +624,8 @@ ActiveRecord::Schema.define(:version => 20151113025751) do t.integer "time" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false + t.datetime "publish_time" + t.datetime "end_time" end create_table "first_pages", :force => true do |t| From fba461f94a62d405c1632eea14902508ec2082bc Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 17 Nov 2015 09:51:16 +0800 Subject: [PATCH 018/191] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E4=B8=AD=E9=A1=B9=E7=9B=AE=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E7=9A=84=E5=9B=9E=E5=A4=8D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/messages_controller.rb | 5 +++++ app/controllers/organizations_controller.rb | 6 +++--- .../organizations/_org_activities.html.erb | 4 ++-- .../organizations/_project_create.html.erb | 2 +- .../organizations/_project_message.html.erb | 18 ++++++++++++++++++ app/views/organizations/show.html.erb | 9 ++++++--- 6 files changed, 35 insertions(+), 9 deletions(-) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 4f78d61f5..9b090de9a 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -174,6 +174,11 @@ class MessagesController < ApplicationController user_activity.updated_at = Time.now user_activity.save end + org_activity = OrgActivity.where("org_act_type='Message' and org_act_id =#{@topic.id}").first + if org_activity + org_activity.updated_at = Time.now + org_activity.save + end #@topic.update_attribute(:updated_on, Time.now) if !@reply.new_record? if params[:asset_id] diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 6a1030adc..392966d68 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -56,10 +56,10 @@ class OrganizationsController < ApplicationController if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) @organization = Organization.find(params[:id]) project_ids = @organization.projects.map(&:id) << 0 - @org_activities = OrgActivity.where("(container_id =? and container_type =?) or (container_type ='Project' and container_id in (#{project_ids.join(',')}))", + @org_activities = OrgActivity.where("(container_id =? and container_type =?) or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')}))", @organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) - @org_activities_count = OrgActivity.where("(container_id =? and container_type =?) or (container_type ='Project' and container_id in (#{project_ids.join(',')}))" , - @organization.id, 'Organization ').count + # @org_activities_count = OrgActivity.where("(container_id =? and container_type =?) or (container_type ='Project' and container_id in (#{project_ids.join(',')}))" , + # @organization.id, 'Organization ').count # @org_project_activties = ForgeActivity.where("project_id in (#{project_ids.join(',')}) and forge_act_type in('Issue','Message','ProjectCreateInfo')").order("updated_at desc").page(params[:page] || 1).per(10) # @org_project_activties_count = ForgeActivity.where('project_id in (?)',project_ids.join(',')).count #@org_activities = paginateHelper @org_activities, 10 diff --git a/app/views/organizations/_org_activities.html.erb b/app/views/organizations/_org_activities.html.erb index 148bb9efe..9523a0a15 100644 --- a/app/views/organizations/_org_activities.html.erb +++ b/app/views/organizations/_org_activities.html.erb @@ -31,8 +31,8 @@ <%= render :partial => 'organizations/org_project_issue', :locals => {:activity => Issue.find(act.org_act_id),:user_activity_id =>act.id} %> <% when 'Message' %> <%= render :partial => 'organizations/project_message', :locals => {:activity => Message.find(act.org_act_id),:user_activity_id =>act.id} %> - <%# when 'ProjectCreateInfo'%> - <%#= render :partial => 'organizations/project_create', :locals => {:activity => act,:user_activity_id =>act.id} %> + <% when 'ProjectCreateInfo'%> + <%= render :partial => 'organizations/project_create', :locals => {:activity => act,:user_activity_id =>act.id} %> <% end %> <% end %> <% end %> diff --git a/app/views/organizations/_project_create.html.erb b/app/views/organizations/_project_create.html.erb index d966d8e18..607c14a45 100644 --- a/app/views/organizations/_project_create.html.erb +++ b/app/views/organizations/_project_create.html.erb @@ -1,4 +1,4 @@ -<% project = Project.find(activity.project_id) %> +<% project = Project.find(activity.org_act_id) %> <% user = User.find(project.user_id)%>
    diff --git a/app/views/organizations/_project_message.html.erb b/app/views/organizations/_project_message.html.erb index 85ed08f2f..2708bb546 100644 --- a/app/views/organizations/_project_message.html.erb +++ b/app/views/organizations/_project_message.html.erb @@ -95,6 +95,24 @@
    <% end %> +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
    +
    +
    + <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%> + + + +
    + +
    +

    + <% end%> +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb index 1ccb2f0e5..36cc24225 100644 --- a/app/views/organizations/show.html.erb +++ b/app/views/organizations/show.html.erb @@ -14,14 +14,17 @@
    最新动态
    - + +
    <% if !@organization.home_id.nil? and OrgDocumentComment.where("id = ?", @organization.home_id).count > 0 %> From 6f5cb8f1426a0935690266fcdfa0777a615abab4 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 17 Nov 2015 10:17:07 +0800 Subject: [PATCH 019/191] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E7=9A=84=E8=BF=87=E6=BB=A4=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=8C=E7=BB=84=E7=BB=87=E5=8A=A8=E6=80=81=E5=8C=85=E6=8B=AC?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=8A=A8=E6=80=81=E5=92=8C=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E7=9A=84=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations_controller.rb | 18 +++++++++++------- app/views/organizations/show.html.erb | 20 ++++++++++++++++---- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 392966d68..b35d7f3db 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -56,13 +56,17 @@ class OrganizationsController < ApplicationController if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) @organization = Organization.find(params[:id]) project_ids = @organization.projects.map(&:id) << 0 - @org_activities = OrgActivity.where("(container_id =? and container_type =?) or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')}))", - @organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) - # @org_activities_count = OrgActivity.where("(container_id =? and container_type =?) or (container_type ='Project' and container_id in (#{project_ids.join(',')}))" , - # @organization.id, 'Organization ').count - # @org_project_activties = ForgeActivity.where("project_id in (#{project_ids.join(',')}) and forge_act_type in('Issue','Message','ProjectCreateInfo')").order("updated_at desc").page(params[:page] || 1).per(10) - # @org_project_activties_count = ForgeActivity.where('project_id in (?)',project_ids.join(',')).count - #@org_activities = paginateHelper @org_activities, 10 + case params[:type] + when nil + @org_activities = OrgActivity.where("(container_id =? and container_type =?) or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')}))", + @organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) + when 'project_issue' + @org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Issue' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'project_message' + @org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Message' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'org' + @org_activities = OrgActivity.where("container_id =? and container_type =?",@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) + end @page = params[:page] respond_to do |format| format.html diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb index 36cc24225..e62a66913 100644 --- a/app/views/organizations/show.html.erb +++ b/app/views/organizations/show.html.erb @@ -16,10 +16,22 @@
    最新动态
    • -
        -
      • 全部动态
      • -
      • - 我的动态 +
          +
        • +
            +
          • 项目动态
          • +
          • <%= link_to "问题动态", {:controller => "organizations", :action => "show", :type => "project_issue"}, :class => "homepagePostTypeQuestion postTypeGrey"%> +
          • <%= link_to "论坛动态", {:controller => "organizations", :action => "show", :type => "project_message"}, :class => "homepagePostTypeForum postTypeGrey"%> + +
          +
        • +
        • +
            +
          • 更多
          • +
          • <%= link_to "组织动态", {:controller => "organizations", :action => "show", :type => "org"}, :class =>"homepagePostTypeMessage postTypeGrey"%> +
          • <%= link_to "全部动态", {:controller => "organizations", :action => "show", :type => nil}, :class =>"homepagePostTypeAll postTypeGrey"%> +
      • From 8aeae831b88aa13bda3340f5e52fd0efee525330 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 17 Nov 2015 10:56:11 +0800 Subject: [PATCH 020/191] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E4=B8=AD=E6=B7=BB=E5=8A=A0=E7=BB=84=E7=BB=87=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=BB=84=E7=BB=87=E5=88=97=E8=A1=A8=EF=BC=8C?= =?UTF-8?q?=E8=80=8C=E4=B8=8D=E6=98=AF=E9=9A=90=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/org_projects_controller.rb | 19 ++++++++++++++++++- app/views/org_projects/create.js.erb | 18 ++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/app/controllers/org_projects_controller.rb b/app/controllers/org_projects_controller.rb index 733df95b7..c944193bd 100644 --- a/app/controllers/org_projects_controller.rb +++ b/app/controllers/org_projects_controller.rb @@ -4,8 +4,25 @@ class OrgProjectsController < ApplicationController @project = Project.find(params[:project_id]) org_ids.each do |org_id| OrgProject.create(:organization_id => org_id.to_i, :project_id => params[:project_id].to_i, :created_at => Time.now) - p 1 end + + #更新组织列表 + condition = '%%' + if !params[:orgs].nil? + condition = "%#{params[:orgs].strip}%".gsub(" ","") + end + project_org_ids = OrgProject.find_by_sql("select distinct organization_id from org_projects where project_id = #{params[:project_id]}").map(&:organization_id) + if project_org_ids.empty? + @orgs_not_in_project = Organization.where("(is_public or creator_id =?) = 1 and name like ?",User.current.id, condition).page((params[:page].to_i || 1)).per(10) + @org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count + else + project_org_ids = "(" + project_org_ids.join(',') + ")" + @orgs_not_in_project = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page((params[:page].to_i || 1)).per(10) + @org_count = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count + end + # @project_count = Project.project_entities.visible.like(params[:name]).page(params[:page]).count + @orgs_page = Paginator.new @org_count, 10,params[:page] + respond_to do |format| format.js end diff --git a/app/views/org_projects/create.js.erb b/app/views/org_projects/create.js.erb index 545918c73..23cbab024 100644 --- a/app/views/org_projects/create.js.erb +++ b/app/views/org_projects/create.js.erb @@ -1,6 +1,20 @@ - $("#search_orgs_result_list").html(""); +$("#search_orgs_result_list").append('
          '); +<% @orgs_not_in_project.each do |org|%> + link = "
        • "; + $("#search_orgs_result_list").append(link ); +<%end %> +$("#search_orgs_result_list").append('
        ') +<% if @org_count > 10 %> + $("#paginator").html(' <%= pagination_links_full @orgs_page, @org_count ,:per_page_links => true,:remote =>true,:flag=>true %>'); +//$("#paginator").css("display", "block"); + +//$("#paginator").css("display", "none"); +<% end %> + + +//$("#search_orgs_result_list").html(""); //$("#search_orgs_result_list").append('
          '); +//$("#paginator").css("display", "none"); $("#added_orgs").html(""); -$("#paginator").css("display", "none"); $("#added_orgs").html('<%= escape_javascript(render :partial => "projects/settings/added_orgs", :locals => {:orgs => @project.organizations, :project_id => @project.id}) %>') \ No newline at end of file From 0316bf698f10087a747988ba193b55a01399c7e6 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 17 Nov 2015 11:25:17 +0800 Subject: [PATCH 021/191] =?UTF-8?q?exercise=E6=96=B0=E5=A2=9E=E3=80=81upda?= =?UTF-8?q?te?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 59 ++++++++++++++++++++++++-- app/helpers/exercise_helper.rb | 11 +++++ 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 296c744b6..87854619c 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -16,11 +16,42 @@ class ExerciseController < ApplicationController end def show - + @exercise = Exercise.find params[:id] + if @exercise.exercise_status != 2 && (!User.current.allowed_to?(:as_teacher,@course) || User.current.admin?) + render_403 + return + end + # 问卷消息状态更新 + # REDO:问卷添加消息 + #已提交问卷的用户不能再访问该界面 + if has_commit_exercise?(@poll.id,User.current.id) && (!User.current.admin?) + redirect_to poll_index_url(:polls_type => "Course", :polls_group_id => @course.id) + else + @can_edit_poll = (!has_commit_poll?(@poll.id,User.current.id)) || User.current.admin? + @percent = get_percent(@poll,User.current) + poll_questions = @poll.poll_questions + @poll_questions = paginateHelper poll_questions,5 #分页 + respond_to do |format| + format.html {render :layout => 'base_courses'} + end + end + end end def new - + option = { + :exercise_name => "", + :exercise_description => "", + :course_id => @course.id, + :exercise_status => 1, + :user_id => User.current.id, + :start_at => "", + :end_at => "" + } + @exercise = Exercise.create option + if @exercise + redirect_to edit_exercise_url @exercise.id + end end def create @@ -32,11 +63,31 @@ class ExerciseController < ApplicationController end def update - + @exercise.exercise_name = params[:exercise_name] + @exercise.exercise_description = params[:exercise_name] + @exercise.start_at = params[:start_at] + @exercise.end_at = params[:end_at] + if @exercise.save + respond_to do |format| + format.js + end + else + render_404 + end end def destroy - + if @exercise && @exercise.destroy + if @is_teacher + polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id}") + else + polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id} and polls_status = 2") + end + @polls = paginateHelper polls,20 #分页 + respond_to do |format| + format.js + end + end end #统计结果 diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index 7fc7b1421..844cff1c1 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -1,3 +1,14 @@ # encoding: utf-8 module ExerciseHelper + + #判断用户是否已经提交了问卷 + def has_commit_exercise?(poll_id,user_id) + pu = PollUser.find_by_poll_id_and_user_id(poll_id,user_id) + if pu.nil? + false + else + true + end + end + end \ No newline at end of file From 034a92bb7b45d4a3b23b6bf0724c966cfcdc4e32 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 17 Nov 2015 15:18:07 +0800 Subject: [PATCH 022/191] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E6=B5=8B=E9=AA=8C?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 10 +- app/views/exercise/_edit_head.html.erb | 24 ++ app/views/exercise/_exercise_content.html.erb | 23 ++ app/views/exercise/_exercise_form.html.erb | 333 ++++++++++++++++++ app/views/exercise/_new_MC.html.erb | 38 ++ app/views/exercise/_new_MCQ.html.erb | 39 ++ app/views/exercise/_new_single.html.erb | 28 ++ app/views/exercise/_student_exercise.html.erb | 71 ++-- app/views/exercise/_student_table.html.erb | 22 ++ app/views/exercise/edit.html.erb | 1 + app/views/exercise/new.html.erb | 1 + public/stylesheets/courses.css | 15 + 12 files changed, 581 insertions(+), 24 deletions(-) create mode 100644 app/views/exercise/_edit_head.html.erb create mode 100644 app/views/exercise/_exercise_content.html.erb create mode 100644 app/views/exercise/_exercise_form.html.erb create mode 100644 app/views/exercise/_new_MC.html.erb create mode 100644 app/views/exercise/_new_MCQ.html.erb create mode 100644 app/views/exercise/_new_single.html.erb create mode 100644 app/views/exercise/_student_table.html.erb create mode 100644 app/views/exercise/edit.html.erb diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 296c744b6..ce3412caa 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -20,7 +20,10 @@ class ExerciseController < ApplicationController end def new - + @exercise = Exercise.new + respond_to do |format| + format.html{render :layout => 'base_courses'} + end end def create @@ -28,7 +31,9 @@ class ExerciseController < ApplicationController end def edit - + respond_to do |format| + format.html{render :layout => 'base_courses'} + end end def update @@ -51,6 +56,7 @@ class ExerciseController < ApplicationController @exercise_count = @exercise.exercise_users.where('score is not NULL').count if @is_teacher || (!@exercise.exercise_users.where(:user_id => User.current.id).empty? && Time.parse(@exercise.end_time.to_s).strftime("%Y-%m-%d-%H-%M-%S") <= Time.now.strftime("%Y-%m-%d-%H-%M-%S")) @exercise_users_list = @exercise.exercise_users.where('score is not NULL') + @show_all = true; elsif !@exercise.exercise_users.where(:user_id => User.current.id).empty? && Time.parse(@exercise.end_time.to_s).strftime("%Y-%m-%d-%H-%M-%S") > Time.now.strftime("%Y-%m-%d-%H-%M-%S") @exercise_users_list = @exercise.exercise_users.where("user_id = ? and score is not NULL",User.current.id) else diff --git a/app/views/exercise/_edit_head.html.erb b/app/views/exercise/_edit_head.html.erb new file mode 100644 index 000000000..b315d343c --- /dev/null +++ b/app/views/exercise/_edit_head.html.erb @@ -0,0 +1,24 @@ +
          +
          + +
          + <%# if edit_mode %> + + <%# end %> +
          + + <%= calendar_for('homework_end_time')%> +
          + <%# if edit_mode %> + + <%# end %> +
          + + <%= calendar_for('homework_publish_time')%> +
          +
          考试时长:分钟
          +
          + + 保存 取消 +
          +
          \ No newline at end of file diff --git a/app/views/exercise/_exercise_content.html.erb b/app/views/exercise/_exercise_content.html.erb new file mode 100644 index 000000000..76bad6a83 --- /dev/null +++ b/app/views/exercise/_exercise_content.html.erb @@ -0,0 +1,23 @@ + +<% poll.exercise_questions.each do |poll_question|%> +
          + + +
          +<% end %> \ No newline at end of file diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb new file mode 100644 index 000000000..a062f1d80 --- /dev/null +++ b/app/views/exercise/_exercise_form.html.erb @@ -0,0 +1,333 @@ +<%= stylesheet_link_tag 'polls', :media => 'all' %> + +
          +
          + + +
          + <%= render :partial => 'edit_head', :locals => {:poll => @exercise}%> +
          + + +
          + <%= render :partial => 'exercise_content', :locals => {:poll => @exercise}%> +
          + + + +
          发布 +
          + + +
          +
          +
          + +
          +
          diff --git a/app/views/exercise/_new_MC.html.erb b/app/views/exercise/_new_MC.html.erb new file mode 100644 index 000000000..0ff662b3f --- /dev/null +++ b/app/views/exercise/_new_MC.html.erb @@ -0,0 +1,38 @@ +
          +
          + + + +
          +
          +
            +
          • + + +
          • +
            +
          • + + +
          • +
            +
          • + + +
          • +
            +
          • + + +
          • +
            +
          • + + +
          • +
            +
          +
          + +
          +
          \ No newline at end of file diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb new file mode 100644 index 000000000..0ba2a0133 --- /dev/null +++ b/app/views/exercise/_new_MCQ.html.erb @@ -0,0 +1,39 @@ +
          +
          + + + +
          +
          +
            +
          • + + +
          • +
            +
          • + + +
          • +
            +
          • + + +
          • +
            +
          • + + +
          • +
            +
          • + + +
          • +
            +
          +
          + +
          +
          \ No newline at end of file diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb new file mode 100644 index 000000000..0082303b7 --- /dev/null +++ b/app/views/exercise/_new_single.html.erb @@ -0,0 +1,28 @@ +
          +
          + + + +
          +
          +
            +
          • + + +
          • +
            +
          • + + +
          • +
            +
          • + + +
          • +
            +
          +
          + +
          +
          \ No newline at end of file diff --git a/app/views/exercise/_student_exercise.html.erb b/app/views/exercise/_student_exercise.html.erb index b133baa04..25bf3f7cd 100644 --- a/app/views/exercise/_student_exercise.html.erb +++ b/app/views/exercise/_student_exercise.html.erb @@ -10,37 +10,64 @@ 您已提交 <% end %> - <%if @is_teacher || @exercise.exercise_status == 3%> -
          - + <%#if @is_teacher || @exercise.exercise_status == 3%> + <%#= select_tag(:student_work_in_group,options_for_select(course_group_list(@course),@group), {:class => "classSplit"}) unless course_group_list(@course).empty? %> - <% end%> + <%# end%>
          - <%= render :partial => "evaluation_un_title"%> + <%= render :partial => "student_table"%>
          -<% @stundet_works.each do |student_work|%> - <% if @is_evaluation%> - <%= render :partial => "evaluation_work", :locals => {:student_work => student_work}%> - <% else%> - <%= render :partial => "evaluation_un_work", :locals => {:student_work => student_work}%> - <% end%> -
          -
          - <% if student_work.user == User.current && !@is_evaluation %> - <% if @homework.homework_type == 2%> - <%=render :partial => 'programing_work_show', :locals=> {:work => student_work, :score =>student_work_score(student_work,User.current),:student_work_scores => student_work.student_works_scores.order("updated_at desc")} %> - <% else %> - <%=render :partial => 'show' , :locals=> {:work => student_work, :score =>student_work_score(student_work,User.current),:student_work_scores => student_work.student_works_scores.order("updated_at desc")} %> - <% end %> - <% end %> -
          +<% @exercise_users_list.each do |exercise|%> + +
            +
          • +
              +
            • + <%= link_to(image_tag(url_to_avatar(exercise.user),:width =>"40",:height => "40"),user_activities_path(exercise.user)) %> +
            • +
              +
            • +
                +
              • + <%= exercise.user.show_name%> +
              • +
              • + <%= exercise.user.user_extensions.nil? ? "--" : exercise.user.user_extensions.student_id%> +
              • +
              • + -- +
              • +
              +
            • +
              +
            +
          • +
          • + <% if exercise.created_at%> + <%= Time.parse(format_time(exercise.created_at)).strftime("%m-%d %H:%M")%>  + <% end %> +
          • + +
          • + <%= exercise.score.nil? ? "--" : format("%.1f",exercise.score)%> +
          • + +
          +
          <% end%> \ No newline at end of file diff --git a/app/views/exercise/_student_table.html.erb b/app/views/exercise/_student_table.html.erb new file mode 100644 index 000000000..719667973 --- /dev/null +++ b/app/views/exercise/_student_table.html.erb @@ -0,0 +1,22 @@ +
            +
          • +    + 姓名 + 学号 + 班级 +
          • + +
          • + <%= link_to "时间",'',:class => "c_dark f14 fb fl ml50" ,:remote => true%> + <%# if @show_all && @order == "created_at"%> + <%#= link_to "", student_work_index_path(:homework => @homework.id,:order => "created_at", :sort => @score, :name => @name, :group => @group) ,:class => "#{@score == 'desc' ? 'st_up' : 'st_down'} mt10",:remote => true%> + <%# end%> +
          • + +
          • + <%= link_to "成绩",'',:class => "c_dark f14 fb fl ml10",:remote => true%> + <%# if @show_all && @order == "score"%> + <%#= link_to "", student_work_index_path(:homework => @homework.id,:order => "score", :sort => @score, :name => @name, :group => @group) ,:class => "#{@score == 'desc' ? 'st_up' : 'st_down'} mt10",:remote => true%> + <%# end%> +
          • +
          \ No newline at end of file diff --git a/app/views/exercise/edit.html.erb b/app/views/exercise/edit.html.erb new file mode 100644 index 000000000..0b20dc90e --- /dev/null +++ b/app/views/exercise/edit.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'exercise_form'%> \ No newline at end of file diff --git a/app/views/exercise/new.html.erb b/app/views/exercise/new.html.erb index e69de29bb..3d983d64f 100644 --- a/app/views/exercise/new.html.erb +++ b/app/views/exercise/new.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'exercise_form'%> diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 5469078a5..fdba7426a 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -83,6 +83,7 @@ a.hworkSearchIcon:hover {background:url(../images/nav_icon.png) -49px -1px no-re .width180{width: 180px;} .width525{width: 525px;} .width285{width: 285px;} +.width530{width: 530px;} .mr95{margin-right: 95px;} .mr140 {margin-right: 140px;} .ml100{margin-left: 100px;} @@ -1141,3 +1142,17 @@ input.sendSourceText { width: 50px; height: 25px; } + +/*20151117在线测验byTim*/ +.testContainer {width:698px; border:1px solid #cbcbcb;background:#eeeeee; padding:10px; margin-bottom:10px;} +.testTitle{ width:678px; height:40px; padding:0 10px; text-align:center; font-size:16px; font-weight:bold; background:#fff;border-style:solid; border:1px solid #CBCBCB;} +.testDes{ width:678px; height:120px; padding:10px; margin-bottom:10px; background:#fff; border-style:solid; border:1px solid #CBCBCB; resize:none;} +.btn_submit{ width:56px; height:24px; padding-top:4px;background:#269ac9; color:#fff; text-align:center; display:block; float:left; margin-right:10px;} +a:hover.btn_submit{background:#297fb8;} +.btn_cancel{width:54px; height:22px; padding-top:4px;background:#fff; color:#999; border:1px solid #999; text-align:center; display:block; float:left; } +a:hover.btn_cancel{ color:#666;} +.testQuestion{ width:708px; height: auto; border:1px solid #cbcbcb; padding:10px 0 0 10px; margin-bottom:10px;} +.mr118 {margin-right:118px !important;} +.questionContainer {width:698px; border:1px solid #cbcbcb;background:#eeeeee; padding:10px; margin-bottom:10px;} +.questionTitle{ width:644px; height:30px; border:1px solid #cbcbcb; padding-left:5px; background:#fff;} +.examTime {width:40px; border:1px solid #cbcbcb; outline:none; height:28px; text-align:center; padding-left:0px; } \ No newline at end of file From 23ca20692fe6a10358c05422dafaa53e02e5d1c3 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 17 Nov 2015 15:20:59 +0800 Subject: [PATCH 023/191] =?UTF-8?q?=E9=97=AE=E5=8D=B7=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 71 ++++++++++++++++++++++---- app/helpers/exercise_helper.rb | 4 +- db/schema.rb | 54 +------------------- 3 files changed, 65 insertions(+), 64 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 87854619c..e29ae8176 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -21,21 +21,18 @@ class ExerciseController < ApplicationController render_403 return end - # 问卷消息状态更新 - # REDO:问卷添加消息 #已提交问卷的用户不能再访问该界面 - if has_commit_exercise?(@poll.id,User.current.id) && (!User.current.admin?) - redirect_to poll_index_url(:polls_type => "Course", :polls_group_id => @course.id) + if has_commit_exercise?(@exercise.id, User.current.id) && (!User.current.admin?) + redirect_to poll_index_url(:course_id=> @course.id) else - @can_edit_poll = (!has_commit_poll?(@poll.id,User.current.id)) || User.current.admin? - @percent = get_percent(@poll,User.current) + @can_edit_poll = (!has_commit_exercise?(@exercise.id,User.current.id)) || User.current.admin? + @percent = get_percent(@exercise,User.current) poll_questions = @poll.poll_questions @poll_questions = paginateHelper poll_questions,5 #分页 respond_to do |format| format.html {render :layout => 'base_courses'} end end - end end def new @@ -45,8 +42,8 @@ class ExerciseController < ApplicationController :course_id => @course.id, :exercise_status => 1, :user_id => User.current.id, - :start_at => "", - :end_at => "" + :time => "", + :end_time => "" } @exercise = Exercise.create option if @exercise @@ -92,7 +89,63 @@ class ExerciseController < ApplicationController #统计结果 def statistics_result + @exercise = Exercise.find(params[:id]) + exercise_questions = @exercise.poll_questions + @exercise_questions = paginateHelper exercise_questions, 5 + respond_to do |format| + format.html{render :layout => 'base_courses'} + end + end + #添加题目 + #question_type 1:单选 2:多选 3:填空题 + def create_exercise_question + question_title = params[:exercise_questions_title].nil? || params[:poll_questions_title].empty? ? l(:label_enter_single_title) : params[:poll_questions_title] + option = { + :is_necessary => (params[:is_necessary]=="true" ? 1 : 0), + :question_title => question_title, + :question_type => params[:question_type] || 1, + :question_number => @poll.poll_questions.count + 1 + } + @poll_questions = @poll.poll_questions.new option + if params[:question_answer] + for i in 1..params[:question_answer].count + answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1] + question_option = { + :answer_position => i, + :answer_text => answer + } + @poll_questions.poll_answers.new question_option + end + end + # 如果是插入的话,那么从插入的这个id以后的question_num都将要+1 + if params[:quest_id] + @is_insert = true + @poll.poll_questions.where("question_number > #{params[:quest_num].to_i}").update_all(" question_number = question_number + 1") + @poll_question_num = params[:quest_num].to_i + @poll_questions.question_number = params[:quest_num].to_i + 1 + end + if @poll_questions.save + respond_to do |format| + format.js + end + end + + end + + #发布问卷 + def publish_excercise + @exercise.exercise_status = 2 + @exercise.publish_time = Time.now + if @exercise.save + if params[:is_remote] + redirect_to poll_index_url(:course_id => @course.id) + else + respond_to do |format| + format.js + end + end + end end def student_exercise_list diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index 844cff1c1..410a9936b 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -2,8 +2,8 @@ module ExerciseHelper #判断用户是否已经提交了问卷 - def has_commit_exercise?(poll_id,user_id) - pu = PollUser.find_by_poll_id_and_user_id(poll_id,user_id) + def has_commit_exercise?(exercise_id, user_id) + pu = PollUser.find_by_poll_id_and_user_id(excercise_id, user_id) if pu.nil? false else diff --git a/db/schema.rb b/db/schema.rb index 3feb43adb..25d561e86 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 => 20151116065904) do +ActiveRecord::Schema.define(:version => 20151116071721) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -241,58 +241,6 @@ ActiveRecord::Schema.define(:version => 20151116065904) do add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true - create_table "code_review_assignments", :force => true do |t| - t.integer "issue_id" - t.integer "change_id" - t.integer "attachment_id" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.string "action_type" - t.integer "changeset_id" - end - - create_table "code_review_project_settings", :force => true do |t| - t.integer "project_id" - t.integer "tracker_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "updated_by" - t.boolean "hide_code_review_tab", :default => false - t.integer "auto_relation", :default => 1 - t.integer "assignment_tracker_id" - t.text "auto_assign" - t.integer "lock_version", :default => 0, :null => false - t.boolean "tracker_in_review_dialog", :default => false - end - - create_table "code_review_user_settings", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.integer "mail_notification", :default => 0, :null => false - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "code_reviews", :force => true do |t| - t.integer "project_id" - t.integer "change_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "line" - t.integer "updated_by_id" - t.integer "lock_version", :default => 0, :null => false - t.integer "status_changed_from" - t.integer "status_changed_to" - t.integer "issue_id" - t.string "action_type" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.integer "attachment_id" - t.integer "file_count", :default => 0, :null => false - t.boolean "diff_all" - end - create_table "comments", :force => true do |t| t.string "commented_type", :limit => 30, :default => "", :null => false t.integer "commented_id", :default => 0, :null => false From 3b7a2ed8aa4f9aba0f8ab511d66fc31b5fcc78d2 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 17 Nov 2015 16:20:10 +0800 Subject: [PATCH 024/191] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=BA=93=E4=B8=8D=E8=83=BD=E6=96=B0=E5=BB=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/projects/settings/_join_org.html.erb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/views/projects/settings/_join_org.html.erb b/app/views/projects/settings/_join_org.html.erb index 57ae714bd..589bed1b9 100644 --- a/app/views/projects/settings/_join_org.html.erb +++ b/app/views/projects/settings/_join_org.html.erb @@ -16,12 +16,13 @@
          关联组织
          - <%= form_tag url_for(:controller => 'org_projects', :action => 'create', :project_id => @project.id), :id => 'join_orgs_for_project', :remote => true %> - -
          -
            - 关联 - 取消 + <%= form_tag url_for(:controller => 'org_projects', :action => 'create', :project_id => @project.id), :id => 'join_orgs_for_project', :remote => true do %> + +
            +
              + 关联 + 取消 + <% end %>
              From 42a499815af751064198e93cde1b604ff113ad84 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 17 Nov 2015 16:34:07 +0800 Subject: [PATCH 025/191] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/configuration.yml | 2 +- config/initializers/gitlab_config.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/configuration.yml b/config/configuration.yml index 3790045aa..7c62e8988 100644 --- a/config/configuration.yml +++ b/config/configuration.yml @@ -201,7 +201,7 @@ default: judge_server: 'http://judge.trustie.net/' # Git's url - gitlab_address: 'http://gitfast.trustie.net' + gitlab_address: 'http://git.trustie.net' # specific configuration options for production environment # that overrides the default ones diff --git a/config/initializers/gitlab_config.rb b/config/initializers/gitlab_config.rb index c82b2edff..6e015d4b8 100644 --- a/config/initializers/gitlab_config.rb +++ b/config/initializers/gitlab_config.rb @@ -1,8 +1,8 @@ Gitlab.configure do |config| # config.endpoint = 'http://192.168.41.130:3000/trustie/api/v3' # API endpoint URL, default: ENV['GITLAB_API_ENDPOINT'] # config.private_token = 'cK15gUDwvt8EEkzwQ_63' # user's private token, default: ENV['GITLAB_API_PRIVATE_TOKEN'] - config.endpoint = 'http://gitfast.trustie.net/api/v3' # API endpoint URL, default: ENV['GITLAB_API_ENDPOINT'] - config.private_token = 'fPc_gBmEiSANve8TCfxW' # user's private token, default: ENV['GITLAB_API_PRIVATE_TOKEN'] + config.endpoint = 'http://git.trustie.net/api/v3' # API endpoint URL, default: ENV['GITLAB_API_ENDPOINT'] + config.private_token = 'kZUYYbAY12QSQ2Tx1zes' # user's private token, default: ENV['GITLAB_API_PRIVATE_TOKEN'] # Optional # config.user_agent = 'Custom User Agent' # user agent, default: 'Gitlab Ruby Gem [version]' # config.sudo = 'user' # username for sudo mode, default: nil From 71bf80c7a54948c6ecfb663b924829a50e5c16b2 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 17 Nov 2015 17:34:50 +0800 Subject: [PATCH 026/191] =?UTF-8?q?1.=E5=88=9B=E5=BB=BA=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=85=B3=E8=81=94=E8=A1=A8=EF=BC=8C=E5=BB=BA?= =?UTF-8?q?=E7=AB=8B=E7=9B=B8=E5=BA=94=E6=A8=A1=E5=9E=8B=E5=8F=8A=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=99=A8=EF=BC=9B=202.=E5=9C=A8=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=AD=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E7=BB=84=E4=B8=AD=E5=8A=9F=E8=83=BD=EF=BC=9B=203.?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AE=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E7=BB=84=E7=BB=87=E5=88=97=E8=A1=A8=E7=9A=84=E4=B8=8A?= =?UTF-8?q?=E4=B8=80=E9=A1=B5=E5=92=8C=E4=B8=8B=E4=B8=80=E9=A1=B5=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/javascripts/org_courses.js.coffee | 3 + app/assets/stylesheets/org_courses.css.scss | 3 + app/controllers/courses_controller.rb | 23 ++ app/controllers/org_courses_controller.rb | 48 +++ app/helpers/org_courses_helper.rb | 2 + app/models/course.rb | 2 + app/models/org_course.rb | 5 + app/models/organization.rb | 2 + .../search_public_orgs_not_in_course.js.erb | 13 + app/views/courses/settings.html.erb | 7 + .../courses/settings/_added_orgs.html.erb | 9 + app/views/courses/settings/_join_org.html.erb | 74 ++++ app/views/layouts/base_org.html.erb | 5 + app/views/org_courses/create.js.erb | 13 + app/views/org_courses/destroy.js.erb | 17 + .../projects/settings/_added_orgs.html.erb | 3 +- .../projects/settings/_join_org.html.erb | 37 +- config/routes.rb | 10 + .../20151117033430_create_org_courses.rb | 12 + db/schema.rb | 354 ++++++++++++++++-- public/javascripts/course.js | 18 +- public/javascripts/project.js | 14 + .../org_courses_controller_spec.rb | 5 + 23 files changed, 611 insertions(+), 68 deletions(-) create mode 100644 app/assets/javascripts/org_courses.js.coffee create mode 100644 app/assets/stylesheets/org_courses.css.scss create mode 100644 app/controllers/org_courses_controller.rb create mode 100644 app/helpers/org_courses_helper.rb create mode 100644 app/models/org_course.rb create mode 100644 app/views/courses/search_public_orgs_not_in_course.js.erb create mode 100644 app/views/courses/settings/_added_orgs.html.erb create mode 100644 app/views/courses/settings/_join_org.html.erb create mode 100644 app/views/org_courses/create.js.erb create mode 100644 app/views/org_courses/destroy.js.erb create mode 100644 db/migrate/20151117033430_create_org_courses.rb create mode 100644 spec/controllers/org_courses_controller_spec.rb diff --git a/app/assets/javascripts/org_courses.js.coffee b/app/assets/javascripts/org_courses.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/org_courses.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/org_courses.css.scss b/app/assets/stylesheets/org_courses.css.scss new file mode 100644 index 000000000..026af5d01 --- /dev/null +++ b/app/assets/stylesheets/org_courses.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the org_courses controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 1a561006a..fd53660c6 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -29,6 +29,29 @@ class CoursesController < ApplicationController before_filter :require_login, :only => [:join, :unjoin] #before_filter :allow_join, :only => [:join] + #查找组织 + def search_public_orgs_not_in_course + condition = '%%' + if !params[:name].nil? + condition = "%#{params[:name].strip}%".gsub(" ","") + end + course_org_ids = OrgCourse.find_by_sql("select distinct organization_id from org_courses where course_id = #{params[:id]}").map(&:organization_id) + if course_org_ids.empty? + @orgs_not_in_course = Organization.where("(is_public or creator_id =?) and name like ?",User.current.id, condition).page((params[:page].to_i || 1)).per(10) + @org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count + else + course_org_ids = "(" + course_org_ids.join(',') + ")" + @orgs_not_in_course = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page((params[:page].to_i || 1)).per(10) + @org_count = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count + end + # @course_count = Project.course_entities.visible.like(params[:name]).page(params[:page]).count + @orgs_page = Paginator.new @org_count, 10,params[:page] + #render :json => {:orgs => @orgs_not_in_course, :count => @org_count}.to_json + respond_to do |format| + format.js + end + end + def join if User.current.logged? cs = CoursesService.new diff --git a/app/controllers/org_courses_controller.rb b/app/controllers/org_courses_controller.rb new file mode 100644 index 000000000..d7e59382a --- /dev/null +++ b/app/controllers/org_courses_controller.rb @@ -0,0 +1,48 @@ +class OrgCoursesController < ApplicationController + def create + org_ids = params[:orgNames] + @course = Course.find(params[:course_id]) + org_ids.each do |org_id| + OrgCourse.create(:organization_id => org_id.to_i, :course_id => params[:course_id].to_i, :created_at => Time.now) + end + + condition = '%%' + if !params[:name].nil? + condition = "%#{params[:name].strip}%".gsub(" ","") + end + course_org_ids = OrgCourse.find_by_sql("select distinct organization_id from org_courses where course_id = #{params[:course_id]}").map(&:organization_id) + if course_org_ids.empty? + @orgs_not_in_course = Organization.where("(is_public or creator_id =?) = 1 and name like ?",User.current.id, condition).page((params[:page].to_i || 1)).per(10) + @org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count + else + course_org_ids = "(" + course_org_ids.join(',') + ")" + @orgs_not_in_course = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page((params[:page].to_i || 1)).per(10) + @org_count = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count + end + # @course_count = Course.course_entities.visible.like(params[:name]).page(params[:page]).count + @orgs_page = Paginator.new @org_count, 10,params[:page] + #render :json => {:orgs => @orgs_not_in_course, :count => @org_count}.to_json + respond_to do |format| + format.js + end + end + + def destroy + @course = Course.find(params[:course_id]) + @org_course = OrgCourse.find(params[:id]) + @org_course.destroy + + condition = '%%' + course_org_ids = OrgCourse.find_by_sql("select distinct organization_id from org_courses where course_id = #{params[:course_id]}").map(&:organization_id) + if course_org_ids.empty? + @orgs_not_in_course = Organization.where("(is_public or creator_id =?) = 1 and name like ?",User.current.id, condition).page( 1).per(10) + @org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count + else + course_org_ids = "(" + course_org_ids.join(',') + ")" + @orgs_not_in_course = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page( 1).per(10) + @org_count = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count + end + # @course_count = Course.course_entities.visible.like(params[:name]).page(params[:page]).count + @orgs_page = Paginator.new @org_count, 10,1 + end +end diff --git a/app/helpers/org_courses_helper.rb b/app/helpers/org_courses_helper.rb new file mode 100644 index 000000000..28655e52e --- /dev/null +++ b/app/helpers/org_courses_helper.rb @@ -0,0 +1,2 @@ +module OrgCoursesHelper +end diff --git a/app/models/course.rb b/app/models/course.rb index 7288c3b3b..a9f72ad61 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -18,6 +18,8 @@ class Course < ActiveRecord::Base :conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})" has_many :principals, :through => :member_principals, :source => :principal has_many :users, :through => :members + has_many :org_courses + has_many :organizations, :through => :org_courses # has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy has_many :journals_for_messages, :as => :jour, :dependent => :destroy # has_many :homework_for_courses, :dependent => :destroy diff --git a/app/models/org_course.rb b/app/models/org_course.rb new file mode 100644 index 000000000..8c198794a --- /dev/null +++ b/app/models/org_course.rb @@ -0,0 +1,5 @@ +class OrgCourse < ActiveRecord::Base + #attr_accessible :organization, :course, :created_at + belongs_to :organization + belongs_to :course +end diff --git a/app/models/organization.rb b/app/models/organization.rb index 7778da477..d3755b5ee 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -3,7 +3,9 @@ class Organization < ActiveRecord::Base has_many :org_members, :dependent => :destroy has_many :org_projects ,:dependent => :destroy has_many :projects,:through => :org_projects + has_many :courses, :through => :org_courses has_many :org_document_comments, :dependent => :destroy + has_many :org_courses has_many :users, :through => :org_members validates_uniqueness_of :name after_create :save_as_org_activity diff --git a/app/views/courses/search_public_orgs_not_in_course.js.erb b/app/views/courses/search_public_orgs_not_in_course.js.erb new file mode 100644 index 000000000..76f9bcedb --- /dev/null +++ b/app/views/courses/search_public_orgs_not_in_course.js.erb @@ -0,0 +1,13 @@ +$("#search_orgs_result_list").html(""); +$("#search_orgs_result_list").append('
                '); +<% @orgs_not_in_course.each do |org|%> + link = "
              • "; + $("#search_orgs_result_list").append(link ); +<%end %> +$("#search_orgs_result_list").append('
              ') +<% if @org_count > 10 %> + $("#paginator").html(' <%= pagination_links_full @orgs_page, @org_count ,:per_page_links => true,:remote =>true,:flag=>true%>'); + $("#paginator").css("display", "block"); +<% else %> + $("#paginator").css("display", "none"); +<% end %> diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb index a90be14ea..d598b96d6 100644 --- a/app/views/courses/settings.html.erb +++ b/app/views/courses/settings.html.erb @@ -10,6 +10,9 @@
            • 成员
            • +
            • + 组织 +
            @@ -91,6 +94,10 @@ <%= render :partial => "course_members" %>
            + +
            + <%= render :partial => 'courses/settings/join_org' %> +
            \ No newline at end of file diff --git a/app/views/layouts/base_org.html.erb b/app/views/layouts/base_org.html.erb index 6b4eab72a..d59cf8ee2 100644 --- a/app/views/layouts/base_org.html.erb +++ b/app/views/layouts/base_org.html.erb @@ -112,6 +112,11 @@
            <%= render :partial => 'layouts/footer' %>
            + + + diff --git a/app/views/org_courses/create.js.erb b/app/views/org_courses/create.js.erb new file mode 100644 index 000000000..d61120e1a --- /dev/null +++ b/app/views/org_courses/create.js.erb @@ -0,0 +1,13 @@ +$("#search_orgs_result_list").html(""); +$("#search_orgs_result_list").append('
              '); +<% @orgs_not_in_course.each do |org|%> + link = "
            • "; + $("#search_orgs_result_list").append(link ); +<% end %> +$("#search_orgs_result_list").append('
            ') +<% if @org_count > 10 %> + $("#paginator").html(' <%= pagination_links_full @orgs_page, @org_count ,:per_page_links => true,:remote =>true,:flag=>true %>'); +<% end %> + +$("#added_orgs").html(""); +$("#added_orgs").html('<%= escape_javascript(render :partial => "courses/settings/added_orgs", :locals => {:orgs => @course.organizations, :course_id => @course.id}) %>') \ No newline at end of file diff --git a/app/views/org_courses/destroy.js.erb b/app/views/org_courses/destroy.js.erb new file mode 100644 index 000000000..639a7625b --- /dev/null +++ b/app/views/org_courses/destroy.js.erb @@ -0,0 +1,17 @@ +$("#added_orgs").html(""); +$("#added_orgs").html('<%= escape_javascript(render :partial => "courses/settings/added_orgs", :locals => {:orgs => @course.organizations, :course_id => @course.id}) %>') + +$("#search_orgs_result_list").html(""); +$("#search_orgs_result_list").append('
              '); +<% @orgs_not_in_course.each do |org|%> + link = "
            • "; + $("#search_orgs_result_list").append(link ); +<%end %> +$("#search_orgs_result_list").append('
            ') +<% if @org_count > 10 %> + $("#paginator").html(' <%= pagination_links_full @orgs_page, @org_count ,:per_page_links => true,:remote =>true,:flag=>true%>'); + $("#paginator").css("display", "block"); +<% else %> + $("#paginator").css("display", "none"); +<% end %> + diff --git a/app/views/projects/settings/_added_orgs.html.erb b/app/views/projects/settings/_added_orgs.html.erb index d07ead277..19e0c07fe 100644 --- a/app/views/projects/settings/_added_orgs.html.erb +++ b/app/views/projects/settings/_added_orgs.html.erb @@ -2,7 +2,8 @@
          • 名称操作
          • <% orgs.each do |org| %>
          • <%= org.name %> - <%= link_to "取消关联", org_project_path(:id => OrgProject.where(:organization_id => org.id, :project_id => project_id).first.id, :project_id => project_id), + 取消关联 + <%#= link_to "取消关联", org_project_path(:id => OrgProject.where(:organization_id => org.id, :project_id => project_id).first.id, :project_id => project_id), :method => 'delete',:remote => true, :class => "relatedListOption fl linkGrey3" %>
          • <% end %> diff --git a/app/views/projects/settings/_join_org.html.erb b/app/views/projects/settings/_join_org.html.erb index 57ae714bd..5733623a2 100644 --- a/app/views/projects/settings/_join_org.html.erb +++ b/app/views/projects/settings/_join_org.html.erb @@ -7,11 +7,6 @@ <%= stylesheet_link_tag 'org' %> -
              -
            • 组织
            • -
            • -
              -
            关联组织 @@ -50,21 +45,6 @@ $.ajax({ url: '<%= url_for(:controller => 'projects', :action => 'search_public_orgs_not_in_project') %>'+'?name='+ e.target.value+'&page='+page, type:'get' -// success: function(data){ -// orgs = data.orgs; -// count = data.count; -// maxPage = Math.ceil(count/10); -// $("#search_orgs_result_list").next().html(""); -// if(orgs.length != undefined && orgs.length != 0){ -// var i = 0; -// for(; i" + orgs[i].organization.name + "
            "; -// console.log(link) -// $("#search_orgs_result_list").next().append(link ); -// } -// -// } -// } }); } @@ -84,24 +64,11 @@ $.ajax({ url: '<%= url_for(:controller => 'projects', :action => 'search_public_orgs_not_in_project') %>'+'?page=1', type:'get' -// success: function(data){ -// orgs = data.orgs; -// count = data.count; -// maxPage = Math.ceil(count/10); -// $("#search_orgs_result_list").next().html(""); -// if(orgs.length != undefined && orgs.length != 0){ -// var i = 0; -// for(; i" + orgs[i].organization.name + "
            "; -// console.log(link) -// $("#search_orgs_result_list").next().append(link ); -// } -// -// } -// } }); }); function cancel_join_orgs() { $("#search_orgs_result_list").html(""); + $("#paginator").html(""); + $("#paginator").css("display", "none"); } \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 24d159f04..f2a08d35e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -79,6 +79,15 @@ RedmineApp::Application.routes.draw do end end + + resources :org_courses do + member do + + end + collection do + + end + end #match '/organizations/:organization_id/org_document_comments/new', :to => 'org_document_comments#new', :as => 'new_org_documents', :via => [:get, :post] #match '/organizations/:organization_id/org_document_comments/create', :to => 'org_document_comments#create', :as => 'create_org_documents', :via => [:post] resources :homework_users @@ -850,6 +859,7 @@ RedmineApp::Application.routes.draw do post 'search_course_outline' post 'set_course_outline' get 'syllabus' + get 'search_public_orgs_not_in_course' end collection do match 'join_private_courses', :via => [:get, :post] diff --git a/db/migrate/20151117033430_create_org_courses.rb b/db/migrate/20151117033430_create_org_courses.rb new file mode 100644 index 000000000..847489f18 --- /dev/null +++ b/db/migrate/20151117033430_create_org_courses.rb @@ -0,0 +1,12 @@ +class CreateOrgCourses < ActiveRecord::Migration + def up + create_table :org_courses do |t| + t.integer :organization_id + t.integer :course_id + t.timestamp :created_at + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 1f48eaf02..4df54cede 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 => 20151110011003) do +ActiveRecord::Schema.define(:version => 20151117033430) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -293,6 +293,16 @@ ActiveRecord::Schema.define(:version => 20151110011003) do t.boolean "diff_all" end + create_table "columns_priv", :id => false, :force => true do |t| + t.string "Host", :limit => 60, :default => "", :null => false + t.string "Db", :limit => 64, :default => "", :null => false + t.string "User", :limit => 16, :default => "", :null => false + t.string "Table_name", :limit => 64, :default => "", :null => false + t.string "Column_name", :limit => 64, :default => "", :null => false + t.timestamp "Timestamp", :null => false + t.string "Column_priv", :limit => 0, :default => "", :null => false + end + create_table "comments", :force => true do |t| t.string "commented_type", :limit => 30, :default => "", :null => false t.integer "commented_id", :default => 0, :null => false @@ -491,6 +501,33 @@ ActiveRecord::Schema.define(:version => 20151110011003) do add_index "custom_values", ["custom_field_id"], :name => "index_custom_values_on_custom_field_id" add_index "custom_values", ["customized_type", "customized_id"], :name => "custom_values_customized" + create_table "db", :id => false, :force => true do |t| + t.string "Host", :limit => 60, :default => "", :null => false + t.string "Db", :limit => 64, :default => "", :null => false + t.string "User", :limit => 16, :default => "", :null => false + t.string "Select_priv", :limit => 1, :default => "N", :null => false + t.string "Insert_priv", :limit => 1, :default => "N", :null => false + t.string "Update_priv", :limit => 1, :default => "N", :null => false + t.string "Delete_priv", :limit => 1, :default => "N", :null => false + t.string "Create_priv", :limit => 1, :default => "N", :null => false + t.string "Drop_priv", :limit => 1, :default => "N", :null => false + t.string "Grant_priv", :limit => 1, :default => "N", :null => false + t.string "References_priv", :limit => 1, :default => "N", :null => false + t.string "Index_priv", :limit => 1, :default => "N", :null => false + t.string "Alter_priv", :limit => 1, :default => "N", :null => false + t.string "Create_tmp_table_priv", :limit => 1, :default => "N", :null => false + t.string "Lock_tables_priv", :limit => 1, :default => "N", :null => false + t.string "Create_view_priv", :limit => 1, :default => "N", :null => false + t.string "Show_view_priv", :limit => 1, :default => "N", :null => false + t.string "Create_routine_priv", :limit => 1, :default => "N", :null => false + t.string "Alter_routine_priv", :limit => 1, :default => "N", :null => false + t.string "Execute_priv", :limit => 1, :default => "N", :null => false + t.string "Event_priv", :limit => 1, :default => "N", :null => false + t.string "Trigger_priv", :limit => 1, :default => "N", :null => false + end + + add_index "db", ["User"], :name => "User" + create_table "delayed_jobs", :force => true do |t| t.integer "priority", :default => 0, :null => false t.integer "attempts", :default => 0, :null => false @@ -528,23 +565,26 @@ ActiveRecord::Schema.define(:version => 20151110011003) do add_index "documents", ["created_on"], :name => "index_documents_on_created_on" add_index "documents", ["project_id"], :name => "documents_project_id" - create_table "dts", :force => true do |t| - t.string "IPLineCode" - t.string "Description" - t.string "Num" - t.string "Variable" - t.string "TraceInfo" - t.string "Method" + create_table "dts", :primary_key => "Num", :force => true do |t| + t.string "Defect", :limit => 50 + t.string "Category", :limit => 50 t.string "File" - t.string "IPLine" - t.string "Review" - t.string "Category" - t.string "Defect" - t.string "PreConditions" - t.string "StartLine" + t.string "Method" + t.string "Module", :limit => 20 + t.string "Variable", :limit => 50 + t.integer "StartLine" + t.integer "IPLine" + t.string "IPLineCode", :limit => 200 + t.string "Judge", :limit => 15 + t.integer "Review", :limit => 1 + t.string "Description" + t.text "PreConditions", :limit => 2147483647 + t.text "TraceInfo", :limit => 2147483647 + t.text "Code", :limit => 2147483647 t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" + t.integer "id", :null => false end create_table "enabled_modules", :force => true do |t| @@ -569,6 +609,31 @@ ActiveRecord::Schema.define(:version => 20151110011003) 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 "event", :id => false, :force => true do |t| + t.string "db", :limit => 64, :default => "", :null => false + t.string "name", :limit => 64, :default => "", :null => false + t.binary "body", :limit => 2147483647, :null => false + t.string "definer", :limit => 77, :default => "", :null => false + t.datetime "execute_at" + t.integer "interval_value" + t.string "interval_field", :limit => 18 + t.timestamp "created", :null => false + t.timestamp "modified", :null => false + t.datetime "last_executed" + t.datetime "starts" + t.datetime "ends" + t.string "status", :limit => 18, :default => "ENABLED", :null => false + t.string "on_completion", :limit => 8, :default => "DROP", :null => false + t.string "sql_mode", :limit => 0, :default => "", :null => false + t.string "comment", :limit => 64, :default => "", :null => false + t.integer "originator", :null => false + t.string "time_zone", :limit => 64, :default => "SYSTEM", :null => false + t.string "character_set_client", :limit => 32 + t.string "collation_connection", :limit => 32 + t.string "db_collation", :limit => 32 + t.binary "body_utf8", :limit => 2147483647 + end + create_table "first_pages", :force => true do |t| t.string "web_title" t.string "title" @@ -620,6 +685,21 @@ ActiveRecord::Schema.define(:version => 20151110011003) do t.integer "locked" end + create_table "func", :primary_key => "name", :force => true do |t| + t.boolean "ret", :default => false, :null => false + t.string "dl", :limit => 128, :default => "", :null => false + t.string "type", :limit => 9, :null => false + end + + create_table "general_log", :id => false, :force => true do |t| + t.timestamp "event_time", :null => false + t.text "user_host", :limit => 16777215, :null => false + t.integer "thread_id", :null => false + t.integer "server_id", :null => false + t.string "command_type", :limit => 64, :null => false + t.text "argument", :limit => 16777215, :null => false + end + create_table "groups_users", :id => false, :force => true do |t| t.integer "group_id", :null => false t.integer "user_id", :null => false @@ -627,6 +707,35 @@ ActiveRecord::Schema.define(:version => 20151110011003) do add_index "groups_users", ["group_id", "user_id"], :name => "groups_users_ids", :unique => true + create_table "help_category", :primary_key => "help_category_id", :force => true do |t| + t.string "name", :limit => 64, :null => false + t.integer "parent_category_id", :limit => 2 + t.text "url", :null => false + end + + add_index "help_category", ["name"], :name => "name", :unique => true + + create_table "help_keyword", :primary_key => "help_keyword_id", :force => true do |t| + t.string "name", :limit => 64, :null => false + end + + add_index "help_keyword", ["name"], :name => "name", :unique => true + + create_table "help_relation", :id => false, :force => true do |t| + t.integer "help_topic_id", :null => false + t.integer "help_keyword_id", :null => false + end + + create_table "help_topic", :primary_key => "help_topic_id", :force => true do |t| + t.string "name", :limit => 64, :null => false + t.integer "help_category_id", :limit => 2, :null => false + t.text "description", :null => false + t.text "example", :null => false + t.text "url", :null => false + end + + add_index "help_topic", ["name"], :name => "name", :unique => true + create_table "homework_attaches", :force => true do |t| t.integer "bid_id" t.integer "user_id" @@ -712,6 +821,29 @@ ActiveRecord::Schema.define(:version => 20151110011003) do t.datetime "updated_at", :null => false end + create_table "host", :id => false, :force => true do |t| + t.string "Host", :limit => 60, :default => "", :null => false + t.string "Db", :limit => 64, :default => "", :null => false + t.string "Select_priv", :limit => 1, :default => "N", :null => false + t.string "Insert_priv", :limit => 1, :default => "N", :null => false + t.string "Update_priv", :limit => 1, :default => "N", :null => false + t.string "Delete_priv", :limit => 1, :default => "N", :null => false + t.string "Create_priv", :limit => 1, :default => "N", :null => false + t.string "Drop_priv", :limit => 1, :default => "N", :null => false + t.string "Grant_priv", :limit => 1, :default => "N", :null => false + t.string "References_priv", :limit => 1, :default => "N", :null => false + t.string "Index_priv", :limit => 1, :default => "N", :null => false + t.string "Alter_priv", :limit => 1, :default => "N", :null => false + t.string "Create_tmp_table_priv", :limit => 1, :default => "N", :null => false + t.string "Lock_tables_priv", :limit => 1, :default => "N", :null => false + t.string "Create_view_priv", :limit => 1, :default => "N", :null => false + t.string "Show_view_priv", :limit => 1, :default => "N", :null => false + t.string "Create_routine_priv", :limit => 1, :default => "N", :null => false + t.string "Alter_routine_priv", :limit => 1, :default => "N", :null => false + t.string "Execute_priv", :limit => 1, :default => "N", :null => false + t.string "Trigger_priv", :limit => 1, :default => "N", :null => false + end + create_table "invite_lists", :force => true do |t| t.integer "project_id" t.integer "user_id" @@ -814,16 +946,6 @@ ActiveRecord::Schema.define(:version => 20151110011003) do add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_details_copy", :force => true do |t| - t.integer "journal_id", :default => 0, :null => false - t.string "property", :limit => 30, :default => "", :null => false - t.string "prop_key", :limit => 30, :default => "", :null => false - t.text "old_value" - t.text "value" - end - - add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_replies", :id => false, :force => true do |t| t.integer "journal_id" t.integer "user_id" @@ -951,6 +1073,15 @@ ActiveRecord::Schema.define(:version => 20151110011003) do add_index "messages", ["last_reply_id"], :name => "index_messages_on_last_reply_id" add_index "messages", ["parent_id"], :name => "messages_parent_id" + create_table "ndb_binlog_index", :primary_key => "epoch", :force => true do |t| + t.integer "Position", :limit => 8, :null => false + t.string "File", :null => false + t.integer "inserts", :limit => 8, :null => false + t.integer "updates", :limit => 8, :null => false + t.integer "deletes", :limit => 8, :null => false + t.integer "schemaops", :limit => 8, :null => false + end + create_table "news", :force => true do |t| t.integer "project_id" t.string "title", :limit => 60, :default => "", :null => false @@ -960,6 +1091,7 @@ ActiveRecord::Schema.define(:version => 20151110011003) do t.datetime "created_on" t.integer "comments_count", :default => 0, :null => false t.integer "course_id" + t.integer "sticky", :default => 0 end add_index "news", ["author_id"], :name => "index_news_on_author_id" @@ -1055,6 +1187,12 @@ ActiveRecord::Schema.define(:version => 20151110011003) do t.datetime "updated_at", :null => false end + create_table "org_courses", :force => true do |t| + t.integer "organization_id" + t.integer "course_id" + t.datetime "created_at" + end + create_table "org_document_comments", :force => true do |t| t.string "title" t.text "content" @@ -1076,8 +1214,7 @@ ActiveRecord::Schema.define(:version => 20151110011003) do create_table "org_members", :force => true do |t| t.integer "user_id" t.integer "organization_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" end create_table "org_projects", :force => true do |t| @@ -1104,6 +1241,10 @@ ActiveRecord::Schema.define(:version => 20151110011003) do t.datetime "updated_at", :null => false end + create_table "plugin", :primary_key => "name", :force => true do |t| + t.string "dl", :limit => 128, :default => "", :null => false + end + create_table "poll_answers", :force => true do |t| t.integer "poll_question_id" t.text "answer_text" @@ -1179,6 +1320,42 @@ ActiveRecord::Schema.define(:version => 20151110011003) do t.datetime "updated_at", :null => false end + create_table "proc", :id => false, :force => true do |t| + t.string "db", :limit => 64, :default => "", :null => false + t.string "name", :limit => 64, :default => "", :null => false + t.string "type", :limit => 9, :null => false + t.string "specific_name", :limit => 64, :default => "", :null => false + t.string "language", :limit => 3, :default => "SQL", :null => false + t.string "sql_data_access", :limit => 17, :default => "CONTAINS_SQL", :null => false + t.string "is_deterministic", :limit => 3, :default => "NO", :null => false + t.string "security_type", :limit => 7, :default => "DEFINER", :null => false + t.binary "param_list", :null => false + t.binary "returns", :limit => 2147483647, :null => false + t.binary "body", :limit => 2147483647, :null => false + t.string "definer", :limit => 77, :default => "", :null => false + t.timestamp "created", :null => false + t.timestamp "modified", :null => false + t.string "sql_mode", :limit => 0, :default => "", :null => false + t.text "comment", :null => false + t.string "character_set_client", :limit => 32 + t.string "collation_connection", :limit => 32 + t.string "db_collation", :limit => 32 + t.binary "body_utf8", :limit => 2147483647 + end + + create_table "procs_priv", :id => false, :force => true do |t| + t.string "Host", :limit => 60, :default => "", :null => false + t.string "Db", :limit => 64, :default => "", :null => false + t.string "User", :limit => 16, :default => "", :null => false + t.string "Routine_name", :limit => 64, :default => "", :null => false + t.string "Routine_type", :limit => 9, :null => false + t.string "Grantor", :limit => 77, :default => "", :null => false + t.string "Proc_priv", :limit => 0, :default => "", :null => false + t.timestamp "Timestamp", :null => false + end + + add_index "procs_priv", ["Grantor"], :name => "Grantor" + create_table "project_infos", :force => true do |t| t.integer "project_id" t.integer "user_id" @@ -1253,6 +1430,18 @@ ActiveRecord::Schema.define(:version => 20151110011003) do add_index "projects_trackers", ["project_id", "tracker_id"], :name => "projects_trackers_unique", :unique => true add_index "projects_trackers", ["project_id"], :name => "projects_trackers_project_id" + create_table "proxies_priv", :id => false, :force => true do |t| + t.string "Host", :limit => 60, :default => "", :null => false + t.string "User", :limit => 16, :default => "", :null => false + t.string "Proxied_host", :limit => 60, :default => "", :null => false + t.string "Proxied_user", :limit => 16, :default => "", :null => false + t.boolean "With_grant", :default => false, :null => false + t.string "Grantor", :limit => 77, :default => "", :null => false + t.timestamp "Timestamp", :null => false + end + + add_index "proxies_priv", ["Grantor"], :name => "Grantor" + create_table "queries", :force => true do |t| t.integer "project_id" t.string "name", :default => "", :null => false @@ -1366,6 +1555,17 @@ ActiveRecord::Schema.define(:version => 20151110011003) do t.integer "is_teacher_score", :default => 0 end + create_table "servers", :primary_key => "Server_name", :force => true do |t| + t.string "Host", :limit => 64, :default => "", :null => false + t.string "Db", :limit => 64, :default => "", :null => false + t.string "Username", :limit => 64, :default => "", :null => false + t.string "Password", :limit => 64, :default => "", :null => false + t.integer "Port", :default => 0, :null => false + t.string "Socket", :limit => 64, :default => "", :null => false + t.string "Wrapper", :limit => 64, :default => "", :null => false + t.string "Owner", :limit => 64, :default => "", :null => false + end + create_table "settings", :force => true do |t| t.string "name", :default => "", :null => false t.text "value" @@ -1386,6 +1586,20 @@ ActiveRecord::Schema.define(:version => 20151110011003) do t.string "description" end + create_table "slow_log", :id => false, :force => true do |t| + t.timestamp "start_time", :null => false + t.text "user_host", :limit => 16777215, :null => false + t.time "query_time", :null => false + t.time "lock_time", :null => false + t.integer "rows_sent", :null => false + t.integer "rows_examined", :null => false + t.string "db", :limit => 512, :null => false + t.integer "last_insert_id", :null => false + t.integer "insert_id", :null => false + t.integer "server_id", :null => false + t.text "sql_text", :limit => 16777215, :null => false + end + create_table "softapplications", :force => true do |t| t.string "name" t.text "description" @@ -1467,6 +1681,19 @@ ActiveRecord::Schema.define(:version => 20151110011003) do t.string "subject" end + create_table "tables_priv", :id => false, :force => true do |t| + t.string "Host", :limit => 60, :default => "", :null => false + t.string "Db", :limit => 64, :default => "", :null => false + t.string "User", :limit => 16, :default => "", :null => false + t.string "Table_name", :limit => 64, :default => "", :null => false + t.string "Grantor", :limit => 77, :default => "", :null => false + t.timestamp "Timestamp", :null => false + t.string "Table_priv", :limit => 0, :default => "", :null => false + t.string "Column_priv", :limit => 0, :default => "", :null => false + end + + add_index "tables_priv", ["Grantor"], :name => "Grantor" + create_table "taggings", :force => true do |t| t.integer "tag_id" t.integer "taggable_id" @@ -1516,6 +1743,32 @@ ActiveRecord::Schema.define(:version => 20151110011003) do add_index "time_entries", ["project_id"], :name => "time_entries_project_id" add_index "time_entries", ["user_id"], :name => "index_time_entries_on_user_id" + create_table "time_zone", :primary_key => "Time_zone_id", :force => true do |t| + t.string "Use_leap_seconds", :limit => 1, :default => "N", :null => false + end + + create_table "time_zone_leap_second", :primary_key => "Transition_time", :force => true do |t| + t.integer "Correction", :null => false + end + + create_table "time_zone_name", :primary_key => "Name", :force => true do |t| + t.integer "Time_zone_id", :null => false + end + + create_table "time_zone_transition", :id => false, :force => true do |t| + t.integer "Time_zone_id", :null => false + t.integer "Transition_time", :limit => 8, :null => false + t.integer "Transition_type_id", :null => false + end + + create_table "time_zone_transition_type", :id => false, :force => true do |t| + t.integer "Time_zone_id", :null => false + t.integer "Transition_type_id", :null => false + t.integer "Offset", :default => 0, :null => false + t.integer "Is_DST", :limit => 1, :default => 0, :null => false + t.string "Abbreviation", :limit => 8, :default => "", :null => false + end + create_table "tokens", :force => true do |t| t.integer "user_id", :default => 0, :null => false t.string "action", :limit => 30, :default => "", :null => false @@ -1534,6 +1787,51 @@ ActiveRecord::Schema.define(:version => 20151110011003) do t.integer "fields_bits", :default => 0 end + create_table "user", :id => false, :force => true do |t| + t.string "Host", :limit => 60, :default => "", :null => false + t.string "User", :limit => 16, :default => "", :null => false + t.string "Password", :limit => 41, :default => "", :null => false + t.string "Select_priv", :limit => 1, :default => "N", :null => false + t.string "Insert_priv", :limit => 1, :default => "N", :null => false + t.string "Update_priv", :limit => 1, :default => "N", :null => false + t.string "Delete_priv", :limit => 1, :default => "N", :null => false + t.string "Create_priv", :limit => 1, :default => "N", :null => false + t.string "Drop_priv", :limit => 1, :default => "N", :null => false + t.string "Reload_priv", :limit => 1, :default => "N", :null => false + t.string "Shutdown_priv", :limit => 1, :default => "N", :null => false + t.string "Process_priv", :limit => 1, :default => "N", :null => false + t.string "File_priv", :limit => 1, :default => "N", :null => false + t.string "Grant_priv", :limit => 1, :default => "N", :null => false + t.string "References_priv", :limit => 1, :default => "N", :null => false + t.string "Index_priv", :limit => 1, :default => "N", :null => false + t.string "Alter_priv", :limit => 1, :default => "N", :null => false + t.string "Show_db_priv", :limit => 1, :default => "N", :null => false + t.string "Super_priv", :limit => 1, :default => "N", :null => false + t.string "Create_tmp_table_priv", :limit => 1, :default => "N", :null => false + t.string "Lock_tables_priv", :limit => 1, :default => "N", :null => false + t.string "Execute_priv", :limit => 1, :default => "N", :null => false + t.string "Repl_slave_priv", :limit => 1, :default => "N", :null => false + t.string "Repl_client_priv", :limit => 1, :default => "N", :null => false + t.string "Create_view_priv", :limit => 1, :default => "N", :null => false + t.string "Show_view_priv", :limit => 1, :default => "N", :null => false + t.string "Create_routine_priv", :limit => 1, :default => "N", :null => false + t.string "Alter_routine_priv", :limit => 1, :default => "N", :null => false + t.string "Create_user_priv", :limit => 1, :default => "N", :null => false + t.string "Event_priv", :limit => 1, :default => "N", :null => false + t.string "Trigger_priv", :limit => 1, :default => "N", :null => false + t.string "Create_tablespace_priv", :limit => 1, :default => "N", :null => false + t.string "ssl_type", :limit => 9, :default => "", :null => false + t.binary "ssl_cipher", :null => false + t.binary "x509_issuer", :null => false + t.binary "x509_subject", :null => false + t.integer "max_questions", :default => 0, :null => false + t.integer "max_updates", :default => 0, :null => false + t.integer "max_connections", :default => 0, :null => false + t.integer "max_user_connections", :default => 0, :null => false + t.string "plugin", :limit => 64, :default => "" + t.text "authentication_string" + end + create_table "user_activities", :force => true do |t| t.string "act_type" t.integer "act_id" diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 84e087c49..f3ca6fafa 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -2,10 +2,20 @@ function course_setting(id) { //alert(id); - $('#tb_'+id).removeClass().addClass("hwork_hovertab"); - $('#tbc_0'+id).removeClass().addClass("dis"); - $('#tb_'+(3-id)).removeClass().addClass("hwork_normaltab"); - $('#tbc_0'+(3-id)).removeClass().addClass("undis"); + //$('#tb_'+id).removeClass().addClass("hwork_hovertab"); + //$('#tbc_0'+id).removeClass().addClass("dis"); + //$('#tb_'+(3-id)).removeClass().addClass("hwork_normaltab"); + //$('#tbc_0'+(3-id)).removeClass().addClass("undis"); + for (var i = 1; i < 4; i++) { + if (i == id) { + $("#tb_" + i).removeClass().addClass("hwork_hovertab"); + $("#tbc_0" + i).removeClass().addClass("dis"); + } + else { + $("#tb_" + i).removeClass().addClass("hwork_normaltab"); + $("#tbc_0" + i).removeClass().addClass("undis"); + } + } } $(function(){ diff --git a/public/javascripts/project.js b/public/javascripts/project.js index a31ae2356..c3888aec7 100644 --- a/public/javascripts/project.js +++ b/public/javascripts/project.js @@ -526,4 +526,18 @@ function jsCopy2(id){ function zip(){ alert("该功能正在紧张的开发中,我们会争取在最短时间内上线,如若对您工作造成不便敬请谅解!") +} + +//取消关联 +function cancel_relation(orgId,projectId){ + $.ajax({ + url:'/org_projects/'+orgId+"?project_id="+projectId, + type:'DELETE', + success:function(data) { + $.ajax({ + url: ' /projects/'+projectId+'/search_public_orgs_not_in_project', + type:'get' + }); + } + }); } \ No newline at end of file diff --git a/spec/controllers/org_courses_controller_spec.rb b/spec/controllers/org_courses_controller_spec.rb new file mode 100644 index 000000000..d8c3b3b91 --- /dev/null +++ b/spec/controllers/org_courses_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe OrgCoursesController, :type => :controller do + +end From 4a0865ab76a55b9aa36da8109b9509a846ec14d8 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 17 Nov 2015 18:20:47 +0800 Subject: [PATCH 027/191] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=92=8C=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E9=A2=98=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 84 +++++++++++++++++++------- 1 file changed, 62 insertions(+), 22 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 3870fe9c5..2237a9cfe 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -21,7 +21,7 @@ class ExerciseController < ApplicationController render_403 return end - #已提交问卷的用户不能再访问该界面 + # 已提交问卷的用户不能再访问该界面 if has_commit_exercise?(@exercise.id, User.current.id) && (!User.current.admin?) redirect_to poll_index_url(:course_id=> @course.id) else @@ -67,20 +67,10 @@ class ExerciseController < ApplicationController end def destroy - if @exercise && @exercise.destroy - if @is_teacher - polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id}") - else - polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id} and polls_status = 2") - end - @polls = paginateHelper polls,20 #分页 - respond_to do |format| - format.js - end - end + end - #统计结果 + # 统计结果 def statistics_result @exercise = Exercise.find(params[:id]) exercise_questions = @exercise.poll_questions @@ -90,17 +80,16 @@ class ExerciseController < ApplicationController end end - #添加题目 - #question_type 1:单选 2:多选 3:填空题 + # 添加题目 + # question_type 1:单选 2:多选 3:填空题 def create_exercise_question question_title = params[:exercise_questions_title].nil? || params[:poll_questions_title].empty? ? l(:label_enter_single_title) : params[:poll_questions_title] option = { - :is_necessary => (params[:is_necessary]=="true" ? 1 : 0), :question_title => question_title, :question_type => params[:question_type] || 1, - :question_number => @poll.poll_questions.count + 1 + :question_number => @exercise.exercise_questions.count + 1 } - @poll_questions = @poll.poll_questions.new option + @exercise_questions = @exercise.exercise_questions.new option if params[:question_answer] for i in 1..params[:question_answer].count answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1] @@ -108,15 +97,15 @@ class ExerciseController < ApplicationController :answer_position => i, :answer_text => answer } - @poll_questions.poll_answers.new question_option + @exercise_questions.poll_answers.new question_option end end # 如果是插入的话,那么从插入的这个id以后的question_num都将要+1 if params[:quest_id] @is_insert = true - @poll.poll_questions.where("question_number > #{params[:quest_num].to_i}").update_all(" question_number = question_number + 1") - @poll_question_num = params[:quest_num].to_i - @poll_questions.question_number = params[:quest_num].to_i + 1 + @exercise.exercise_questions.where("question_number > #{params[:quest_num].to_i}").update_all(" question_number = question_number + 1") + # @exercise_question_num = params[:quest_num].to_i + @exercise_questions.question_number = params[:quest_num].to_i + 1 end if @poll_questions.save respond_to do |format| @@ -126,6 +115,57 @@ class ExerciseController < ApplicationController end + # 修改题目 + # params[:exercise_question] The id of exercise_question + # params[:question_answer] eg:A、B、C选项 + def update_exercise_question + @exercise_question = ExerciseQuestion.find params[:exercise_question] + @exercise_questions.question_title = params[:exercise_questions_title].nil? || params[:exercise_questions_title].empty? ? l(:label_enter_single_title) : params[:exercise_questions_title] + ################处理选项 + if params[:question_answer] + @exercise_question.exercise_answers.each do |answer| + answer.destroy unless params[:question_answer].keys.include? answer.id.to_s + end + # 界面需要判断选择题至少有一个选项 + for i in 1..params[:question_answer].count + question = @exercise_question.exercise_answers.find_by_id params[:question_answer].keys[i-1] + answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1] + if question + question.exercise_choices_id = i + question.answer_text = answer + question.save + else + question_option = { + :exercise_choices_id => i, + :answer_text => answer + } + @exercise_question.exercise_answers.new question_option + end + end + end + @exercise_question.save + respond_to do |format| + format.js + end + end + + # 删除题目 + def delete_exercise_question + @exercise_question = ExerciseQuestion.find params[:exercise_question] + @exercise = @exercise_question.exercise + exercise_questions = @exercise.exercise_questions.where("question_number > #{@exercise_question.question_number}") + poll_questions.each do |question| + question.question_number -= 1 + question.save + end + if @poll_question && @poll_question.destroy + respond_to do |format| + format.js + end + end + end + + #发布问卷 def publish_excercise @exercise.exercise_status = 2 From cc08e5e32e47bb8118c07deccd299454945f7441 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 17 Nov 2015 18:22:31 +0800 Subject: [PATCH 028/191] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E6=B5=8B=E9=AA=8C?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 22 ++++++- app/views/exercise/_edit_head.html.erb | 62 ++++++++++++------- app/views/exercise/_exercise_content.html.erb | 2 +- app/views/exercise/_exercise_form.html.erb | 31 +++++++--- app/views/exercise/_new_single.html.erb | 8 +-- app/views/exercise/_show_head.html.erb | 6 ++ app/views/exercise/create.js.erb | 4 ++ app/views/exercise/edit.html.erb | 3 +- public/stylesheets/courses.css | 3 +- 9 files changed, 101 insertions(+), 40 deletions(-) create mode 100644 app/views/exercise/_show_head.html.erb create mode 100644 app/views/exercise/create.js.erb diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index ce3412caa..6f275530e 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -1,7 +1,7 @@ class ExerciseController < ApplicationController layout "base_courses" - before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list] + before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list,:edit] def index @is_teacher = User.current.allowed_to?(:as_teacher,@course) if @is_teacher @@ -27,10 +27,28 @@ class ExerciseController < ApplicationController end def create - + if params[:exercise] + exercise = Exercise.find(params[:exercise_id]) if params[:exercise_id] + exercise ||= Exercise.new + exercise.exercise_name = params[:exercise][:exercise_name] + exercise.exercise_description = params[:exercise][:exercise_description] + exercise.end_time = params[:exercise][:end_time] + exercise.publish_time = params[:exercise][:publish_time] + exercise.user_id = User.current.id + exercise.time = params[:exercise][:time] + exercise.course_id = params[:course_id] + exercise.exercise_status = 1 + if exercise.save + @exercise = exercise + respond_to do |format| + format.js + end + end + end end def edit + @exercise = Exercise.find params[:id] respond_to do |format| format.html{render :layout => 'base_courses'} end diff --git a/app/views/exercise/_edit_head.html.erb b/app/views/exercise/_edit_head.html.erb index b315d343c..a66d9dbb2 100644 --- a/app/views/exercise/_edit_head.html.erb +++ b/app/views/exercise/_edit_head.html.erb @@ -1,24 +1,38 @@ -
            -
            - -
            - <%# if edit_mode %> - - <%# end %> -
            - - <%= calendar_for('homework_end_time')%> -
            - <%# if edit_mode %> - - <%# end %> -
            - - <%= calendar_for('homework_publish_time')%> -
            -
            考试时长:分钟
            -
            - - 保存 取消 -
            -
            \ No newline at end of file +<%= form_for(@exercise, + :html => { :multipart => true }, + :url => {:controller => 'exercise', + :action => 'create', + :course_id => @course.id + },:remote=>true ) do |f| %> +
            +
            + +
            + <%# if edit_mode %> + + <%# end %> +
            + + <%= calendar_for('exercise_publish_time')%> +
            + <%# if edit_mode %> + + <%# end %> +
            + + <%= calendar_for('exercise_end_time')%> +
            +
            考试时长:分钟
            +
            + + +
            +
            +<% end %> \ No newline at end of file diff --git a/app/views/exercise/_exercise_content.html.erb b/app/views/exercise/_exercise_content.html.erb index 76bad6a83..bffd7e221 100644 --- a/app/views/exercise/_exercise_content.html.erb +++ b/app/views/exercise/_exercise_content.html.erb @@ -1,5 +1,5 @@ -<% poll.exercise_questions.each do |poll_question|%> +<% exercise.exercise_questions.each do |poll_question|%>
            - <%= render :partial => 'edit_head', :locals => {:poll => @exercise}%> + <%= render :partial => 'edit_head', :locals => {:exercise => @exercise}%>
            - <%= render :partial => 'exercise_content', :locals => {:poll => @exercise}%> + <%= render :partial => 'exercise_content', :locals => {:exercise => @exercise}%>
            @@ -321,7 +334,11 @@
            -
            发布 + +
            +
            + +
            提交
            diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb index 0082303b7..8ef1e1e04 100644 --- a/app/views/exercise/_new_single.html.erb +++ b/app/views/exercise/_new_single.html.erb @@ -2,23 +2,23 @@
            - +
            • - +
            • - +
            • - +
            diff --git a/app/views/exercise/_show_head.html.erb b/app/views/exercise/_show_head.html.erb new file mode 100644 index 000000000..f7d2b9295 --- /dev/null +++ b/app/views/exercise/_show_head.html.erb @@ -0,0 +1,6 @@ +
            + +

            <%= exercise.exercise_name%>

            + <%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%> +
            +
            \ No newline at end of file diff --git a/app/views/exercise/create.js.erb b/app/views/exercise/create.js.erb new file mode 100644 index 000000000..65b8dd327 --- /dev/null +++ b/app/views/exercise/create.js.erb @@ -0,0 +1,4 @@ +$("#polls_head_show").html("<%= escape_javascript(render :partial => 'show_head', :locals => {:exercise => @exercise}) %>"); +$("#polls_head_edit").html("<%= escape_javascript(render :partial => 'edit_head', :locals => {:exercise => @exercise}) %>"); +$("#polls_head_edit").hide(); +$("#polls_head_show").show(); \ No newline at end of file diff --git a/app/views/exercise/edit.html.erb b/app/views/exercise/edit.html.erb index 0b20dc90e..aef506ad8 100644 --- a/app/views/exercise/edit.html.erb +++ b/app/views/exercise/edit.html.erb @@ -1 +1,2 @@ -<%= render :partial => 'exercise_form'%> \ No newline at end of file +<%#= render :partial => 'exercise_form'%> +111 \ No newline at end of file diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index fdba7426a..da393afaa 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -713,6 +713,7 @@ img.ui-datepicker-trigger { width:16px; height:15px; float:left; + margin: 7px; } .label{ width:80px; text-align:right; font-size:14px; display:block; float:left;} @@ -1146,7 +1147,7 @@ input.sendSourceText { /*20151117在线测验byTim*/ .testContainer {width:698px; border:1px solid #cbcbcb;background:#eeeeee; padding:10px; margin-bottom:10px;} .testTitle{ width:678px; height:40px; padding:0 10px; text-align:center; font-size:16px; font-weight:bold; background:#fff;border-style:solid; border:1px solid #CBCBCB;} -.testDes{ width:678px; height:120px; padding:10px; margin-bottom:10px; background:#fff; border-style:solid; border:1px solid #CBCBCB; resize:none;} +.testDes{ width:678px; height:60px; padding:10px; margin-bottom:10px; background:#fff; border-style:solid; border:1px solid #CBCBCB; resize:none;} .btn_submit{ width:56px; height:24px; padding-top:4px;background:#269ac9; color:#fff; text-align:center; display:block; float:left; margin-right:10px;} a:hover.btn_submit{background:#297fb8;} .btn_cancel{width:54px; height:22px; padding-top:4px;background:#fff; color:#999; border:1px solid #999; text-align:center; display:block; float:left; } From f68ffc99ec9e8fa51a43c62a491dd4c9d65095a1 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 17 Nov 2015 18:26:39 +0800 Subject: [PATCH 029/191] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=8D=95=E9=80=89?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_new_MC.html.erb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/exercise/_new_MC.html.erb b/app/views/exercise/_new_MC.html.erb index 0ff662b3f..db61316fe 100644 --- a/app/views/exercise/_new_MC.html.erb +++ b/app/views/exercise/_new_MC.html.erb @@ -1,3 +1,4 @@ +<%= form_for ExerciseQuestion.new,:url =>create_exercise_question_exercise_path(@exercise.id),:remote => true do |f|%>
            @@ -35,4 +36,5 @@
            -
            \ No newline at end of file +
            +<% end %> \ No newline at end of file From b635fdaeb775b8f7aaa5fb719c72c0b8d50ecde0 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 17 Nov 2015 18:33:42 +0800 Subject: [PATCH 030/191] =?UTF-8?q?=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/routes.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/routes.rb b/config/routes.rb index 1a66d2424..b1e4725e6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -152,6 +152,7 @@ RedmineApp::Application.routes.draw do get 'statistics_result' get 'student_exercise_list' get 'export_exercise' + post 'create_exercise_question' end collection do #生成路径为 /exercise/方法名 From 99f4483a161f2600d04081e50dec105e51f4c21a Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 17 Nov 2015 18:34:01 +0800 Subject: [PATCH 031/191] =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=97=AE=E5=8D=B7?= =?UTF-8?q?=EF=BC=88=E6=9C=AA=E5=AE=8C=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 2237a9cfe..46173c499 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -158,7 +158,7 @@ class ExerciseController < ApplicationController question.question_number -= 1 question.save end - if @poll_question && @poll_question.destroy + if @exercise_question && @exercise_question.destroy respond_to do |format| format.js end From 3cdda2a60a02ce2c9668ff94b8a6a0f5cb9801d1 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 17 Nov 2015 19:29:25 +0800 Subject: [PATCH 032/191] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 33 ++++++++++++++++++++------ 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index f58abc53f..8fa5e0230 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -1,7 +1,9 @@ class ExerciseController < ApplicationController layout "base_courses" + before_filter :find_exercise_and_course, :only => [:create_exercise_question] before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list,:edit] + def index @is_teacher = User.current.allowed_to?(:as_teacher,@course) if @is_teacher @@ -36,9 +38,19 @@ class ExerciseController < ApplicationController end def new - @exercise = Exercise.new - respond_to do |format| - format.html{render :layout => 'base_courses'} + option = { + :exercise_name => "", + :course_id => @course.id, + :exercise_status => 1, + :user_id => User.current.id, + :time => Time.now, + :end_time => Time.now, + :publish_time => Time.now, + :polls_description => "" + } + @exercise = Exercise.create option + if @exercise + redirect_to edit_exercise_url @exercise.id end end @@ -71,10 +83,10 @@ class ExerciseController < ApplicationController end def update - @exercise.exercise_name = params[:exercise_name] - @exercise.exercise_description = params[:exercise_name] - @exercise.start_at = params[:start_at] - @exercise.end_at = params[:end_at] + @exercise.exercise_name = params[:exercise][:exercise_name] + @exercise.exercise_description = params[:exercise][:exercise_description] + @exercise.time = params[:exercise][:time] + @exercise.end_time = params[:exercise][:end_time] if @exercise.save respond_to do |format| format.js @@ -218,6 +230,13 @@ class ExerciseController < ApplicationController end private + def find_exercise_and_course + @exercise = Exercise.find params[:id] + @course = Course.find @exercise.course_id + rescue Exception => e + render_404 + end + def find_course @course = Course.find params[:course_id] rescue Exception => e From 631418a01242b80adc4f3b81e951d2af6c412a6b Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 17 Nov 2015 19:33:14 +0800 Subject: [PATCH 033/191] =?UTF-8?q?=E5=8D=95=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_edit_head.html.erb | 2 +- app/views/exercise/_new_MC.html.erb | 39 ++++++++++++++++++-------- app/views/exercise/_new_MCQ.html.erb | 4 +-- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/app/views/exercise/_edit_head.html.erb b/app/views/exercise/_edit_head.html.erb index a66d9dbb2..14a67bd29 100644 --- a/app/views/exercise/_edit_head.html.erb +++ b/app/views/exercise/_edit_head.html.erb @@ -1,7 +1,7 @@ <%= form_for(@exercise, :html => { :multipart => true }, :url => {:controller => 'exercise', - :action => 'create', + :action => 'update', :course_id => @course.id },:remote=>true ) do |f| %>
            diff --git a/app/views/exercise/_new_MC.html.erb b/app/views/exercise/_new_MC.html.erb index db61316fe..87cd22d81 100644 --- a/app/views/exercise/_new_MC.html.erb +++ b/app/views/exercise/_new_MC.html.erb @@ -1,31 +1,45 @@ -<%= form_for ExerciseQuestion.new,:url =>create_exercise_question_exercise_path(@exercise.id),:remote => true do |f|%> +<%#= form_for ExerciseQuestion.new,:url =>create_exercise_question_exercise_path(@exercise.id),:remote => true do |f|%> +<%= form_for(ExerciseQuestion.new, + :html => { :multipart => true }, + :url => {:controller => 'exercise', + :action => 'create_exercise_question', + :course_id => @course.id + },:remote=>true ) do |f| %>
            - +
            • - -
            • + + + +
            • - -
            • + + + +
            • - -
            • + + + +
            • - -
            • + + + +
            • @@ -34,7 +48,10 @@
            - +
            <% end %> \ No newline at end of file diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb index 0ba2a0133..cabd9bf57 100644 --- a/app/views/exercise/_new_MCQ.html.erb +++ b/app/views/exercise/_new_MCQ.html.erb @@ -1,8 +1,8 @@
            - - + +
            diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index efcd15a66..408be0aa3 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -79,6 +79,7 @@ <%= render :partial => 'attachments_links', :locals => {:attachments => @memo.attachments, :options => options, :is_float => true} %> <% end %>
            +
            最后更新:<%= format_date(@memo.updated_at)%>
            From 282c7f5bd2fe7c7779164af93a201f762bc51d5c Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 18 Nov 2015 10:46:56 +0800 Subject: [PATCH 040/191] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=A2=98=E7=9B=AE=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 18 +++++++++++------- ...151118014720_add_show_result_to_exercise.rb | 5 +++++ ..._add_question_score_to_exercise_question.rb | 5 +++++ db/schema.rb | 4 +++- 4 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 db/migrate/20151118014720_add_show_result_to_exercise.rb create mode 100644 db/migrate/20151118015638_add_question_score_to_exercise_question.rb diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 8ca8ca31f..c892b6583 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -1,8 +1,9 @@ class ExerciseController < ApplicationController layout "base_courses" - before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit,:update] + before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show] before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list] + helper :Exercise def index remove_invalid_exercise(@course) @@ -47,7 +48,8 @@ class ExerciseController < ApplicationController :time => "", :end_time => "", :publish_time => "", - :exercise_description => "" + :exercise_description => "", + :show_result => "" } @exercise = Exercise.create option if @exercise @@ -88,6 +90,7 @@ class ExerciseController < ApplicationController @exercise.time = params[:exercise][:time] @exercise.end_time = params[:exercise][:end_time] @exercise.publish_time = params[:exercise][:publish_time] + @exercise.publish_time = params[:exercise][:show_result] if @exercise.save respond_to do |format| format.js @@ -118,17 +121,18 @@ class ExerciseController < ApplicationController option = { :question_title => question_title, :question_type => params[:question_type] || 1, - :question_number => @exercise.exercise_questions.count + 1 + :question_number => @exercise.exercise_questions.count + 1, + :question_score => params[:question_score] } @exercise_questions = @exercise.exercise_questions.new option if params[:question_answer] for i in 1..params[:question_answer].count answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1] question_option = { - :exercise_choice_id => i, - :answer_text => answer + :choice_position => i, + :choice_text => answer } - @exercise_questions.exercise_answers.new question_option + @exercise_questions.exercise_choices.new question_option end end # 如果是插入的话,那么从插入的这个id以后的question_num都将要+1 @@ -141,7 +145,7 @@ class ExerciseController < ApplicationController if @exercise_questions.save standart_answer = ExerciseStandardAnswer.new standart_answer.exercise_question_id = @exercise_questions.id - standart_answer.exercise_choice_id = params[:exercise_choice] + @exercise_questions.question_type == 3 ? standart_answer.answer_text = params[:exercise_choice] : standart_answer.exercise_choice_id = params[:exercise_choice] standart_answer.save respond_to do |format| format.js diff --git a/db/migrate/20151118014720_add_show_result_to_exercise.rb b/db/migrate/20151118014720_add_show_result_to_exercise.rb new file mode 100644 index 000000000..8148a277d --- /dev/null +++ b/db/migrate/20151118014720_add_show_result_to_exercise.rb @@ -0,0 +1,5 @@ +class AddShowResultToExercise < ActiveRecord::Migration + def change + add_column :exercises, :show_result, :integer + end +end diff --git a/db/migrate/20151118015638_add_question_score_to_exercise_question.rb b/db/migrate/20151118015638_add_question_score_to_exercise_question.rb new file mode 100644 index 000000000..a3235dcad --- /dev/null +++ b/db/migrate/20151118015638_add_question_score_to_exercise_question.rb @@ -0,0 +1,5 @@ +class AddQuestionScoreToExerciseQuestion < ActiveRecord::Migration + def change + add_column :exercise_questions, :question_score, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 25d561e86..8d506225f 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 => 20151116071721) do +ActiveRecord::Schema.define(:version => 20151118015638) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -544,6 +544,7 @@ ActiveRecord::Schema.define(:version => 20151116071721) do t.integer "exercise_id" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false + t.integer "question_score" end create_table "exercise_standard_answers", :force => true do |t| @@ -574,6 +575,7 @@ ActiveRecord::Schema.define(:version => 20151116071721) do t.datetime "updated_at", :null => false t.datetime "publish_time" t.datetime "end_time" + t.integer "show_result" end create_table "first_pages", :force => true do |t| From 265fe08b2c7638d4b8d21db4ffa809f8bff10004 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 18 Nov 2015 10:49:57 +0800 Subject: [PATCH 041/191] =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E6=B5=8B=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 1 + app/helpers/exercise_helper.rb | 11 +++++- app/views/exercise/_edit_MC.html.erb | 0 app/views/exercise/_edit_MCQ.html.erb | 0 app/views/exercise/_edit_head.html.erb | 4 +- app/views/exercise/_edit_single.html.erb | 0 app/views/exercise/_exercise_content.html.erb | 37 +++++++++--------- app/views/exercise/_exercise_form.html.erb | 4 +- app/views/exercise/_new_MC.html.erb | 9 ++++- app/views/exercise/_new_MCQ.html.erb | 39 +++++++++++++------ app/views/exercise/_new_single.html.erb | 14 +++++-- app/views/exercise/_show_MC.html.erb | 36 +++++++++++++++++ app/views/exercise/_show_MCQ.html.erb | 0 app/views/exercise/_show_head.html.erb | 14 +++++-- app/views/exercise/_show_single.html.erb | 0 public/stylesheets/courses.css | 11 +++++- 16 files changed, 134 insertions(+), 46 deletions(-) create mode 100644 app/views/exercise/_edit_MC.html.erb create mode 100644 app/views/exercise/_edit_MCQ.html.erb create mode 100644 app/views/exercise/_edit_single.html.erb create mode 100644 app/views/exercise/_show_MC.html.erb create mode 100644 app/views/exercise/_show_MCQ.html.erb create mode 100644 app/views/exercise/_show_single.html.erb diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 4d2e266b5..f51bf9a2c 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -4,6 +4,7 @@ class ExerciseController < ApplicationController before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit,:update] before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list] + include ExerciseHelper def index remove_invalid_exercise(@course) @is_teacher = User.current.allowed_to?(:as_teacher,@course) diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index 410a9936b..b9cd9c175 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -3,7 +3,7 @@ module ExerciseHelper #判断用户是否已经提交了问卷 def has_commit_exercise?(exercise_id, user_id) - pu = PollUser.find_by_poll_id_and_user_id(excercise_id, user_id) + pu = ExerciseUser.find_by_excercise_id_and_user_id(exercise_id, user_id) if pu.nil? false else @@ -11,4 +11,13 @@ module ExerciseHelper end end + def convert_to_char(str) + result = "" + if str.count >= 1 + for i in 0 .. str.count do i + result += (str[i].to_i + 64).chr + end + end + end + end \ No newline at end of file diff --git a/app/views/exercise/_edit_MC.html.erb b/app/views/exercise/_edit_MC.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/exercise/_edit_MCQ.html.erb b/app/views/exercise/_edit_MCQ.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/exercise/_edit_head.html.erb b/app/views/exercise/_edit_head.html.erb index 21326e2c8..9868a4465 100644 --- a/app/views/exercise/_edit_head.html.erb +++ b/app/views/exercise/_edit_head.html.erb @@ -7,14 +7,14 @@ <%# end %>
            - + " > <%= calendar_for('exercise_publish_time')%>
            <%# if edit_mode %> <%# end %>
            - + " > <%= calendar_for('exercise_end_time')%>
            考试时长:分钟
            diff --git a/app/views/exercise/_edit_single.html.erb b/app/views/exercise/_edit_single.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/exercise/_exercise_content.html.erb b/app/views/exercise/_exercise_content.html.erb index bffd7e221..9e139fe32 100644 --- a/app/views/exercise/_exercise_content.html.erb +++ b/app/views/exercise/_exercise_content.html.erb @@ -1,22 +1,21 @@ - -<% exercise.exercise_questions.each do |poll_question|%> -
            - - @@ -71,4 +71,16 @@ $("#search_orgs_result_list").html(""); $("#paginator").css("display", "none") } + function course_join_org(courseId) { + $.ajax({ + url: "/org_courses?" + $("#join_orgs_for_course").serialize() + "&course_id=" + courseId, + type: "post", + success: function (data) { + $.ajax({ + url: "/courses/" + courseId + "/search_public_orgs_not_in_course", + type: "get" + }); + } + }); + } \ No newline at end of file diff --git a/app/views/org_courses/create.js.erb b/app/views/org_courses/create.js.erb index d61120e1a..1bf7bc207 100644 --- a/app/views/org_courses/create.js.erb +++ b/app/views/org_courses/create.js.erb @@ -1,13 +1,2 @@ -$("#search_orgs_result_list").html(""); -$("#search_orgs_result_list").append('
              '); -<% @orgs_not_in_course.each do |org|%> - link = "
            • "; - $("#search_orgs_result_list").append(link ); -<% end %> -$("#search_orgs_result_list").append('
            ') -<% if @org_count > 10 %> - $("#paginator").html(' <%= pagination_links_full @orgs_page, @org_count ,:per_page_links => true,:remote =>true,:flag=>true %>'); -<% end %> - $("#added_orgs").html(""); -$("#added_orgs").html('<%= escape_javascript(render :partial => "courses/settings/added_orgs", :locals => {:orgs => @course.organizations, :course_id => @course.id}) %>') \ No newline at end of file +$("#added_orgs").html('<%= escape_javascript(render :partial => "courses/settings/added_orgs", :locals => {:orgs => @course.organizations, :course_id => @course.id}) %>'); \ No newline at end of file diff --git a/app/views/org_courses/destroy.js.erb b/app/views/org_courses/destroy.js.erb index 639a7625b..9984f6a4c 100644 --- a/app/views/org_courses/destroy.js.erb +++ b/app/views/org_courses/destroy.js.erb @@ -1,17 +1,4 @@ $("#added_orgs").html(""); -$("#added_orgs").html('<%= escape_javascript(render :partial => "courses/settings/added_orgs", :locals => {:orgs => @course.organizations, :course_id => @course.id}) %>') +$("#added_orgs").html('<%= escape_javascript(render :partial => "courses/settings/added_orgs", :locals => {:orgs => @course.organizations, :course_id => @course.id}) %>'); -$("#search_orgs_result_list").html(""); -$("#search_orgs_result_list").append('
              '); -<% @orgs_not_in_course.each do |org|%> - link = "
            • "; - $("#search_orgs_result_list").append(link ); -<%end %> -$("#search_orgs_result_list").append('
            ') -<% if @org_count > 10 %> - $("#paginator").html(' <%= pagination_links_full @orgs_page, @org_count ,:per_page_links => true,:remote =>true,:flag=>true%>'); - $("#paginator").css("display", "block"); -<% else %> - $("#paginator").css("display", "none"); -<% end %> diff --git a/app/views/org_projects/create.js.erb b/app/views/org_projects/create.js.erb index 23cbab024..ee3c67bbd 100644 --- a/app/views/org_projects/create.js.erb +++ b/app/views/org_projects/create.js.erb @@ -1,20 +1,2 @@ -$("#search_orgs_result_list").html(""); -$("#search_orgs_result_list").append('
              '); -<% @orgs_not_in_project.each do |org|%> - link = "
            • "; - $("#search_orgs_result_list").append(link ); -<%end %> -$("#search_orgs_result_list").append('
            ') -<% if @org_count > 10 %> - $("#paginator").html(' <%= pagination_links_full @orgs_page, @org_count ,:per_page_links => true,:remote =>true,:flag=>true %>'); -//$("#paginator").css("display", "block"); - -//$("#paginator").css("display", "none"); -<% end %> - - -//$("#search_orgs_result_list").html(""); -//$("#search_orgs_result_list").append('
              '); -//$("#paginator").css("display", "none"); $("#added_orgs").html(""); $("#added_orgs").html('<%= escape_javascript(render :partial => "projects/settings/added_orgs", :locals => {:orgs => @project.organizations, :project_id => @project.id}) %>') \ No newline at end of file diff --git a/app/views/org_projects/destroy.js.erb b/app/views/org_projects/destroy.js.erb index 49ea1dc33..f8927280a 100644 --- a/app/views/org_projects/destroy.js.erb +++ b/app/views/org_projects/destroy.js.erb @@ -1,22 +1,4 @@ -//$("#search_orgs_result_list").html(""); -////$("#paginator").css("display", "none"); $("#added_orgs").html(""); -$("#added_orgs").html('<%= escape_javascript(render :partial => "projects/settings/added_orgs", :locals => {:orgs => @project.organizations, :project_id => @project.id}) %>') -//$.ajax({ -// url: '<%#= url_for(:controller => 'projects', :action => 'search_public_orgs_not_in_project') %>'+'?page=1', -// type:'get' -//}); -$("#search_orgs_result_list").html(""); -$("#search_orgs_result_list").append('
                '); -<% @orgs_not_in_project.each do |org|%> -link = "
              • "; -$("#search_orgs_result_list").append(link ); -<%end %> -$("#search_orgs_result_list").append('
              ') -<% if @org_count > 10 %> -$("#paginator").html(' <%= pagination_links_full @orgs_page, @org_count ,:per_page_links => true,:remote =>true,:flag=>true%>'); -$("#paginator").css("display", "block"); -<% else %> -$("#paginator").css("display", "none"); -<% end %> +$("#added_orgs").html('<%= escape_javascript(render :partial => "projects/settings/added_orgs", :locals => {:orgs => @project.organizations, :project_id => @project.id}) %>'); + diff --git a/app/views/projects/search_public_orgs_not_in_project.js.erb b/app/views/projects/search_public_orgs_not_in_project.js.erb index 69005d304..6599e97f7 100644 --- a/app/views/projects/search_public_orgs_not_in_project.js.erb +++ b/app/views/projects/search_public_orgs_not_in_project.js.erb @@ -1,3 +1,9 @@ +//翻页提醒 +if($("#join_orgs_for_project input:checked").size() > 0) +{ + alert('翻页或搜索后将丢失当前选择的用户数据!'); +} + $("#search_orgs_result_list").html(""); $("#search_orgs_result_list").append('
                '); <% @orgs_not_in_project.each do |org|%> diff --git a/app/views/projects/settings/_join_org.html.erb b/app/views/projects/settings/_join_org.html.erb index 5733623a2..ca3cafed5 100644 --- a/app/views/projects/settings/_join_org.html.erb +++ b/app/views/projects/settings/_join_org.html.erb @@ -11,12 +11,13 @@
                关联组织
                - <%= form_tag url_for(:controller => 'org_projects', :action => 'create', :project_id => @project.id), :id => 'join_orgs_for_project', :remote => true %> - -
                -
                  - 关联 - 取消 + <%= form_tag url_for(:controller => 'org_projects', :action => 'create', :project_id => @project.id), :id => 'join_orgs_for_project', :remote => true do %> + +
                  +
                    + 关联 + 取消 + <% end %>
                    @@ -59,7 +60,6 @@ $("input[name='orgs']").on('input', function (e) { throttle(search_orgs,window,e); }); - $(document).ready(function(){ $.ajax({ url: '<%= url_for(:controller => 'projects', :action => 'search_public_orgs_not_in_project') %>'+'?page=1', @@ -71,4 +71,16 @@ $("#paginator").html(""); $("#paginator").css("display", "none"); } + function join_org(projectId) { + $.ajax({ + url: '/org_projects' + "?" + $('#join_orgs_for_project').serialize() + "&project_id=" + projectId, + type: 'post', + success: function (data) { + $.ajax({ + url: '/projects/'+projectId+'/search_public_orgs_not_in_project', + type: 'get' + }); + } + }); + } \ No newline at end of file diff --git a/public/javascripts/course.js b/public/javascripts/course.js index f3ca6fafa..80e39ea4f 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -1286,6 +1286,20 @@ function course_outline(id){ ' /courses/'+id+'/course_outline'+"?is_in_show_outline_page="+(arguments[1] ? arguments[1] : 'N') ) } + +//取消课程组织关联 +function cancel_org_course_relation(id, courseId){ + $.ajax({ + url:"/org_courses/" + id + "?course_id=" + courseId, + type: "delete", + success:function(data){ + $.ajax({ + url: "/courses/" + courseId + "/search_public_orgs_not_in_course", + type:'get' + }); + } + }); +} //$(function(){ // $('#course_outline_search').on('input',function(){ // alert('<%= @course.id%>') From b231b44e81f894347a4b5baf9f2ece8717f127a6 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 18 Nov 2015 11:12:40 +0800 Subject: [PATCH 043/191] =?UTF-8?q?1.=E9=A1=B9=E7=9B=AE=E5=92=8C=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E4=B8=AD=EF=BC=8C=E6=B7=BB=E5=8A=A0=E7=BF=BB=E9=A1=B5?= =?UTF-8?q?=E6=8F=90=E9=86=92=EF=BC=9B=202.=E9=A1=B9=E7=9B=AE=E5=92=8C?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=B8=AD=EF=BC=8C=E5=88=A0=E9=99=A4=E7=BB=84?= =?UTF-8?q?=E7=BB=87=E5=85=B3=E8=81=94=E6=97=B6=EF=BC=8C=E7=BB=99=E5=87=BA?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=EF=BC=8C=E7=A1=AE=E8=AE=A4=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/search_public_orgs_not_in_course.js.erb | 4 ++++ public/javascripts/course.js | 1 + public/javascripts/project.js | 1 + 3 files changed, 6 insertions(+) diff --git a/app/views/courses/search_public_orgs_not_in_course.js.erb b/app/views/courses/search_public_orgs_not_in_course.js.erb index 76f9bcedb..084583d2a 100644 --- a/app/views/courses/search_public_orgs_not_in_course.js.erb +++ b/app/views/courses/search_public_orgs_not_in_course.js.erb @@ -1,3 +1,7 @@ +if($("#join_orgs_for_course input:checked").size() > 0) +{ + alert("翻页或搜索后将丢失当前选择的用户数据"); +} $("#search_orgs_result_list").html(""); $("#search_orgs_result_list").append('
                      '); <% @orgs_not_in_course.each do |org|%> diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 80e39ea4f..5d89e6442 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -1289,6 +1289,7 @@ function course_outline(id){ //取消课程组织关联 function cancel_org_course_relation(id, courseId){ + if(confirm("确定取消关联吗?") == false) return; $.ajax({ url:"/org_courses/" + id + "?course_id=" + courseId, type: "delete", diff --git a/public/javascripts/project.js b/public/javascripts/project.js index c3888aec7..31d487bd9 100644 --- a/public/javascripts/project.js +++ b/public/javascripts/project.js @@ -530,6 +530,7 @@ function zip(){ //取消关联 function cancel_relation(orgId,projectId){ + if(confirm("确定取消关联吗?") == false) return; $.ajax({ url:'/org_projects/'+orgId+"?project_id="+projectId, type:'DELETE', From f6251b758b1068727e14df1d8bfaa2a4df9aeaeb Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 18 Nov 2015 12:55:18 +0800 Subject: [PATCH 044/191] =?UTF-8?q?1.=E8=BF=81=E7=A7=BB=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=95=B0=E6=8D=AE=E8=87=B3=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E5=8A=A8=E6=80=81=202.=E2=80=9C=E9=A1=B9=E7=9B=AE=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E8=BF=81=E7=A7=BB=E8=87=B3=E7=BB=84=E7=BB=87=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E2=80=9D=E8=BF=81=E7=A7=BB=E6=96=87=E4=BB=B6=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=BA=8B=E7=89=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...copy_forge_activities_to_org_activities.rb | 21 ++++++++++++------- ...opy_course_activities_to_org_activities.rb | 21 +++++++++++++++++++ 2 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 db/migrate/20151118031602_copy_course_activities_to_org_activities.rb diff --git a/db/migrate/20151116020842_copy_forge_activities_to_org_activities.rb b/db/migrate/20151116020842_copy_forge_activities_to_org_activities.rb index 95c4ed5bf..d3ded425e 100644 --- a/db/migrate/20151116020842_copy_forge_activities_to_org_activities.rb +++ b/db/migrate/20151116020842_copy_forge_activities_to_org_activities.rb @@ -1,13 +1,18 @@ class CopyForgeActivitiesToOrgActivities < ActiveRecord::Migration def up - ForgeActivity.all.each do |forge_act| - OrgActivity.create(:user_id => forge_act.user_id, - :org_act_id => forge_act.forge_act_id, - :org_act_type => forge_act.forge_act_type, - :container_id => forge_act.project_id, - :container_type => 'Project', - :created_at => forge_act.created_at, - :updated_at => forge_act.updated_at) + count = ForgeActivity.all.count/30 + 1 + for i in 1 ... count do + transaction do + ForgeActivity.page(i).per(30).each do + OrgActivity.create(:user_id => forge_act.user_id, + :org_act_id => forge_act.forge_act_id, + :org_act_type => forge_act.forge_act_type, + :container_id => forge_act.project_id, + :container_type => 'Project', + :created_at => forge_act.created_at, + :updated_at => forge_act.updated_at) + end + end end end diff --git a/db/migrate/20151118031602_copy_course_activities_to_org_activities.rb b/db/migrate/20151118031602_copy_course_activities_to_org_activities.rb new file mode 100644 index 000000000..e616064e7 --- /dev/null +++ b/db/migrate/20151118031602_copy_course_activities_to_org_activities.rb @@ -0,0 +1,21 @@ +class CopyCourseActivitiesToOrgActivities < ActiveRecord::Migration + def up + count = CourseActivity.all.count/30 + 1 + for i in 1 ... count do + transaction do + CourseActivity.page(i).per(30).each do |course_act| + OrgActivity.create(:user_id => course_act.user_id, + :org_act_type => course_act.course_act_type, + :org_act_id => course_act.course_act_id, + :container_id => course_act.course_id, + :container_type => "Course", + :created_at => course_act.created_at, + :updated_at => course_act.updated_at) + end + end + end + end + + def down + end +end From deb0f151c477fec0e023038e8791182f71acea33 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 18 Nov 2015 13:55:42 +0800 Subject: [PATCH 045/191] =?UTF-8?q?=E5=8D=95=E9=80=89=E6=95=B0=E5=AD=97?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 27 +++++++++++++++++++++++--- app/helpers/exercise_helper.rb | 7 ++++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index c892b6583..d06f4ee8d 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -3,7 +3,7 @@ class ExerciseController < ApplicationController before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show] before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list] - helper :Exercise + include ExerciseHelper def index remove_invalid_exercise(@course) @@ -29,7 +29,7 @@ class ExerciseController < ApplicationController if has_commit_exercise?(@exercise.id, User.current.id) && (!User.current.admin?) redirect_to exercise_index_url(:course_id=> @course.id) else - @can_edit_poll = (!has_commit_exercise?(@exercise.id,User.current.id)) || User.current.admin? + @can_edit_excercise = (!has_commit_exercise?(@exercise.id,User.current.id)) || User.current.admin? @percent = get_percent(@exercise,User.current) exercise_questions = @exercise.exercise_questions @exercise_questions = paginateHelper exercise_questions,5 #分页 @@ -145,7 +145,7 @@ class ExerciseController < ApplicationController if @exercise_questions.save standart_answer = ExerciseStandardAnswer.new standart_answer.exercise_question_id = @exercise_questions.id - @exercise_questions.question_type == 3 ? standart_answer.answer_text = params[:exercise_choice] : standart_answer.exercise_choice_id = params[:exercise_choice] + @exercise_questions.question_type == 3 ? standart_answer.answer_text = translate_standard_answer(params[:exercise_choice]) : standart_answer.exercise_choice_id = translate_standard_answer(params[:exercise_choice]) standart_answer.save respond_to do |format| format.js @@ -239,6 +239,27 @@ class ExerciseController < ApplicationController end private + def get_complete_question(exercise,user) + questions = exercise.exercise_questions + complete_question = [] + questions.each do |question| + answers = get_user_answer(question,user) + if !(answers.nil? || answers.count < 1) + complete_question << question + end + end + complete_question + end + + def get_percent exercise,user + complete_count = get_complete_question(exercise,user).count + if exercise.exercise_questions.count == 0 + return 0 + else + return (complete_count.to_f / exercise.exercise_questions.count.to_f)*100 + end + end + def remove_invalid_exercise(course) exercises = course.exercises.where("exercise_name=?","") unless exercises.empty? diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index 410a9936b..6b8d8644e 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -1,9 +1,14 @@ # encoding: utf-8 module ExerciseHelper + # 单选 + def translate_standard_answer(params) + answer = params.ord - 64 + end + #判断用户是否已经提交了问卷 def has_commit_exercise?(exercise_id, user_id) - pu = PollUser.find_by_poll_id_and_user_id(excercise_id, user_id) + pu = PollUser.find_by_poll_id_and_user_id(exercise_id, user_id) if pu.nil? false else From 25344ef0def1268c3e929595d8ef5fdabf58373e Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 18 Nov 2015 14:01:55 +0800 Subject: [PATCH 046/191] =?UTF-8?q?show=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index d06f4ee8d..dffa3d403 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -30,7 +30,7 @@ class ExerciseController < ApplicationController redirect_to exercise_index_url(:course_id=> @course.id) else @can_edit_excercise = (!has_commit_exercise?(@exercise.id,User.current.id)) || User.current.admin? - @percent = get_percent(@exercise,User.current) + # @percent = get_percent(@exercise,User.current) exercise_questions = @exercise.exercise_questions @exercise_questions = paginateHelper exercise_questions,5 #分页 respond_to do |format| @@ -239,6 +239,13 @@ class ExerciseController < ApplicationController end private + # 获取问题的答案 + def get_user_answer(question,user) + user_answer = question.poll_votes.where("#{PollVote.table_name}.user_id = #{user.id}") + user_answer + end + + # 是否完成了答题 def get_complete_question(exercise,user) questions = exercise.exercise_questions complete_question = [] @@ -251,6 +258,7 @@ class ExerciseController < ApplicationController complete_question end + def get_percent exercise,user complete_count = get_complete_question(exercise,user).count if exercise.exercise_questions.count == 0 From 249b15751d67e89f1d4fad0c747f3848aea8c74b Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 18 Nov 2015 14:05:29 +0800 Subject: [PATCH 047/191] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E5=A4=9A=E9=80=89?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 2 +- app/helpers/exercise_helper.rb | 14 +++-- app/views/exercise/_exercise_form.html.erb | 4 +- app/views/exercise/_new_MC.html.erb | 1 - app/views/exercise/_new_MCQ.html.erb | 11 +++- app/views/exercise/_show_MC.html.erb | 4 +- app/views/exercise/_show_MCQ.html.erb | 41 +++++++++++++++ .../exercise/create_exercise_question.js.erb | 26 ++++++++++ db/schema.rb | 52 +++++++++++++++++++ 9 files changed, 145 insertions(+), 10 deletions(-) create mode 100644 app/views/exercise/create_exercise_question.js.erb diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index b4f1c7eb1..36d745b80 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -91,7 +91,7 @@ class ExerciseController < ApplicationController @exercise.time = params[:exercise][:time] @exercise.end_time = params[:exercise][:end_time] @exercise.publish_time = params[:exercise][:publish_time] - @exercise.publish_time = params[:exercise][:show_result] + @exercise.show_result = params[:exercise][:show_result] if @exercise.save respond_to do |format| format.js diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index b9cd9c175..1768b7f19 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -13,11 +13,19 @@ module ExerciseHelper def convert_to_char(str) result = "" - if str.count >= 1 - for i in 0 .. str.count do i - result += (str[i].to_i + 64).chr + length = str.length + unless str.nil? + if length === 1 + result += (str.to_i + 64).chr + return result + elsif length > 1 + for i in 0...length + result += (str[i].to_i + 64).chr + end + return result end end + return result end end \ No newline at end of file diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index c4b7ee421..8567c6641 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -319,7 +319,7 @@
                      <%= render :partial => 'edit_head', :locals => {:exercise => @exercise}%>
                      - +
                      <%= render :partial => 'exercise_content', :locals => {:exercise => @exercise}%> @@ -340,7 +340,7 @@
                      提交
                      - +
                      diff --git a/app/views/exercise/_new_MC.html.erb b/app/views/exercise/_new_MC.html.erb index 5748713de..09e9e27f1 100644 --- a/app/views/exercise/_new_MC.html.erb +++ b/app/views/exercise/_new_MC.html.erb @@ -1,4 +1,3 @@ -<%#= form_for ExerciseQuestion.new,:url =>create_exercise_question_exercise_path(@exercise.id),:remote => true do |f|%> <%= form_for(ExerciseQuestion.new, :html => { :multipart => true }, :url => {:controller => 'exercise', diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb index 4163e9f13..9b5c4adef 100644 --- a/app/views/exercise/_new_MCQ.html.erb +++ b/app/views/exercise/_new_MCQ.html.erb @@ -1,8 +1,14 @@ +<%= form_for(ExerciseQuestion.new, + :html => { :multipart => true }, + :url => {:controller => 'exercise', + :action => 'create_exercise_question', + :course_id => @course.id + },:remote=>true ) do |f| %>
                      - +
                      -
                      \ No newline at end of file +
                      +<% end %> \ No newline at end of file diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb index bfaea32aa..09575ab00 100644 --- a/app/views/exercise/_show_MC.html.erb +++ b/app/views/exercise/_show_MC.html.erb @@ -1,6 +1,8 @@
                      第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
                      - <%= exercise_question.question_title %>(<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>)
                      + <%= exercise_question.question_title %> + (<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>) +
                      <%#= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id), method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> diff --git a/app/views/exercise/_show_MCQ.html.erb b/app/views/exercise/_show_MCQ.html.erb index e69de29bb..9a7f82f54 100644 --- a/app/views/exercise/_show_MCQ.html.erb +++ b/app/views/exercise/_show_MCQ.html.erb @@ -0,0 +1,41 @@ +
                      +
                      第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
                      + <%= exercise_question.question_title %> + (<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>) +
                      + <%#= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id), + method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> + + +
                      +
                      + + + <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> + + + + <% end %> + +
                      + +
                      +
                      +
                      + +
                      +
                      + \ No newline at end of file diff --git a/app/views/exercise/create_exercise_question.js.erb b/app/views/exercise/create_exercise_question.js.erb new file mode 100644 index 000000000..42077931c --- /dev/null +++ b/app/views/exercise/create_exercise_question.js.erb @@ -0,0 +1,26 @@ +<% if @is_insert %> +$("#poll_content").html('<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise})%>'); +<% else %> +$("#new_poll_question").html(""); + +$("#poll_content").append("
                      " + + "
                      " + + "<% if @exercise_questions.question_type == 1%>" + + "<%= escape_javascript(render :partial => 'show_MC', :locals => {:exercise_question => @exercise_questions}) %>" + + "<% elsif @exercise_questions.question_type == 2%>" + + "<%= escape_javascript(render :partial => 'show_MCQ', :locals => {:exercise_question => @exercise_questions}) %>" + + "<% elsif @exercise_questions.question_type == 3%>" + + "<%= escape_javascript(render :partial => 'show_single', :locals => {:exercise_question => @exercise_questions}) %>" + + "<% end%>" + + "
                      " + + "" + + "
                      "); +<% end %> diff --git a/db/schema.rb b/db/schema.rb index 8d506225f..07dac5706 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -241,6 +241,58 @@ ActiveRecord::Schema.define(:version => 20151118015638) do add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true + create_table "code_review_assignments", :force => true do |t| + t.integer "issue_id" + t.integer "change_id" + t.integer "attachment_id" + t.string "file_path" + t.string "rev" + t.string "rev_to" + t.string "action_type" + t.integer "changeset_id" + end + + create_table "code_review_project_settings", :force => true do |t| + t.integer "project_id" + t.integer "tracker_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "updated_by" + t.boolean "hide_code_review_tab", :default => false + t.integer "auto_relation", :default => 1 + t.integer "assignment_tracker_id" + t.text "auto_assign" + t.integer "lock_version", :default => 0, :null => false + t.boolean "tracker_in_review_dialog", :default => false + end + + create_table "code_review_user_settings", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.integer "mail_notification", :default => 0, :null => false + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "code_reviews", :force => true do |t| + t.integer "project_id" + t.integer "change_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "line" + t.integer "updated_by_id" + t.integer "lock_version", :default => 0, :null => false + t.integer "status_changed_from" + t.integer "status_changed_to" + t.integer "issue_id" + t.string "action_type" + t.string "file_path" + t.string "rev" + t.string "rev_to" + t.integer "attachment_id" + t.integer "file_count", :default => 0, :null => false + t.boolean "diff_all" + end + create_table "comments", :force => true do |t| t.string "commented_type", :limit => 30, :default => "", :null => false t.integer "commented_id", :default => 0, :null => false From 89657750049da7cb046a8dea85786c83b8118bde Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 18 Nov 2015 14:06:21 +0800 Subject: [PATCH 048/191] =?UTF-8?q?show=E6=96=B9=E6=B3=95=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercise_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index 513f27c16..cdfdf4abb 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -8,7 +8,7 @@ module ExerciseHelper #判断用户是否已经提交了问卷 def has_commit_exercise?(exercise_id, user_id) - pu = ExerciseUser.find_by_excercise_id_and_user_id(exercise_id, user_id) + pu = ExerciseUser.find_by_exercise_id_and_user_id(exercise_id, user_id) if pu.nil? false else From de17ffa6059a6e9ed843b144627fdb93ccf84c05 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 18 Nov 2015 14:31:35 +0800 Subject: [PATCH 049/191] =?UTF-8?q?=E5=8C=BA=E5=88=86=E7=AD=94=E6=A1=88?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 3 +-- app/helpers/exercise_helper.rb | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 810c61533..75c158435 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -146,7 +146,7 @@ class ExerciseController < ApplicationController if @exercise_questions.save standart_answer = ExerciseStandardAnswer.new standart_answer.exercise_question_id = @exercise_questions.id - @exercise_questions.question_type == 3 ? standart_answer.answer_text = translate_standard_answer(params[:exercise_choice]) : standart_answer.exercise_choice_id = translate_standard_answer(params[:exercise_choice]) + @exercise_questions.question_type == 3 ? standart_answer.answer_text = translate_standard_answer(params[:exercise_choice]) : standart_answer.exercise_choice_id = sigle_selection_standard_answer(params[:exercise_choice]) standart_answer.save respond_to do |format| format.js @@ -205,7 +205,6 @@ class ExerciseController < ApplicationController end end - #发布问卷 def publish_excercise @exercise.exercise_status = 2 diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index 339861730..a0e76cbdb 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -2,8 +2,19 @@ module ExerciseHelper # 单选 - def translate_standard_answer(params) - answer = params.ord - 64 + def sigle_selection_standard_answer(params) + size = params.ord - 64 + # 输入的为小写字母答案 + if size > 0 + answer = params.ord - 96 + else + answer = params.ord + end + end + + # 多选 + def multiselect_standard_answer(params) + answer = params.ord end #判断用户是否已经提交了问卷 From 935b1f9f9ec95c21dabde8a1f8ed7ee29c68fa74 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 18 Nov 2015 14:50:03 +0800 Subject: [PATCH 050/191] =?UTF-8?q?=E5=A4=A7=E5=86=99=E5=B0=8F=E5=86=99?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercise_helper.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index a0e76cbdb..2c92ffad7 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -3,12 +3,11 @@ module ExerciseHelper # 单选 def sigle_selection_standard_answer(params) - size = params.ord - 64 - # 输入的为小写字母答案 + size = params.ord - 96 if size > 0 answer = params.ord - 96 else - answer = params.ord + answer = params.ord - 64 end end From f850a71b59599a0f0e038bdabc5e3f047c5bae16 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 18 Nov 2015 15:30:39 +0800 Subject: [PATCH 051/191] =?UTF-8?q?=E6=B5=8B=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercise_helper.rb | 11 +++++++++++ app/views/exercise/_exercise_form.html.erb | 17 +++++++++-------- app/views/exercise/_new_MC.html.erb | 16 ++++++++-------- app/views/exercise/_new_MCQ.html.erb | 18 +++++++++--------- .../exercise/create_exercise_question.js.erb | 1 + 5 files changed, 38 insertions(+), 25 deletions(-) diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index 2c92ffad7..4cafa8e62 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -43,4 +43,15 @@ module ExerciseHelper return result end + def get_current_score exercise + score = 0 + unless exercise.nil? + exercise.exercise_questions.each do |exercise_question| + score += exercise_question.question_score + end + return score + end + return score + end + end \ No newline at end of file diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index 8567c6641..61e288079 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -76,21 +76,21 @@ '
                        '+ '
                      • '+ ''+ - ''+ + ''+ ''+ ''+ '
                      • '+ '
                        '+ '
                      • '+ ''+ - ''+ + ''+ ''+ ''+ '
                      • '+ '
                        '+ '
                      • '+ ''+ - ''+ + ''+ ''+ ''+ '
                      • '+ @@ -134,21 +134,21 @@ '
                          '+ '
                        • '+ ''+ - ''+ + ''+ ''+ ''+ '
                        • '+ '
                          '+ '
                        • '+ ''+ - ''+ + ''+ ''+ ''+ '
                        • '+ '
                          '+ '
                        • '+ ''+ - ''+ + ''+ ''+ ''+ '
                        • '+ @@ -274,7 +274,7 @@ //单选题 function add_single_answer(doc) { - doc.parent().after("
                        • " + + doc.parent().after("
                        • " + ""+ "
                        • "); } @@ -319,7 +319,8 @@
                          <%= render :partial => 'edit_head', :locals => {:exercise => @exercise}%>
                          - + <% current_score = get_current_score @exercise %> +
                          ">目前试卷总分:<%=current_score %>分
                          <%= render :partial => 'exercise_content', :locals => {:exercise => @exercise}%> diff --git a/app/views/exercise/_new_MC.html.erb b/app/views/exercise/_new_MC.html.erb index 09e9e27f1..158f8be96 100644 --- a/app/views/exercise/_new_MC.html.erb +++ b/app/views/exercise/_new_MC.html.erb @@ -18,29 +18,29 @@
                        • - - + +
                        • - - + +
                        • - - + +
                        • - - + +
                        • diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb index 9b5c4adef..f5a8257ca 100644 --- a/app/views/exercise/_new_MCQ.html.erb +++ b/app/views/exercise/_new_MCQ.html.erb @@ -8,7 +8,7 @@
                          - +
                            @@ -18,29 +18,29 @@
                          • - - + +
                          • - - + +
                          • - - + +
                          • - - + +
                          • diff --git a/app/views/exercise/create_exercise_question.js.erb b/app/views/exercise/create_exercise_question.js.erb index 42077931c..224dc0a95 100644 --- a/app/views/exercise/create_exercise_question.js.erb +++ b/app/views/exercise/create_exercise_question.js.erb @@ -23,4 +23,5 @@ $("#poll_content").append("
                            " + "
                            " + "
                          "); +$("#current_score").html("<%=get_current_score @exercise %>分"); <% end %> From 219774afabb76354b045e5e7786ed71c974503f0 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 18 Nov 2015 16:05:08 +0800 Subject: [PATCH 052/191] =?UTF-8?q?=E5=B0=86=E8=AF=BE=E7=A8=8B=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E5=8A=A0=E5=85=A5=E7=BB=84=E7=BB=87=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations_controller.rb | 19 +- app/models/course_activity.rb | 23 ++- app/views/layouts/_org_courses.html.erb | 12 ++ app/views/layouts/_org_projects.html.erb | 4 +- app/views/layouts/base_org.html.erb | 14 +- .../organizations/_org_activities.html.erb | 14 ++ .../organizations/_org_course_create.html.erb | 36 ++++ .../_org_course_homework.html.erb | 187 ++++++++++++++++++ .../_org_course_message.html.erb | 140 +++++++++++++ .../organizations/_org_course_news.html.erb | 106 ++++++++++ .../organizations/_org_course_poll.html.erb | 56 ++++++ .../organizations/more_org_courses.js.erb | 2 + app/views/organizations/show.html.erb | 2 +- config/routes.rb | 1 + public/javascripts/org.js | 8 + 15 files changed, 614 insertions(+), 10 deletions(-) create mode 100644 app/views/layouts/_org_courses.html.erb create mode 100644 app/views/organizations/_org_course_create.html.erb create mode 100644 app/views/organizations/_org_course_homework.html.erb create mode 100644 app/views/organizations/_org_course_message.html.erb create mode 100644 app/views/organizations/_org_course_news.html.erb create mode 100644 app/views/organizations/_org_course_poll.html.erb create mode 100644 app/views/organizations/more_org_courses.js.erb diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index b35d7f3db..8c8d8bae4 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -56,10 +56,14 @@ class OrganizationsController < ApplicationController if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) @organization = Organization.find(params[:id]) project_ids = @organization.projects.map(&:id) << 0 + course_ids = @organization.courses.map(&:id) << 0 + course_types = "('Message','News','HomeworkCommon','Poll','Course')" case params[:type] when nil - @org_activities = OrgActivity.where("(container_id =? and container_type =?) or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')}))", - @organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) + @org_activities = OrgActivity.where("(container_id =? and container_type =?) " + + "or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')})) "+ + "or (container_type ='Course' and org_act_type in #{course_types} and container_id in (#{course_ids.join(',')}))", + @organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) when 'project_issue' @org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Issue' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) when 'project_message' @@ -145,7 +149,16 @@ class OrganizationsController < ApplicationController def more_org_projects @organization = Organization.find params[:id] @page = params[:page] - @org_projects = @organization.org_projects.reorder('created_at').page((params[:page].to_i || 1) +1).per(5) + @org_projects = @organization.projects.reorder('created_at').page((params[:page].to_i || 1) +1).per(5) + respond_to do |format| + format.js + end + end + + def more_org_courses + @organization = Organization.find(params[:id]) + @page = params[:page] + @org_courses = @organization.courses.reorder('created_at').page((params[:page].to_i || 1) + 1 ).per(5) respond_to do |format| format.js end diff --git a/app/models/course_activity.rb b/app/models/course_activity.rb index 4e74142ad..cd3234196 100644 --- a/app/models/course_activity.rb +++ b/app/models/course_activity.rb @@ -5,7 +5,7 @@ class CourseActivity < ActiveRecord::Base belongs_to :course belongs_to :user has_many :user_acts, :class_name => 'UserAcivity',:as =>:act - after_save :add_user_activity + after_save :add_user_activity, :add_course_activity before_destroy :destroy_user_activity #在个人动态里面增加当前动态 @@ -30,6 +30,27 @@ class CourseActivity < ActiveRecord::Base end end + def add_course_activity + org_activity = OrgActivity.where("org_act_type = '#{self.course_act_type.to_s}' and org_act_id = '#{self.course_act_id}'").first + if org_activity + org_activity.save + else + if self.course_act_type == 'Message' && !self.course_act.parent_id.nil? + org_activity = OrgActivity.where("org_act_type = 'Message' and org_act_id = #{self.course_act.parent.id}").first + org_activity.created_at = self.created_at + org_activity.save + else + OrgActivity.create(:user_id => self.user_id, + :org_act_id => self.course_act_id, + :org_act_type => self.course_act_type, + :container_id => self.course_id, + :container_type => 'Course', + :created_at => self.created_at, + :updated_at => self.updated_at) + end + end + end + def destroy_user_activity user_activity = UserActivity.where("act_type = '#{self.course_act_type.to_s}' and act_id = '#{self.course_act_id}'") user_activity.destroy_all diff --git a/app/views/layouts/_org_courses.html.erb b/app/views/layouts/_org_courses.html.erb new file mode 100644 index 000000000..2837ef71f --- /dev/null +++ b/app/views/layouts/_org_courses.html.erb @@ -0,0 +1,12 @@ +<% courses.each do |course|%> + <%# pro = Project.find course.course_id %> +
                        • + <%= link_to course.name, course_path(course.id,:host=>Setting.host_name), :class => "coursesLineGrey hidden", :title => course.name%> +
                        • +<% end %> +<% if courses.size == 5%> +
                        • + + +
                        • +<% end%> \ No newline at end of file diff --git a/app/views/layouts/_org_projects.html.erb b/app/views/layouts/_org_projects.html.erb index be65fd516..687b54ecd 100644 --- a/app/views/layouts/_org_projects.html.erb +++ b/app/views/layouts/_org_projects.html.erb @@ -1,7 +1,7 @@ <% projects.each do |project|%> - <% pro = Project.find project.project_id %> + <%# pro = Project.find project.project_id %>
                        • - <%= link_to pro.name, project_path(pro.id,:host=>Setting.host_name), :class => "coursesLineGrey hidden", :title => pro.name%> + <%= link_to project.name, project_path(project.id,:host=>Setting.host_name), :class => "coursesLineGrey hidden", :title => project.name%>
                        • <% end %> <% if projects.size == 5%> diff --git a/app/views/layouts/base_org.html.erb b/app/views/layouts/base_org.html.erb index d59cf8ee2..84edf02e1 100644 --- a/app/views/layouts/base_org.html.erb +++ b/app/views/layouts/base_org.html.erb @@ -86,17 +86,25 @@ <%= link_to "动态",organization_path(@organization), :class => "homepageMenuText" %>
                          项目 - -
                          + +
                      - <%= render :partial => 'layouts/org_projects',:locals=>{:projects=>@organization.org_projects.reorder('created_at').limit(5),:org_id=>@organization.id,:page=>1}%> + <%= render :partial => 'layouts/org_projects',:locals=>{:projects=>@organization.projects.reorder('created_at').limit(5),:org_id=>@organization.id,:page=>1}%>
                    +
                    课程 + +
                    +
                    +
                      + <%= render :partial => 'layouts/org_courses',:locals=>{:courses=>@organization.courses.reorder('created_at').limit(5),:org_id=>@organization.id,:page=>1}%> +
                    +
                diff --git a/app/views/organizations/_org_activities.html.erb b/app/views/organizations/_org_activities.html.erb index 9523a0a15..aa48fedf1 100644 --- a/app/views/organizations/_org_activities.html.erb +++ b/app/views/organizations/_org_activities.html.erb @@ -35,6 +35,20 @@ <%= render :partial => 'organizations/project_create', :locals => {:activity => act,:user_activity_id =>act.id} %> <% end %> <% end %> + <% if act.container_type == 'Course' %> + <% case act.org_act_type.to_s %> + <% when 'HomeworkCommon' %> + <%= render :partial => 'org_course_homework', :locals => {:activity => HomeworkCommon.find(act.org_act_id),:user_activity_id =>act.id,:course_activity => 0} %> + <% when 'News' %> + <%= render :partial => 'org_course_news', :locals => {:activity => News.find(act.org_act_id),:user_activity_id =>act.id} %> + <% when 'Message'%> + <%= render :partial => 'org_course_message', :locals => {:activity => Message.find(act.org_act_id),:user_activity_id =>act.id} %> + <% when 'Poll' %> + <%= render :partial => 'org_course_poll', :locals => {:activity => Poll.find(act.org_act_id), :user_activity_id => act.id} %> + <% when 'Course'%> + <%= render :partial => 'org_course_create', :locals => {:activity => Course.find(act.org_act_id), :user_activity_id => act.id} %> + <% end %> + <% end %> <% end %> <%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> diff --git a/app/views/organizations/_org_course_create.html.erb b/app/views/organizations/_org_course_create.html.erb new file mode 100644 index 000000000..97213283e --- /dev/null +++ b/app/views/organizations/_org_course_create.html.erb @@ -0,0 +1,36 @@ +
                +
                +
                + <%= link_to image_tag(url_to_avatar(activity.teacher), :width => "50", :height => "50"), user_path(activity.tea_id), :alt => "用户头像" %> +
                +
                +
                + <% if activity.try(:teacher).try(:realname) == ' ' %> + <%= link_to activity.try(:teacher), user_path(activity.tea_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:teacher).try(:realname), user_path(activity.tea_id), :class => "newsBlue mr15" %> + <% end %> + TO + <%= link_to activity.name.to_s+" | 课程", course_path(activity.id,:host=>Setting.host_course), :class => "newsBlue ml15" %> +
                +
                + <%= link_to activity.name, course_path(activity.id,:host=>Setting.host_course), :class => "postGrey" %> +
                +
                + 创建时间:<%= format_time(activity.created_at) %> +
                + +
                +
                +
                +
                \ No newline at end of file diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb new file mode 100644 index 000000000..9699eff5f --- /dev/null +++ b/app/views/organizations/_org_course_homework.html.erb @@ -0,0 +1,187 @@ +<% is_teacher = User.current.allowed_to?(:as_teacher,activity.course) %> +
                +
                +
                + <%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user_id), :alt => "用户头像" %> +
                +
                +
                + <% if activity.try(:user).try(:realname) == ' ' %> + <%= link_to activity.try(:user), user_path(activity.user_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:user).try(:realname), user_path(activity.user_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> + <% end %> TO + <%= link_to activity.course.name.to_s+" | 课程作业", homework_common_index_path(:course => activity.course.id, :host=> Setting.host_course), :class => "newsBlue ml15"%> +
                + + <% if activity.homework_detail_manual%> + <% if activity.homework_detail_manual.comment_status == 1%> + <% if activity.anonymous_comment == 0%> + 未开启匿评 + <% else %> + 匿评已禁用 + <% end %> + <% if Time.parse(activity.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")%> + 作品提交中 + <% elsif Time.parse(activity.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") %> + 作品补交中 + <% end %> + <% elsif activity.homework_detail_manual.comment_status == 2%> + <% if activity.anonymous_comment == 0%> + 匿评中 + <% else %> + 匿评已禁用 + <% end %> + 教师评阅中 + <% elsif activity.homework_detail_manual.comment_status == 3%> + <% if activity.anonymous_comment == 0%> + 匿评已结束 + <% else %> + 匿评已禁用 + <% end %> + 教师评阅中 + <% end%> + <% end%> +
                +
                + <% is_teacher = User.current.allowed_to?(:as_teacher,activity.course) %> + <%= user_for_homework_common activity,is_teacher %> +
                + + <% if activity.homework_type == 2 && is_teacher%> +
                + <%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: activity.id, is_test: true), class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %> +
                + <% end %> + <% if activity.homework_type == 2%> +
                + 语言: + <%= activity.language_name%> +
                + <% end %> + +
                截止时间:<%= activity.end_time.to_s %> 23:59
                +
                +
                +
                + <%= activity.description.html_safe %> +
                +
                +
                + + +
                +
                + <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => activity.attachments} %> +
                +
                + <% if is_teacher%> + <% comment_status = activity.homework_detail_manual.comment_status %> +
                +
                  +
                • +
                    +
                  • + <%= link_to l(:button_edit),edit_homework_common_path(activity,:is_in_course => -1,:course_activity=>course_activity), :class => "postOptionLink"%> +
                  • +
                  • + <%= link_to(l(:label_bid_respond_delete), homework_common_path(activity,:is_in_course => -1,:course_activity=>course_activity),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %> +
                  • +
                  • + <%= link_to("评分设置", score_rule_set_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => 0),:class => "postOptionLink", :remote => true) %> +
                  • + <% if activity.anonymous_comment == 0 %> +
                  • + <%= link_to("匿评设置", start_evaluation_set_homework_common_path(activity),:class => "postOptionLink", :remote => true) if activity.homework_detail_manual.comment_status == 1%> +
                  • +
                  • + <%= homework_anonymous_comment activity,-1,user_activity_id,course_activity %> +
                  • + <% end %> + <% if activity.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%> +
                  • + <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%> +
                  • + <% end %> +
                  +
                • +
                +
                + <% end%> +
                +
                +
                + + <% count=activity.journals_for_messages.count %> +
                +
                +
                +
                + 回复(<%= count %>) +
                +
                + <%if count>3 %> + + <% end %> +
                + + <% replies_all_i = 0 %> + <% if count > 0 %> +
                +
                  + <% activity.journals_for_messages.reorder("created_on desc").each do |comment| %> + + <% replies_all_i = replies_all_i + 1 %> +
                • +
                  + <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %> +
                  +
                  +
                  + <% if comment.try(:user).try(:realname) == ' ' %> + <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(comment.created_on) %> +
                  +
                  + <%= comment.notes.html_safe %>
                  +
                  +
                  +
                • + <% end %> +
                +
                + <% end %> + +
                +
                <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
                +
                +
                + <%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_homework_message', :id => activity.id},:method => "post", :remote => true) do |f|%> + <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %> + <%= hidden_field_tag 'course_activity',params[:course_activity],:value =>course_activity %> + +
                + +
                +

                + <% end%> +
                +
                +
                +
                +
                +
                +
                \ No newline at end of file diff --git a/app/views/organizations/_org_course_message.html.erb b/app/views/organizations/_org_course_message.html.erb new file mode 100644 index 000000000..9ca8f5d10 --- /dev/null +++ b/app/views/organizations/_org_course_message.html.erb @@ -0,0 +1,140 @@ +
                +
                +
                + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %> +
                +
                +
                + <% if activity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %> + <% end %> + TO + <%= link_to activity.course.name.to_s+" | 课程讨论区", course_boards_path(activity.course,:host=> Setting.host_course), :class => "newsBlue ml15 mr5"%> +
                + + <% if activity.sticky == 1%> + 置顶 + <% end%> + <% if activity.locked%> +        + <% end%> +
                +
                + 发帖时间:<%= format_time(activity.created_on) %> +
                +
                +
                + <% if activity.parent_id.nil? %> + <%= activity.content.to_s.html_safe%> + <% else %> + <%= activity.parent.content.to_s.html_safe%> + <% end %> +
                +
                +
                + + +
                + +
                +
                +
                + <% count=0 %> + <% if activity.parent %> + <% count=activity.parent.children.count%> + <% else %> + <% count=activity.children.count%> + <% end %> +
                +
                +
                +
                回复( + <%= count %> + )
                +
                <%#=format_date(activity.updated_on)%>
                + <%if count > 3 %> + + <% end %> +
                + + <% activity= activity.parent ? activity.parent : activity%> + <% replies_all_i = 0 %> + <% if count > 0 %> +
                +
                  + <% activity.children.reorder("created_on desc").each do |reply|%> + + <% replies_all_i=replies_all_i+1 %> +
                • +
                  + <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id,:host=>Setting.host_user), :alt => "用户头像" %> +
                  +
                  +
                  + <% if reply.try(:author).try(:realname) == ' ' %> + <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(reply.created_on) %> +
                  +
                  + <%= reply.content.html_safe %> +
                  +
                  +
                  +
                • + <% end %> +
                +
                + <% end %> + + <% if !activity.locked? && authorize_for_course('messages', 'reply') %> +
                +
                <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
                +
                +
                + <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%> + + + +
                + +
                +

                + <% end%> +
                +
                +
                +
                +
                +
                + <% end %> +
                +
                diff --git a/app/views/organizations/_org_course_news.html.erb b/app/views/organizations/_org_course_news.html.erb new file mode 100644 index 000000000..475a982e5 --- /dev/null +++ b/app/views/organizations/_org_course_news.html.erb @@ -0,0 +1,106 @@ +
                +
                +
                + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> +
                +
                +
                + <% if @ctivity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% end %> TO + <%= link_to activity.course.name.to_s+" | 课程通知", course_news_index_path(activity.course), :class => "newsBlue ml15" %> +
                + + <% if activity.sticky == 1%> + 置顶 + <% end%> +
                +
                + 发布时间:<%= format_time(activity.created_on) %> +
                +
                +
                + <%= activity.description.html_safe %> +
                +
                +
                + + +
                +
                +
                +
                + <% count=activity.comments.count %> +
                +
                +
                +
                + 回复(<%= count %>) +
                +
                <%#= format_date(activity.updated_on) %>
                + <%if count>3 %> + + <% end %> +
                + + <% replies_all_i = 0 %> + <% if count > 0 %> +
                +
                  + <% activity.comments.reorder("created_on desc").each do |comment| %> + + <% replies_all_i = replies_all_i + 1 %> +
                • +
                  + <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_path(comment.author_id), :alt => "用户头像" %> +
                  +
                  +
                  + <% if comment.try(:author).try(:realname) == ' ' %> + <%= link_to comment.try(:author), user_path(comment.author_id), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(comment.created_on) %> +
                  +
                  + <%= comment.comments.html_safe %>
                  +
                  +
                  +
                • + <% end %> +
                +
                + <% end %> + +
                +
                <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
                +
                +
                + <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%> + + +
                + +
                +

                + <% end%> +
                +
                +
                +
                +
                +
                +
                \ No newline at end of file diff --git a/app/views/organizations/_org_course_poll.html.erb b/app/views/organizations/_org_course_poll.html.erb new file mode 100644 index 000000000..c363909d9 --- /dev/null +++ b/app/views/organizations/_org_course_poll.html.erb @@ -0,0 +1,56 @@ +<% has_commit = has_commit_poll?(activity.id ,User.current)%> +<% poll_name = activity.polls_name.empty? ? l(:label_poll_new) : activity.polls_name%> +<% if ( activity.polls_status==2) %> +
                +
                +
                + + <%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user_id), :alt => "用户头像" %> +
                +
                +
                + <% if activity.try(:user).try(:realname) == ' ' %> + <%= link_to activity.try(:user), user_path(activity.user_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:user).try(:realname), user_path(activity.user_id), :class => "newsBlue mr15" %> + <% end %> + TO + <%= link_to Course.find(activity.polls_group_id).name.to_s+" | 问卷", poll_index_path(:polls_type => "Course", :polls_group_id => activity.polls_group_id), :class => "newsBlue ml15" %> + +
                +
                + <%#= link_to activity.polls_name.to_s/*+"(问卷名称)"*/, %> + <% if has_commit %> + <%= link_to poll_name, poll_result_poll_path(activity.id), :class => "postGrey"%> + <% else %> + <%= link_to poll_name, poll_path(activity.id), :class => "postGrey"%> + <% end %> +
                +
                + 发布时间:<%= format_time(activity.published_at) %> +
                +
                +
                + <%= activity.polls_description.html_safe %> +
                +
                +
                + + +
                + +
                +
                +
                +
                +<% end %> \ No newline at end of file diff --git a/app/views/organizations/more_org_courses.js.erb b/app/views/organizations/more_org_courses.js.erb new file mode 100644 index 000000000..02bfb1d70 --- /dev/null +++ b/app/views/organizations/more_org_courses.js.erb @@ -0,0 +1,2 @@ +$("#show_more_org_course").replaceWith("<%= escape_javascript( render :partial => 'layouts/org_courses', + :locals => {:courses => @org_courses,:org_id => @organization, :page => @page} )%>"); diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb index e62a66913..acaf2879e 100644 --- a/app/views/organizations/show.html.erb +++ b/app/views/organizations/show.html.erb @@ -42,7 +42,7 @@ <% if !@organization.home_id.nil? and OrgDocumentComment.where("id = ?", @organization.home_id).count > 0 %> <% act = OrgActivity.where("org_act_type = 'OrgDocumentComment' and org_act_id =?", @organization.home_id).first %> diff --git a/config/routes.rb b/config/routes.rb index f2a08d35e..c68c8a1c1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -38,6 +38,7 @@ RedmineApp::Application.routes.draw do put 'set_homepage' get 'members' get 'more_org_projects' + get 'more_org_courses' end collection do get 'check_uniq' diff --git a/public/javascripts/org.js b/public/javascripts/org.js index e26995931..1e1951006 100644 --- a/public/javascripts/org.js +++ b/public/javascripts/org.js @@ -42,4 +42,12 @@ function show_more_org_project(url){ } ); +} + +function show_more_org_course(url){ + $.get( + url, + {page: $("#org_course_page_num").val()}, + function (data){} + ); } \ No newline at end of file From cd2d947cb2c74c57605ad483e43a71595f0f282e Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 18 Nov 2015 16:06:34 +0800 Subject: [PATCH 053/191] =?UTF-8?q?=E5=A4=9A=E9=A1=B9=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E6=A0=87=E5=87=86=E7=AD=94=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 8 +++++++- app/helpers/exercise_helper.rb | 15 +++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 75c158435..2bc8612a4 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -146,7 +146,13 @@ class ExerciseController < ApplicationController if @exercise_questions.save standart_answer = ExerciseStandardAnswer.new standart_answer.exercise_question_id = @exercise_questions.id - @exercise_questions.question_type == 3 ? standart_answer.answer_text = translate_standard_answer(params[:exercise_choice]) : standart_answer.exercise_choice_id = sigle_selection_standard_answer(params[:exercise_choice]) + if @exercise_questions.question_type == 1 + standart_answer.exercise_choice_id = sigle_selection_standard_answer(params[:exercise_choice]) + elsif @exercise_questions.question_type == 2 + standart_answer.exercise_choice_id = multiselect_standard_answer(params[:exercise_choice]) + else + standart_answer.answer_text = sigle_selection_standard_answer(params[:exercise_choice]) + end standart_answer.save respond_to do |format| format.js diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index 2c92ffad7..d4caf00b5 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -4,7 +4,7 @@ module ExerciseHelper # 单选 def sigle_selection_standard_answer(params) size = params.ord - 96 - if size > 0 + if size > 0 # 小写字母答案 answer = params.ord - 96 else answer = params.ord - 64 @@ -13,7 +13,18 @@ module ExerciseHelper # 多选 def multiselect_standard_answer(params) - answer = params.ord + size = params.ord - 96 + answer = "" + if size > 0 # 小写字母答案 + for i in 0..(params.length-1) + answer += (params[i].ord - 96).to_s + end + else + for i in 0..(params.length-1) + answer += (params[i].ord - 64).to_s + end + end + answer.to_i end #判断用户是否已经提交了问卷 From fe3fbacdbc7bf6e594b3763fac33a2d5c6eb06ca Mon Sep 17 00:00:00 2001 From: houxiang Date: Wed, 18 Nov 2015 16:11:51 +0800 Subject: [PATCH 054/191] modify commit count show --- app/controllers/repositories_controller.rb | 28 +++++++++++++++++++++- app/views/projects/show.html.erb | 4 ++-- app/views/repositories/_revisions.html.erb | 6 +++++ app/views/repositories/changes.html.erb | 4 +++- app/views/repositories/show.html.erb | 2 +- 5 files changed, 39 insertions(+), 5 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 21ee6e1de..de44f44d5 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -271,11 +271,37 @@ update alias_method :browse, :show + + #add by houxiang + + def get_commits(id) + g = Gitlab.client + tmp_commit = g.commits(id,page:0) + commits = [] + i=0 + while tmp_commit!=[] + commits = commits+tmp_commit + i=i+1 + tmp_commit = g.commits(id,page:i) + end + commits_count = commits.length + + return commits_count + + end + + def changes @entry = @repository.entry(@path, @rev) (show_error_not_found; return) unless @entry g = Gitlab.client - @commits = g.commits(@project.gpid, page:params[:page]) + limit = 20 + + + @commits = g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s) + @commits_count = get_commits(@project.gpid) + @commits_pages = Redmine::Pagination::Paginator.new @commits_count,limit,params[:page] + @commit = g.commit(@project.gpid,@rev) # @changesets = g.get ("/projects/#{@project.gpid}/repository/commits?#{@rev}") #@changesets = @repository.latest_changesets(@path, @rev, Setting.repository_log_display_limit.to_i) diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index 22317dc91..8d371912e 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -20,7 +20,7 @@ <% next if e.forge_act_type.safe_constantize.nil? act = e.forge_act; next if act.nil? %> - + \ <% if e.forge_act_type == "Issue" %>
                <%= image_tag(url_to_avatar(act.author), :width => "42", :height => "42") %> @@ -111,4 +111,4 @@ <% end %> <% end %> <% end %> -<%= paginate @events_pages, :left => 3, :right => 3 %> \ No newline at end of file +<%= paginate @events_pages, :left => 3, :right => 3 %> diff --git a/app/views/repositories/_revisions.html.erb b/app/views/repositories/_revisions.html.erb index 837096c89..50c973fb4 100644 --- a/app/views/repositories/_revisions.html.erb +++ b/app/views/repositories/_revisions.html.erb @@ -13,6 +13,7 @@ + <% show_diff = revisions.size > 1 %> <% line_num = 1 %> <% revisions.each do |changeset| %> @@ -48,4 +49,9 @@ <%#= submit_tag(l(:label_view_diff), :name => nil, :class=>"c_blue") if show_diff %>

                +
                  + <%= pagination_links_full commits_pages, commits_count, :per_page_links => false, :remote => false, :flag => true%> +
                + <% end %> + diff --git a/app/views/repositories/changes.html.erb b/app/views/repositories/changes.html.erb index 428799f07..3780df172 100644 --- a/app/views/repositories/changes.html.erb +++ b/app/views/repositories/changes.html.erb @@ -14,7 +14,9 @@ <%= render_properties(@properties) %>
                - <%= render(:partial => 'revisions', :locals => {:project => @project, :path => @path, :revisions => @commits, :entry => @entry }) unless @commits.empty? %> + + <%= render(:partial => 'revisions', :locals => {:project => @project, :path => @path ,:revisions => @commits, :entry => @entry ,:commits_pages =>@commits_pages , :commits_count => @commits_count}) unless @commits.empty? %> +
                <% content_for :header_tags do %> <%= stylesheet_link_tag "scm" %> diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 9601e5188..af53d760f 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -40,7 +40,7 @@ - <%=link_to @changesets_all_count, {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev} %> 提交 + <%=link_to @changesets_all_count, {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev,:page=>1} %> 提交
                <% end %> From d407610740ba73698f3db4a49e3573d68db6b0bd Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 18 Nov 2015 16:51:47 +0800 Subject: [PATCH 055/191] =?UTF-8?q?=E5=A1=AB=E7=A9=BA=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_exercise_form.html.erb | 27 ++++++++++++++----- app/views/exercise/_new_MCQ.html.erb | 2 +- app/views/exercise/_new_single.html.erb | 11 ++++++-- app/views/exercise/_show_MC.html.erb | 6 ++--- app/views/exercise/_show_MCQ.html.erb | 6 ++--- app/views/exercise/_show_single.html.erb | 25 +++++++++++++++++ .../exercise/delete_exercise_question.js.erb | 1 + .../exercise/update_exercise_question.js.erb | 0 config/routes.rb | 1 + 9 files changed, 63 insertions(+), 16 deletions(-) create mode 100644 app/views/exercise/delete_exercise_question.js.erb create mode 100644 app/views/exercise/update_exercise_question.js.erb diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index 61e288079..1d78fb435 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -61,7 +61,12 @@ function insert_MC(quest_type,quest_num,quest_id){ $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( - '<%#= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@exercise.id),:remote => true do |f|%>'+ + '<%= form_for(ExerciseQuestion.new, + :html => { :multipart => true }, + :url => {:controller => 'exercise', + :action => 'create_exercise_question', + :course_id => @course.id + },:remote=>true ) do |f|%>'+ '
                '+ '
                '+ ''+ @@ -107,7 +112,7 @@ '
                '+ '
                '+ '
                '+ - '<%# end%>' + '<% end%>' ); $("#poll_questions_title").focus(); } @@ -119,7 +124,12 @@ function insert_MCQ(quest_type,quest_num,quest_id){ $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( - '<%#= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@exercise.id),:remote => true do |f|%>'+ + '<%= form_for(ExerciseQuestion.new, + :html => { :multipart => true }, + :url => {:controller => 'exercise', + :action => 'create_exercise_question', + :course_id => @course.id + },:remote=>true ) do |f|%>'+ '
                '+ '
                '+ ''+ @@ -165,7 +175,7 @@ '
                '+ '
                '+ '
                '+ - '<%# end%>' + '<% end%>' ); $("#poll_questions_title").focus(); } @@ -177,7 +187,12 @@ function insert_SINGLE(quest_type,quest_num,quest_id){ $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( - '<%#= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@exercise.id),:remote => true do |f|%>'+ + '<%= form_for(ExerciseQuestion.new, + :html => { :multipart => true }, + :url => {:controller => 'exercise', + :action => 'create_exercise_question', + :course_id => @course.id + },:remote=>true ) do |f|%>'+ '
                '+ '
                '+ ''+ @@ -198,7 +213,7 @@ '
                '+ '
                '+ '
                '+ - '<%# end%>' + '<% end%>' ); $("#poll_questions_title").focus(); } diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb index f5a8257ca..6e58d620e 100644 --- a/app/views/exercise/_new_MCQ.html.erb +++ b/app/views/exercise/_new_MCQ.html.erb @@ -47,7 +47,7 @@
              • - +
              diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb index f48c7673d..e4e1db695 100644 --- a/app/views/exercise/_new_single.html.erb +++ b/app/views/exercise/_new_single.html.erb @@ -1,8 +1,14 @@ +<%= form_for(ExerciseQuestion.new, + :html => { :multipart => true }, + :url => {:controller => 'exercise', + :action => 'create_exercise_question', + :course_id => @course.id + },:remote=>true ) do |f| %>
              - +
              -
              \ No newline at end of file + +<% end %> \ No newline at end of file diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb index 09575ab00..e7bf20206 100644 --- a/app/views/exercise/_show_MC.html.erb +++ b/app/views/exercise/_show_MC.html.erb @@ -4,7 +4,7 @@ (<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>) - <%#= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id), + <%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id), method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> @@ -31,8 +31,8 @@ \ No newline at end of file diff --git a/app/views/exercise/_show_MCQ.html.erb b/app/views/exercise/_show_MCQ.html.erb index 9a7f82f54..f69b855bd 100644 --- a/app/views/exercise/_show_MCQ.html.erb +++ b/app/views/exercise/_show_MCQ.html.erb @@ -3,7 +3,7 @@ <%= exercise_question.question_title %> (<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>) - <%#= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id), + <%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id), method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> @@ -32,9 +32,7 @@ diff --git a/app/views/exercise/_show_single.html.erb b/app/views/exercise/_show_single.html.erb index e69de29bb..07ecce94d 100644 --- a/app/views/exercise/_show_single.html.erb +++ b/app/views/exercise/_show_single.html.erb @@ -0,0 +1,25 @@ +
              +
              第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
              + <%= exercise_question.question_title %> +
              + <%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id), + method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> + + +
              +
              + <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> + 候选答案:<%= exercise_choice.choice_text%>
              + <% end %> +
              +
              + +
              +
              + \ No newline at end of file diff --git a/app/views/exercise/delete_exercise_question.js.erb b/app/views/exercise/delete_exercise_question.js.erb new file mode 100644 index 000000000..eb6300eb5 --- /dev/null +++ b/app/views/exercise/delete_exercise_question.js.erb @@ -0,0 +1 @@ +$("#poll_content").html("<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise}) %>"); \ No newline at end of file diff --git a/app/views/exercise/update_exercise_question.js.erb b/app/views/exercise/update_exercise_question.js.erb new file mode 100644 index 000000000..e69de29bb diff --git a/config/routes.rb b/config/routes.rb index b1e4725e6..8dba79d2c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -156,6 +156,7 @@ RedmineApp::Application.routes.draw do end collection do #生成路径为 /exercise/方法名 + delete 'delete_exercise_question' end end From af981f841ec13ae180fcabed12b7ee1c0638af13 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 18 Nov 2015 16:52:03 +0800 Subject: [PATCH 056/191] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E7=BF=BB=E9=A1=B5=E6=8F=90=E9=86=92=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=94=B9=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 1 + app/controllers/projects_controller.rb | 1 + .../courses/search_public_orgs_not_in_course.js.erb | 10 ++++++---- app/views/courses/settings/_join_org.html.erb | 2 +- .../projects/search_public_orgs_not_in_project.js.erb | 11 ++++++----- app/views/projects/settings/_join_org.html.erb | 2 +- public/javascripts/course.js | 2 +- public/javascripts/project.js | 2 +- 8 files changed, 18 insertions(+), 13 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index fd53660c6..cd1de16fc 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -46,6 +46,7 @@ class CoursesController < ApplicationController end # @course_count = Project.course_entities.visible.like(params[:name]).page(params[:page]).count @orgs_page = Paginator.new @org_count, 10,params[:page] + @hint_flag = params[:hint_flag] #render :json => {:orgs => @orgs_not_in_course, :count => @org_count}.to_json respond_to do |format| format.js diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index baa7db060..715f56d3d 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -86,6 +86,7 @@ class ProjectsController < ApplicationController end # @project_count = Project.project_entities.visible.like(params[:name]).page(params[:page]).count @orgs_page = Paginator.new @org_count, 10,params[:page] + @no_roll_hint = params[:hint_flag] #render :json => {:orgs => @orgs_not_in_project, :count => @org_count}.to_json respond_to do |format| format.js diff --git a/app/views/courses/search_public_orgs_not_in_course.js.erb b/app/views/courses/search_public_orgs_not_in_course.js.erb index 084583d2a..2669f8a0f 100644 --- a/app/views/courses/search_public_orgs_not_in_course.js.erb +++ b/app/views/courses/search_public_orgs_not_in_course.js.erb @@ -1,7 +1,9 @@ -if($("#join_orgs_for_course input:checked").size() > 0) -{ - alert("翻页或搜索后将丢失当前选择的用户数据"); -} +<% if @hint_flag.nil? %> + if($("#join_orgs_for_course input:checked").size() > 0) + { + alert("翻页或搜索后将丢失当前选择的用户数据"); + } +<% end %> $("#search_orgs_result_list").html(""); $("#search_orgs_result_list").append('
                '); <% @orgs_not_in_course.each do |org|%> diff --git a/app/views/courses/settings/_join_org.html.erb b/app/views/courses/settings/_join_org.html.erb index 50715f437..cd2d515cc 100644 --- a/app/views/courses/settings/_join_org.html.erb +++ b/app/views/courses/settings/_join_org.html.erb @@ -77,7 +77,7 @@ type: "post", success: function (data) { $.ajax({ - url: "/courses/" + courseId + "/search_public_orgs_not_in_course", + url: "/courses/" + courseId + "/search_public_orgs_not_in_course?hint_flag=true&name=" + $("input[name='orgs']").val().trim(), type: "get" }); } diff --git a/app/views/projects/search_public_orgs_not_in_project.js.erb b/app/views/projects/search_public_orgs_not_in_project.js.erb index 6599e97f7..c8ac999a1 100644 --- a/app/views/projects/search_public_orgs_not_in_project.js.erb +++ b/app/views/projects/search_public_orgs_not_in_project.js.erb @@ -1,9 +1,10 @@ //翻页提醒 -if($("#join_orgs_for_project input:checked").size() > 0) -{ - alert('翻页或搜索后将丢失当前选择的用户数据!'); -} - +<% if @no_roll_hint.nil? %> + if( $("#join_orgs_for_project input:checked").size() > 0) + { + alert('翻页或搜索后将丢失当前选择的用户数据!'); + } +<% end %> $("#search_orgs_result_list").html(""); $("#search_orgs_result_list").append('
                  '); <% @orgs_not_in_project.each do |org|%> diff --git a/app/views/projects/settings/_join_org.html.erb b/app/views/projects/settings/_join_org.html.erb index ca3cafed5..8b8425934 100644 --- a/app/views/projects/settings/_join_org.html.erb +++ b/app/views/projects/settings/_join_org.html.erb @@ -77,7 +77,7 @@ type: 'post', success: function (data) { $.ajax({ - url: '/projects/'+projectId+'/search_public_orgs_not_in_project', + url: '/projects/'+projectId+'/search_public_orgs_not_in_project?hint_flag=true&name='+ $("input[name='orgs']").val().trim(), type: 'get' }); } diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 5d89e6442..9f1815695 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -1295,7 +1295,7 @@ function cancel_org_course_relation(id, courseId){ type: "delete", success:function(data){ $.ajax({ - url: "/courses/" + courseId + "/search_public_orgs_not_in_course", + url: "/courses/" + courseId + "/search_public_orgs_not_in_course?hint_flag=true", type:'get' }); } diff --git a/public/javascripts/project.js b/public/javascripts/project.js index 31d487bd9..f3e6b76ce 100644 --- a/public/javascripts/project.js +++ b/public/javascripts/project.js @@ -536,7 +536,7 @@ function cancel_relation(orgId,projectId){ type:'DELETE', success:function(data) { $.ajax({ - url: ' /projects/'+projectId+'/search_public_orgs_not_in_project', + url: ' /projects/'+projectId+'/search_public_orgs_not_in_project?hint_flag=true', type:'get' }); } From ac95e1584ccbac1cfb5ea645d91f6a0c14044fbe Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 18 Nov 2015 17:23:57 +0800 Subject: [PATCH 057/191] =?UTF-8?q?=E9=97=AE=E5=8D=B7=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 14 ++++++++++++-- app/views/exercise/destroy.js.erb | 1 + app/views/exercise/index.html.erb | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 app/views/exercise/destroy.js.erb diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 2bc8612a4..89a5c195e 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -1,7 +1,7 @@ class ExerciseController < ApplicationController layout "base_courses" - before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show] + before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show, :destroy] before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list] include ExerciseHelper @@ -102,7 +102,17 @@ class ExerciseController < ApplicationController end def destroy - + if @exercise && @exercise.destroy + if @is_teacher + exercises = Exercise.where("course_id =?", @course.id) + else + exercises = Exercise.where("course_id =? and exercise_status =?", @course.id, 2) + end + @exercises = paginateHelper exercises,20 #分页 + respond_to do |format| + format.js + end + end end # 统计结果 diff --git a/app/views/exercise/destroy.js.erb b/app/views/exercise/destroy.js.erb new file mode 100644 index 000000000..c17b5a0f6 --- /dev/null +++ b/app/views/exercise/destroy.js.erb @@ -0,0 +1 @@ +$("#exercise").html("<%= escape_javascript(render :partial => 'exercises_list') %>"); \ No newline at end of file diff --git a/app/views/exercise/index.html.erb b/app/views/exercise/index.html.erb index 1a8d15181..bbe4dd707 100644 --- a/app/views/exercise/index.html.erb +++ b/app/views/exercise/index.html.erb @@ -1,4 +1,4 @@ <%= stylesheet_link_tag 'polls', :media => 'all' %> -
                  +
                  <%= render :partial => 'exercises_list'%>
                  \ No newline at end of file From 8e359c3d94a00e927e405e12e9825777e5b179b2 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 18 Nov 2015 17:27:29 +0800 Subject: [PATCH 058/191] =?UTF-8?q?=E9=9A=90=E8=97=8F=E6=88=91=E7=9A=84?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E7=9A=84=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_organizations.html.erb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/users/user_organizations.html.erb b/app/views/users/user_organizations.html.erb index e2a24b2aa..8c082b225 100644 --- a/app/views/users/user_organizations.html.erb +++ b/app/views/users/user_organizations.html.erb @@ -6,12 +6,12 @@
                  组织列表 - <%= form_tag url_for(:controller => 'users', :action => 'search_user_orgs', :id => User.current.id), :method => 'get', :id => "search_org_form", :class=>"resourcesSearchloadBox", :style=>"float:right; margin-top:-5px;" do %> - + + - - 搜索 - <% end %> + + +
                  From 3d3d50f1eaa64bcf57ffe6173ed423da48fbba9b Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 18 Nov 2015 17:56:01 +0800 Subject: [PATCH 059/191] =?UTF-8?q?=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 4 +- app/views/exercise/_edit_MC.html.erb | 63 +++++++++++++++++++++++++ app/views/exercise/_new_single.html.erb | 6 +-- config/routes.rb | 1 + 4 files changed, 69 insertions(+), 5 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 2bc8612a4..ebd3d9d2b 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -166,7 +166,7 @@ class ExerciseController < ApplicationController # params[:question_answer] eg:A、B、C选项 def update_exercise_question @exercise_question = ExerciseQuestion.find params[:exercise_question] - @exercise_questions.question_title = params[:exercise_questions_title].nil? || params[:exercise_questions_title].empty? ? l(:label_enter_single_title) : params[:exercise_questions_title] + @exercise_question.question_title = params[:exercise_questions_title].nil? || params[:exercise_questions_title].empty? ? l(:label_enter_single_title) : params[:exercise_questions_title] ################处理选项 if params[:question_answer] @exercise_question.exercise_answers.each do |answer| @@ -182,7 +182,7 @@ class ExerciseController < ApplicationController question.save else question_option = { - :exercise_choices_id => i, + :exercise_choice_id => i, :answer_text => answer } @exercise_question.exercise_answers.new question_option diff --git a/app/views/exercise/_edit_MC.html.erb b/app/views/exercise/_edit_MC.html.erb index e69de29bb..5a406537b 100644 --- a/app/views/exercise/_edit_MC.html.erb +++ b/app/views/exercise/_edit_MC.html.erb @@ -0,0 +1,63 @@ +<%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%> + + + +
                  +
                  + + + +
                  +
                  +
                    +
                  • + + 分 +
                  • +
                    +
                    + <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> +
                  • + + + + +
                  • +
                    + <% end %> +
                    +
                  • + + +
                  • +
                    +
                  +
                  + +
                  +
                  + +<% end%> \ No newline at end of file diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb index e4e1db695..4d9baf729 100644 --- a/app/views/exercise/_new_single.html.erb +++ b/app/views/exercise/_new_single.html.erb @@ -19,17 +19,17 @@
                • - +
                • - +
                • - +
                diff --git a/config/routes.rb b/config/routes.rb index 8dba79d2c..422f470d5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -157,6 +157,7 @@ RedmineApp::Application.routes.draw do collection do #生成路径为 /exercise/方法名 delete 'delete_exercise_question' + post 'update_exercise_question' end end From 1606e9ddab70950b194a7a5fc2d5c9a535580bcd Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 18 Nov 2015 18:28:17 +0800 Subject: [PATCH 060/191] 0 --- app/controllers/exercise_controller.rb | 4 +++- app/helpers/exercise_helper.rb | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 89a5c195e..f83e31a56 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -136,6 +136,7 @@ class ExerciseController < ApplicationController :question_score => params[:question_score] } @exercise_questions = @exercise.exercise_questions.new option + # params[:question_answer] 题目选项 if params[:question_answer] for i in 1..params[:question_answer].count answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1] @@ -154,6 +155,7 @@ class ExerciseController < ApplicationController @exercise_questions.question_number = params[:quest_num].to_i + 1 end if @exercise_questions.save + # params[:exercise_choice] 标准答案参数 standart_answer = ExerciseStandardAnswer.new standart_answer.exercise_question_id = @exercise_questions.id if @exercise_questions.question_type == 1 @@ -161,7 +163,7 @@ class ExerciseController < ApplicationController elsif @exercise_questions.question_type == 2 standart_answer.exercise_choice_id = multiselect_standard_answer(params[:exercise_choice]) else - standart_answer.answer_text = sigle_selection_standard_answer(params[:exercise_choice]) + standart_answer.answer_text = fill_standart_answer(params[:exercise_choice]) end standart_answer.save respond_to do |format| diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index c1bf07407..3a7c0a00a 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -27,6 +27,10 @@ module ExerciseHelper answer.to_i end + def fill_standart_answer(params) + + end + #判断用户是否已经提交了问卷 def has_commit_exercise?(exercise_id, user_id) pu = ExerciseUser.find_by_exercise_id_and_user_id(exercise_id, user_id) From 8cf22767f9d75046fd8a1010771d17b21b53d201 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 18 Nov 2015 19:58:00 +0800 Subject: [PATCH 061/191] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E9=97=AE=E7=AD=94?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 39 ++++++++++++++++---------- app/helpers/exercise_helper.rb | 7 +++-- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index f363b9297..0afc9dfda 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -156,16 +156,24 @@ class ExerciseController < ApplicationController end if @exercise_questions.save # params[:exercise_choice] 标准答案参数 - standart_answer = ExerciseStandardAnswer.new - standart_answer.exercise_question_id = @exercise_questions.id - if @exercise_questions.question_type == 1 - standart_answer.exercise_choice_id = sigle_selection_standard_answer(params[:exercise_choice]) - elsif @exercise_questions.question_type == 2 - standart_answer.exercise_choice_id = multiselect_standard_answer(params[:exercise_choice]) + # 问答题标准答案有三个,单独处理 + if @exercise_questions.question_type == 3 + for i in 1..params[:exercise_choice].count + standart_answer = ExerciseStandardAnswer.new + standart_answer.exercise_question_id = @exercise_questions.id + standart_answer.answer_text = params[:exercise_choice].values[i-1] + standart_answer.save + end else - standart_answer.answer_text = fill_standart_answer(params[:exercise_choice]) + standart_answer = ExerciseStandardAnswer.new + standart_answer.exercise_question_id = @exercise_questions.id + if @exercise_questions.question_type == 1 + standart_answer.exercise_choice_id = sigle_selection_standard_answer(params[:exercise_choice]) + else + standart_answer.exercise_choice_id = multiselect_standard_answer(params[:exercise_choice]) + end + standart_answer.save end - standart_answer.save respond_to do |format| format.js end @@ -178,16 +186,17 @@ class ExerciseController < ApplicationController # params[:question_answer] eg:A、B、C选项 def update_exercise_question @exercise_question = ExerciseQuestion.find params[:exercise_question] - @exercise_question.question_title = params[:exercise_questions_title].nil? || params[:exercise_questions_title].empty? ? l(:label_enter_single_title) : params[:exercise_questions_title] + @exercise_question.question_title = params[:question_title].nil? || params[:question_title].empty? ? l(:label_enter_single_title) : params[:question_title] + @exercise_question.question_score = params[:question_score] ################处理选项 if params[:question_answer] - @exercise_question.exercise_answers.each do |answer| - answer.destroy unless params[:question_answer].keys.include? answer.id.to_s - end + # @exercise_question.exercise_choices.each do |answer| + # answer.destroy unless params[:question_answer].keys.include? answer.id.to_s + # end # 界面需要判断选择题至少有一个选项 - for i in 1..params[:question_answer].count - question = @exercise_question.exercise_answers.find_by_id params[:question_answer].keys[i-1] - answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1] + for i in 1..@exercise_question.exercise_choices.count + question = @exercise_question.exercise_choices.find_by_id params[:question_answer].keys[i-1] + # answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1] if question question.exercise_choices_id = i question.answer_text = answer diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index 3a7c0a00a..7f3d1862e 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -27,8 +27,11 @@ module ExerciseHelper answer.to_i end - def fill_standart_answer(params) - + def fill_standart_answer(params, standart_answer) + params.each do |param| + standart_answer.answer_text = param.value + standart_answer.save + end end #判断用户是否已经提交了问卷 From 368fc339c0a4a47b1c358a2bb4cb896ecb5dd622 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 18 Nov 2015 20:14:19 +0800 Subject: [PATCH 062/191] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_edit_MCQ.html.erb | 63 ++++++++++++++ app/views/exercise/_edit_single.html.erb | 58 +++++++++++++ app/views/exercise/_exercise_content.html.erb | 83 ++++++++++++++----- app/views/exercise/_exercise_form.html.erb | 2 +- app/views/exercise/_show_MC.html.erb | 2 +- app/views/exercise/_show_MCQ.html.erb | 2 +- app/views/exercise/_show_single.html.erb | 4 +- .../exercise/create_exercise_question.js.erb | 72 +++++++++++----- .../exercise/update_exercise_question.js.erb | 19 +++++ 9 files changed, 259 insertions(+), 46 deletions(-) diff --git a/app/views/exercise/_edit_MCQ.html.erb b/app/views/exercise/_edit_MCQ.html.erb index e69de29bb..bd7270688 100644 --- a/app/views/exercise/_edit_MCQ.html.erb +++ b/app/views/exercise/_edit_MCQ.html.erb @@ -0,0 +1,63 @@ +<%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%> + + + +
                +
                + + + +
                +
                +
                  +
                • + + 分 +
                • +
                  +
                  + <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> +
                • + + + + +
                • +
                  + <% end %> +
                  +
                • + + +
                • +
                  +
                +
                + +
                +
                + +<% end%> \ No newline at end of file diff --git a/app/views/exercise/_edit_single.html.erb b/app/views/exercise/_edit_single.html.erb index e69de29bb..070e99343 100644 --- a/app/views/exercise/_edit_single.html.erb +++ b/app/views/exercise/_edit_single.html.erb @@ -0,0 +1,58 @@ +<%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%> + + + +
                +
                + + + +
                +
                +
                  +
                • + + 分 +
                • +
                  +
                  + <% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %> +
                • + + + + +
                • +
                  + <% end %> +
                  +
                  +
                +
                + +
                +
                + +<% end%> \ No newline at end of file diff --git a/app/views/exercise/_exercise_content.html.erb b/app/views/exercise/_exercise_content.html.erb index 9e139fe32..c5f8f3c94 100644 --- a/app/views/exercise/_exercise_content.html.erb +++ b/app/views/exercise/_exercise_content.html.erb @@ -1,22 +1,65 @@ -<% exercise.exercise_questions.each do |exercise_question|%> -
                -
                - <% if exercise_question.question_type == 1%> - <%= render :partial => 'show_MC', :locals => {:exercise_question => exercise_question} %> - <% elsif exercise_question.question_type == 2%> - <%= render :partial => 'show_MCQ', :locals => {:exercise_question => exercise_question} %> - <% elsif exercise_question.question_type == 3%> - <%= render :partial => 'show_single', :locals => {:exercise_question => exercise_question} %> - <% end%> +<% mc_question_list = exercise.exercise_questions.where("question_type=1") %> +<% mcq_question_list = exercise.exercise_questions.where("question_type=2") %> +<% single_question_list = exercise.exercise_questions.where("question_type=3") %> +
                "> +

                单选题

                + <% mc_question_list.each do |exercise_question| %> +
                +
                + <%= render :partial => 'show_MC', :locals => {:exercise_question => exercise_question} %> +
                +
                - +
                "> +

                多选题

                + <% mcq_question_list.each do |exercise_question| %> +
                +
                + <%= render :partial => 'show_MCQ', :locals => {:exercise_question => exercise_question} %> +
                +
                -
                -<% end %> \ No newline at end of file + <% end %> +
                +
                "> +

                填空题

                + <% single_question_list.each do |exercise_question| %> +
                +
                + <%= render :partial => 'show_single', :locals => {:exercise_question => exercise_question} %> +
                + +
                + <% end %> +
                +<%# exercise.exercise_questions.each do |exercise_question|%> + +<%# end %> \ No newline at end of file diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index 1d78fb435..4ac594d76 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -335,7 +335,7 @@ <%= render :partial => 'edit_head', :locals => {:exercise => @exercise}%>
                <% current_score = get_current_score @exercise %> -
                ">目前试卷总分:<%=current_score %>分
                +
                " id="current_score_div">目前试卷总分:<%=current_score %>分
                <%= render :partial => 'exercise_content', :locals => {:exercise => @exercise}%> diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb index e7bf20206..d44652603 100644 --- a/app/views/exercise/_show_MC.html.erb +++ b/app/views/exercise/_show_MC.html.erb @@ -10,7 +10,7 @@
                - +
                <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> diff --git a/app/views/exercise/_show_MCQ.html.erb b/app/views/exercise/_show_MCQ.html.erb index f69b855bd..db9fa2dd4 100644 --- a/app/views/exercise/_show_MCQ.html.erb +++ b/app/views/exercise/_show_MCQ.html.erb @@ -9,7 +9,7 @@
                -
                +
                <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> diff --git a/app/views/exercise/_show_single.html.erb b/app/views/exercise/_show_single.html.erb index 07ecce94d..591848d76 100644 --- a/app/views/exercise/_show_single.html.erb +++ b/app/views/exercise/_show_single.html.erb @@ -8,8 +8,8 @@
                - <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> - 候选答案:<%= exercise_choice.choice_text%>
                + <% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %> + 候选答案:<%= exercise_choice.answer_text%>
                <% end %>
                diff --git a/app/views/exercise/create_exercise_question.js.erb b/app/views/exercise/create_exercise_question.js.erb index 224dc0a95..db9468350 100644 --- a/app/views/exercise/create_exercise_question.js.erb +++ b/app/views/exercise/create_exercise_question.js.erb @@ -1,27 +1,57 @@ <% if @is_insert %> -$("#poll_content").html('<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise})%>'); + $("#poll_content").html('<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise})%>'); <% else %> -$("#new_poll_question").html(""); - -$("#poll_content").append("
                " + - "
                " + - "<% if @exercise_questions.question_type == 1%>" + - "<%= escape_javascript(render :partial => 'show_MC', :locals => {:exercise_question => @exercise_questions}) %>" + - "<% elsif @exercise_questions.question_type == 2%>" + - "<%= escape_javascript(render :partial => 'show_MCQ', :locals => {:exercise_question => @exercise_questions}) %>" + - "<% elsif @exercise_questions.question_type == 3%>" + - "<%= escape_javascript(render :partial => 'show_single', :locals => {:exercise_question => @exercise_questions}) %>" + - "<% end%>" + + $("#new_poll_question").html(""); + <%if @exercise_questions.question_type == 1%> + $("#mc_question_list").show().append("
                " + + "
                " + + "<%= escape_javascript(render :partial => 'show_MC', :locals => {:exercise_question => @exercise_questions}) %>" + + "
                " + + "" + + "
                "); + <% end %> + <%if @exercise_questions.question_type == 2%> + $("#mcq_question_list").show().append("
                " + + "
                " + + "<%= escape_javascript(render :partial => 'show_MCQ', :locals => {:exercise_question => @exercise_questions}) %>" + + "
                " + + "" + + "
                "); + <% end %> + <%if @exercise_questions.question_type == 3%> + $("#single_question_list").show().append("
                " + + "
                " + + "<%= escape_javascript(render :partial => 'show_single', :locals => {:exercise_question => @exercise_questions}) %>" + + "
                " + + "" + + "
                "); + <% end %> +/*$("#poll_content").append("
                " + + "
                " + + "<%# if @exercise_questions.question_type == 1%>" + + "<%#= escape_javascript(render :partial => 'show_MC', :locals => {:exercise_question => @exercise_questions}) %>" + + "<%# elsif @exercise_questions.question_type == 2%>" + + "<%#= escape_javascript(render :partial => 'show_MCQ', :locals => {:exercise_question => @exercise_questions}) %>" + + "<%# elsif @exercise_questions.question_type == 3%>" + + "<%#= escape_javascript(render :partial => 'show_single', :locals => {:exercise_question => @exercise_questions}) %>" + + "<%# end%>" + "
                " + - ""); + "
                ");*/ $("#current_score").html("<%=get_current_score @exercise %>分"); +$("#current_score_div").show(); <% end %> diff --git a/app/views/exercise/update_exercise_question.js.erb b/app/views/exercise/update_exercise_question.js.erb index e69de29bb..0f0a23cec 100644 --- a/app/views/exercise/update_exercise_question.js.erb +++ b/app/views/exercise/update_exercise_question.js.erb @@ -0,0 +1,19 @@ +$("#poll_questions_<%= @exercise_question.id%>").html("
                " + + "<% if @exercise_question.question_type == 1%>" + + "<%= escape_javascript(render :partial => 'show_MC', :locals => {:exercise_question => @exercise_question}) %>" + + "<% elsif @exercise_question.question_type == 2%>" + + "<%= escape_javascript(render :partial => 'show_MCQ', :locals => {:exercise_question => @exercise_question}) %>" + + "<% elsif @exercise_question.question_type == 3%>" + + "<%= escape_javascript(render :partial => 'show_single', :locals => {:exercise_question => @exercise_question}) %>" + + "<% end%>" + + "
                " + + ""); +$("#current_score").html("<%=get_current_score @exercise %>分"); From 2296a2f50ce95774e15f7b0cf7011c9309182825 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 18 Nov 2015 21:16:24 +0800 Subject: [PATCH 063/191] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BD=9C=E4=B8=9A=20=E8=80=81=E5=B8=88?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=BD=9C=E4=B8=9A=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 159 ++++++++++++++++++++++++- config/routes.rb | 2 + 2 files changed, 158 insertions(+), 3 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 0afc9dfda..a291a2229 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -1,7 +1,7 @@ class ExerciseController < ApplicationController layout "base_courses" - before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show, :destroy] + before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show, :destroy, :commit_exercise, :commit_answer] before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list] include ExerciseHelper @@ -265,10 +265,163 @@ class ExerciseController < ApplicationController end end + # 学生提交答卷 + def commit_answer + eq = ExerciseQuestion.find(params[:poll_question_id]) + if has_commit_exercise?(@exercise.id,User.current.id) && (!User.current.admin?) + render :json => {:text => "failure"} + return + end + if eq.question_type == 1 + # 单选题 + ea = ExerciseAnswer.find_by_exercise_question_id_and_user_id(params[:exercise_question_id],User.current.id) + if ea.nil? + # 尚未答该题,添加答案 + ea = ExerciseAnswer.new + ea.user_id = User.current.id + ea.exercise_question_id = params[:exercise_question_id] + end + #修改该题对应答案 + ea.exercise_choice_id = params[:exercise_choice_id] + if ea.save + # 保存成功返回成功信息及当前以答题百分比 + @percent = get_percent(@exercise,User.current) + render :json => {:text => "ok" ,:percent => format("%.2f" ,@percent)} + else + #返回失败信息 + render :json => {:text => "failure"} + end + elsif eq.question_type == 2 + #多选题 + ea = ExerciseAnswer.find_by_exercise_question_id_and_user_id(params[:exercise_question_id],User.current.id) + if ea.nil? + #尚未答该题,添加答案 + ea = ExerciseAnswer.new + ea.user_id = User.current.id + ea.exercise_question_id = params[:exercise_question_id] + ea.exercise_choice_id = params[:exercise_choice_id] + if ea.save + @percent = get_percent(@exercise,User.current) + render :json => {:text => "true",:percent => format("%.2f" ,@percent)} + else + render :json => {:text => "failure"} + end + else + #pv不为空,则当前选项之前已被选择,再次点击则是不再选择该项,故删除该答案 + if pv.delete + @percent = get_percent(@exercise, User.current) + render :json => {:text => "false" ,:percent => format("%.2f" , @percent)} + else + render :json => {:text => "failure"} + end + end + elsif eq.question_type == 3 + #单行文本,多行文本题 + ea = ExerciseAnswer.find_by_exercise_question_id_and_user_id(params[:exercise_question_id], User.current.id) + if ea.nil? + # ea为空之前尚未答题,添加答案 + if params[:answer_text].nil? || params[:answer_text].blank? + #用户提交空答案,视作不作答 + @percent = get_percent(@exercise,User.current) + render :json => {:text => ea.answer_text,:percent => format("%.2f", @percent)} + else + #添加答案 + ea = ExerciseAnswer.new + ea.user_id = User.current.id + ea.exercise_question_id = params[:exercise_question_id] + ea.answer_text = params[:answer_text] + if ea.save + @percent = get_percent(@exercise,User.current) + render :json => {:text => pv.vote_text,:percent => format("%.2f",@percent)} + else + render :json => {:text => "failure"} + end + end + else + # ea不为空说明用户之前已作答 + if params[:answer_text].nil? || params[:answer_text].blank? + # 用户提交空答案,视为删除答案 + if ea.delete + @percent = get_percent(@exercise,User.current) + render :json => {:text => ea.answer_text,:percent => format("%.2f", @percent)} + else + render :json => {:text => "failure"} + end + else + #用户修改答案 + ea.answer_text = params[:answer_text] + if ea.save + @percent = get_percent(@exercise,User.current) + render :json => {:text => pv.vote_text,:percent => format("%.2f", @percent)} + else + render :json => {:text => "failure"} + end + end + end + + else + render :json => {:text => "failure"} + end + end + + # 提交问卷 + def commit_exercise + # 老师不需要提交 + if User.current.allowed_to?(:as_teacher,@course) + redirect_to exercise_url(@exercise) + else + # 答题过程中需要统计完成量 + @uncomplete_question = get_uncomplete_question(@exercise, User.current) + # 获取改学生的考试得分 + score = get_answer_score(@exercise) + if @uncomplete_question.count < 1 + # 查看是否有已提交记录 + eu = get_exercise_user(@exercise.id, User.current.id) + eu.user_id = User.current.id + eu.exercise_id = @exercise.id + eu.score = score + if eu.save + #redirect_to poll_index_path(:polls_group_id => @course.id,:polls_type => 'Course') + @status = 0 #提交成功 + else + @status = 2 #未知错误 + end + else + @status = 1 #有未做得必答题 + end + respond_to do |format| + format.js + end + end + end + + private + # ExerciseUser记录用户是否已提交问卷有对应的记录则已提交,没有则新建一个 + def get_exercise_user exercise_id,user_id + eu = ExerciseUser.find_by_exercise_id_and_user_id(exercise_id,user_id) + if eu.nil? + eu = ExerciseUser.new + end + eu + end + + #获取未完成的题目 + def get_uncomplete_question exercise,user + all_questions = exercise.exercise_questions + uncomplete_question = [] + all_questions.each do |question| + answers = get_user_answer(question, user) + if answers.nil? || answers.count < 1 + uncomplete_question << question + end + end + uncomplete_question + end + # 获取问题的答案 def get_user_answer(question,user) - user_answer = question.poll_votes.where("#{PollVote.table_name}.user_id = #{user.id}") + user_answer = question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{user.id}") user_answer end @@ -285,7 +438,7 @@ class ExerciseController < ApplicationController complete_question end - + # 获取答题百分比 def get_percent exercise,user complete_count = get_complete_question(exercise,user).count if exercise.exercise_questions.count == 0 diff --git a/config/routes.rb b/config/routes.rb index 422f470d5..516b8977f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -153,6 +153,8 @@ RedmineApp::Application.routes.draw do get 'student_exercise_list' get 'export_exercise' post 'create_exercise_question' + post 'commit_answer' + post 'commit_exercise' end collection do #生成路径为 /exercise/方法名 From a173e924d00d60c7fed10238a6a93f8ed046654a Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 19 Nov 2015 09:13:46 +0800 Subject: [PATCH 064/191] =?UTF-8?q?=E6=8F=92=E5=85=A5=E9=A2=98=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_edit_MC.html.erb | 2 +- app/views/exercise/_edit_MCQ.html.erb | 2 +- app/views/exercise/_edit_single.html.erb | 2 +- app/views/exercise/_exercise_form.html.erb | 331 ++++++++++++--------- app/views/exercise/_new_single.html.erb | 12 +- app/views/exercise/_show_MC.html.erb | 9 +- app/views/exercise/_show_MCQ.html.erb | 2 +- app/views/exercise/_show_single.html.erb | 9 +- 8 files changed, 207 insertions(+), 162 deletions(-) diff --git a/app/views/exercise/_edit_MC.html.erb b/app/views/exercise/_edit_MC.html.erb index 5a406537b..c769fe634 100644 --- a/app/views/exercise/_edit_MC.html.erb +++ b/app/views/exercise/_edit_MC.html.erb @@ -18,7 +18,7 @@ } -
                +
                diff --git a/app/views/exercise/_edit_MCQ.html.erb b/app/views/exercise/_edit_MCQ.html.erb index bd7270688..01e63cb24 100644 --- a/app/views/exercise/_edit_MCQ.html.erb +++ b/app/views/exercise/_edit_MCQ.html.erb @@ -18,7 +18,7 @@ } -
                +
                diff --git a/app/views/exercise/_edit_single.html.erb b/app/views/exercise/_edit_single.html.erb index 070e99343..1048b2145 100644 --- a/app/views/exercise/_edit_single.html.erb +++ b/app/views/exercise/_edit_single.html.erb @@ -17,7 +17,7 @@ } -
                +
                diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index 4ac594d76..863f68a72 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -60,60 +60,74 @@ } function insert_MC(quest_type,quest_num,quest_id){ - $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( - '<%= form_for(ExerciseQuestion.new, - :html => { :multipart => true }, - :url => {:controller => 'exercise', - :action => 'create_exercise_question', - :course_id => @course.id - },:remote=>true ) do |f|%>'+ - '
                '+ - '
                '+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - '
                '+ - '
                '+ - '
                  '+ - '
                • '+ - ''+ - ''+ - ''+ - ''+ - '
                • '+ - '
                  '+ - '
                • '+ - ''+ - ''+ - ''+ - ''+ - '
                • '+ - '
                  '+ - '
                • '+ - ''+ - ''+ - ''+ - ''+ - '
                • '+ - '
                  '+ - '
                '+ - '
                '+ - ''+ - '
                '+ - '
                '+ - '<% end%>' - ); + if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == "") { + $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( + '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>{:controller=> 'exercise',:action=>'create_exercise_question',:course_id=>@course.id},:remote=>true) do |f|%>'+ + '
                '+ + '
                '+ + ''+ + ''+ + ''+ + ''+ + ''+ + '
                '+ + '
                '+ + '
                  '+ + '
                • '+ + ''+ + '分'+ + '
                • '+ + '
                • '+ + ''+ + ''+ + ''+ + ''+ + '
                • '+ + '
                  '+ + '
                • '+ + ''+ + ''+ + ''+ + ''+ + '
                • '+ + '
                  '+ + '
                • '+ + ''+ + ''+ + ''+ + ''+ + '
                • '+ + '
                  '+ + '
                • '+ + ''+ + ''+ + ''+ + ''+ + '
                • '+ + '
                  '+ + '
                • '+ + ''+ + ''+ + '
                • '+ + '
                  '+ + '
                '+ + '
                '+ + ''+ + '
                '+ + '
                '+ + '<% end%>' + ); + } + else { + $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(""); + } $("#poll_questions_title").focus(); } @@ -123,60 +137,73 @@ } function insert_MCQ(quest_type,quest_num,quest_id){ - $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( - '<%= form_for(ExerciseQuestion.new, - :html => { :multipart => true }, - :url => {:controller => 'exercise', - :action => 'create_exercise_question', - :course_id => @course.id - },:remote=>true ) do |f|%>'+ - '
                '+ - '
                '+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - '
                '+ - '
                '+ - '
                  '+ - '
                • '+ - ''+ - ''+ - ''+ - ''+ - '
                • '+ - '
                  '+ - '
                • '+ - ''+ - ''+ - ''+ - ''+ - '
                • '+ - '
                  '+ - '
                • '+ - ''+ - ''+ - ''+ - ''+ - '
                • '+ - '
                  '+ - '
                '+ - '
                '+ - ''+ - '
                '+ - '
                '+ - '<% end%>' - ); + if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == ""){ + $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( + '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>{:controller=> 'exercise',:action=>'create_exercise_question',:course_id=>@course.id},:remote=>true) do |f|%>'+ + '
                '+ + '
                '+ + ''+ + ''+ + ''+ + ''+ + ''+ + '
                '+ + '
                '+ + '
                  '+ + '
                • '+ + ''+ + '分'+ + '
                • '+ + '
                • '+ + ''+ + ''+ + ''+ + ''+ + '
                • '+ + '
                  '+ + '
                • '+ + ''+ + ''+ + ''+ + ''+ + '
                • '+ + '
                  '+ + '
                • '+ + ''+ + ''+ + ''+ + ''+ + '
                • '+ + '
                  '+ + '
                • '+ + ''+ + ''+ + ''+ + ''+ + '
                • '+ + '
                  '+ + '
                • '+ + ''+ + ''+ + '
                • '+ + '
                  '+ + '
                '+ + '
                '+ + ''+ + '
                '+ + '
                '+ + '<% end%>' + ); + } else { + $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(""); + } $("#poll_questions_title").focus(); } @@ -186,35 +213,61 @@ } function insert_SINGLE(quest_type,quest_num,quest_id){ - $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( - '<%= form_for(ExerciseQuestion.new, - :html => { :multipart => true }, - :url => {:controller => 'exercise', - :action => 'create_exercise_question', - :course_id => @course.id - },:remote=>true ) do |f|%>'+ - '
                '+ - '
                '+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - '
                '+ - ''+ - '
                '+ - '
                '+ - '<% end%>' - ); + if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == "") { + $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( + '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>{:controller=> 'exercise',:action=>'create_exercise_question',:course_id=>@course.id},:remote=>true) do |f|%>'+ + '
                '+ + '
                '+ + ''+ + ''+ + ''+ + ''+ + ''+ + '
                '+ + '
                '+ + '
                  '+ + '
                • '+ + ''+ + '分'+ + '
                • '+ + '
                • '+ + ''+ + ''+ + ''+ + ''+ + '
                • '+ + '
                  '+ + '
                • '+ + ''+ + ''+ + ''+ + ''+ + '
                • '+ + '
                  '+ + '
                • '+ + ''+ + ''+ + ''+ + ''+ + '
                • '+ + '
                  '+ + '
                '+ + '
                '+ + ''+ + '
                '+ + '
                '+ + '<% end%>' + ); + } else { + $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(""); + } $("#poll_questions_title").focus(); } @@ -247,13 +300,13 @@ function add_poll_question(doc) { var title = $.trim($("#poll_questions_title").val()); - if(title.length == 0){alert("标题不能为空");}else{doc.parent().parent().parent().submit();} + if(title.length == 0){alert("题目标题不能为空");}else{doc.parent().parent().parent().submit();} } //修改标题时确定按钮 function edit_poll_question(doc,id) { var title = $.trim($("#poll_questions_title_" + id).val()); - if(title.length == 0){alert("标题不能为空");}else{doc.parent().parent().parent().submit();} + if(title.length == 0){alert("题目标题不能为空");}else{doc.parent().parent().parent().submit();} } //问卷头 diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb index 4d9baf729..a8c6f57ea 100644 --- a/app/views/exercise/_new_single.html.erb +++ b/app/views/exercise/_new_single.html.erb @@ -20,17 +20,23 @@
              • -
              • + + +
              • -
              • + + +
              • -
              • + + +
                diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb index d44652603..241cc6009 100644 --- a/app/views/exercise/_show_MC.html.erb +++ b/app/views/exercise/_show_MC.html.erb @@ -7,7 +7,7 @@ <%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id), method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> - +
                @@ -28,11 +28,4 @@
                -
                - \ No newline at end of file diff --git a/app/views/exercise/_show_MCQ.html.erb b/app/views/exercise/_show_MCQ.html.erb index db9fa2dd4..7dd52b30a 100644 --- a/app/views/exercise/_show_MCQ.html.erb +++ b/app/views/exercise/_show_MCQ.html.erb @@ -6,7 +6,7 @@ <%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id), method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> - +
                diff --git a/app/views/exercise/_show_single.html.erb b/app/views/exercise/_show_single.html.erb index 591848d76..452a14bc4 100644 --- a/app/views/exercise/_show_single.html.erb +++ b/app/views/exercise/_show_single.html.erb @@ -5,7 +5,7 @@ <%= link_to("", delete_exercise_question_exercise_index_path(:exercise_question => exercise_question.id), method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %> - +
                <% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %> @@ -15,11 +15,4 @@
                -
                - \ No newline at end of file From ea47a8085acb10d4fb90edf2140cd84fc9b613ac Mon Sep 17 00:00:00 2001 From: "Gan Yi.ang" Date: Thu, 19 Nov 2015 09:20:25 +0800 Subject: [PATCH 065/191] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=E6=97=A0=E5=93=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/projects/settings/_join_org.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/projects/settings/_join_org.html.erb b/app/views/projects/settings/_join_org.html.erb index 57ae714bd..1af9f3e44 100644 --- a/app/views/projects/settings/_join_org.html.erb +++ b/app/views/projects/settings/_join_org.html.erb @@ -16,12 +16,13 @@
                关联组织
                - <%= form_tag url_for(:controller => 'org_projects', :action => 'create', :project_id => @project.id), :id => 'join_orgs_for_project', :remote => true %> + <%= form_tag url_for(:controller => 'org_projects', :action => 'create', :project_id => @project.id), :id => 'join_orgs_for_project', :remote => true do %>
                  关联 取消 + <% end %>
                  From 478a534c96cf467a7260c6e6ee36f959710f8716 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 19 Nov 2015 10:08:11 +0800 Subject: [PATCH 066/191] =?UTF-8?q?1.=E5=B0=86=E8=AF=BE=E7=A8=8B=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E5=8A=A0=E5=85=A5=E7=BB=84=E7=BB=87=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E7=9A=84=E8=BF=87=E6=BB=A4=E6=9D=A1=E4=BB=B6=E4=B8=AD=EF=BC=9B?= =?UTF-8?q?=202.=E5=88=9B=E5=BB=BA=E6=96=87=E7=AB=A0=E6=88=90=E5=8A=9F?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E7=BB=99=E5=87=BA=E4=BF=A1=E6=81=AF=E6=8F=90?= =?UTF-8?q?=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org_document_comments_controller.rb | 2 +- app/controllers/organizations_controller.rb | 8 ++++++++ app/views/org_document_comments/index.html.erb | 2 +- app/views/organizations/show.html.erb | 18 ++++++++++++++++-- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index 13a188e72..af229635c 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -12,7 +12,7 @@ class OrgDocumentCommentsController < ApplicationController @org_document_comment.title = params[:org_document_comment][:title] @org_document_comment.content = params[:org_document_comment][:content] if @org_document_comment.save - #flash[:notice] = 'success' + flash.keep[:notice] = l(:notice_successful_create) OrgActivity redirect_to organization_org_document_comments_path(@organization) else diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 8c8d8bae4..3713beb22 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -70,6 +70,14 @@ class OrganizationsController < ApplicationController @org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Message' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) when 'org' @org_activities = OrgActivity.where("container_id =? and container_type =?",@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_homework' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'HomeworkCommon' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_news' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'News' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_message' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Message' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_poll' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Poll' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) end @page = params[:page] respond_to do |format| diff --git a/app/views/org_document_comments/index.html.erb b/app/views/org_document_comments/index.html.erb index d9b1d9579..6019dae14 100644 --- a/app/views/org_document_comments/index.html.erb +++ b/app/views/org_document_comments/index.html.erb @@ -19,6 +19,6 @@ init_activity_KindEditor_data(<%= document.id%>, null, "87%"); }); - <%= render :partial => 'organizations/show_org_document', :locals => {:document => document} %> + <%= render :partial => 'organizations/show_org_document', :locals => {:document => document, :act => OrgActivity.where("org_act_type='OrgDocumentComment'and org_act_id=?", document.id).first} %> <% end %> <% end %> \ No newline at end of file diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb index acaf2879e..e44e0778d 100644 --- a/app/views/organizations/show.html.erb +++ b/app/views/organizations/show.html.erb @@ -17,6 +17,19 @@
                    • +
                    • +
                        +
                      • 课程动态
                      • +
                      • <%= link_to "作业动态", {:controller => "organizations", :action => "show", :type => "course_homework"}, :class => "homepagePostTypeAssignment postTypeGrey"%> +
                      • +
                      • <%= link_to "通知动态", {:controller => "organizations", :action => "show", :type => "course_news"}, :class => "homepagePostTypeNotice postTypeGrey"%> + +
                      • <%= link_to "论坛动态", {:controller => "organizations", :action => "show", :type => "course_message"}, :class => "homepagePostTypeForum postTypeGrey"%> +
                      • <%= link_to "问卷动态", {:controller => "organizations", :action => "show", :type => "course_poll"}, :class => "homepagePostTypeQuiz postTypeGrey"%> + + +
                      +
                      • 项目动态
                      • @@ -48,12 +61,13 @@ <% act = OrgActivity.where("org_act_type = 'OrgDocumentComment' and org_act_id =?", @organization.home_id).first %> <%= render :partial => 'show_org_document', :locals => {:document => OrgDocumentComment.find(@organization.home_id), :home_id => @organization.home_id, :act => act} %> <% end %> - -<%= render :partial => 'organizations/org_activities', +<% if @org_activities %> + <%= render :partial => 'organizations/org_activities', :locals => {:org_activities =>@org_activities, :page=>@page, :org => @organization, :org_act_count=>@org_activities.count}%> +<% end %> From 09659387e7f7ec2f9bfb1aba83eaa322ea388256 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 19 Nov 2015 10:15:33 +0800 Subject: [PATCH 067/191] =?UTF-8?q?=E6=96=87=E7=AB=A0=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E4=B8=AD=EF=BC=8C=E5=B0=86=E7=BB=84=E7=BB=87=E6=94=B9=E6=88=90?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=96=87=E7=AB=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/organizations/_show_org_document.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/organizations/_show_org_document.html.erb b/app/views/organizations/_show_org_document.html.erb index e352288ab..1324729ac 100644 --- a/app/views/organizations/_show_org_document.html.erb +++ b/app/views/organizations/_show_org_document.html.erb @@ -11,7 +11,7 @@ <% if document.organization.home_id == document.id %> 首页 <% else %> - 组织 + 组织文章 <% end %>
                  <%= document.title %>
                  From 4cd9f6a50278a9f513f31c335d6ee3341e75973b Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 19 Nov 2015 11:37:49 +0800 Subject: [PATCH 068/191] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E9=A2=98=E7=9B=AE?= =?UTF-8?q?=E6=97=B6=E5=88=86=E6=95=B0=E8=87=AA=E5=8A=A8=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=90=8C=E4=B8=80=E7=B1=BB=E5=9E=8B=E9=A2=98=E7=9B=AE=E7=9A=84?= =?UTF-8?q?=E6=9C=80=E5=90=8E=E4=B8=80=E4=B8=AA=E5=88=86=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_exercise_form.html.erb | 237 +----------------- app/views/exercise/_new_MC.html.erb | 3 +- app/views/exercise/_new_MCQ.html.erb | 3 +- app/views/exercise/_new_question.html.erb | 24 ++ app/views/exercise/_new_single.html.erb | 3 +- app/views/exercise/_show_MC.html.erb | 77 +++++- app/views/exercise/_show_MCQ.html.erb | 83 +++++- app/views/exercise/_show_single.html.erb | 64 ++++- .../exercise/create_exercise_question.js.erb | 1 + 9 files changed, 254 insertions(+), 241 deletions(-) create mode 100644 app/views/exercise/_new_question.html.erb diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index 863f68a72..4bb2c31ab 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -54,223 +54,6 @@ } } - function add_MC(){ - $("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MC') %>"); - $("#poll_questions_title").focus(); - } - - function insert_MC(quest_type,quest_num,quest_id){ - if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == "") { - $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( - '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>{:controller=> 'exercise',:action=>'create_exercise_question',:course_id=>@course.id},:remote=>true) do |f|%>'+ - '
                  '+ - '
                  '+ - ''+ - ''+ - ''+ - ''+ - ''+ - '
                  '+ - '
                  '+ - '
                    '+ - '
                  • '+ - ''+ - '分'+ - '
                  • '+ - '
                  • '+ - ''+ - ''+ - ''+ - ''+ - '
                  • '+ - '
                    '+ - '
                  • '+ - ''+ - ''+ - ''+ - ''+ - '
                  • '+ - '
                    '+ - '
                  • '+ - ''+ - ''+ - ''+ - ''+ - '
                  • '+ - '
                    '+ - '
                  • '+ - ''+ - ''+ - ''+ - ''+ - '
                  • '+ - '
                    '+ - '
                  • '+ - ''+ - ''+ - '
                  • '+ - '
                    '+ - '
                  '+ - '
                  '+ - ''+ - '
                  '+ - '
                  '+ - '<% end%>' - ); - } - else { - $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(""); - } - $("#poll_questions_title").focus(); - } - - function add_MCQ(){ - $("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MCQ') %>"); - $("#poll_questions_title").focus(); - } - - function insert_MCQ(quest_type,quest_num,quest_id){ - if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == ""){ - $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( - '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>{:controller=> 'exercise',:action=>'create_exercise_question',:course_id=>@course.id},:remote=>true) do |f|%>'+ - '
                  '+ - '
                  '+ - ''+ - ''+ - ''+ - ''+ - ''+ - '
                  '+ - '
                  '+ - '
                    '+ - '
                  • '+ - ''+ - '分'+ - '
                  • '+ - '
                  • '+ - ''+ - ''+ - ''+ - ''+ - '
                  • '+ - '
                    '+ - '
                  • '+ - ''+ - ''+ - ''+ - ''+ - '
                  • '+ - '
                    '+ - '
                  • '+ - ''+ - ''+ - ''+ - ''+ - '
                  • '+ - '
                    '+ - '
                  • '+ - ''+ - ''+ - ''+ - ''+ - '
                  • '+ - '
                    '+ - '
                  • '+ - ''+ - ''+ - '
                  • '+ - '
                    '+ - '
                  '+ - '
                  '+ - ''+ - '
                  '+ - '
                  '+ - '<% end%>' - ); - } else { - $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(""); - } - $("#poll_questions_title").focus(); - } - - function add_single(){ - $("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_single') %>"); - $("#poll_questions_title").focus(); - } - - function insert_SINGLE(quest_type,quest_num,quest_id){ - if($.trim($("#insert_new_poll_question_"+quest_type+"_"+quest_id).html()) == "") { - $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( - '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>{:controller=> 'exercise',:action=>'create_exercise_question',:course_id=>@course.id},:remote=>true) do |f|%>'+ - '
                  '+ - '
                  '+ - ''+ - ''+ - ''+ - ''+ - ''+ - '
                  '+ - '
                  '+ - '
                    '+ - '
                  • '+ - ''+ - '分'+ - '
                  • '+ - '
                  • '+ - ''+ - ''+ - ''+ - ''+ - '
                  • '+ - '
                    '+ - '
                  • '+ - ''+ - ''+ - ''+ - ''+ - '
                  • '+ - '
                    '+ - '
                  • '+ - ''+ - ''+ - ''+ - ''+ - '
                  • '+ - '
                    '+ - '
                  '+ - '
                  '+ - ''+ - '
                  '+ - '
                  '+ - '<% end%>' - ); - } else { - $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(""); - } - $("#poll_questions_title").focus(); - } - //选择导入调查问卷 function importPoll(){ importPollPopWindow = $("#import_poll"); @@ -297,10 +80,15 @@ } //添加标题时确定按钮 - function add_poll_question(doc) + function add_poll_question(doc,quest_type,quest_id) { - var title = $.trim($("#poll_questions_title").val()); - if(title.length == 0){alert("题目标题不能为空");}else{doc.parent().parent().parent().submit();} + if(arguments[1] && arguments[2]){ + var title = $.trim($("#poll_questions_title_"+quest_type+"_"+quest_id)); + if(title.length == 0){alert("题目标题不能为空");}else{doc.parent().parent().parent().submit();} + } else { + var title = $.trim($("#poll_questions_title").val()); + if(title.length == 0){alert("题目标题不能为空");}else{doc.parent().parent().parent().submit();} + } } //修改标题时确定按钮 function edit_poll_question(doc,id) @@ -394,13 +182,8 @@ <%= render :partial => 'exercise_content', :locals => {:exercise => @exercise}%>
                  -
                  - -
                  +
                  + <%= render :partial => 'new_question', :locals => {:exercise => @exercise} %>
                  diff --git a/app/views/exercise/_new_MC.html.erb b/app/views/exercise/_new_MC.html.erb index 158f8be96..3da0021ce 100644 --- a/app/views/exercise/_new_MC.html.erb +++ b/app/views/exercise/_new_MC.html.erb @@ -13,8 +13,9 @@
                  • + <% score = exercise.exercise_questions.where("question_type=1").last.nil? ? "": exercise.exercise_questions.where("question_type=1").last.question_score %> - 分 +
                  • diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb index 6e58d620e..044ecd629 100644 --- a/app/views/exercise/_new_MCQ.html.erb +++ b/app/views/exercise/_new_MCQ.html.erb @@ -13,8 +13,9 @@
                    • + <% score = exercise.exercise_questions.where("question_type=2").last.nil? ? "": exercise.exercise_questions.where("question_type=2").last.question_score %> - 分 +
                    • diff --git a/app/views/exercise/_new_question.html.erb b/app/views/exercise/_new_question.html.erb new file mode 100644 index 000000000..d41ad1ca7 --- /dev/null +++ b/app/views/exercise/_new_question.html.erb @@ -0,0 +1,24 @@ + +
                      + + \ No newline at end of file diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb index a8c6f57ea..ad5af1937 100644 --- a/app/views/exercise/_new_single.html.erb +++ b/app/views/exercise/_new_single.html.erb @@ -13,8 +13,9 @@
                      • + <% score = exercise.exercise_questions.where("question_type=3").last.nil? ? "": exercise.exercise_questions.where("question_type=3").last.question_score %> - 分 +
                      • diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb index 241cc6009..1c90f6908 100644 --- a/app/views/exercise/_show_MC.html.erb +++ b/app/views/exercise/_show_MC.html.erb @@ -28,4 +28,79 @@
                      -
                      \ No newline at end of file +
                    + + \ No newline at end of file diff --git a/app/views/exercise/_show_MCQ.html.erb b/app/views/exercise/_show_MCQ.html.erb index 7dd52b30a..08a012fd3 100644 --- a/app/views/exercise/_show_MCQ.html.erb +++ b/app/views/exercise/_show_MCQ.html.erb @@ -28,12 +28,77 @@
                    - \ No newline at end of file + + \ No newline at end of file diff --git a/app/views/exercise/_show_single.html.erb b/app/views/exercise/_show_single.html.erb index 452a14bc4..8232e68f3 100644 --- a/app/views/exercise/_show_single.html.erb +++ b/app/views/exercise/_show_single.html.erb @@ -15,4 +15,66 @@
                  -
                  \ No newline at end of file +
                  + + \ No newline at end of file diff --git a/app/views/exercise/create_exercise_question.js.erb b/app/views/exercise/create_exercise_question.js.erb index db9468350..37199a70e 100644 --- a/app/views/exercise/create_exercise_question.js.erb +++ b/app/views/exercise/create_exercise_question.js.erb @@ -1,6 +1,7 @@ <% if @is_insert %> $("#poll_content").html('<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise})%>'); <% else %> + $("#new_exercise_question").html('<%= escape_javascript(render :partial => 'new_question', :locals => {:exercise => @exercise}) %>'); $("#new_poll_question").html(""); <%if @exercise_questions.question_type == 1%> $("#mc_question_list").show().append("
                  " + From bc47382115689c4cfdddc93717b9e7c53c564e31 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 19 Nov 2015 11:38:44 +0800 Subject: [PATCH 069/191] =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E7=AD=94=E5=8D=B7=E5=90=8E=EF=BC=8C=E7=BB=99=E5=87=BA=E5=BE=97?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 42 +++++++++++++++++++++----- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index a291a2229..58c6f772b 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -190,9 +190,9 @@ class ExerciseController < ApplicationController @exercise_question.question_score = params[:question_score] ################处理选项 if params[:question_answer] - # @exercise_question.exercise_choices.each do |answer| - # answer.destroy unless params[:question_answer].keys.include? answer.id.to_s - # end + @exercise_question.exercise_choices.each do |answer| + answer.destroy unless params[:question_answer].keys.include? answer.id.to_s + end # 界面需要判断选择题至少有一个选项 for i in 1..@exercise_question.exercise_choices.count question = @exercise_question.exercise_choices.find_by_id params[:question_answer].keys[i-1] @@ -265,9 +265,10 @@ class ExerciseController < ApplicationController end end - # 学生提交答卷 + # 学生提交答卷,选着答案的课程中提交 def commit_answer - eq = ExerciseQuestion.find(params[:poll_question_id]) + eq = ExerciseQuestion.find(params[:exercise_question_id]) + # 已提交过的则不允许答题 if has_commit_exercise?(@exercise.id,User.current.id) && (!User.current.admin?) render :json => {:text => "failure"} return @@ -369,11 +370,12 @@ class ExerciseController < ApplicationController # 老师不需要提交 if User.current.allowed_to?(:as_teacher,@course) redirect_to exercise_url(@exercise) + # REDO: 提示提交成功 else # 答题过程中需要统计完成量 @uncomplete_question = get_uncomplete_question(@exercise, User.current) # 获取改学生的考试得分 - score = get_answer_score(@exercise) + score = calculate_student_score(@exercise, User.current) if @uncomplete_question.count < 1 # 查看是否有已提交记录 eu = get_exercise_user(@exercise.id, User.current.id) @@ -395,6 +397,26 @@ class ExerciseController < ApplicationController end end + # 计算学生得分 + def calculate_student_score(exercise, user) + score = 0 + exercise_qustions = exercise.exercise_questions + exercise_qustions.each do |question| + answer = get_user_answer(question, user) + standard_answer = get_user_standard_answer(question, user) + # 问答题有多个答案 + if question.question_type == 3 + if standard_answer.exercise_choice_id.include?(answer.exercise_choice_id) + score = score + question.question_score + end + else + if answer.exercise_choice_id == standard_answer.exercise_choice_id + score = score + question.question_score + end + end + end + score + end private # ExerciseUser记录用户是否已提交问卷有对应的记录则已提交,没有则新建一个 @@ -419,12 +441,18 @@ class ExerciseController < ApplicationController uncomplete_question end - # 获取问题的答案 + # 获取当前学生回答问题的答案 def get_user_answer(question,user) user_answer = question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{user.id}") user_answer end + # 获取问题的标准答案 + def get_user_standard_answer(question,user) + standard_answer = question.exercise_standard_answers + standard_answer + end + # 是否完成了答题 def get_complete_question(exercise,user) questions = exercise.exercise_questions From 3929aa6dded402df31197c038d00d25875cc713f Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 19 Nov 2015 13:06:17 +0800 Subject: [PATCH 070/191] =?UTF-8?q?=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_edit_MC.html.erb | 4 ++-- app/views/exercise/_edit_MCQ.html.erb | 4 ++-- app/views/exercise/_edit_head.html.erb | 2 +- app/views/exercise/_new_MC.html.erb | 1 + app/views/exercise/_new_MCQ.html.erb | 1 + app/views/exercise/_new_single.html.erb | 1 + 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/views/exercise/_edit_MC.html.erb b/app/views/exercise/_edit_MC.html.erb index c769fe634..ef46e47a8 100644 --- a/app/views/exercise/_edit_MC.html.erb +++ b/app/views/exercise/_edit_MC.html.erb @@ -1,4 +1,4 @@ -<%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%> +<%= form_for("",:class => 'new_or_edit_question',:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%> \ No newline at end of file diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb index 06b8939c3..ad5af1937 100644 --- a/app/views/exercise/_new_single.html.erb +++ b/app/views/exercise/_new_single.html.erb @@ -1,6 +1,5 @@ <%= form_for(ExerciseQuestion.new, :html => { :multipart => true }, - :class => 'new_or_edit_question', :url => {:controller => 'exercise', :action => 'create_exercise_question', :course_id => @course.id diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb index 1c90f6908..21d6ef4bb 100644 --- a/app/views/exercise/_show_MC.html.erb +++ b/app/views/exercise/_show_MC.html.erb @@ -32,75 +32,80 @@ \ No newline at end of file diff --git a/app/views/exercise/_show_MCQ.html.erb b/app/views/exercise/_show_MCQ.html.erb index 08a012fd3..a6ffbeb82 100644 --- a/app/views/exercise/_show_MCQ.html.erb +++ b/app/views/exercise/_show_MCQ.html.erb @@ -31,74 +31,79 @@ \ No newline at end of file diff --git a/app/views/exercise/_show_single.html.erb b/app/views/exercise/_show_single.html.erb index 8232e68f3..4e36530ed 100644 --- a/app/views/exercise/_show_single.html.erb +++ b/app/views/exercise/_show_single.html.erb @@ -19,62 +19,67 @@ \ No newline at end of file From f6bfd7824d296f915b327aabfceaa67ffea85d3d Mon Sep 17 00:00:00 2001 From: "Gan Yi.ang" Date: Thu, 19 Nov 2015 14:42:37 +0800 Subject: [PATCH 073/191] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9F=A5=E7=9C=8Bcom?= =?UTF-8?q?mits=E9=82=A3=E4=B8=AA=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 15 +++++++-------- app/views/repositories/show.html.erb | 3 ++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 3993368a7..3129dbf02 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -354,17 +354,16 @@ update def get_commits(id) g = Gitlab.client - tmp_commit = g.commits(id,page:0) - commits = [] + tmp_commit_count = g.commits(id,page:0).count + commit_count = 0 i=0 - while tmp_commit!=[] - commits = commits+tmp_commit + while tmp_commit_count!=0 + commit_count = commit_count+tmp_commit_count i=i+1 - tmp_commit = g.commits(id,page:i) + tmp_commit_count = g.commits(id,page:i).count end - commits_count = commits.length - return commits_count + return commit_count end @@ -377,7 +376,7 @@ update @commits = g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s) - @commits_count = get_commits(@project.gpid) + @commits_count = params[:commit_count].to_i @commits_pages = Redmine::Pagination::Paginator.new @commits_count,limit,params[:page] @commit = g.commit(@project.gpid,@rev) diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index e8596b717..7aac3af1d 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -40,7 +40,8 @@ - <%=link_to @changesets_all_count, {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev,:page=>1} %> 提交 + <%=link_to @changesets_all_count, {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev,:page=>1 ,:commit_count =>"#{@changesets_all_count}"} %> 提交 +
                  <% end %> From fdedcbfa815c494250723ec684e1911c4676fae7 Mon Sep 17 00:00:00 2001 From: houxiang Date: Thu, 19 Nov 2015 14:59:26 +0800 Subject: [PATCH 074/191] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 23 +++------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 3129dbf02..4b395b2a3 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -350,32 +350,14 @@ update alias_method :browse, :show - #add by houxiang - - def get_commits(id) - g = Gitlab.client - tmp_commit_count = g.commits(id,page:0).count - commit_count = 0 - i=0 - while tmp_commit_count!=0 - commit_count = commit_count+tmp_commit_count - i=i+1 - tmp_commit_count = g.commits(id,page:i).count - end - - return commit_count - - end - - def changes @entry = @repository.entry(@path, @rev) (show_error_not_found; return) unless @entry g = Gitlab.client limit = 20 - - + #每次页面的换回值从1开始,但是gitlab的页面查询是从0开始,所以先改变page的类型减一在改回来 @commits = g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s) + #页面传递必须要str类型,但是Paginator的初始化必须要num类型,需要类型转化 @commits_count = params[:commit_count].to_i @commits_pages = Redmine::Pagination::Paginator.new @commits_count,limit,params[:page] @@ -387,6 +369,7 @@ update render :layout => 'base_projects' end + def revisions @changeset_count = @repository.changesets.count @changeset_pages = Paginator.new @changeset_count, From 56e96a035bdab1adf2054e3bbeec52a96e539766 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Thu, 19 Nov 2015 15:01:03 +0800 Subject: [PATCH 075/191] schema.rb --- db/schema.rb | 364 ++++++--------------------------------------------- 1 file changed, 37 insertions(+), 327 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 4df54cede..ae220df3d 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 => 20151117033430) do +ActiveRecord::Schema.define(:version => 20151118031602) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -293,16 +293,6 @@ ActiveRecord::Schema.define(:version => 20151117033430) do t.boolean "diff_all" end - create_table "columns_priv", :id => false, :force => true do |t| - t.string "Host", :limit => 60, :default => "", :null => false - t.string "Db", :limit => 64, :default => "", :null => false - t.string "User", :limit => 16, :default => "", :null => false - t.string "Table_name", :limit => 64, :default => "", :null => false - t.string "Column_name", :limit => 64, :default => "", :null => false - t.timestamp "Timestamp", :null => false - t.string "Column_priv", :limit => 0, :default => "", :null => false - end - create_table "comments", :force => true do |t| t.string "commented_type", :limit => 30, :default => "", :null => false t.integer "commented_id", :default => 0, :null => false @@ -435,8 +425,8 @@ ActiveRecord::Schema.define(:version => 20151117033430) do t.string "code" t.integer "time" t.string "extra" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "location" t.string "term" t.string "string" @@ -446,14 +436,15 @@ ActiveRecord::Schema.define(:version => 20151117033430) do t.string "class_period" t.integer "school_id" t.text "description" - t.integer "status", :default => 1 - t.integer "attachmenttype", :default => 2 + t.integer "status", :default => 1 + t.integer "attachmenttype", :default => 2 t.integer "lft" t.integer "rgt" - t.integer "is_public", :limit => 1, :default => 1 - t.integer "inherit_members", :limit => 1, :default => 1 - t.integer "open_student", :default => 0 - t.integer "outline", :default => 0 + t.integer "is_public", :limit => 1, :default => 1 + t.integer "inherit_members", :limit => 1, :default => 1 + t.integer "open_student", :default => 0 + t.integer "outline", :default => 0 + t.integer "publish_resource", :default => 0 end create_table "custom_fields", :force => true do |t| @@ -501,33 +492,6 @@ ActiveRecord::Schema.define(:version => 20151117033430) do add_index "custom_values", ["custom_field_id"], :name => "index_custom_values_on_custom_field_id" add_index "custom_values", ["customized_type", "customized_id"], :name => "custom_values_customized" - create_table "db", :id => false, :force => true do |t| - t.string "Host", :limit => 60, :default => "", :null => false - t.string "Db", :limit => 64, :default => "", :null => false - t.string "User", :limit => 16, :default => "", :null => false - t.string "Select_priv", :limit => 1, :default => "N", :null => false - t.string "Insert_priv", :limit => 1, :default => "N", :null => false - t.string "Update_priv", :limit => 1, :default => "N", :null => false - t.string "Delete_priv", :limit => 1, :default => "N", :null => false - t.string "Create_priv", :limit => 1, :default => "N", :null => false - t.string "Drop_priv", :limit => 1, :default => "N", :null => false - t.string "Grant_priv", :limit => 1, :default => "N", :null => false - t.string "References_priv", :limit => 1, :default => "N", :null => false - t.string "Index_priv", :limit => 1, :default => "N", :null => false - t.string "Alter_priv", :limit => 1, :default => "N", :null => false - t.string "Create_tmp_table_priv", :limit => 1, :default => "N", :null => false - t.string "Lock_tables_priv", :limit => 1, :default => "N", :null => false - t.string "Create_view_priv", :limit => 1, :default => "N", :null => false - t.string "Show_view_priv", :limit => 1, :default => "N", :null => false - t.string "Create_routine_priv", :limit => 1, :default => "N", :null => false - t.string "Alter_routine_priv", :limit => 1, :default => "N", :null => false - t.string "Execute_priv", :limit => 1, :default => "N", :null => false - t.string "Event_priv", :limit => 1, :default => "N", :null => false - t.string "Trigger_priv", :limit => 1, :default => "N", :null => false - end - - add_index "db", ["User"], :name => "User" - create_table "delayed_jobs", :force => true do |t| t.integer "priority", :default => 0, :null => false t.integer "attempts", :default => 0, :null => false @@ -565,26 +529,23 @@ ActiveRecord::Schema.define(:version => 20151117033430) do add_index "documents", ["created_on"], :name => "index_documents_on_created_on" add_index "documents", ["project_id"], :name => "documents_project_id" - create_table "dts", :primary_key => "Num", :force => true do |t| - t.string "Defect", :limit => 50 - t.string "Category", :limit => 50 - t.string "File" - t.string "Method" - t.string "Module", :limit => 20 - t.string "Variable", :limit => 50 - t.integer "StartLine" - t.integer "IPLine" - t.string "IPLineCode", :limit => 200 - t.string "Judge", :limit => 15 - t.integer "Review", :limit => 1 + create_table "dts", :force => true do |t| + t.string "IPLineCode" t.string "Description" - t.text "PreConditions", :limit => 2147483647 - t.text "TraceInfo", :limit => 2147483647 - t.text "Code", :limit => 2147483647 + t.string "Num" + t.string "Variable" + t.string "TraceInfo" + t.string "Method" + t.string "File" + t.string "IPLine" + t.string "Review" + t.string "Category" + t.string "Defect" + t.string "PreConditions" + t.string "StartLine" t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "id", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "enabled_modules", :force => true do |t| @@ -609,31 +570,6 @@ ActiveRecord::Schema.define(:version => 20151117033430) 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 "event", :id => false, :force => true do |t| - t.string "db", :limit => 64, :default => "", :null => false - t.string "name", :limit => 64, :default => "", :null => false - t.binary "body", :limit => 2147483647, :null => false - t.string "definer", :limit => 77, :default => "", :null => false - t.datetime "execute_at" - t.integer "interval_value" - t.string "interval_field", :limit => 18 - t.timestamp "created", :null => false - t.timestamp "modified", :null => false - t.datetime "last_executed" - t.datetime "starts" - t.datetime "ends" - t.string "status", :limit => 18, :default => "ENABLED", :null => false - t.string "on_completion", :limit => 8, :default => "DROP", :null => false - t.string "sql_mode", :limit => 0, :default => "", :null => false - t.string "comment", :limit => 64, :default => "", :null => false - t.integer "originator", :null => false - t.string "time_zone", :limit => 64, :default => "SYSTEM", :null => false - t.string "character_set_client", :limit => 32 - t.string "collation_connection", :limit => 32 - t.string "db_collation", :limit => 32 - t.binary "body_utf8", :limit => 2147483647 - end - create_table "first_pages", :force => true do |t| t.string "web_title" t.string "title" @@ -685,21 +621,6 @@ ActiveRecord::Schema.define(:version => 20151117033430) do t.integer "locked" end - create_table "func", :primary_key => "name", :force => true do |t| - t.boolean "ret", :default => false, :null => false - t.string "dl", :limit => 128, :default => "", :null => false - t.string "type", :limit => 9, :null => false - end - - create_table "general_log", :id => false, :force => true do |t| - t.timestamp "event_time", :null => false - t.text "user_host", :limit => 16777215, :null => false - t.integer "thread_id", :null => false - t.integer "server_id", :null => false - t.string "command_type", :limit => 64, :null => false - t.text "argument", :limit => 16777215, :null => false - end - create_table "groups_users", :id => false, :force => true do |t| t.integer "group_id", :null => false t.integer "user_id", :null => false @@ -707,35 +628,6 @@ ActiveRecord::Schema.define(:version => 20151117033430) do add_index "groups_users", ["group_id", "user_id"], :name => "groups_users_ids", :unique => true - create_table "help_category", :primary_key => "help_category_id", :force => true do |t| - t.string "name", :limit => 64, :null => false - t.integer "parent_category_id", :limit => 2 - t.text "url", :null => false - end - - add_index "help_category", ["name"], :name => "name", :unique => true - - create_table "help_keyword", :primary_key => "help_keyword_id", :force => true do |t| - t.string "name", :limit => 64, :null => false - end - - add_index "help_keyword", ["name"], :name => "name", :unique => true - - create_table "help_relation", :id => false, :force => true do |t| - t.integer "help_topic_id", :null => false - t.integer "help_keyword_id", :null => false - end - - create_table "help_topic", :primary_key => "help_topic_id", :force => true do |t| - t.string "name", :limit => 64, :null => false - t.integer "help_category_id", :limit => 2, :null => false - t.text "description", :null => false - t.text "example", :null => false - t.text "url", :null => false - end - - add_index "help_topic", ["name"], :name => "name", :unique => true - create_table "homework_attaches", :force => true do |t| t.integer "bid_id" t.integer "user_id" @@ -821,29 +713,6 @@ ActiveRecord::Schema.define(:version => 20151117033430) do t.datetime "updated_at", :null => false end - create_table "host", :id => false, :force => true do |t| - t.string "Host", :limit => 60, :default => "", :null => false - t.string "Db", :limit => 64, :default => "", :null => false - t.string "Select_priv", :limit => 1, :default => "N", :null => false - t.string "Insert_priv", :limit => 1, :default => "N", :null => false - t.string "Update_priv", :limit => 1, :default => "N", :null => false - t.string "Delete_priv", :limit => 1, :default => "N", :null => false - t.string "Create_priv", :limit => 1, :default => "N", :null => false - t.string "Drop_priv", :limit => 1, :default => "N", :null => false - t.string "Grant_priv", :limit => 1, :default => "N", :null => false - t.string "References_priv", :limit => 1, :default => "N", :null => false - t.string "Index_priv", :limit => 1, :default => "N", :null => false - t.string "Alter_priv", :limit => 1, :default => "N", :null => false - t.string "Create_tmp_table_priv", :limit => 1, :default => "N", :null => false - t.string "Lock_tables_priv", :limit => 1, :default => "N", :null => false - t.string "Create_view_priv", :limit => 1, :default => "N", :null => false - t.string "Show_view_priv", :limit => 1, :default => "N", :null => false - t.string "Create_routine_priv", :limit => 1, :default => "N", :null => false - t.string "Alter_routine_priv", :limit => 1, :default => "N", :null => false - t.string "Execute_priv", :limit => 1, :default => "N", :null => false - t.string "Trigger_priv", :limit => 1, :default => "N", :null => false - end - create_table "invite_lists", :force => true do |t| t.integer "project_id" t.integer "user_id" @@ -946,6 +815,16 @@ ActiveRecord::Schema.define(:version => 20151117033430) do add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" + create_table "journal_details_copy", :force => true do |t| + t.integer "journal_id", :default => 0, :null => false + t.string "property", :limit => 30, :default => "", :null => false + t.string "prop_key", :limit => 30, :default => "", :null => false + t.text "old_value" + t.text "value" + end + + add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id" + create_table "journal_replies", :id => false, :force => true do |t| t.integer "journal_id" t.integer "user_id" @@ -1073,15 +952,6 @@ ActiveRecord::Schema.define(:version => 20151117033430) do add_index "messages", ["last_reply_id"], :name => "index_messages_on_last_reply_id" add_index "messages", ["parent_id"], :name => "messages_parent_id" - create_table "ndb_binlog_index", :primary_key => "epoch", :force => true do |t| - t.integer "Position", :limit => 8, :null => false - t.string "File", :null => false - t.integer "inserts", :limit => 8, :null => false - t.integer "updates", :limit => 8, :null => false - t.integer "deletes", :limit => 8, :null => false - t.integer "schemaops", :limit => 8, :null => false - end - create_table "news", :force => true do |t| t.integer "project_id" t.string "title", :limit => 60, :default => "", :null => false @@ -1214,7 +1084,8 @@ ActiveRecord::Schema.define(:version => 20151117033430) do create_table "org_members", :force => true do |t| t.integer "user_id" t.integer "organization_id" - t.datetime "created_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "org_projects", :force => true do |t| @@ -1241,10 +1112,6 @@ ActiveRecord::Schema.define(:version => 20151117033430) do t.datetime "updated_at", :null => false end - create_table "plugin", :primary_key => "name", :force => true do |t| - t.string "dl", :limit => 128, :default => "", :null => false - end - create_table "poll_answers", :force => true do |t| t.integer "poll_question_id" t.text "answer_text" @@ -1320,42 +1187,6 @@ ActiveRecord::Schema.define(:version => 20151117033430) do t.datetime "updated_at", :null => false end - create_table "proc", :id => false, :force => true do |t| - t.string "db", :limit => 64, :default => "", :null => false - t.string "name", :limit => 64, :default => "", :null => false - t.string "type", :limit => 9, :null => false - t.string "specific_name", :limit => 64, :default => "", :null => false - t.string "language", :limit => 3, :default => "SQL", :null => false - t.string "sql_data_access", :limit => 17, :default => "CONTAINS_SQL", :null => false - t.string "is_deterministic", :limit => 3, :default => "NO", :null => false - t.string "security_type", :limit => 7, :default => "DEFINER", :null => false - t.binary "param_list", :null => false - t.binary "returns", :limit => 2147483647, :null => false - t.binary "body", :limit => 2147483647, :null => false - t.string "definer", :limit => 77, :default => "", :null => false - t.timestamp "created", :null => false - t.timestamp "modified", :null => false - t.string "sql_mode", :limit => 0, :default => "", :null => false - t.text "comment", :null => false - t.string "character_set_client", :limit => 32 - t.string "collation_connection", :limit => 32 - t.string "db_collation", :limit => 32 - t.binary "body_utf8", :limit => 2147483647 - end - - create_table "procs_priv", :id => false, :force => true do |t| - t.string "Host", :limit => 60, :default => "", :null => false - t.string "Db", :limit => 64, :default => "", :null => false - t.string "User", :limit => 16, :default => "", :null => false - t.string "Routine_name", :limit => 64, :default => "", :null => false - t.string "Routine_type", :limit => 9, :null => false - t.string "Grantor", :limit => 77, :default => "", :null => false - t.string "Proc_priv", :limit => 0, :default => "", :null => false - t.timestamp "Timestamp", :null => false - end - - add_index "procs_priv", ["Grantor"], :name => "Grantor" - create_table "project_infos", :force => true do |t| t.integer "project_id" t.integer "user_id" @@ -1430,18 +1261,6 @@ ActiveRecord::Schema.define(:version => 20151117033430) do add_index "projects_trackers", ["project_id", "tracker_id"], :name => "projects_trackers_unique", :unique => true add_index "projects_trackers", ["project_id"], :name => "projects_trackers_project_id" - create_table "proxies_priv", :id => false, :force => true do |t| - t.string "Host", :limit => 60, :default => "", :null => false - t.string "User", :limit => 16, :default => "", :null => false - t.string "Proxied_host", :limit => 60, :default => "", :null => false - t.string "Proxied_user", :limit => 16, :default => "", :null => false - t.boolean "With_grant", :default => false, :null => false - t.string "Grantor", :limit => 77, :default => "", :null => false - t.timestamp "Timestamp", :null => false - end - - add_index "proxies_priv", ["Grantor"], :name => "Grantor" - create_table "queries", :force => true do |t| t.integer "project_id" t.string "name", :default => "", :null => false @@ -1555,17 +1374,6 @@ ActiveRecord::Schema.define(:version => 20151117033430) do t.integer "is_teacher_score", :default => 0 end - create_table "servers", :primary_key => "Server_name", :force => true do |t| - t.string "Host", :limit => 64, :default => "", :null => false - t.string "Db", :limit => 64, :default => "", :null => false - t.string "Username", :limit => 64, :default => "", :null => false - t.string "Password", :limit => 64, :default => "", :null => false - t.integer "Port", :default => 0, :null => false - t.string "Socket", :limit => 64, :default => "", :null => false - t.string "Wrapper", :limit => 64, :default => "", :null => false - t.string "Owner", :limit => 64, :default => "", :null => false - end - create_table "settings", :force => true do |t| t.string "name", :default => "", :null => false t.text "value" @@ -1586,20 +1394,6 @@ ActiveRecord::Schema.define(:version => 20151117033430) do t.string "description" end - create_table "slow_log", :id => false, :force => true do |t| - t.timestamp "start_time", :null => false - t.text "user_host", :limit => 16777215, :null => false - t.time "query_time", :null => false - t.time "lock_time", :null => false - t.integer "rows_sent", :null => false - t.integer "rows_examined", :null => false - t.string "db", :limit => 512, :null => false - t.integer "last_insert_id", :null => false - t.integer "insert_id", :null => false - t.integer "server_id", :null => false - t.text "sql_text", :limit => 16777215, :null => false - end - create_table "softapplications", :force => true do |t| t.string "name" t.text "description" @@ -1681,19 +1475,6 @@ ActiveRecord::Schema.define(:version => 20151117033430) do t.string "subject" end - create_table "tables_priv", :id => false, :force => true do |t| - t.string "Host", :limit => 60, :default => "", :null => false - t.string "Db", :limit => 64, :default => "", :null => false - t.string "User", :limit => 16, :default => "", :null => false - t.string "Table_name", :limit => 64, :default => "", :null => false - t.string "Grantor", :limit => 77, :default => "", :null => false - t.timestamp "Timestamp", :null => false - t.string "Table_priv", :limit => 0, :default => "", :null => false - t.string "Column_priv", :limit => 0, :default => "", :null => false - end - - add_index "tables_priv", ["Grantor"], :name => "Grantor" - create_table "taggings", :force => true do |t| t.integer "tag_id" t.integer "taggable_id" @@ -1743,32 +1524,6 @@ ActiveRecord::Schema.define(:version => 20151117033430) do add_index "time_entries", ["project_id"], :name => "time_entries_project_id" add_index "time_entries", ["user_id"], :name => "index_time_entries_on_user_id" - create_table "time_zone", :primary_key => "Time_zone_id", :force => true do |t| - t.string "Use_leap_seconds", :limit => 1, :default => "N", :null => false - end - - create_table "time_zone_leap_second", :primary_key => "Transition_time", :force => true do |t| - t.integer "Correction", :null => false - end - - create_table "time_zone_name", :primary_key => "Name", :force => true do |t| - t.integer "Time_zone_id", :null => false - end - - create_table "time_zone_transition", :id => false, :force => true do |t| - t.integer "Time_zone_id", :null => false - t.integer "Transition_time", :limit => 8, :null => false - t.integer "Transition_type_id", :null => false - end - - create_table "time_zone_transition_type", :id => false, :force => true do |t| - t.integer "Time_zone_id", :null => false - t.integer "Transition_type_id", :null => false - t.integer "Offset", :default => 0, :null => false - t.integer "Is_DST", :limit => 1, :default => 0, :null => false - t.string "Abbreviation", :limit => 8, :default => "", :null => false - end - create_table "tokens", :force => true do |t| t.integer "user_id", :default => 0, :null => false t.string "action", :limit => 30, :default => "", :null => false @@ -1787,51 +1542,6 @@ ActiveRecord::Schema.define(:version => 20151117033430) do t.integer "fields_bits", :default => 0 end - create_table "user", :id => false, :force => true do |t| - t.string "Host", :limit => 60, :default => "", :null => false - t.string "User", :limit => 16, :default => "", :null => false - t.string "Password", :limit => 41, :default => "", :null => false - t.string "Select_priv", :limit => 1, :default => "N", :null => false - t.string "Insert_priv", :limit => 1, :default => "N", :null => false - t.string "Update_priv", :limit => 1, :default => "N", :null => false - t.string "Delete_priv", :limit => 1, :default => "N", :null => false - t.string "Create_priv", :limit => 1, :default => "N", :null => false - t.string "Drop_priv", :limit => 1, :default => "N", :null => false - t.string "Reload_priv", :limit => 1, :default => "N", :null => false - t.string "Shutdown_priv", :limit => 1, :default => "N", :null => false - t.string "Process_priv", :limit => 1, :default => "N", :null => false - t.string "File_priv", :limit => 1, :default => "N", :null => false - t.string "Grant_priv", :limit => 1, :default => "N", :null => false - t.string "References_priv", :limit => 1, :default => "N", :null => false - t.string "Index_priv", :limit => 1, :default => "N", :null => false - t.string "Alter_priv", :limit => 1, :default => "N", :null => false - t.string "Show_db_priv", :limit => 1, :default => "N", :null => false - t.string "Super_priv", :limit => 1, :default => "N", :null => false - t.string "Create_tmp_table_priv", :limit => 1, :default => "N", :null => false - t.string "Lock_tables_priv", :limit => 1, :default => "N", :null => false - t.string "Execute_priv", :limit => 1, :default => "N", :null => false - t.string "Repl_slave_priv", :limit => 1, :default => "N", :null => false - t.string "Repl_client_priv", :limit => 1, :default => "N", :null => false - t.string "Create_view_priv", :limit => 1, :default => "N", :null => false - t.string "Show_view_priv", :limit => 1, :default => "N", :null => false - t.string "Create_routine_priv", :limit => 1, :default => "N", :null => false - t.string "Alter_routine_priv", :limit => 1, :default => "N", :null => false - t.string "Create_user_priv", :limit => 1, :default => "N", :null => false - t.string "Event_priv", :limit => 1, :default => "N", :null => false - t.string "Trigger_priv", :limit => 1, :default => "N", :null => false - t.string "Create_tablespace_priv", :limit => 1, :default => "N", :null => false - t.string "ssl_type", :limit => 9, :default => "", :null => false - t.binary "ssl_cipher", :null => false - t.binary "x509_issuer", :null => false - t.binary "x509_subject", :null => false - t.integer "max_questions", :default => 0, :null => false - t.integer "max_updates", :default => 0, :null => false - t.integer "max_connections", :default => 0, :null => false - t.integer "max_user_connections", :default => 0, :null => false - t.string "plugin", :limit => 64, :default => "" - t.text "authentication_string" - end - create_table "user_activities", :force => true do |t| t.string "act_type" t.integer "act_id" From 34a2c2c90df55e40b39af8372f9a337656fa6de6 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Thu, 19 Nov 2015 15:13:34 +0800 Subject: [PATCH 076/191] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E6=B7=BB=E5=8A=A0=20=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=85=81=E8=AE=B8=E5=AD=A6=E7=94=9F=E4=B8=8A=E4=BC=A0=E8=B5=84?= =?UTF-8?q?=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/courses_service.rb | 2 ++ app/views/courses/new.html.erb | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 04e2c24ee..5d60238bf 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -186,6 +186,7 @@ class CoursesService #params[:setup_time]:暂不传(貌似已经没用了) #params[:endup_time]: 暂不传(貌似已经没用了) #params[:class_period]:学时总数 + #params[:course][:publish_resource]允许学生上传资源 def create_course(params,current_user) if current_user.user_extensions.identity @course = Course.new @@ -202,6 +203,7 @@ class CoursesService @course.class_period = params[:class_period].to_i params[:course][:is_public] ? @course.is_public = 1 : @course.is_public = 0 params[:course][:open_student] ? @course.open_student = 1 : @course.open_student = 0 + params[:course][:publish_resource] ? @course.publish_resource = 1 : @course.publish_resource = 0 else end diff --git a/app/views/courses/new.html.erb b/app/views/courses/new.html.erb index d2c17917e..f1b917816 100644 --- a/app/views/courses/new.html.erb +++ b/app/views/courses/new.html.erb @@ -50,6 +50,12 @@ (打钩为"学生列表公开",不打钩为不公开,若不公开,则课程外部人员看不到学生列表)
                  +
                • + + id="course_publish_resource" name="course[publish_resource]" type="checkbox" /> + (打钩为"允许学生上传资源",不打钩为"不允许学生上传资源") +
                  +
                • 提交 <%= link_to "取消",user_activities_path(User.current.id),:class => "blue_btn grey_btn fl c_white"%> From 841ebb78468d1ec0198d03e4cd9ce05f89139feb Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 19 Nov 2015 16:21:31 +0800 Subject: [PATCH 077/191] =?UTF-8?q?=E7=AE=80=E5=8D=95=E9=A2=98=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=EF=BC=8C=E6=9C=AA=E5=AE=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 54 ++++++++++++++++++------ app/views/exercise/_edit_MC.html.erb | 2 +- app/views/exercise/_edit_MCQ.html.erb | 4 +- app/views/exercise/_edit_single.html.erb | 2 +- 4 files changed, 44 insertions(+), 18 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index dd4e543ff..faaae4997 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -188,30 +188,43 @@ class ExerciseController < ApplicationController @exercise_question = ExerciseQuestion.find params[:exercise_question] @exercise_question.question_title = params[:question_title].nil? || params[:question_title].empty? ? l(:label_enter_single_title) : params[:question_title] @exercise_question.question_score = params[:question_score] - # 处理选项 + # 处理选项:如果选了某个选项,那么则要删除之前的选项 if params[:question_answer] - @exercise_question.exercise_choices.each do |answer| - answer.destroy unless params[:question_answer].keys.include? answer.id.to_s - end + # @exercise_question.exercise_choices.each do |answer| + # answer.destroy unless params[:question_answer].keys.include? answer.id.to_s + # end for i in 1..params[:question_answer].count question = @exercise_question.exercise_choices.find_by_id params[:question_answer].keys[i-1] answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1] if question - question.exercise_choices_id = i - question.answer_text = answer + question.choice_position = i + question.choice_text = answer question.save else question_option = { - :exercise_choice_id => i, - :answer_text => answer + :choice_position => i, + :choice_text => answer } - @exercise_question.exercise_answers.new question_option + @exercise_question.exercise_choices.new question_option end end end - @exercise_question.save - respond_to do |format| - format.js + # 更新标准答案 + if params[:exercise_choice] + if @exercise_question.question_type == 3 + for i in 1..params[:exercise_choice].count + question_standart = @exercise_question.exercise_standard_answers.find_by_id params[:exercise_choice].keys[i] + answer_standart = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1] + end + else + answer_standart = @exercise_question.exercise_standard_answers.first + answer_standart.exercise_choice_id = params[:exercise_choice] + answer_standart.save + end + @exercise_question.save + respond_to do |format| + format.js + end end end @@ -231,7 +244,7 @@ class ExerciseController < ApplicationController end end - #发布问卷 + # 发布试卷 def publish_excercise @exercise.exercise_status = 2 @exercise.publish_time = Time.now @@ -246,6 +259,19 @@ class ExerciseController < ApplicationController end end + # 重新发布试卷 + def republish_excercise + @exercise.exercise_questions.each do |exercise_question| + exercise_question.exercise_ansers.destroy_all + end + # @poll.poll_users.destroy_all + # @poll.polls_status = 1 + # @poll.save + # respond_to do |format| + # format.js + # end + end + def student_exercise_list @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? @exercise = Exercise.find params[:id] @@ -264,7 +290,7 @@ class ExerciseController < ApplicationController end end - # 学生提交答卷,选着答案的课程中提交 + # 学生提交答卷,选中答案的过程中提交 def commit_answer eq = ExerciseQuestion.find(params[:exercise_question_id]) # 已提交过的则不允许答题 diff --git a/app/views/exercise/_edit_MC.html.erb b/app/views/exercise/_edit_MC.html.erb index 9c6f3c396..76bad697c 100644 --- a/app/views/exercise/_edit_MC.html.erb +++ b/app/views/exercise/_edit_MC.html.erb @@ -35,7 +35,7 @@ <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
                • - +
                • diff --git a/app/views/exercise/_edit_MCQ.html.erb b/app/views/exercise/_edit_MCQ.html.erb index 0186b3041..a3ae74324 100644 --- a/app/views/exercise/_edit_MCQ.html.erb +++ b/app/views/exercise/_edit_MCQ.html.erb @@ -9,7 +9,7 @@ $("#poll_answers_<%=exercise_question.id%>").html("<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>" + "
                • " + "" + - "" + + "" + "" + "" + "
                • " + @@ -35,7 +35,7 @@ <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
                • - +
                • diff --git a/app/views/exercise/_edit_single.html.erb b/app/views/exercise/_edit_single.html.erb index 1048b2145..647ab02de 100644 --- a/app/views/exercise/_edit_single.html.erb +++ b/app/views/exercise/_edit_single.html.erb @@ -34,7 +34,7 @@ <% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %>
                • - +
                • From f3614999da1927e565b550f79889f0ac4bebf2a6 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 19 Nov 2015 16:38:46 +0800 Subject: [PATCH 078/191] gi --- app/controllers/exercise_controller.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index faaae4997..5510b1539 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -213,8 +213,19 @@ class ExerciseController < ApplicationController if params[:exercise_choice] if @exercise_question.question_type == 3 for i in 1..params[:exercise_choice].count - question_standart = @exercise_question.exercise_standard_answers.find_by_id params[:exercise_choice].keys[i] - answer_standart = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1] + # 找到对应的标准答案 + question_standart = @exercise_question.exercise_standard_answers.find_by_id params[:exercise_choice].keys[i-1] + # 标准答案值 + answer_standart = (params[:exercise_choice].values[i-1].nil? || params[:exercise_choice].values[i-1].empty?) ? l(:label_new_answer) : params[:exercise_choice].values[i-1] + if question_standart + question_standart.answer_text = answer_standart + question_standart.save + else + standart_answer_option = { + :answer_text => question_standart + } + @exercise_question.exercise_standard_answers.new standart_answer_option + end end else answer_standart = @exercise_question.exercise_standard_answers.first From 02f6b636cd4f963d5bea0f985b18eafed71c4f2f Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 19 Nov 2015 17:09:59 +0800 Subject: [PATCH 079/191] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 5510b1539..8561b112a 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -190,9 +190,9 @@ class ExerciseController < ApplicationController @exercise_question.question_score = params[:question_score] # 处理选项:如果选了某个选项,那么则要删除之前的选项 if params[:question_answer] - # @exercise_question.exercise_choices.each do |answer| - # answer.destroy unless params[:question_answer].keys.include? answer.id.to_s - # end + @exercise_question.exercise_choices.each do |answer| + answer.destroy unless params[:question_answer].keys.include? answer.id.to_s + end for i in 1..params[:question_answer].count question = @exercise_question.exercise_choices.find_by_id params[:question_answer].keys[i-1] answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1] @@ -229,7 +229,7 @@ class ExerciseController < ApplicationController end else answer_standart = @exercise_question.exercise_standard_answers.first - answer_standart.exercise_choice_id = params[:exercise_choice] + answer_standart.exercise_choice_id = @exercise_question.question_type == 1 ? sigle_selection_standard_answer(params[:exercise_choice]) : multiselect_standard_answer(params[:exercise_choice]) answer_standart.save end @exercise_question.save From 2c1b03079b04c2c8056538fde19a703c6789dbe4 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 19 Nov 2015 17:18:58 +0800 Subject: [PATCH 080/191] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E6=B5=8B=E9=AA=8C?= =?UTF-8?q?=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 1 + app/views/exercise/_edit_head.html.erb | 2 +- app/views/exercise/_edit_single.html.erb | 4 +- app/views/exercise/_exercise_content.html.erb | 25 +--- app/views/exercise/_exercise_form.html.erb | 39 ++---- app/views/exercise/_exercise_student.html.erb | 127 ++++++++++++++++++ app/views/exercise/_exercise_submit.html.erb | 35 +++++ .../exercise/_exercise_submit_info.html.erb | 35 +++++ app/views/exercise/_new_single.html.erb | 6 +- app/views/exercise/_show_head.html.erb | 2 +- app/views/exercise/_show_single.html.erb | 6 +- .../exercise/create_exercise_question.js.erb | 22 +-- .../exercise/delete_exercise_question.js.erb | 4 +- app/views/exercise/show.html.erb | 6 +- app/views/exercise/update.js.erb | 3 +- .../exercise/update_exercise_question.js.erb | 1 + 16 files changed, 230 insertions(+), 88 deletions(-) create mode 100644 app/views/exercise/_exercise_student.html.erb create mode 100644 app/views/exercise/_exercise_submit.html.erb create mode 100644 app/views/exercise/_exercise_submit_info.html.erb diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index dd4e543ff..f1b90dba8 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -22,6 +22,7 @@ class ExerciseController < ApplicationController def show @exercise = Exercise.find params[:id] + @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? if @exercise.exercise_status != 2 && (!User.current.allowed_to?(:as_teacher,@course) || User.current.admin?) render_403 return diff --git a/app/views/exercise/_edit_head.html.erb b/app/views/exercise/_edit_head.html.erb index 9868a4465..3090cc2c5 100644 --- a/app/views/exercise/_edit_head.html.erb +++ b/app/views/exercise/_edit_head.html.erb @@ -17,7 +17,7 @@ " > <%= calendar_for('exercise_end_time')%> -
                  考试时长:分钟
                  +
                  测验时长:分钟
                  <% end %> - -<%# exercise.exercise_questions.each do |exercise_question|%> - -<%# end %> \ No newline at end of file + \ No newline at end of file diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index 934e51b71..6e0953e74 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -134,6 +134,12 @@ ""+ "
                  "); } + function add_candidate_answer(doc) + { + doc.parent().after("
                • " + + ""+ + "
                • "); + } function remove_single_answer(doc) { if(doc.parent().siblings("li").length == 0) @@ -145,32 +151,6 @@ doc.parent().remove(); } } - - function poll_submit() - { - var head_form = $("form.edit_exercise"); - var question_form = $("form.new_exercise_question"); - <% current_score = get_current_score @exercise %> - var score = <%=current_score %>; - if(head_form.length > 0){ - alert("请先保存测验标题及测验基本信息。"); - } else if(question_form.length > 0) { - alert("请先保存正在编辑的题目。"); - } else if( score < 100) { - alert(""); - } - else{ - $('#ajax-modal').html('<%#= escape_javascript(render :partial => 'poll_submit', locals: { :poll => @exercise,:is_remote => false}) %>'); - showModal('ajax-modal', '310px'); - $('#ajax-modal').css('height','120px'); - $('#ajax-modal').siblings().remove(); - $('#ajax-modal').before("" + - ""); - $('#ajax-modal').parent().removeClass("alert_praise"); - $('#ajax-modal').parent().css("top","").css("left",""); - $('#ajax-modal').parent().addClass("popbox_polls"); - } - }
                  @@ -196,11 +176,8 @@
                  -
                  提交 -
                  - - -
                  +
                  + <%= render :partial => 'exercise_submit', :locals => {:exercise => @exercise} %>
                  diff --git a/app/views/exercise/_exercise_student.html.erb b/app/views/exercise/_exercise_student.html.erb new file mode 100644 index 000000000..5a139fd5d --- /dev/null +++ b/app/views/exercise/_exercise_student.html.erb @@ -0,0 +1,127 @@ + +
                  +
                  +
                  +

                  <%= exercise.exercise_name%>

                  +
                  开始时间:<%=format_time(exercise_student.start_at.to_s) %>测验时长:<%=exercise.time %>分钟 +
                  剩余时长:1 小时 30 分钟 0 秒
                  +
                  +
                  <%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%>
                  +
                  +
                  +
                  + <% mc_question_list = exercise_questions.where("question_type=1") %> + <% mcq_question_list = exercise_questions.where("question_type=2") %> + <% single_question_list = exercise_questions.where("question_type=3") %> +
                  "> +

                  单选题

                  + <% mc_question_list.each do |exercise_question| %> +
                  +
                  +
                  +
                  第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
                  + <%= exercise_question.question_title %> +
                  +
                  +
                  +
                  + + <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> + + + + <% end %> + +
                  + +
                  +
                  +
                  +
                  + + <% end %> + +
                  "> +

                  多选题

                  + <% mcq_question_list.each do |exercise_question| %> +
                  +
                  +
                  +
                  第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
                  + <%= exercise_question.question_title %> +
                  +
                  +
                  + + + <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> + + + + <% end %> + +
                  + +
                  +
                  +
                  +
                  +
                  + <% end %> +
                  +
                  "> +

                  填空题

                  + <% single_question_list.each do |exercise_question| %> +
                  +
                  +
                  +
                  第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
                  + <%= exercise_question.question_title %> +
                  +
                  +
                  + +
                  +
                  +
                  +
                  + <% end %> +
                  + +
                  + + + + \ No newline at end of file diff --git a/app/views/exercise/_exercise_submit.html.erb b/app/views/exercise/_exercise_submit.html.erb new file mode 100644 index 000000000..e242eacc7 --- /dev/null +++ b/app/views/exercise/_exercise_submit.html.erb @@ -0,0 +1,35 @@ +<%= form_for("", + :html => { :multipart => true }, + :url => {:controller => 'exercise', + :action => 'commit_exercise' + },:remote=>true ) do |f| %> +
                  + 提交 +
                  + + +
                  +
                  +<% end %> + + \ No newline at end of file diff --git a/app/views/exercise/_exercise_submit_info.html.erb b/app/views/exercise/_exercise_submit_info.html.erb new file mode 100644 index 000000000..66d8da985 --- /dev/null +++ b/app/views/exercise/_exercise_submit_info.html.erb @@ -0,0 +1,35 @@ + + + + + + + +
                  +
                  +
                  +

                  当前测验分数为<%=score %>分, +
                  + 是否确定提交该测验? +

                  + +
                  +
                  +
                  +
                  + + + diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb index ad5af1937..6e088cd74 100644 --- a/app/views/exercise/_new_single.html.erb +++ b/app/views/exercise/_new_single.html.erb @@ -21,21 +21,21 @@
                • - +
                • - +
                • - +
                • diff --git a/app/views/exercise/_show_head.html.erb b/app/views/exercise/_show_head.html.erb index ec9f06035..ac7c1c162 100644 --- a/app/views/exercise/_show_head.html.erb +++ b/app/views/exercise/_show_head.html.erb @@ -5,7 +5,7 @@
                  发布时间:<%=Time.parse(format_time(exercise.publish_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.publish_time%> 截止时间:<%=Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") if exercise.end_time %> - 考试时长:<%= exercise.time %>分钟
                  + 测验时长:<%= exercise.time %>分钟
                  <%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%>
                  diff --git a/app/views/exercise/_show_single.html.erb b/app/views/exercise/_show_single.html.erb index 4e36530ed..30a0e354c 100644 --- a/app/views/exercise/_show_single.html.erb +++ b/app/views/exercise/_show_single.html.erb @@ -44,21 +44,21 @@ '
                • '+ ''+ ''+ - ''+ + ''+ ''+ '
                • '+ '
                  '+ '
                • '+ ''+ ''+ - ''+ + ''+ ''+ '
                • '+ '
                  '+ '
                • '+ ''+ ''+ - ''+ + ''+ ''+ '
                • '+ '
                  '+ diff --git a/app/views/exercise/create_exercise_question.js.erb b/app/views/exercise/create_exercise_question.js.erb index 37199a70e..9047cfeda 100644 --- a/app/views/exercise/create_exercise_question.js.erb +++ b/app/views/exercise/create_exercise_question.js.erb @@ -1,8 +1,10 @@ <% if @is_insert %> $("#poll_content").html('<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise})%>'); + $("#exercise_submit").html("<%= escape_javascript(render :partial => 'exercise_submit', :locals => {:exercise => @exercise}) %>"); <% else %> $("#new_exercise_question").html('<%= escape_javascript(render :partial => 'new_question', :locals => {:exercise => @exercise}) %>'); $("#new_poll_question").html(""); + $("#exercise_submit").html("<%= escape_javascript(render :partial => 'exercise_submit', :locals => {:exercise => @exercise}) %>"); <%if @exercise_questions.question_type == 1%> $("#mc_question_list").show().append("
                  " + "
                  " + @@ -33,26 +35,6 @@ "
                  " + "
                  "); <% end %> -/*$("#poll_content").append("
                  " + - "
                  " + - "<%# if @exercise_questions.question_type == 1%>" + - "<%#= escape_javascript(render :partial => 'show_MC', :locals => {:exercise_question => @exercise_questions}) %>" + - "<%# elsif @exercise_questions.question_type == 2%>" + - "<%#= escape_javascript(render :partial => 'show_MCQ', :locals => {:exercise_question => @exercise_questions}) %>" + - "<%# elsif @exercise_questions.question_type == 3%>" + - "<%#= escape_javascript(render :partial => 'show_single', :locals => {:exercise_question => @exercise_questions}) %>" + - "<%# end%>" + - "
                  " + - "" + - "
                  ");*/ $("#current_score").html("<%=get_current_score @exercise %>分"); $("#current_score_div").show(); <% end %> diff --git a/app/views/exercise/delete_exercise_question.js.erb b/app/views/exercise/delete_exercise_question.js.erb index eb6300eb5..d07a80b47 100644 --- a/app/views/exercise/delete_exercise_question.js.erb +++ b/app/views/exercise/delete_exercise_question.js.erb @@ -1 +1,3 @@ -$("#poll_content").html("<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise}) %>"); \ No newline at end of file +$("#poll_content").html("<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise}) %>"); +$("#current_score").html("<%=get_current_score @exercise %>分"); +$("#exercise_submit").html("<%= escape_javascript(render :partial => 'exercise_submit', :locals => {:exercise => @exercise}) %>"); \ No newline at end of file diff --git a/app/views/exercise/show.html.erb b/app/views/exercise/show.html.erb index b23c1c517..6638020d1 100644 --- a/app/views/exercise/show.html.erb +++ b/app/views/exercise/show.html.erb @@ -1 +1,5 @@ -111111 \ No newline at end of file +<% if @is_teacher %> + +<% else %> + <%=render :partial => 'exercise_student', :locals => {:exercise =>@exercise, :exercise_questions => @exercise_questions,:exercise_student => @exercise_student} %> +<% end %> \ No newline at end of file diff --git a/app/views/exercise/update.js.erb b/app/views/exercise/update.js.erb index 65b8dd327..9724b2bd1 100644 --- a/app/views/exercise/update.js.erb +++ b/app/views/exercise/update.js.erb @@ -1,4 +1,5 @@ $("#polls_head_show").html("<%= escape_javascript(render :partial => 'show_head', :locals => {:exercise => @exercise}) %>"); $("#polls_head_edit").html("<%= escape_javascript(render :partial => 'edit_head', :locals => {:exercise => @exercise}) %>"); $("#polls_head_edit").hide(); -$("#polls_head_show").show(); \ No newline at end of file +$("#polls_head_show").show(); +$("#exercise_submit").html("<%= escape_javascript(render :partial => 'exercise_submit', :locals => {:exercise => @exercise}) %>"); \ No newline at end of file diff --git a/app/views/exercise/update_exercise_question.js.erb b/app/views/exercise/update_exercise_question.js.erb index 0f0a23cec..73aea3140 100644 --- a/app/views/exercise/update_exercise_question.js.erb +++ b/app/views/exercise/update_exercise_question.js.erb @@ -17,3 +17,4 @@ $("#poll_questions_<%= @exercise_question.id%>").html("
                  {:exercise => @exercise}) %>"); From 7ab0f4764aa308c8bd858dde1f4af80ac5c8d6fa Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 19 Nov 2015 17:31:26 +0800 Subject: [PATCH 081/191] =?UTF-8?q?=E4=B8=BB=E7=AE=A1=E9=A2=98=E6=8F=92?= =?UTF-8?q?=E5=85=A5=E5=88=A0=E9=99=A4=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 9b09a28d9..a48298a83 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -223,7 +223,7 @@ class ExerciseController < ApplicationController question_standart.save else standart_answer_option = { - :answer_text => question_standart + :answer_text => answer_standart } @exercise_question.exercise_standard_answers.new standart_answer_option end From 87e7a51278a847747f1dbf841d193dfcee4ff390 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 19 Nov 2015 17:36:58 +0800 Subject: [PATCH 082/191] =?UTF-8?q?=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index a48298a83..18248331c 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -213,6 +213,10 @@ class ExerciseController < ApplicationController # 更新标准答案 if params[:exercise_choice] if @exercise_question.question_type == 3 + # 删除不合理的选项 + @exercise_question.exercise_standard_answers.each do |answer| + answer.destroy unless params[:exercise_choice].keys.include? answer.id.to_s + end for i in 1..params[:exercise_choice].count # 找到对应的标准答案 question_standart = @exercise_question.exercise_standard_answers.find_by_id params[:exercise_choice].keys[i-1] From d91a6c03b1f44d989621b4378bf3123cbcd16e9d Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 19 Nov 2015 17:50:24 +0800 Subject: [PATCH 083/191] =?UTF-8?q?=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_edit_MC.html.erb | 2 +- app/views/exercise/_edit_single.html.erb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/exercise/_edit_MC.html.erb b/app/views/exercise/_edit_MC.html.erb index 76bad697c..a1c8aa8b1 100644 --- a/app/views/exercise/_edit_MC.html.erb +++ b/app/views/exercise/_edit_MC.html.erb @@ -9,7 +9,7 @@ $("#poll_answers_<%=exercise_question.id%>").html("<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>" + "
                • " + "" + - "" + + "" + "" + "" + "
                • " + diff --git a/app/views/exercise/_edit_single.html.erb b/app/views/exercise/_edit_single.html.erb index feeb3715d..d22747457 100644 --- a/app/views/exercise/_edit_single.html.erb +++ b/app/views/exercise/_edit_single.html.erb @@ -5,10 +5,10 @@ { $("#poll_questions_title_<%=exercise_question.id%>").val("<%= exercise_question.question_title%>") $("#poll_question_score_<%=exercise_question.id %>").val("<%= exercise_question.question_score%>") - $("#poll_answers_<%=exercise_question.id%>").html("<% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %> %>" + + $("#poll_answers_<%=exercise_question.id%>").html("<% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %>" + "
                • " + "" + - "" + + "" + "" + "" + From 74343a49299ab500a1685fe254b3d7c4a94d92c2 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 19 Nov 2015 20:35:08 +0800 Subject: [PATCH 084/191] =?UTF-8?q?=E5=8F=91=E5=B8=83=E9=97=AE=E5=8D=B7?= =?UTF-8?q?=E3=80=81=E5=8F=96=E6=B6=88=E9=97=AE=E5=8D=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 19 ++-- app/views/exercise/_alert.html.erb | 27 ++++++ app/views/exercise/_exercise.html.erb | 4 +- .../exercise/_exercise_republish.html.erb | 0 app/views/exercise/index.html.erb | 87 +++++++++++++++++++ app/views/exercise/publish_exercise.js.erb | 10 +++ app/views/exercise/republish_exercise.js.erb | 10 +++ config/routes.rb | 2 + 8 files changed, 148 insertions(+), 11 deletions(-) create mode 100644 app/views/exercise/_alert.html.erb create mode 100644 app/views/exercise/_exercise_republish.html.erb create mode 100644 app/views/exercise/publish_exercise.js.erb create mode 100644 app/views/exercise/republish_exercise.js.erb diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 18248331c..d13c02d27 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -1,7 +1,7 @@ class ExerciseController < ApplicationController layout "base_courses" - before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show, :destroy, :commit_exercise, :commit_answer] + before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show, :destroy, :commit_exercise, :commit_answer,:publish_exercise,:republish_exercise] before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list] include ExerciseHelper @@ -261,7 +261,7 @@ class ExerciseController < ApplicationController end # 发布试卷 - def publish_excercise + def publish_exercise @exercise.exercise_status = 2 @exercise.publish_time = Time.now if @exercise.save @@ -276,16 +276,17 @@ class ExerciseController < ApplicationController end # 重新发布试卷 - def republish_excercise + # 重新发布的时候会删除所有的答题 + def republish_exercise @exercise.exercise_questions.each do |exercise_question| exercise_question.exercise_ansers.destroy_all end - # @poll.poll_users.destroy_all - # @poll.polls_status = 1 - # @poll.save - # respond_to do |format| - # format.js - # end + @exercise.exercise_users.destroy_all + @exercise.exercise_status = 1 + @exercise.save + respond_to do |format| + format.js + end end def student_exercise_list diff --git a/app/views/exercise/_alert.html.erb b/app/views/exercise/_alert.html.erb new file mode 100644 index 000000000..b3de53d1f --- /dev/null +++ b/app/views/exercise/_alert.html.erb @@ -0,0 +1,27 @@ + + + + + + + +
                  +
                  +
                  +

                  + <%= message%> +

                  + +
                  +
                  +
                  +
                  + + + diff --git a/app/views/exercise/_exercise.html.erb b/app/views/exercise/_exercise.html.erb index 15a684a62..e44cd69c6 100644 --- a/app/views/exercise/_exercise.html.erb +++ b/app/views/exercise/_exercise.html.erb @@ -19,9 +19,9 @@ <% end%> <% if exercise.exercise_status == 1 %> -
                • 发布试卷
                • +
                • 发布试卷
                • <% elsif exercise.exercise_status == 2%> -
                • 取消发布
                • +
                • 取消发布
                • <% else%>
                • 发布试卷
                • <% end%> diff --git a/app/views/exercise/_exercise_republish.html.erb b/app/views/exercise/_exercise_republish.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/exercise/index.html.erb b/app/views/exercise/index.html.erb index bbe4dd707..8e8940f33 100644 --- a/app/views/exercise/index.html.erb +++ b/app/views/exercise/index.html.erb @@ -1,4 +1,91 @@ <%= stylesheet_link_tag 'polls', :media => 'all' %> +
                  <%= render :partial => 'exercises_list'%>
                  \ No newline at end of file diff --git a/app/views/exercise/publish_exercise.js.erb b/app/views/exercise/publish_exercise.js.erb new file mode 100644 index 000000000..ac2899402 --- /dev/null +++ b/app/views/exercise/publish_exercise.js.erb @@ -0,0 +1,10 @@ +$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise',:locals => {:exercise => @exercise}) %>"); +$('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_memo_create_succ)}) %>"); +showModal('ajax-modal', '250px'); +//$('#ajax-modal').css('height','111px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().removeClass("alert_praise"); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("poll_alert_form"); \ No newline at end of file diff --git a/app/views/exercise/republish_exercise.js.erb b/app/views/exercise/republish_exercise.js.erb new file mode 100644 index 000000000..320cd3cf0 --- /dev/null +++ b/app/views/exercise/republish_exercise.js.erb @@ -0,0 +1,10 @@ +$("#exercises_<%= @exercise.id %>").html("<%= escape_javascript(render :partial => 'exercise_content',:locals => {:exercise => @exercise}) %>"); +$('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_poll_republish_success)}) %>"); +showModal('ajax-modal', '250px'); +//$('#ajax-modal').css('height','80px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().removeClass("alert_praise"); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("poll_alert_form"); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 516b8977f..559bf4376 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -152,6 +152,8 @@ RedmineApp::Application.routes.draw do get 'statistics_result' get 'student_exercise_list' get 'export_exercise' + get 'publish_exercise' + get 'republish_exercise' post 'create_exercise_question' post 'commit_answer' post 'commit_exercise' From 20a80fe6eb2b250f91885a132c3b5b3e3e81f10a Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 19 Nov 2015 20:38:03 +0800 Subject: [PATCH 085/191] =?UTF-8?q?=E4=BF=AE=E6=94=B9JS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/index.html.erb | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/app/views/exercise/index.html.erb b/app/views/exercise/index.html.erb index 8e8940f33..14db03e09 100644 --- a/app/views/exercise/index.html.erb +++ b/app/views/exercise/index.html.erb @@ -57,34 +57,6 @@ } } - function close_poll(poll_id) - { - $('#ajax-modal').html("
                  " + - "
                  " + - "
                  " + - "

                  问卷关闭后学生将不能继续提交问卷,
                  是否确定关闭该问卷?

                  " + - "
                  " + - "确  定" + - "取  消" + - "
                  " + - "
                  " + - "
                  " + - "
                  " + - "
                  "); - showModal('ajax-modal', '310px'); - $('#ajax-modal').css('height','120px'); - $('#ajax-modal').siblings().remove(); - $('#ajax-modal').before("" + - ""); - $('#ajax-modal').parent().removeClass("alert_praise"); - $('#ajax-modal').parent().css("top","").css("left",""); - $('#ajax-modal').parent().addClass("popbox_polls"); - } - - function closeModal() - { - hideModal($("#popbox_upload")); - }
                  <%= render :partial => 'exercises_list'%> From 7dc16775dcaa7902a145007a899bf02bdf7e9366 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 19 Nov 2015 20:44:01 +0800 Subject: [PATCH 086/191] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...51119124148_add_end_at_to_exercise_user.rb | 5 ++ db/schema.rb | 55 +------------------ 2 files changed, 7 insertions(+), 53 deletions(-) create mode 100644 db/migrate/20151119124148_add_end_at_to_exercise_user.rb diff --git a/db/migrate/20151119124148_add_end_at_to_exercise_user.rb b/db/migrate/20151119124148_add_end_at_to_exercise_user.rb new file mode 100644 index 000000000..db4cc4c47 --- /dev/null +++ b/db/migrate/20151119124148_add_end_at_to_exercise_user.rb @@ -0,0 +1,5 @@ +class AddEndAtToExerciseUser < ActiveRecord::Migration + def change + add_column :exercise_users, :end_at, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb index 07dac5706..042058c5a 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 => 20151118015638) do +ActiveRecord::Schema.define(:version => 20151119124148) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -241,58 +241,6 @@ ActiveRecord::Schema.define(:version => 20151118015638) do add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true - create_table "code_review_assignments", :force => true do |t| - t.integer "issue_id" - t.integer "change_id" - t.integer "attachment_id" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.string "action_type" - t.integer "changeset_id" - end - - create_table "code_review_project_settings", :force => true do |t| - t.integer "project_id" - t.integer "tracker_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "updated_by" - t.boolean "hide_code_review_tab", :default => false - t.integer "auto_relation", :default => 1 - t.integer "assignment_tracker_id" - t.text "auto_assign" - t.integer "lock_version", :default => 0, :null => false - t.boolean "tracker_in_review_dialog", :default => false - end - - create_table "code_review_user_settings", :force => true do |t| - t.integer "user_id", :default => 0, :null => false - t.integer "mail_notification", :default => 0, :null => false - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "code_reviews", :force => true do |t| - t.integer "project_id" - t.integer "change_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "line" - t.integer "updated_by_id" - t.integer "lock_version", :default => 0, :null => false - t.integer "status_changed_from" - t.integer "status_changed_to" - t.integer "issue_id" - t.string "action_type" - t.string "file_path" - t.string "rev" - t.string "rev_to" - t.integer "attachment_id" - t.integer "file_count", :default => 0, :null => false - t.boolean "diff_all" - end - create_table "comments", :force => true do |t| t.string "commented_type", :limit => 30, :default => "", :null => false t.integer "commented_id", :default => 0, :null => false @@ -614,6 +562,7 @@ ActiveRecord::Schema.define(:version => 20151118015638) do t.datetime "start_at" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false + t.datetime "end_at" end create_table "exercises", :force => true do |t| From 9aee23507c43df0fca15bd5de423b8803795bed3 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 19 Nov 2015 21:19:18 +0800 Subject: [PATCH 087/191] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E7=AD=94=E9=A2=98?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E3=80=81=E7=AD=94=E9=A2=98=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E3=80=81=E8=80=81=E5=B8=88=E7=9A=84=E8=AF=95?= =?UTF-8?q?=E5=8D=B7=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 6 +- app/helpers/exercise_helper.rb | 19 +++ app/views/exercise/_commit_alert.html.erb | 12 ++ app/views/exercise/_exercise_student.html.erb | 103 +++++++++---- .../_exercise_student_result.html.erb | 135 ++++++++++++++++++ app/views/exercise/_exercise_submit.html.erb | 3 +- app/views/exercise/_exercise_teacher.html.erb | 117 +++++++++++++++ app/views/exercise/_new_MC.html.erb | 6 +- app/views/exercise/_new_MCQ.html.erb | 6 +- app/views/exercise/_new_single.html.erb | 6 +- app/views/exercise/_show_MC.html.erb | 2 +- app/views/exercise/_show_MCQ.html.erb | 2 +- app/views/exercise/_show_single.html.erb | 2 +- app/views/exercise/commit_exercise.js.erb | 9 ++ app/views/exercise/show.html.erb | 8 +- .../exercise/update_exercise_question.js.erb | 2 +- 16 files changed, 390 insertions(+), 48 deletions(-) create mode 100644 app/views/exercise/_commit_alert.html.erb create mode 100644 app/views/exercise/_exercise_student_result.html.erb create mode 100644 app/views/exercise/_exercise_teacher.html.erb create mode 100644 app/views/exercise/commit_exercise.js.erb diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 18248331c..69e8ebd80 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -374,7 +374,7 @@ class ExerciseController < ApplicationController ea.answer_text = params[:answer_text] if ea.save @percent = get_percent(@exercise,User.current) - render :json => {:text => pv.vote_text,:percent => format("%.2f",@percent)} + render :json => {:text => ea.answer_text,:percent => format("%.2f",@percent)} else render :json => {:text => "failure"} end @@ -416,13 +416,13 @@ class ExerciseController < ApplicationController # 答题过程中需要统计完成量 @uncomplete_question = get_uncomplete_question(@exercise, User.current) # 获取改学生的考试得分 - score = calculate_student_score(@exercise, User.current) + @score = calculate_student_score(@exercise, User.current) if @uncomplete_question.count < 1 # 查看是否有已提交记录 eu = get_exercise_user(@exercise.id, User.current.id) eu.user_id = User.current.id eu.exercise_id = @exercise.id - eu.score = score + eu.score = @score if eu.save #redirect_to poll_index_path(:polls_group_id => @course.id,:polls_type => 'Course') @status = 0 #提交成功 diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index 7f3d1862e..5b28234e8 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -72,4 +72,23 @@ module ExerciseHelper return score end + def answer_be_selected?(answer,user) + pv = answer.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{user.id} ") + if !pv.nil? && pv.count > 0 + true + else + false + end + end + + #获取文本题答案 + def get_anwser_vote_text(question_id,user_id) + pv = ExerciseAnswer.find_by_exercise_question_id_and_user_id(question_id,user_id) + if pv.nil? + '' + else + pv.answer_text + end + end + end \ No newline at end of file diff --git a/app/views/exercise/_commit_alert.html.erb b/app/views/exercise/_commit_alert.html.erb new file mode 100644 index 000000000..d92ca51fb --- /dev/null +++ b/app/views/exercise/_commit_alert.html.erb @@ -0,0 +1,12 @@ +
                  + <% if status == 0 %> +

                  提交成功!您的分数是:<%=@score %>分。

                  + <%= link_to "确定", exercise_path(),:class => 'commit'%> + <% elsif status == 1 %> +

                  您还有尚未作答的题目请完成后再提交!

                  + <%= link_to "确定", "javascript:void(0)",:onclick => 'hidden_atert_form();',:class => 'commit'%> + <% else %> +

                  发生未知错误,请检查您的网络。

                  + <%= link_to "确定", "javascript:void(0)",:onclick => 'hidden_atert_form();',:class => 'commit'%> + <% end %> +
                  diff --git a/app/views/exercise/_exercise_student.html.erb b/app/views/exercise/_exercise_student.html.erb index 5a139fd5d..0cc34958f 100644 --- a/app/views/exercise/_exercise_student.html.erb +++ b/app/views/exercise/_exercise_student.html.erb @@ -4,33 +4,15 @@ $("#homework_page_right").css("min-height",$("#LSide").height()-30); $("#Container").css("width","1000px"); }); - function click_<%= pa.id %>(obj) - { - $.ajax({ - type: "post", - url: "<%= commit_answer_poll_path(@poll) %>", - data: { - poll_answer_id: <%= pa.id %>, - poll_question_id: <%= pq.id %> - }, - success: function (data) { - var dataObj = eval(data); - obj.checked = true; - var span = $('#percent'); - span.html(dataObj.percent); - } - }); - } - function student_submit_exercise(){ - - }

                  <%= exercise.exercise_name%>

                  -
                  开始时间:<%=format_time(exercise_student.start_at.to_s) %>测验时长:<%=exercise.time %>分钟 -
                  剩余时长:1 小时 30 分钟 0 秒
                  +
                  + 开始时间:<%=format_time(exercise_user.start_at.to_s) %> + 测验时长:<%=exercise.time %>分钟 + 剩余时长:1 小时 30 分钟 0 秒
                  <%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%>
                  @@ -56,7 +38,31 @@ @@ -87,7 +93,31 @@ @@ -112,14 +142,35 @@
                  - + + >
                  <% end %>
                  - +
                  + <%= link_to l(:button_submit),commit_exercise_exercise_path(exercise), :method => :post,:class => "ur_button_submit",:style => "margin-left:80px;",:format => 'js',:remote=>true %> +
                  diff --git a/app/views/exercise/_exercise_student_result.html.erb b/app/views/exercise/_exercise_student_result.html.erb new file mode 100644 index 000000000..40f9b953b --- /dev/null +++ b/app/views/exercise/_exercise_student_result.html.erb @@ -0,0 +1,135 @@ + +
                  +
                  +
                  +

                  <%= exercise.exercise_name%>

                  +
                  + 开始时间:<%=format_time(exercise_user.start_at.to_s) %> + 测验时长:<%=exercise.time %>分钟 + <% time = exercise_user.end_at - exercise_user.start_at %> + 测验用时:<%= (time % (24*60*60)) / (60*60)%> 小时 <%= ((time % (24*60*60)) % (60*60)) / 60%> 分钟 <%= ((time % (24*60*60)) % (60*60)) % 60%> 秒 +
                  +
                  <%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%>
                  +
                  +
                  +
                  得分:<%=exercise_user.score %>分
                  + <% mc_question_list = exercise_questions.where("question_type=1") %> + <% mcq_question_list = exercise_questions.where("question_type=2") %> + <% single_question_list = exercise_questions.where("question_type=3") %> +
                  "> +

                  单选题

                  + <% mc_question_list.each do |exercise_question| %> +
                  +
                  +
                  +
                  第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
                  + <%= exercise_question.question_title %> + + <% if exercise_question.exercise_standard_answers.first.exercise_choice_id == exercise_question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{User.current.id}.first.exercise_choice_id ") %> + √ + <% else %> + × + <% end %>
                  + 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %> +
                  +
                  +
                  + + + <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> + + + + <% end %> + +
                  + +
                  +
                  +
                  +
                  +
                  + <% end %> +
                  +
                  "> +

                  多选题

                  + <% mcq_question_list.each do |exercise_question| %> +
                  +
                  +
                  +
                  第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
                  + <%= exercise_question.question_title %> + + <% if exercise_question.exercise_standard_answers.first.exercise_choice_id == exercise_question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{User.current.id}.first.exercise_choice_id ") %> + √ + <% else %> + × + <% end %>
                  + 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %> +
                  +
                  +
                  + + + <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> + + + + <% end %> + +
                  + +
                  +
                  +
                  +
                  +
                  + <% end %> +
                  +
                  "> +

                  填空题

                  + <% single_question_list.each do |exercise_question| %> +
                  +
                  +
                  +
                  第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
                  + <%= exercise_question.question_title %> + + <% if exercise_question.exercise_standard_answers.first.exercise_choice_id == exercise_question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{User.current.id}.first.exercise_choice_id ") %> + √ + <% else %> + × + <% end %>
                  + 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %> +
                  +
                  +
                  + <% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %> + 候选答案:<%= exercise_choice.answer_text%>
                  + <% end %> +
                  +
                  + > +
                  +
                  +
                  +
                  + <% end %> +
                  +
                  + +
                  + +
                  \ No newline at end of file diff --git a/app/views/exercise/_exercise_submit.html.erb b/app/views/exercise/_exercise_submit.html.erb index e242eacc7..a8892b27e 100644 --- a/app/views/exercise/_exercise_submit.html.erb +++ b/app/views/exercise/_exercise_submit.html.erb @@ -1,7 +1,8 @@ <%= form_for("", :html => { :multipart => true }, :url => {:controller => 'exercise', - :action => 'commit_exercise' + :action => 'commit_exercise', + :id => exercise.id },:remote=>true ) do |f| %>
                  提交 diff --git a/app/views/exercise/_exercise_teacher.html.erb b/app/views/exercise/_exercise_teacher.html.erb new file mode 100644 index 000000000..18f62e403 --- /dev/null +++ b/app/views/exercise/_exercise_teacher.html.erb @@ -0,0 +1,117 @@ + +
                  +
                  +
                  +

                  <%= exercise.exercise_name%>

                  +
                  + 发布时间:<%=format_time(exercise.publish_time.to_s) %> + 截止时间:<%=format_time(exercise.end_time.to_s) %> + <% time = exercise_user.end_at - exercise_user.start_at %> + 测验时长:<%=exercise.time %>分钟 +
                  +
                  <%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%>
                  +
                  +
                  + <% mc_question_list = exercise_questions.where("question_type=1") %> + <% mcq_question_list = exercise_questions.where("question_type=2") %> + <% single_question_list = exercise_questions.where("question_type=3") %> +
                  "> +

                  单选题

                  + <% mc_question_list.each do |exercise_question| %> +
                  +
                  +
                  +
                  第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
                  + <%= exercise_question.question_title %>
                  + 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %> +
                  +
                  +
                  + + + <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> + + + + <% end %> + +
                  + +
                  +
                  +
                  +
                  +
                  + <% end %> +
                  +
                  "> +

                  多选题

                  + <% mcq_question_list.each do |exercise_question| %> +
                  +
                  +
                  +
                  第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
                  + <%= exercise_question.question_title %>
                  + 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %> +
                  +
                  +
                  + + + <% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %> + + + + <% end %> + +
                  + +
                  +
                  +
                  +
                  +
                  + <% end %> +
                  +
                  "> +

                  填空题

                  + <% single_question_list.each do |exercise_question| %> +
                  +
                  +
                  +
                  第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
                  + <%= exercise_question.question_title %>
                  + 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %> +
                  +
                  +
                  + <% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %> + 候选答案:<%= exercise_choice.answer_text%>
                  + <% end %> +
                  +
                  +
                  +
                  + <% end %> +
                  +
                  + <%= link_to l(:button_submit),exercise_index_path(:course_id => @course.id),:class => "ur_button_submit" %> + <%= link_to l(:button_edit), edit_exercise_path(exercise.id), :class => "ur_button_submit fr"%> +
                  +
                  + +
                  + +
                  \ No newline at end of file diff --git a/app/views/exercise/_new_MC.html.erb b/app/views/exercise/_new_MC.html.erb index 3da0021ce..0b9543009 100644 --- a/app/views/exercise/_new_MC.html.erb +++ b/app/views/exercise/_new_MC.html.erb @@ -1,9 +1,7 @@ <%= form_for(ExerciseQuestion.new, :html => { :multipart => true }, - :url => {:controller => 'exercise', - :action => 'create_exercise_question', - :course_id => @course.id - },:remote=>true ) do |f| %> + :url=>create_exercise_question_exercise_path(exercise_question.id), + :remote=>true ) do |f| %>
                  diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb index 044ecd629..2f1f28395 100644 --- a/app/views/exercise/_new_MCQ.html.erb +++ b/app/views/exercise/_new_MCQ.html.erb @@ -1,9 +1,7 @@ <%= form_for(ExerciseQuestion.new, :html => { :multipart => true }, - :url => {:controller => 'exercise', - :action => 'create_exercise_question', - :course_id => @course.id - },:remote=>true ) do |f| %> + :url=>create_exercise_question_exercise_path(exercise_question.id), + :remote=>true ) do |f| %>
                  diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb index 6e088cd74..ec52fbcad 100644 --- a/app/views/exercise/_new_single.html.erb +++ b/app/views/exercise/_new_single.html.erb @@ -1,9 +1,7 @@ <%= form_for(ExerciseQuestion.new, :html => { :multipart => true }, - :url => {:controller => 'exercise', - :action => 'create_exercise_question', - :course_id => @course.id - },:remote=>true ) do |f| %> + :url=>create_exercise_question_exercise_path(exercise_question.id), + :remote=>true ) do |f| %>
                  diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb index 21d6ef4bb..0883995dc 100644 --- a/app/views/exercise/_show_MC.html.erb +++ b/app/views/exercise/_show_MC.html.erb @@ -39,7 +39,7 @@ } else{ <% score =exercise_question.question_score %> $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( - '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>{:controller=> 'exercise',:action=>'create_exercise_question',:course_id=>@course.id},:remote=>true) do |f|%>'+ + '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.id),:remote=>true) do |f|%>'+ '
                  '+ '
                  '+ ''+ diff --git a/app/views/exercise/_show_MCQ.html.erb b/app/views/exercise/_show_MCQ.html.erb index a6ffbeb82..52f01e6c7 100644 --- a/app/views/exercise/_show_MCQ.html.erb +++ b/app/views/exercise/_show_MCQ.html.erb @@ -38,7 +38,7 @@ } else { <% score =exercise_question.question_score %> $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( - '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>{:controller=> 'exercise',:action=>'create_exercise_question',:course_id=>@course.id},:remote=>true) do |f|%>'+ + '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.id),:remote=>true) do |f|%>'+ '
                  '+ '
                  '+ ''+ diff --git a/app/views/exercise/_show_single.html.erb b/app/views/exercise/_show_single.html.erb index 30a0e354c..933f2edcc 100644 --- a/app/views/exercise/_show_single.html.erb +++ b/app/views/exercise/_show_single.html.erb @@ -26,7 +26,7 @@ } else { <% score =exercise_question.question_score %> $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( - '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>{:controller=> 'exercise',:action=>'create_exercise_question',:course_id=>@course.id},:remote=>true) do |f|%>'+ + '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.id),:remote=>true) do |f|%>'+ '
                  '+ '
                  '+ ''+ diff --git a/app/views/exercise/commit_exercise.js.erb b/app/views/exercise/commit_exercise.js.erb new file mode 100644 index 000000000..2a40df2a5 --- /dev/null +++ b/app/views/exercise/commit_exercise.js.erb @@ -0,0 +1,9 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'commit_alert',:locals => {:status => @status}) %>'); +showModal('ajax-modal', '270px'); +$('#ajax-modal').css('height','110px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().removeClass("alert_praise"); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("alert_box"); \ No newline at end of file diff --git a/app/views/exercise/show.html.erb b/app/views/exercise/show.html.erb index 6638020d1..cee9b084c 100644 --- a/app/views/exercise/show.html.erb +++ b/app/views/exercise/show.html.erb @@ -1,5 +1,9 @@ <% if @is_teacher %> - + <%= render :partial => 'exercise_teacher', :locals =>{:exercise =>@exercise, :exercise_questions => @exercise_questions} %> <% else %> - <%=render :partial => 'exercise_student', :locals => {:exercise =>@exercise, :exercise_questions => @exercise_questions,:exercise_student => @exercise_student} %> + <% if @can_edit_excercise %> + <%=render :partial => 'exercise_student', :locals => {:exercise =>@exercise, :exercise_questions => @exercise_questions,:exercise_user => @exercise_user} %> + <% else %> + <%=render :partial => 'exercise_student_result', :locals => {:exercise =>@exercise, :exercise_questions => @exercise_questions,:exercise_user => @exercise_user} %> + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/exercise/update_exercise_question.js.erb b/app/views/exercise/update_exercise_question.js.erb index 73aea3140..ef9004c06 100644 --- a/app/views/exercise/update_exercise_question.js.erb +++ b/app/views/exercise/update_exercise_question.js.erb @@ -17,4 +17,4 @@ $("#poll_questions_<%= @exercise_question.id%>").html("
                  {:exercise => @exercise}) %>"); +$("#exercise_submit").html("<%= escape_javascript(render :partial => 'exercise_submit', :locals => {:exercise => @exercise_question.exercise}) %>"); From 81e28272774ef3f0455dce8a93757bdb66bd1a8f Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 19 Nov 2015 21:21:02 +0800 Subject: [PATCH 088/191] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 4 ++-- app/helpers/exercise_helper.rb | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index d13c02d27..4941e63ac 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -449,11 +449,11 @@ class ExerciseController < ApplicationController # 问答题有多个答案 if question.question_type == 3 if standard_answer.exercise_choice_id.include?(answer.exercise_choice_id) - score = score + question.question_score + score += question.question_score unless question.question_score.empty? end else if answer.exercise_choice_id == standard_answer.exercise_choice_id - score = score + question.question_score + score += question.question_score unless question.question_score.empty? end end end diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index 7f3d1862e..6cf89cdb8 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -65,7 +65,9 @@ module ExerciseHelper score = 0 unless exercise.nil? exercise.exercise_questions.each do |exercise_question| - score += exercise_question.question_score + unless exercise_question.question_score.nil? + score += exercise_question.question_score + end end return score end From d71d9730bd74f9bf29455578401cb2fa91c1227e Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 20 Nov 2015 09:26:58 +0800 Subject: [PATCH 089/191] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...copy_forge_activities_to_org_activities.rb | 2 +- ...opy_course_activities_to_org_activities.rb | 20 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/db/migrate/20151116020842_copy_forge_activities_to_org_activities.rb b/db/migrate/20151116020842_copy_forge_activities_to_org_activities.rb index d3ded425e..5fbd5469a 100644 --- a/db/migrate/20151116020842_copy_forge_activities_to_org_activities.rb +++ b/db/migrate/20151116020842_copy_forge_activities_to_org_activities.rb @@ -3,7 +3,7 @@ class CopyForgeActivitiesToOrgActivities < ActiveRecord::Migration count = ForgeActivity.all.count/30 + 1 for i in 1 ... count do transaction do - ForgeActivity.page(i).per(30).each do + ForgeActivity.page(i).per(30).each do |forge_act| OrgActivity.create(:user_id => forge_act.user_id, :org_act_id => forge_act.forge_act_id, :org_act_type => forge_act.forge_act_type, diff --git a/db/migrate/20151118031602_copy_course_activities_to_org_activities.rb b/db/migrate/20151118031602_copy_course_activities_to_org_activities.rb index e616064e7..08f952afa 100644 --- a/db/migrate/20151118031602_copy_course_activities_to_org_activities.rb +++ b/db/migrate/20151118031602_copy_course_activities_to_org_activities.rb @@ -4,13 +4,19 @@ class CopyCourseActivitiesToOrgActivities < ActiveRecord::Migration for i in 1 ... count do transaction do CourseActivity.page(i).per(30).each do |course_act| - OrgActivity.create(:user_id => course_act.user_id, - :org_act_type => course_act.course_act_type, - :org_act_id => course_act.course_act_id, - :container_id => course_act.course_id, - :container_type => "Course", - :created_at => course_act.created_at, - :updated_at => course_act.updated_at) + if course_act.course_act_type == 'Message' && !course_act.course_act.parent_id.nil? + org_activity = OrgActivity.where("org_act_type = 'Message' and org_act_id = #{course_act.course_act.parent.id}").first + org_activity.created_at = course_act.created_at + org_activity.save + else + OrgActivity.create(:user_id => course_act.user_id, + :org_act_id => course_act.course_act_id, + :org_act_type => course_act.course_act_type, + :container_id => course_act.course_id, + :container_type => 'Course', + :created_at => course_act.created_at, + :updated_at => course_act.updated_at) + end end end end From d583ca1d7073ea034fb39444935e171f89c338a7 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 20 Nov 2015 09:54:46 +0800 Subject: [PATCH 090/191] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_exercise_submit.html.erb | 7 +++---- app/views/exercise/_exercise_submit_info.html.erb | 14 ++++++++++++-- app/views/exercise/_exercise_teacher.html.erb | 11 +++++------ app/views/exercise/_new_MC.html.erb | 2 +- app/views/exercise/_new_MCQ.html.erb | 2 +- app/views/exercise/_new_single.html.erb | 2 +- app/views/exercise/show.html.erb | 1 + 7 files changed, 24 insertions(+), 15 deletions(-) diff --git a/app/views/exercise/_exercise_submit.html.erb b/app/views/exercise/_exercise_submit.html.erb index a8892b27e..a28c8917b 100644 --- a/app/views/exercise/_exercise_submit.html.erb +++ b/app/views/exercise/_exercise_submit.html.erb @@ -16,15 +16,14 @@ <%= render :partial => 'organizations/show_org_document', :locals => {:document => document, :act => OrgActivity.where("org_act_type='OrgDocumentComment'and org_act_id=?", document.id).first} %> diff --git a/app/views/org_document_comments/quote.js.erb b/app/views/org_document_comments/quote.js.erb new file mode 100644 index 000000000..a71b23f0e --- /dev/null +++ b/app/views/org_document_comments/quote.js.erb @@ -0,0 +1,10 @@ +if($("#reply_message_<%= @org_comment.id%>").length > 0) { + $("#reply_message_<%= @org_comment.id%>").replaceWith("<%= escape_javascript(render :partial => 'org_document_comments/simple_ke_reply_form', :locals => {:reply => @org_comment,:temp =>@temp,:subject =>@subject}) %>"); + $(function(){ + $('#reply_subject').val("<%= raw escape_javascript(@subject) %>"); + $('#quote_quote').val("<%= raw escape_javascript(@temp.content.html_safe) %>"); + init_activity_KindEditor_data(<%= @org_comment.id%>,null,"85%"); + }); +}else if($("#reply_to_message_<%= @org_comment.id %>").length >0) { + $("#reply_to_message_<%= @org_comment.id%>").replaceWith("

                  "); +} \ No newline at end of file diff --git a/app/views/org_document_comments/reply.js.erb b/app/views/org_document_comments/reply.js.erb new file mode 100644 index 000000000..888613c8c --- /dev/null +++ b/app/views/org_document_comments/reply.js.erb @@ -0,0 +1 @@ +//location.reload(); \ No newline at end of file diff --git a/app/views/org_document_comments/show.html.erb b/app/views/org_document_comments/show.html.erb index e69de29bb..ae90b15bb 100644 --- a/app/views/org_document_comments/show.html.erb +++ b/app/views/org_document_comments/show.html.erb @@ -0,0 +1,147 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_activity_KindEditor",'blog' %> + +
                  +
                  +
                  + <%= link_to image_tag(url_to_avatar(User.find(@document.creator_id)), :width => 45, :heigth => 45), user_path(@document.creator_id) %> +
                  +
                  +
                  + <%= link_to User.find(@document.creator_id), user_path(@document.creator.id), :class => "newsBlue mr15" %> + TO  <%= link_to @document.organization.name, organization_path(@document.organization), :class => "newsBlue" %> + | + <% if @document.organization.home_id == @document.id %> + 首页 + <% else %> + 组织文章 + <% end %> +
                  +
                  <%= link_to @document.title, org_document_comment_path(:id => @document.id, :organization_id => @document.organization.id) %>
                  +
                  + 发布时间:<%= format_activity_day(@document.created_at) %> <%= format_time(@document.created_at, false) %>
                  + <% unless @document.content.blank? %> +
                  + <%= @document.content.html_safe %> +
                  + <% end %> + + <% if User.current.admin? || User.current.admin_of_org?(Organization.find(@document.organization_id) || User.current.id == @document.creator_id) %> +
                  +
                    +
                  • +
                      +
                    • + <%= form_for('new_form', :url => {:controller => 'organizations', :action => 'set_homepage', :id => @document.organization_id, :home_id => @document.id}, :method => "put", :remote => true) do |f| %> + 设为首页 + <% end %> +
                    • +
                    • + <%= link_to "编辑文章", edit_org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id), :class => "postOptionLink" %> +
                    • +
                    • + <%= link_to "删除文章", org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id), :method => 'delete', + :data => {:confirm => l(:text_are_you_sure)}, + :remote => true, :class => 'postOptionLink' %> +
                    • +
                    +
                  • +
                  +
                  +
                  + <% end %> +
                  +
                  + <% comments_for_doc = @document.children.reorder("created_at desc") %> + <% count = @document.children.count() %> + +
                  + <% if count > 0 %> +
                  +
                  回复(<%= count %>)
                  +
                  +
                  + <% comments_for_doc.each_with_index do |reply,i| %> + + <% user = User.find(reply.creator_id) %> +
                  +
                  + <%= link_to image_tag(url_to_avatar(user), :width => 33,:height => 33), user_path(user) %> +
                  +
                  +
                  + <%= reply.content.html_safe unless reply.content.nil? %> +
                  +
                  + <%= format_time(reply.created_at) %> + +
                  +

                  +
                  +
                  +
                  + <% end %> +
                  +
                  + <% end %> + <% if User.current.logged?%> +
                  + +
                  +
                  + <%= form_for :org_comment, :url => {:action => 'add_reply_in_doc',:controller => 'org_document_comments', :id => @document.id}, :html => {:multipart => true, :id => 'message_form'} do |f| %> + <%= f.kindeditor :org_content,:width=>'99%',:height => '100px;',:editor_id=>'message_content_editor' %> + <%= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'message_content_editor.html("");', :class => " grey_btn fr c_white mt10 mr5" %> + <%= link_to l(:button_reply), "javascript:void(0)", :onclick => "message_content_editor.sync();$('#message_form').submit();", :class => "blue_btn fr c_white mt10 mb10", :style => "margin-right: 5px;" %> + <% end %> +
                  +
                  +
                  + <% end %> +
                  +
                  + + \ No newline at end of file diff --git a/app/views/organizations/_show_org_document.html.erb b/app/views/organizations/_show_org_document.html.erb index 1324729ac..e74da846e 100644 --- a/app/views/organizations/_show_org_document.html.erb +++ b/app/views/organizations/_show_org_document.html.erb @@ -14,7 +14,7 @@ 组织文章 <% end %>
                  -
                  <%= document.title %>
                  +
                  <%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id) %>
                  发布时间:<%= format_activity_day(document.created_at) %> <%= format_time(document.created_at, false) %>
                  <% unless document.content.blank? %> diff --git a/config/routes.rb b/config/routes.rb index c68c8a1c1..993c1e243 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -66,6 +66,10 @@ RedmineApp::Application.routes.draw do resources :org_document_comments do member do post 'add_reply' + get 'quote' + post 'reply' + post 'add_reply_in_doc' + delete 'delete_reply' end collection do diff --git a/db/migrate/20151116070906_add_created_at_to_org_members.rb b/db/migrate/20151116070906_add_created_at_to_org_members.rb deleted file mode 100644 index 33d3a2817..000000000 --- a/db/migrate/20151116070906_add_created_at_to_org_members.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCreatedAtToOrgMembers < ActiveRecord::Migration - def change - add_column :org_members, :created_at, :timestamp - end -end From 3deebf200688c04940b988b69d20138076b83907 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 20 Nov 2015 11:08:47 +0800 Subject: [PATCH 093/191] show --- app/controllers/exercise_controller.rb | 9 +++++++++ app/helpers/exercise_helper.rb | 17 ++++++++++++++--- ...0151120021958_add_status_to_exercise_user.rb | 5 +++++ db/schema.rb | 3 ++- 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20151120021958_add_status_to_exercise_user.rb diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index cb691c0e3..c3e5d9a67 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -27,11 +27,19 @@ class ExerciseController < ApplicationController render_403 return end + + # 学生点击的时候即创建关联,自动保存 + #eu = ExerciseUser.create(:user_id => User.current, :exercise_id => @exercise.id, :start_at => Time.now, :status => false) + # 已提交问卷的用户不能再访问该界面 if has_commit_exercise?(@exercise.id, User.current.id) && (!User.current.admin?) redirect_to exercise_index_url(:course_id=> @course.id) else + if !@is_teacher && !has_click_exercise?(@exercise.id, User.current.id) + eu = ExerciseUser.create(:user_id => User.current.id, :exercise_id => @exercise.id, :start_at => Time.now, :status => false) + end @can_edit_excercise = (!has_commit_exercise?(@exercise.id,User.current.id)) || User.current.admin? + @exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first # @percent = get_percent(@exercise,User.current) exercise_questions = @exercise.exercise_questions @exercise_questions = paginateHelper exercise_questions,5 #分页 @@ -411,6 +419,7 @@ class ExerciseController < ApplicationController def commit_exercise # 老师不需要提交 if User.current.allowed_to?(:as_teacher,@course) + redirect_to exercise_url(@exercise) # REDO: 提示提交成功 else diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index db45e8d87..ec7421533 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -35,10 +35,21 @@ module ExerciseHelper end end - #判断用户是否已经提交了问卷 + # 判断用户是否已经提交了问卷 + # status 为0的时候是用户点击试卷。为1表示用户已经提交 def has_commit_exercise?(exercise_id, user_id) - pu = ExerciseUser.find_by_exercise_id_and_user_id(exercise_id, user_id) - if pu.nil? + pu = ExerciseUser.where("exercise_id=? and user_id=? and status=?",exercise_id, user_id, true) + if pu.empty? + false + else + true + end + end + + # 判断学生是否点击过问卷,点击则为他保存一个记录,记录start_at + def has_click_exercise?(exercise_id, user_id) + pu = ExerciseUser.where("exercise_id=? and user_id=? and status=?",exercise_id, user_id, false) + if pu.empty? false else true diff --git a/db/migrate/20151120021958_add_status_to_exercise_user.rb b/db/migrate/20151120021958_add_status_to_exercise_user.rb new file mode 100644 index 000000000..ab1355d8c --- /dev/null +++ b/db/migrate/20151120021958_add_status_to_exercise_user.rb @@ -0,0 +1,5 @@ +class AddStatusToExerciseUser < ActiveRecord::Migration + def change + add_column :exercise_users, :status, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 042058c5a..14f4f5eea 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 => 20151119124148) do +ActiveRecord::Schema.define(:version => 20151120021958) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -563,6 +563,7 @@ ActiveRecord::Schema.define(:version => 20151119124148) do t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.datetime "end_at" + t.integer "status" end create_table "exercises", :force => true do |t| From acaac93da1e5fcde0d3744c5009eb911c5d4b044 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 20 Nov 2015 11:08:50 +0800 Subject: [PATCH 094/191] tijiao --- app/views/exercise/_exercise_student.html.erb | 6 +++--- app/views/exercise/_exercise_student_result.html.erb | 6 +++--- app/views/exercise/_exercise_teacher.html.erb | 7 ++++++- app/views/exercise/_show_MC.html.erb | 2 +- app/views/exercise/_show_MCQ.html.erb | 2 +- app/views/exercise/_show_single.html.erb | 2 +- public/stylesheets/courses.css | 3 ++- 7 files changed, 17 insertions(+), 11 deletions(-) diff --git a/app/views/exercise/_exercise_student.html.erb b/app/views/exercise/_exercise_student.html.erb index 0cc34958f..bc91ead85 100644 --- a/app/views/exercise/_exercise_student.html.erb +++ b/app/views/exercise/_exercise_student.html.erb @@ -18,9 +18,9 @@
                  - <% mc_question_list = exercise_questions.where("question_type=1") %> - <% mcq_question_list = exercise_questions.where("question_type=2") %> - <% single_question_list = exercise_questions.where("question_type=3") %> + <% mc_question_list = exercise.exercise_questions.where("question_type=1") %> + <% mcq_question_list = exercise.exercise_questions.where("question_type=2") %> + <% single_question_list = exercise.exercise_questions.where("question_type=3") %>
                  ">

                  单选题

                  <% mc_question_list.each do |exercise_question| %> diff --git a/app/views/exercise/_exercise_student_result.html.erb b/app/views/exercise/_exercise_student_result.html.erb index 40f9b953b..8a723d75c 100644 --- a/app/views/exercise/_exercise_student_result.html.erb +++ b/app/views/exercise/_exercise_student_result.html.erb @@ -19,9 +19,9 @@
                  得分:<%=exercise_user.score %>分
                  - <% mc_question_list = exercise_questions.where("question_type=1") %> - <% mcq_question_list = exercise_questions.where("question_type=2") %> - <% single_question_list = exercise_questions.where("question_type=3") %> + <% mc_question_list = exercise.exercise_questions.where("question_type=1") %> + <% mcq_question_list = exercise.exercise_questions.where("question_type=2") %> + <% single_question_list = exercise.exercise_questions.where("question_type=3") %>
                  ">

                  单选题

                  <% mc_question_list.each do |exercise_question| %> diff --git a/app/views/exercise/_exercise_teacher.html.erb b/app/views/exercise/_exercise_teacher.html.erb index 4ddd5054d..b803519ce 100644 --- a/app/views/exercise/_exercise_teacher.html.erb +++ b/app/views/exercise/_exercise_teacher.html.erb @@ -107,7 +107,12 @@
                  <%= link_to "确定",exercise_index_path(:course_id => @course.id),:class => "ur_button_submit" %> - <%= link_to l(:button_edit), edit_exercise_path(exercise.id), :class => "ur_button_submit", :style => "float:right"%> + <% if exercise.exercise_status == 1 %> + <%= link_to l(:button_edit), edit_exercise_path(exercise.id), :class => "ur_button_submit", :style => "float:right"%> + <% else %> + 编辑 + <%#= link_to l(:button_edit), '', :class => "ur_button_submit", :style => "float:right; background:#a3a3a3"%> + <% end %>
                  diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb index 0883995dc..183e8d190 100644 --- a/app/views/exercise/_show_MC.html.erb +++ b/app/views/exercise/_show_MC.html.erb @@ -39,7 +39,7 @@ } else{ <% score =exercise_question.question_score %> $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( - '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.id),:remote=>true) do |f|%>'+ + '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.exercise.id),:remote=>true) do |f|%>'+ '
                  '+ '
                  '+ ''+ diff --git a/app/views/exercise/_show_MCQ.html.erb b/app/views/exercise/_show_MCQ.html.erb index 52f01e6c7..af2b0facb 100644 --- a/app/views/exercise/_show_MCQ.html.erb +++ b/app/views/exercise/_show_MCQ.html.erb @@ -38,7 +38,7 @@ } else { <% score =exercise_question.question_score %> $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( - '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.id),:remote=>true) do |f|%>'+ + '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.exercise.id),:remote=>true) do |f|%>'+ '
                  '+ '
                  '+ ''+ diff --git a/app/views/exercise/_show_single.html.erb b/app/views/exercise/_show_single.html.erb index 933f2edcc..9c7936e6d 100644 --- a/app/views/exercise/_show_single.html.erb +++ b/app/views/exercise/_show_single.html.erb @@ -26,7 +26,7 @@ } else { <% score =exercise_question.question_score %> $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html( - '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.id),:remote=>true) do |f|%>'+ + '<%= form_for(ExerciseQuestion.new,:html=>{:multipart=>true},:url=>create_exercise_question_exercise_path(exercise_question.exercise.id),:remote=>true) do |f|%>'+ '
                  '+ '
                  '+ ''+ diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index e267b9010..5ff34a4e1 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -1165,4 +1165,5 @@ a:hover.testEdit{ background:url(images/icons.png) -21px -272px no-repeat;} .testEditTitle{ padding:10px 0px ; float:left; width:564px; } .questionEditContainer {border:1px solid #cbcbcb;background:#eeeeee; padding:10px; margin-bottom:10px; margin-top:10px;} .fillInput {border:1px solid #cbcbcb; padding-left:5px; background-color:#ffffff; width:693px; height:30px; color:#888888;} -.mr130 {margin-right:130px;} \ No newline at end of file +.mr130 {margin-right:130px;} +.ur_button_submit{ display:block; width:106px; height:31px; margin:0 auto; background:#15bccf; color:#fff; font-size:16px; text-align:center; padding-top:4px; margin-bottom:10px; } \ No newline at end of file From b10ff36c5172db0f6d9e3a3af21a7d06b2d2ee4a Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 20 Nov 2015 11:12:45 +0800 Subject: [PATCH 095/191] =?UTF-8?q?1.=E7=BB=84=E7=BB=87=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E5=92=8C=E6=88=90=E5=91=98=E8=AE=BF=E9=97=AE=E6=9D=83=E9=99=90?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=EF=BC=9B=202.=E4=BF=AE=E6=94=B9=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E6=96=87=E7=AB=A0=E4=B8=8D=E8=83=BD=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/org_document_comments_controller.rb | 6 +++++- app/controllers/organizations_controller.rb | 6 +++++- app/views/org_document_comments/edit.html.erb | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index 5b02a4e9b..82a25cb01 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -24,7 +24,11 @@ class OrgDocumentCommentsController < ApplicationController end def index - @documents = @organization.org_document_comments.where("parent_id is null").order("created_at desc") + if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) + @documents = @organization.org_document_comments.where("parent_id is null").order("created_at desc") + else + render_403 + end end def update @org_document = OrgDocumentComment.find(params[:id]) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 3713beb22..0d22ab461 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -151,7 +151,11 @@ class OrganizationsController < ApplicationController end def members - @members = OrgMember.where("organization_id =?", @organization.id) + if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) + @members = OrgMember.where("organization_id =?", @organization.id) + else + render_403 + end end def more_org_projects diff --git a/app/views/org_document_comments/edit.html.erb b/app/views/org_document_comments/edit.html.erb index e0224afea..4b50c1064 100644 --- a/app/views/org_document_comments/edit.html.erb +++ b/app/views/org_document_comments/edit.html.erb @@ -26,7 +26,7 @@
                  - <%= kindeditor_tag 'org_document_comment[content]',@org_document.content, :editor_id => 'org1_document_description_editor', :height => "150px" %> + <%= kindeditor_tag 'org_document_comment[content]',@org_document.content, :editor_id => 'org_document_description_editor', :height => "150px" %>
                  From 99945d5bb562a2947a929579915249cb0aa6c95b Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 20 Nov 2015 12:54:41 +0800 Subject: [PATCH 096/191] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E7=AD=94=E9=A2=98?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 2 +- app/views/exercise/_exercise_student.html.erb | 9 ++-- app/views/exercise/_exercise_submit.html.erb | 2 +- db/schema.rb | 52 +++++++++++++++++++ 4 files changed, 60 insertions(+), 5 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index c3e5d9a67..69d6ebd7d 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -353,7 +353,7 @@ class ExerciseController < ApplicationController ea.exercise_choice_id = params[:exercise_choice_id] if ea.save @percent = get_percent(@exercise,User.current) - render :json => {:text => "true",:percent => format("%.2f" ,@percent)} + render :json => {:text => "ok",:percent => format("%.2f" ,@percent)} else render :json => {:text => "failure"} end diff --git a/app/views/exercise/_exercise_student.html.erb b/app/views/exercise/_exercise_student.html.erb index bc91ead85..0b12b917e 100644 --- a/app/views/exercise/_exercise_student.html.erb +++ b/app/views/exercise/_exercise_student.html.erb @@ -4,6 +4,9 @@ $("#homework_page_right").css("min-height",$("#LSide").height()-30); $("#Container").css("width","1000px"); }); + function getTime() { + + }
                  @@ -50,7 +53,7 @@ }, success: function (data) { var dataObj = eval(data); - if(dataObj.text == "true") + if(dataObj.text == "ok") { obj.checked = true; } @@ -105,7 +108,7 @@ }, success: function (data) { var dataObj = eval(data); - if(dataObj.text == "true") + if(dataObj.text == "ok") { obj.checked = true; } @@ -117,7 +120,7 @@ }); } - <%= @can_edit_poll?"":"disabled=disabled" %> > + <%= @can_edit_excercise?"":"disabled=disabled" %> > <%= convert_to_char((index+1).to_s)%>  <%= exercise_choice.choice_text%> diff --git a/app/views/exercise/_exercise_submit.html.erb b/app/views/exercise/_exercise_submit.html.erb index a28c8917b..e9c26a0b5 100644 --- a/app/views/exercise/_exercise_submit.html.erb +++ b/app/views/exercise/_exercise_submit.html.erb @@ -7,7 +7,7 @@
                  提交
                  - +
                  diff --git a/db/schema.rb b/db/schema.rb index 14f4f5eea..ca4e1cad0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -241,6 +241,58 @@ ActiveRecord::Schema.define(:version => 20151120021958) do add_index "changesets_issues", ["changeset_id", "issue_id"], :name => "changesets_issues_ids", :unique => true + create_table "code_review_assignments", :force => true do |t| + t.integer "issue_id" + t.integer "change_id" + t.integer "attachment_id" + t.string "file_path" + t.string "rev" + t.string "rev_to" + t.string "action_type" + t.integer "changeset_id" + end + + create_table "code_review_project_settings", :force => true do |t| + t.integer "project_id" + t.integer "tracker_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "updated_by" + t.boolean "hide_code_review_tab", :default => false + t.integer "auto_relation", :default => 1 + t.integer "assignment_tracker_id" + t.text "auto_assign" + t.integer "lock_version", :default => 0, :null => false + t.boolean "tracker_in_review_dialog", :default => false + end + + create_table "code_review_user_settings", :force => true do |t| + t.integer "user_id", :default => 0, :null => false + t.integer "mail_notification", :default => 0, :null => false + t.datetime "created_at" + t.datetime "updated_at" + end + + create_table "code_reviews", :force => true do |t| + t.integer "project_id" + t.integer "change_id" + t.datetime "created_at" + t.datetime "updated_at" + t.integer "line" + t.integer "updated_by_id" + t.integer "lock_version", :default => 0, :null => false + t.integer "status_changed_from" + t.integer "status_changed_to" + t.integer "issue_id" + t.string "action_type" + t.string "file_path" + t.string "rev" + t.string "rev_to" + t.integer "attachment_id" + t.integer "file_count", :default => 0, :null => false + t.boolean "diff_all" + end + create_table "comments", :force => true do |t| t.string "commented_type", :limit => 30, :default => "", :null => false t.integer "commented_id", :default => 0, :null => false From 13af6e64b272d141729386877a15c19fe5bae4e5 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 20 Nov 2015 12:55:23 +0800 Subject: [PATCH 097/191] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=85=81=E8=AE=B8?= =?UTF-8?q?=E5=AD=A6=E7=94=9F=E6=9F=A5=E7=9C=8B=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index c3e5d9a67..77302c5db 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -419,7 +419,7 @@ class ExerciseController < ApplicationController def commit_exercise # 老师不需要提交 if User.current.allowed_to?(:as_teacher,@course) - + @exercise.update_attributes(:show_result => params[:exercise][:show_result]) redirect_to exercise_url(@exercise) # REDO: 提示提交成功 else From 302dfaf93380ef24179f3ff0fd1b8522063e5b01 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 20 Nov 2015 13:04:51 +0800 Subject: [PATCH 098/191] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E4=B8=87=E5=8D=B7?= =?UTF-8?q?=E5=88=9D=E5=A7=8Bshowresult?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 54f8309ea..3d6b4794f 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -59,7 +59,8 @@ class ExerciseController < ApplicationController :end_time => "", :publish_time => "", :exercise_description => "", - :show_result => "" + :show_result => "", + :show_result => 1 } @exercise = Exercise.create option if @exercise From 07ee81937056274fd0a1b38c68408673bce1511d Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 20 Nov 2015 13:39:40 +0800 Subject: [PATCH 099/191] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E5=A4=9A=E9=80=89?= =?UTF-8?q?=E7=AD=94=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 3d6b4794f..9efcfc19d 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -345,7 +345,7 @@ class ExerciseController < ApplicationController end elsif eq.question_type == 2 #多选题 - ea = ExerciseAnswer.find_by_exercise_question_id_and_user_id(params[:exercise_question_id],User.current.id) + ea = ExerciseAnswer.find_by_exercise_choice_id_and_user_id(params[:exercise_choice_id],User.current.id) if ea.nil? #尚未答该题,添加答案 ea = ExerciseAnswer.new @@ -360,7 +360,7 @@ class ExerciseController < ApplicationController end else #pv不为空,则当前选项之前已被选择,再次点击则是不再选择该项,故删除该答案 - if pv.delete + if ea.delete @percent = get_percent(@exercise, User.current) render :json => {:text => "false" ,:percent => format("%.2f" , @percent)} else From cb3f0d1c97844d2a7fb62053be688425be185aea Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 20 Nov 2015 14:28:47 +0800 Subject: [PATCH 100/191] =?UTF-8?q?=E6=8C=89=E7=B1=BB=E5=9E=8B=E5=88=86?= =?UTF-8?q?=E7=B1=BB=EF=BC=8C=E5=BA=8F=E5=8F=B7=E9=80=92=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 9efcfc19d..cf78cbc05 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -142,7 +142,9 @@ class ExerciseController < ApplicationController option = { :question_title => question_title, :question_type => params[:question_type] || 1, - :question_number => @exercise.exercise_questions.count + 1, + :question_number => params[:question_type] == "1"? @exercise.exercise_questions.where("question_type = 1").count + 1 : + (params[:question_type] == "2" ? (@exercise.exercise_questions.where("question_type = 2").count + 1) : + @exercise.exercise_questions.where("question_type = 3").count + 1), :question_score => params[:question_score] } @exercise_questions = @exercise.exercise_questions.new option @@ -160,7 +162,14 @@ class ExerciseController < ApplicationController # 如果是插入的话,那么从插入的这个id以后的question_num都将要+1 if params[:quest_id] @is_insert = true - @exercise.exercise_questions.where("question_number > #{params[:quest_num].to_i}").update_all(" question_number = question_number + 1") + if @exercise_questions.question_type == 1 + ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 1).update_all(" question_number = question_number + 1") + #@exercise.exercise_questions.where("question_number > #{params[:quest_num].to_i} and question_type == 1").update_all(" question_number = question_number + 1") + elsif @exercise_questions.question_type == 2 + ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 2).update_all(" question_number = question_number + 1") + else + ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 3).update_all(" question_number = question_number + 1") + end # @exercise_question_num = params[:quest_num].to_i @exercise_questions.question_number = params[:quest_num].to_i + 1 end From e3d78bf4f089114f76f6e77d5c373f104a5f37e5 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 20 Nov 2015 14:30:54 +0800 Subject: [PATCH 101/191] =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/organizations/new.html.erb | 4 +- app/views/users/user_organizations.html.erb | 2 +- ...116070906_add_created_at_to_org_members.rb | 5 --- db/schema.rb | 44 ++++++++----------- public/stylesheets/new_user.css | 1 + public/stylesheets/org.css | 2 +- public/stylesheets/public.css | 1 + 7 files changed, 25 insertions(+), 34 deletions(-) delete mode 100644 db/migrate/20151116070906_add_created_at_to_org_members.rb diff --git a/app/views/organizations/new.html.erb b/app/views/organizations/new.html.erb index 1ab3ad933..ab0a4ec50 100644 --- a/app/views/organizations/new.html.erb +++ b/app/views/organizations/new.html.erb @@ -34,8 +34,8 @@ (打钩为公开,不打钩则不公开,若不公开,仅组织成员可见该组织。)
                  -
                • - 提交 +
                • + 创建 <%= link_to "取消",user_activities_path(User.current.id),:class => "blue_btn grey_btn fl c_white"%>
                • diff --git a/app/views/users/user_organizations.html.erb b/app/views/users/user_organizations.html.erb index 8c082b225..e9d78e695 100644 --- a/app/views/users/user_organizations.html.erb +++ b/app/views/users/user_organizations.html.erb @@ -2,7 +2,7 @@ <%#= stylesheet_link_tag 'pleft','prettify','jquery/jquery-ui-1.9.2','header','new_user','repository','org' %>
                  -
                  +
                  组织列表 diff --git a/db/migrate/20151116070906_add_created_at_to_org_members.rb b/db/migrate/20151116070906_add_created_at_to_org_members.rb deleted file mode 100644 index 33d3a2817..000000000 --- a/db/migrate/20151116070906_add_created_at_to_org_members.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddCreatedAtToOrgMembers < ActiveRecord::Migration - def change - add_column :org_members, :created_at, :timestamp - end -end diff --git a/db/schema.rb b/db/schema.rb index ae220df3d..fc2bcee92 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -529,23 +529,26 @@ ActiveRecord::Schema.define(:version => 20151118031602) do add_index "documents", ["created_on"], :name => "index_documents_on_created_on" add_index "documents", ["project_id"], :name => "documents_project_id" - create_table "dts", :force => true do |t| - t.string "IPLineCode" - t.string "Description" - t.string "Num" - t.string "Variable" - t.string "TraceInfo" - t.string "Method" + create_table "dts", :primary_key => "Num", :force => true do |t| + t.string "Defect", :limit => 50 + t.string "Category", :limit => 50 t.string "File" - t.string "IPLine" - t.string "Review" - t.string "Category" - t.string "Defect" - t.string "PreConditions" - t.string "StartLine" + t.string "Method" + t.string "Module", :limit => 20 + t.string "Variable", :limit => 50 + t.integer "StartLine" + t.integer "IPLine" + t.string "IPLineCode", :limit => 200 + t.string "Judge", :limit => 15 + t.integer "Review", :limit => 1 + t.string "Description" + t.text "PreConditions", :limit => 2147483647 + t.text "TraceInfo", :limit => 2147483647 + t.text "Code", :limit => 2147483647 t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" + t.integer "id", :null => false end create_table "enabled_modules", :force => true do |t| @@ -815,16 +818,6 @@ ActiveRecord::Schema.define(:version => 20151118031602) do add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_details_copy", :force => true do |t| - t.integer "journal_id", :default => 0, :null => false - t.string "property", :limit => 30, :default => "", :null => false - t.string "prop_key", :limit => 30, :default => "", :null => false - t.text "old_value" - t.text "value" - end - - add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id" - create_table "journal_replies", :id => false, :force => true do |t| t.integer "journal_id" t.integer "user_id" @@ -1084,6 +1077,7 @@ ActiveRecord::Schema.define(:version => 20151118031602) do create_table "org_members", :force => true do |t| t.integer "user_id" t.integer "organization_id" + t.string "role" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false end diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 6ccfc47f6..d18dd27d8 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -84,6 +84,7 @@ a.linkGrey6:hover {color:#ffffff !important;} .ml90{ margin-left:90px;} .ml100{ margin-left:100px;} .ml110{ margin-left:110px;} +.ml125 { margin-left:125px;} .ml150 { margin-left:150px;} .mr-5 {margin-right:-5px;} .mr5{ margin-right:5px;} diff --git a/public/stylesheets/org.css b/public/stylesheets/org.css index c8116003e..914df16b5 100644 --- a/public/stylesheets/org.css +++ b/public/stylesheets/org.css @@ -2,7 +2,7 @@ /* CSS Document */ .orgName {width:130px; color:#484848;} -.organization_r_h02{ width:970px; height:40px; background:#eaeaea; margin-bottom:10px;} +.organization_r_h02{ width:980px; height:40px; background:#eaeaea; margin-bottom:10px;} .organization_h2{ background:#64bdd9; color:#fff; height:33px; width:90px; text-align:center; font-weight:normal; padding-top:7px; font-size:16px;} .orgSettingOp {width:45px; height:21px; color:#269ac9; text-align:center; border-bottom:3px solid #e4e4e4; float:left; font-weight:bold; cursor:pointer;} diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 49b2906aa..a1dfe3f4d 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -77,6 +77,7 @@ h4{ font-size:14px; color:#3b3b3b;} .ml90{ margin-left:90px;} .ml100{ margin-left:100px;} .ml110{ margin-left:110px;} +.ml125 { margin-left:125px;} .ml320{ margin-left:320px;} .ml150 { margin-left:150px;} .mr-5 {margin-right:-5px;} From 863d7ed4b55ab286aea776bf4a7dabc6972f2348 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 20 Nov 2015 14:34:09 +0800 Subject: [PATCH 102/191] =?UTF-8?q?=E5=8D=95=E9=80=89=E5=92=8C=E5=A1=AB?= =?UTF-8?q?=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_exercise_student.html.erb | 37 +++++++++++++------ app/views/exercise/_exercise_submit.html.erb | 8 ++-- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/app/views/exercise/_exercise_student.html.erb b/app/views/exercise/_exercise_student.html.erb index 0b12b917e..68222f8bd 100644 --- a/app/views/exercise/_exercise_student.html.erb +++ b/app/views/exercise/_exercise_student.html.erb @@ -3,9 +3,24 @@ $("#RSide").removeAttr("id"); $("#homework_page_right").css("min-height",$("#LSide").height()-30); $("#Container").css("width","1000px"); + var time = <%=exercise.time %>; + var total_seconds = time * 60; + getTime(total_seconds); }); - function getTime() { - + function getTime(total_seconds) { + var total_seconds = total_seconds - 1; + var hours = total_seconds / 60 / 60; + var hoursRound = Math.floor(hours); + var minutes = total_seconds /60 - (60 * hoursRound); + var minutesRound = Math.floor(minutes); + var seconds = total_seconds - (60 * 60 * hoursRound) - (60 * minutesRound); + var secondsRound = Math.round(seconds); + $("#rest_hours").html(hoursRound); + $("#rest_minutes").html(minutesRound); + $("#rest_seconds").html(secondsRound); + if(total_seconds >0) { + setTimeout("getTime("+total_seconds+");", 1000); + } }
                  @@ -15,7 +30,7 @@
                  开始时间:<%=format_time(exercise_user.start_at.to_s) %> 测验时长:<%=exercise.time %>分钟 - 剩余时长:1 小时 30 分钟 0 秒 + 剩余时长: 小时  分钟  秒
                  <%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%>
                  @@ -26,11 +41,11 @@ <% single_question_list = exercise.exercise_questions.where("question_type=3") %>
                  ">

                  单选题

                  - <% mc_question_list.each do |exercise_question| %> + <% mc_question_list.each_with_index do |exercise_question, list_index| %>
                  -
                  第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
                  +
                  第<%= list_index+1%>题.(<%= exercise_question.question_score %>分)
                  <%= exercise_question.question_title %>
                  @@ -65,7 +80,7 @@ }); } - <%= radio_button "poll_vote","poll_answer_id",exercise_choice.id,:class=>"ur_radio",:onclick =>"click_#{exercise_choice.id}(this);return false;",:checked => answer_be_selected?(exercise_choice,User.current),:disabled => !@can_edit_excercise %> + <%= radio_button "exercise",exercise_question.id.to_s+"exercise_choice_id",exercise_choice.id,:class=>"ur_radio",:onclick =>"click_#{exercise_choice.id}(this);return false;",:checked => answer_be_selected?(exercise_choice,User.current),:disabled => !@can_edit_excercise %> <%= convert_to_char((index+1).to_s)%>  <%= exercise_choice.choice_text%> @@ -81,11 +96,11 @@
                  ">

                  多选题

                  - <% mcq_question_list.each do |exercise_question| %> + <% mcq_question_list.each_with_index do |exercise_question,list_index| %>
                  -
                  第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
                  +
                  第<%= list_index + 1 %>题.(<%= exercise_question.question_score %>分)
                  <%= exercise_question.question_title %>
                  @@ -136,11 +151,11 @@
                  ">

                  填空题

                  - <% single_question_list.each do |exercise_question| %> + <% single_question_list.each_with_index do |exercise_question, list_index| %>
                  -
                  第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
                  +
                  第<%= list_index + 1%>题.(<%= exercise_question.question_score %>分)
                  <%= exercise_question.question_title %>
                  @@ -164,7 +179,7 @@ } - > + >
                  diff --git a/app/views/exercise/_exercise_submit.html.erb b/app/views/exercise/_exercise_submit.html.erb index e9c26a0b5..acbbea244 100644 --- a/app/views/exercise/_exercise_submit.html.erb +++ b/app/views/exercise/_exercise_submit.html.erb @@ -1,4 +1,4 @@ -<%= form_for("", +<%= form_for(exercise, :html => { :multipart => true }, :url => {:controller => 'exercise', :action => 'commit_exercise', @@ -7,8 +7,10 @@
                  提交
                  - - + <%= f.check_box :show_result, :value => exercise.show_result%> + <%= label_tag 'exercise_show_result', '允许学生查看测验结果' %> +
                  <% end %> From dcbdea9bb50927342583da661134bf2c3fb01468 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 20 Nov 2015 14:50:48 +0800 Subject: [PATCH 103/191] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8D=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E8=AF=A6=E7=BB=86=E5=88=97=E8=A1=A8=E5=88=A0=E9=99=A4=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E9=A1=B5=E9=9D=A2=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=9B=202.=E6=96=87=E7=AB=A0=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E4=B8=AD=EF=BC=8C=E6=96=87=E7=AB=A0=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E6=98=BE=E7=A4=BA=E4=B8=AD=E5=9B=9E=E5=A4=8D=E4=BA=BA?= =?UTF-8?q?=E4=B8=A2=E5=A4=B1=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/org_document_comments_controller.rb | 3 +++ app/views/org_document_comments/destroy.js.erb | 3 ++- app/views/org_document_comments/show.html.erb | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index 82a25cb01..fb40032d4 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -75,6 +75,9 @@ class OrgDocumentCommentsController < ApplicationController org.home_id == nil end end + respond_to do |format| + format.js + end end def delete_reply diff --git a/app/views/org_document_comments/destroy.js.erb b/app/views/org_document_comments/destroy.js.erb index bcebe9d37..adbeff4a6 100644 --- a/app/views/org_document_comments/destroy.js.erb +++ b/app/views/org_document_comments/destroy.js.erb @@ -1 +1,2 @@ -location.reload(); \ No newline at end of file +//location.reload(); +window.location.href = '<%= organization_org_document_comments_path(:organization_id => @org_document_comment.root.organization_id)%>' \ No newline at end of file diff --git a/app/views/org_document_comments/show.html.erb b/app/views/org_document_comments/show.html.erb index ae90b15bb..9df568e02 100644 --- a/app/views/org_document_comments/show.html.erb +++ b/app/views/org_document_comments/show.html.erb @@ -79,6 +79,7 @@ <%= link_to image_tag(url_to_avatar(user), :width => 33,:height => 33), user_path(user) %>
                  + <%= link_to User.find(reply.creator_id).realname, user_path(reply.creator_id), :class => "newsBlue mr10 f14" %>
                  <%= reply.content.html_safe unless reply.content.nil? %>
                  From b0730dfb818ec5a441912839ca966d543998a271 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 20 Nov 2015 15:12:07 +0800 Subject: [PATCH 104/191] =?UTF-8?q?=E6=B5=8B=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_exercise_student.html.erb | 25 +++++++++++-------- .../_exercise_student_result.html.erb | 15 +++++------ app/views/exercise/_exercise_teacher.html.erb | 18 ++++++------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/app/views/exercise/_exercise_student.html.erb b/app/views/exercise/_exercise_student.html.erb index 68222f8bd..af9896b01 100644 --- a/app/views/exercise/_exercise_student.html.erb +++ b/app/views/exercise/_exercise_student.html.erb @@ -8,6 +8,11 @@ getTime(total_seconds); }); function getTime(total_seconds) { + start_time = new Date($("#start_time").html()); + end_time = start_time + 60*60*<%=exercise.time %>; + now = new Date(); + //start = new Date(start_time); + //end_time = start_time; var total_seconds = total_seconds - 1; var hours = total_seconds / 60 / 60; var hoursRound = Math.floor(hours); @@ -27,8 +32,9 @@

                  <%= exercise.exercise_name%>

                  +
                  - 开始时间:<%=format_time(exercise_user.start_at.to_s) %> + 开始时间:<%=format_time(exercise_user.start_at.to_s)%> 测验时长:<%=exercise.time %>分钟 剩余时长: 小时  分钟  秒
                  @@ -36,17 +42,16 @@
                  - <% mc_question_list = exercise.exercise_questions.where("question_type=1") %> - <% mcq_question_list = exercise.exercise_questions.where("question_type=2") %> - <% single_question_list = exercise.exercise_questions.where("question_type=3") %> + <% mc_question_list = exercise.exercise_questions.where("question_type=1").shuffle %> + <% mcq_question_list = exercise.exercise_questions.where("question_type=2").shuffle %> + <% single_question_list = exercise.exercise_questions.where("question_type=3").shuffle %>
                  ">

                  单选题

                  <% mc_question_list.each_with_index do |exercise_question, list_index| %>
                  -
                  第<%= list_index+1%>题.(<%= exercise_question.question_score %>分)
                  - <%= exercise_question.question_title %> +
                  第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分)
                  @@ -100,8 +105,7 @@
                  -
                  第<%= list_index + 1 %>题.(<%= exercise_question.question_score %>分)
                  - <%= exercise_question.question_title %> +
                  第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分)
                  @@ -155,8 +159,7 @@
                  -
                  第<%= list_index + 1%>题.(<%= exercise_question.question_score %>分)
                  - <%= exercise_question.question_title %> +
                  第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分)
                  @@ -173,7 +176,7 @@ }, success: function (data) { var dataObj = eval(data); -// obj.value = dataObj.text; + obj.value = dataObj.text; } }); diff --git a/app/views/exercise/_exercise_student_result.html.erb b/app/views/exercise/_exercise_student_result.html.erb index 8a723d75c..9ce136667 100644 --- a/app/views/exercise/_exercise_student_result.html.erb +++ b/app/views/exercise/_exercise_student_result.html.erb @@ -24,12 +24,11 @@ <% single_question_list = exercise.exercise_questions.where("question_type=3") %>
                  ">

                  单选题

                  - <% mc_question_list.each do |exercise_question| %> + <% mc_question_list.each_with_index do |exercise_question, list_index| %>
                  -
                  第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
                  - <%= exercise_question.question_title %> +
                  第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) <% if exercise_question.exercise_standard_answers.first.exercise_choice_id == exercise_question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{User.current.id}.first.exercise_choice_id ") %> √ @@ -62,12 +61,11 @@
                  ">

                  多选题

                  - <% mcq_question_list.each do |exercise_question| %> + <% mcq_question_list.each_wtih_index do |exercise_question, list_index| %>
                  -
                  第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
                  - <%= exercise_question.question_title %> +
                  第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) <% if exercise_question.exercise_standard_answers.first.exercise_choice_id == exercise_question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{User.current.id}.first.exercise_choice_id ") %> √ @@ -100,12 +98,11 @@
                  ">

                  填空题

                  - <% single_question_list.each do |exercise_question| %> + <% single_question_list.each_with_index do |exercise_question,list_index| %>
                  -
                  第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
                  - <%= exercise_question.question_title %> +
                  第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) <% if exercise_question.exercise_standard_answers.first.exercise_choice_id == exercise_question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{User.current.id}.first.exercise_choice_id ") %> √ diff --git a/app/views/exercise/_exercise_teacher.html.erb b/app/views/exercise/_exercise_teacher.html.erb index b803519ce..606b14aae 100644 --- a/app/views/exercise/_exercise_teacher.html.erb +++ b/app/views/exercise/_exercise_teacher.html.erb @@ -22,12 +22,12 @@ <% single_question_list = exercise.exercise_questions.where("question_type=3") %>
                  ">

                  单选题

                  - <% mc_question_list.each do |exercise_question| %> + <% mc_question_list.each_with_index do |exercise_question, list_index| %>
                  -
                  第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
                  - <%= exercise_question.question_title %>
                  +
                  第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) +
                  标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>
                  @@ -54,12 +54,12 @@
                  ">

                  多选题

                  - <% mcq_question_list.each do |exercise_question| %> + <% mcq_question_list.each_with_index do |exercise_question, index| %>
                  -
                  第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
                  - <%= exercise_question.question_title %>
                  +
                  第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) +
                  标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>
                  @@ -86,12 +86,12 @@
                  ">

                  填空题

                  - <% single_question_list.each do |exercise_question| %> + <% single_question_list.each_with_index do |exercise_question, list_index| %>
                  -
                  第<%= exercise_question.question_number%>题.(<%= exercise_question.question_score %>分)
                  - <%= exercise_question.question_title %>
                  +
                  第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) +
                  标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>
                  From db46e5e4afb172cd5499f1bbc3bdcfe3628b71a5 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 20 Nov 2015 15:13:53 +0800 Subject: [PATCH 105/191] =?UTF-8?q?=E9=97=AE=E5=8D=B7=E5=BE=97=E5=88=86?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 11 +++++++++-- app/helpers/exercise_helper.rb | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index cf78cbc05..04189af6a 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -467,7 +467,7 @@ class ExerciseController < ApplicationController standard_answer = get_user_standard_answer(question, user) # 问答题有多个答案 if question.question_type == 3 - if standard_answer.exercise_choice_id.include?(answer.exercise_choice_id) + if standard_answer.include?(answer.exercise_choice_id) score += question.question_score unless question.question_score.empty? end else @@ -510,7 +510,14 @@ class ExerciseController < ApplicationController # 获取问题的标准答案 def get_user_standard_answer(question,user) - standard_answer = question.exercise_standard_answers + if question.question_type == 3 + standard_answer =[] + question.exercise_standard_answers.each do |answer| + standard_answer << answer.answer_text + end + else + standard_answer = question.exercise_standard_answers + end standard_answer end diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index ec7421533..d67f4443f 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -28,6 +28,7 @@ module ExerciseHelper answer.join("") end + # def fill_standart_answer(params, standart_answer) params.each do |param| standart_answer.answer_text = param.value From 5cfc8c2f8dc00864648a5340dbc319c07f8d111d Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 20 Nov 2015 16:16:46 +0800 Subject: [PATCH 106/191] =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E6=88=96=E8=80=85=E5=9B=9E=E5=A4=8D=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E5=90=8E=EF=BC=8C=E6=9B=B4=E6=96=B0=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E7=9A=84=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/org_document_comments_controller.rb | 4 ++++ app/models/org_document_comment.rb | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index fb40032d4..61a27c433 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -33,6 +33,10 @@ class OrgDocumentCommentsController < ApplicationController def update @org_document = OrgDocumentComment.find(params[:id]) @org_document.update_attributes(:title => params[:org_document_comment][:title], :content => params[:org_document_comment][:content]) + if @org_document.parent.nil? + act = OrgActivity.where("org_act_type='OrgDocumentComment' and org_act_id =?", @org_document.id).first + act.update_attributes(:updated_at => @org_document.updated_at) + end respond_to do |format| format.html {redirect_to organization_org_document_comments_path(:organization_id => @org_document.organization.id)} end diff --git a/app/models/org_document_comment.rb b/app/models/org_document_comment.rb index 2b3c9132a..7b9f9cd75 100644 --- a/app/models/org_document_comment.rb +++ b/app/models/org_document_comment.rb @@ -11,6 +11,10 @@ class OrgDocumentComment < ActiveRecord::Base def document_save_as_org_activity if(self.parent().nil?) self.org_acts << OrgActivity.new(:user_id => User.current.id, :container_id => self.organization.id, :container_type => 'Organization') + else + act = OrgActivity.where("org_act_type='OrgDocumentComment' and org_act_id =?", self.root.id).first + act.update_attributes(:updated_at => self.updated_at) end end + end From a57260aae641e329d17e906679ba237a6d3ea3bb Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 20 Nov 2015 16:41:15 +0800 Subject: [PATCH 107/191] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BD=93=E2=80=9CMes?= =?UTF-8?q?sage=E2=80=9D=E5=9B=9E=E5=A4=8D=E5=AF=B9=E5=BA=94=E7=9A=84?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/forge_activity.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/models/forge_activity.rb b/app/models/forge_activity.rb index 8a94f1019..5005f9eab 100644 --- a/app/models/forge_activity.rb +++ b/app/models/forge_activity.rb @@ -46,17 +46,28 @@ class ForgeActivity < ActiveRecord::Base end def add_org_activity - OrgActivity.create(:user_id => self.user_id, + if self.forge_act_type == 'Message' && !self.forge_act.parent_id.nil? + org_activity = OrgActivity.where("org_act_type = 'Message' and org_act_id = #{self.forge_act.parent.id}").first + org_activity.created_at = self.created_at + org_activity.save + else + OrgActivity.create(:user_id => self.user_id, :org_act_id => self.forge_act_id, :org_act_type => self.forge_act_type, :container_id => self.project_id, :container_type => 'Project', :created_at => self.created_at, :updated_at => self.updated_at) + end end def destroy_user_activity user_activity = UserActivity.where("act_type = '#{self.forge_act_type.to_s}' and act_id = '#{self.forge_act_id}'") user_activity.destroy_all end + + def destroy_org_activity + org_acts = OrgActivity.where("org_act_type='#{self.forge_act_type.to_s}' and act_id = '#{self.forge_act_id}'") + org_acts.destroy_all + end end From ed86e3ee5a6a8e3b1002eed90a7865bcf5b23d11 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 20 Nov 2015 17:18:57 +0800 Subject: [PATCH 108/191] =?UTF-8?q?=E4=B8=89=E7=A7=8D=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E9=A2=98=E7=9B=AE=E8=AE=A1=E7=AE=97=E6=80=BB=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 40 ++++++++++++++----- app/views/exercise/_exercise_teacher.html.erb | 2 +- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 04189af6a..2c70757fa 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -437,6 +437,7 @@ class ExerciseController < ApplicationController @uncomplete_question = get_uncomplete_question(@exercise, User.current) # 获取改学生的考试得分 @score = calculate_student_score(@exercise, User.current) + # @score = 100 if @uncomplete_question.count < 1 # 查看是否有已提交记录 eu = get_exercise_user(@exercise.id, User.current.id) @@ -461,22 +462,38 @@ class ExerciseController < ApplicationController # 计算学生得分 def calculate_student_score(exercise, user) score = 0 + score1 = 0 + score2 = 0 + score3 = 0 exercise_qustions = exercise.exercise_questions exercise_qustions.each do |question| answer = get_user_answer(question, user) standard_answer = get_user_standard_answer(question, user) - # 问答题有多个答案 - if question.question_type == 3 - if standard_answer.include?(answer.exercise_choice_id) - score += question.question_score unless question.question_score.empty? - end - else - if answer.exercise_choice_id == standard_answer.exercise_choice_id - score += question.question_score unless question.question_score.empty? + unless answer.nil? + # 问答题有多个答案 + if question.question_type == 3 + if standard_answer.include?(answer.first.answer_text) + score1 = score+ question.question_score unless question.question_score.nil? + end + elsif question.question_type == 1 + if answer.first.exercise_choice.choice_position == standard_answer.exercise_choice_id + score2 = score + question.question_score unless question.question_score.nil? + end + else + ecs = ExerciseAnswer.where("user_id =? and exercise_question_id =?", user.id, question.id) + arr = [] + ecs.each do |ec| + arr << ec.exercise_choice.choice_position + end + arr.sort + arr = arr.join("") + if arr.to_i == standard_answer.exercise_choice_id + score3 = score + question.question_score unless question.question_score.nil? + end end end end - score + score = score1 + score2 + score3 end private @@ -495,7 +512,7 @@ class ExerciseController < ApplicationController uncomplete_question = [] all_questions.each do |question| answers = get_user_answer(question, user) - if answers.nil? || answers.count < 1 + if answers.nil? uncomplete_question << question end end @@ -504,6 +521,7 @@ class ExerciseController < ApplicationController # 获取当前学生回答问题的答案 def get_user_answer(question,user) + # user_answer = ExerciseAnswer.where("user_id=? and exercise_question_id=?", user.id, question.id).first user_answer = question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{user.id}") user_answer end @@ -516,7 +534,7 @@ class ExerciseController < ApplicationController standard_answer << answer.answer_text end else - standard_answer = question.exercise_standard_answers + standard_answer = question.exercise_standard_answers.first end standard_answer end diff --git a/app/views/exercise/_exercise_teacher.html.erb b/app/views/exercise/_exercise_teacher.html.erb index 606b14aae..a3f6380cf 100644 --- a/app/views/exercise/_exercise_teacher.html.erb +++ b/app/views/exercise/_exercise_teacher.html.erb @@ -54,7 +54,7 @@
                  ">

                  多选题

                  - <% mcq_question_list.each_with_index do |exercise_question, index| %> + <% mcq_question_list.each_with_index do |exercise_question, list_index| %>
                  From eee63b2495766cb7699717878025c5a8c7eba279 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 20 Nov 2015 17:25:03 +0800 Subject: [PATCH 109/191] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=89=8D=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E6=95=B0=E6=8D=AE=E4=B8=8D=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 18 ------------ app/helpers/exercise_helper.rb | 19 ++++++++++++ app/views/exercise/_exercise_form.html.erb | 19 +++++++----- app/views/exercise/_exercise_student.html.erb | 29 ++++++++++++------- .../_exercise_student_result.html.erb | 12 ++++++-- app/views/exercise/_exercise_teacher.html.erb | 2 +- app/views/exercise/_new_MC.html.erb | 4 +-- app/views/exercise/_new_MCQ.html.erb | 4 +-- app/views/exercise/_new_single.html.erb | 2 +- app/views/exercise/_show_MC.html.erb | 10 +++---- app/views/exercise/_show_MCQ.html.erb | 10 +++---- app/views/exercise/_show_single.html.erb | 8 ++--- 12 files changed, 78 insertions(+), 59 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 04189af6a..8ef6e8d72 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -502,24 +502,6 @@ class ExerciseController < ApplicationController uncomplete_question end - # 获取当前学生回答问题的答案 - def get_user_answer(question,user) - user_answer = question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{user.id}") - user_answer - end - - # 获取问题的标准答案 - def get_user_standard_answer(question,user) - if question.question_type == 3 - standard_answer =[] - question.exercise_standard_answers.each do |answer| - standard_answer << answer.answer_text - end - else - standard_answer = question.exercise_standard_answers - end - standard_answer - end # 是否完成了答题 def get_complete_question(exercise,user) diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index d67f4443f..21c0144b9 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -106,4 +106,23 @@ module ExerciseHelper end end + # 获取当前学生回答问题的答案 + def get_user_answer(question,user) + user_answer = question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{user.id}") + user_answer + end + + # 获取问题的标准答案 + def get_user_standard_answer(question,user) + if question.question_type == 3 + standard_answer =[] + question.exercise_standard_answers.each do |answer| + standard_answer << answer.answer_text + end + else + standard_answer = question.exercise_standard_answers + end + standard_answer + end + end \ No newline at end of file diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index 6e0953e74..69f55f3d7 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -82,19 +82,22 @@ //添加标题时确定按钮 function add_poll_question(doc,quest_type,quest_id) { - if(arguments[1] && arguments[2]){ - var title = $.trim($("#poll_questions_title_"+quest_type+"_"+quest_id)); - if(title.length == 0){alert("题目标题不能为空");}else{doc.parent().parent().parent().submit();} - } else { - var title = $.trim($("#poll_questions_title").val()); - if(title.length == 0){alert("题目标题不能为空");}else{doc.parent().parent().parent().submit();} - } + var title = $.trim($("#poll_questions_title").val()); + var score = $.trim($("#questions_score").val()); + if(title.length == 0 || score.length == 0){ + alert("题目标题/分数+不能为空"); + }else{ + doc.parent().parent().parent().submit();} } //修改标题时确定按钮 function edit_poll_question(doc,id) { var title = $.trim($("#poll_questions_title_" + id).val()); - if(title.length == 0){alert("题目标题不能为空");}else{doc.parent().parent().parent().submit();} + var score = $.trim($("#poll_question_score_"+ id).val()); + if(title.length == 0 || score.length == 0){ + alert("题目标题不能为空"); + }else{ + doc.parent().parent().parent().submit();} } //问卷头 diff --git a/app/views/exercise/_exercise_student.html.erb b/app/views/exercise/_exercise_student.html.erb index af9896b01..0f51dfeb7 100644 --- a/app/views/exercise/_exercise_student.html.erb +++ b/app/views/exercise/_exercise_student.html.erb @@ -3,17 +3,24 @@ $("#RSide").removeAttr("id"); $("#homework_page_right").css("min-height",$("#LSide").height()-30); $("#Container").css("width","1000px"); - var time = <%=exercise.time %>; - var total_seconds = time * 60; - getTime(total_seconds); + /*start_time = new Date(); + start_time.setFullYear(<%#=exercise_user.start_at.year%>); + start_time.setMonth(<%#=exercise_user.start_at.month%>); + start_time.setDate(<%#=exercise_user.start_at.day%>); + start_time.setHours(<%#=exercise_user.start_at.hour%>); + start_time.setMinutes(<%#=exercise_user.start_at.min%>); + start_time.setSeconds(<%#=exercise_user.start_at.sec%>); + //alert(start_time); + end_time = start_time.getTime() + 1000*60*<%#=exercise.time %>; + getTime(end_time);*/ }); - function getTime(total_seconds) { - start_time = new Date($("#start_time").html()); - end_time = start_time + 60*60*<%=exercise.time %>; + function getTime(end_time) { + //alert(end_time); now = new Date(); + var total_seconds = (now.getTime() - end_time)/1000; //start = new Date(start_time); //end_time = start_time; - var total_seconds = total_seconds - 1; + //var total_seconds = total_seconds - 1; var hours = total_seconds / 60 / 60; var hoursRound = Math.floor(hours); var minutes = total_seconds /60 - (60 * hoursRound); @@ -23,9 +30,9 @@ $("#rest_hours").html(hoursRound); $("#rest_minutes").html(minutesRound); $("#rest_seconds").html(secondsRound); - if(total_seconds >0) { - setTimeout("getTime("+total_seconds+");", 1000); - } + //if(total_seconds >0) { + setTimeout("getTime("+end_time+");", 1000); + //} }
                  @@ -36,7 +43,9 @@
                  开始时间:<%=format_time(exercise_user.start_at.to_s)%> 测验时长:<%=exercise.time %>分钟 +
                  <%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%>
                  diff --git a/app/views/exercise/_exercise_student_result.html.erb b/app/views/exercise/_exercise_student_result.html.erb index 9ce136667..c6b9a251c 100644 --- a/app/views/exercise/_exercise_student_result.html.erb +++ b/app/views/exercise/_exercise_student_result.html.erb @@ -30,7 +30,9 @@
                  第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) - <% if exercise_question.exercise_standard_answers.first.exercise_choice_id == exercise_question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{User.current.id}.first.exercise_choice_id ") %> + <% answer = get_user_answer(exercise_question, User.current)%> + <% standard_answer = get_user_standard_answer(exercise_question, User.current)%> + <% if answer.exercise_choice_id == standard_answer.exercise_choice_id %> √ <% else %> × @@ -67,7 +69,9 @@
                  第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) - <% if exercise_question.exercise_standard_answers.first.exercise_choice_id == exercise_question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{User.current.id}.first.exercise_choice_id ") %> + <% answer = get_user_answer(exercise_question, User.current)%> + <% standard_answer = get_user_standard_answer(exercise_question, User.current)%> + <% if answer.exercise_choice_id == standard_answer.exercise_choice_id %> √ <% else %> × @@ -104,7 +108,9 @@
                  第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分) - <% if exercise_question.exercise_standard_answers.first.exercise_choice_id == exercise_question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{User.current.id}.first.exercise_choice_id ") %> + <% answer = get_user_answer(exercise_question, User.current)%> + <% standard_answer = get_user_standard_answer(exercise_question, User.current)%> + <% if standard_answer.include?(answer.exercise_choice_id) %> √ <% else %> × diff --git a/app/views/exercise/_exercise_teacher.html.erb b/app/views/exercise/_exercise_teacher.html.erb index 606b14aae..a3f6380cf 100644 --- a/app/views/exercise/_exercise_teacher.html.erb +++ b/app/views/exercise/_exercise_teacher.html.erb @@ -54,7 +54,7 @@
                  ">

                  多选题

                  - <% mcq_question_list.each_with_index do |exercise_question, index| %> + <% mcq_question_list.each_with_index do |exercise_question, list_index| %>
                  diff --git a/app/views/exercise/_new_MC.html.erb b/app/views/exercise/_new_MC.html.erb index 5d5170562..b749c4374 100644 --- a/app/views/exercise/_new_MC.html.erb +++ b/app/views/exercise/_new_MC.html.erb @@ -13,7 +13,7 @@
                • <% score = exercise.exercise_questions.where("question_type=1").last.nil? ? "": exercise.exercise_questions.where("question_type=1").last.question_score %> - 分 +
                • @@ -46,7 +46,7 @@
                • - +
                diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb index 96b1476ad..a7029d3ea 100644 --- a/app/views/exercise/_new_MCQ.html.erb +++ b/app/views/exercise/_new_MCQ.html.erb @@ -13,7 +13,7 @@
              • <% score = exercise.exercise_questions.where("question_type=2").last.nil? ? "": exercise.exercise_questions.where("question_type=2").last.question_score %> - 分 +
              • @@ -46,7 +46,7 @@
              • - +
              diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb index c97483bce..1ee79e198 100644 --- a/app/views/exercise/_new_single.html.erb +++ b/app/views/exercise/_new_single.html.erb @@ -13,7 +13,7 @@
            • <% score = exercise.exercise_questions.where("question_type=3").last.nil? ? "": exercise.exercise_questions.where("question_type=3").last.question_score %> - 分 +
            • diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb index 183e8d190..b932eac1e 100644 --- a/app/views/exercise/_show_MC.html.erb +++ b/app/views/exercise/_show_MC.html.erb @@ -46,13 +46,13 @@ ''+ ''+ ''+ - ''+ + ''+ ''+ '
              '+ '
                '+ '
              • '+ ''+ - '分'+ + '分'+ '
              • '+ '
              • '+ ''+ @@ -84,13 +84,13 @@ '
                '+ '
              • '+ ''+ - ''+ + ''+ '
              • '+ '
                '+ '
              '+ '
              '+ ''+ '<% end%>' ); - $("#poll_questions_title_"+quest_type+"_"+quest_id).focus(); + $("#poll_questions_title").focus(); } } else { diff --git a/app/views/exercise/_show_MCQ.html.erb b/app/views/exercise/_show_MCQ.html.erb index af2b0facb..2a91afab5 100644 --- a/app/views/exercise/_show_MCQ.html.erb +++ b/app/views/exercise/_show_MCQ.html.erb @@ -45,13 +45,13 @@ ''+ ''+ ''+ - ''+ + ''+ ''+ '
              '+ '
                '+ '
              • '+ ''+ - '分'+ + '分'+ '
              • '+ '
              • '+ ''+ @@ -83,13 +83,13 @@ '
                '+ '
              • '+ ''+ - ''+ + ''+ '
              • '+ '
                '+ '
              '+ '
              '+ '
              '+ '<% end%>' ); - $("#poll_questions_title_"+quest_type+"_"+quest_id).focus(); + $("#poll_questions_title").focus(); } }else { $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(""); diff --git a/app/views/exercise/_show_single.html.erb b/app/views/exercise/_show_single.html.erb index 9c7936e6d..5f36a931e 100644 --- a/app/views/exercise/_show_single.html.erb +++ b/app/views/exercise/_show_single.html.erb @@ -33,13 +33,13 @@ ''+ ''+ ''+ - ''+ + ''+ ''+ '
              '+ '
                '+ '
              • '+ ''+ - '分'+ + '分'+ '
              • '+ '
              • '+ ''+ @@ -65,7 +65,7 @@ '
              '+ '
              '+ '
              '+ '<% end%>' ); - $("#poll_questions_title_"+quest_type+"_"+quest_id).focus(); + $("#poll_questions_title").focus(); } } else { $("#insert_new_poll_question_"+quest_type+"_"+quest_id).html(""); From 87285578130fe52a93d0f7c85640f4a609ab44e5 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 20 Nov 2015 17:29:15 +0800 Subject: [PATCH 110/191] =?UTF-8?q?=E8=80=81=E5=B8=88=E5=92=8C=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E7=BB=9F=E8=AE=A1=E6=95=B0=E7=9B=AE=E5=8C=BA=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_courses.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index ac8727e21..9c119f37a 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -159,7 +159,7 @@ From 6068867670c33f9868001537c252cb58baa530d4 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 20 Nov 2015 17:42:43 +0800 Subject: [PATCH 111/191] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E5=92=8C=E7=BB=84=E7=BB=87=E5=8A=A8=E6=80=81=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E5=88=A0=E9=99=A4=E7=9B=B8=E5=BA=94=E7=9A=84?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course_activity.rb | 7 ++++++- app/models/forge_activity.rb | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/models/course_activity.rb b/app/models/course_activity.rb index cd3234196..e1f9ab9f5 100644 --- a/app/models/course_activity.rb +++ b/app/models/course_activity.rb @@ -6,7 +6,7 @@ class CourseActivity < ActiveRecord::Base belongs_to :user has_many :user_acts, :class_name => 'UserAcivity',:as =>:act after_save :add_user_activity, :add_course_activity - before_destroy :destroy_user_activity + before_destroy :destroy_user_activity, :destroy_org_activity #在个人动态里面增加当前动态 def add_user_activity @@ -55,4 +55,9 @@ class CourseActivity < ActiveRecord::Base user_activity = UserActivity.where("act_type = '#{self.course_act_type.to_s}' and act_id = '#{self.course_act_id}'") user_activity.destroy_all end + + def destroy_org_activity + org_activity = OrgActivity.where("org_act_type = '#{self.course_act_type.to_s}' and org_act_id = '#{self.course_act_id}'") + org_activity.destroy_all + end end diff --git a/app/models/forge_activity.rb b/app/models/forge_activity.rb index 5005f9eab..bb5f30442 100644 --- a/app/models/forge_activity.rb +++ b/app/models/forge_activity.rb @@ -21,7 +21,7 @@ class ForgeActivity < ActiveRecord::Base validates :forge_act_type, presence: true has_many :user_acts, :class_name => 'UserAcivity',:as =>:act after_save :add_user_activity, :add_org_activity - before_destroy :destroy_user_activity + before_destroy :destroy_user_activity, :destroy_org_activity #在个人动态里面增加当前动态 def add_user_activity @@ -67,7 +67,7 @@ class ForgeActivity < ActiveRecord::Base end def destroy_org_activity - org_acts = OrgActivity.where("org_act_type='#{self.forge_act_type.to_s}' and act_id = '#{self.forge_act_id}'") + org_acts = OrgActivity.where("org_act_type='#{self.forge_act_type.to_s}' and org_act_id = '#{self.forge_act_id}'") org_acts.destroy_all end end From 332ace0f34c85e5d0a833da755e7b58c254d10ac Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 20 Nov 2015 18:00:11 +0800 Subject: [PATCH 112/191] =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 1 + app/views/exercise/_exercise.html.erb | 24 ++++++++++------------ app/views/exercise/_exercise_form.html.erb | 4 ++-- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index e23560efe..1a8faff55 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -112,6 +112,7 @@ class ExerciseController < ApplicationController end def destroy + @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? if @exercise && @exercise.destroy if @is_teacher exercises = Exercise.where("course_id =?", @course.id) diff --git a/app/views/exercise/_exercise.html.erb b/app/views/exercise/_exercise.html.erb index e44cd69c6..78ca97887 100644 --- a/app/views/exercise/_exercise.html.erb +++ b/app/views/exercise/_exercise.html.erb @@ -20,10 +20,8 @@ <% if exercise.exercise_status == 1 %>
            • 发布试卷
            • - <% elsif exercise.exercise_status == 2%> + <% else %>
            • 取消发布
            • - <% else%> -
            • 发布试卷
            • <% end%> <%= link_to(l(:button_delete), exercise,:method => :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml5 mr10") %> @@ -34,17 +32,17 @@
            • 编辑
            • <% end%> - <% if exercise.exercise_status == 2 %> -
            • 关闭
            • - <% else %> -
            • 关闭
            • - <% end%> + <%# if exercise.exercise_status == 2 %> + + <%# else %> + + <%# end%> - <% if exercise.exercise_status == 1%> -
            • 导出
            • - <% elsif exercise.exercise_status == 2 || exercise.exercise_status == 3 %> -
            • <%= link_to "导出", export_exercise_exercise_path(exercise.id,:format => "xls"), :class => "polls_de fr ml5"%>
            • - <% end%> + <%# if exercise.exercise_status == 1%> + + <%# elsif exercise.exercise_status == 2 || exercise.exercise_status == 3 %> + + <%# end%>
            • <%= format_date exercise.created_at.to_date%>
            • diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index 69f55f3d7..22589097a 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -83,9 +83,9 @@ function add_poll_question(doc,quest_type,quest_id) { var title = $.trim($("#poll_questions_title").val()); - var score = $.trim($("#questions_score").val()); + var score = $.trim($("#question_score").val()); if(title.length == 0 || score.length == 0){ - alert("题目标题/分数+不能为空"); + alert("题目标题/分数不能为空"); }else{ doc.parent().parent().parent().submit();} } From 97485ca2216a9a95de22995e88da23c396e7fec0 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 20 Nov 2015 18:01:50 +0800 Subject: [PATCH 113/191] =?UTF-8?q?=E4=BF=AE=E6=94=B9show=E9=80=BB?= =?UTF-8?q?=E8=BE=91=20=E6=8F=90=E4=BA=A4=E9=97=AE=E5=8D=B7=E5=90=8E?= =?UTF-8?q?=E5=AD=A6=E7=94=9F=E9=A1=B5=E9=9D=A2=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 47 +++++++++++++------ .../_exercise_student_result.html.erb | 13 +++-- 2 files changed, 39 insertions(+), 21 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index e23560efe..3164235d5 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -27,19 +27,21 @@ class ExerciseController < ApplicationController render_403 return end - + @can_edit_excercise = (!has_commit_exercise?(@exercise.id,User.current.id)) || User.current.admin? + @exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first # 学生点击的时候即创建关联,自动保存 #eu = ExerciseUser.create(:user_id => User.current, :exercise_id => @exercise.id, :start_at => Time.now, :status => false) # 已提交问卷的用户不能再访问该界面 if has_commit_exercise?(@exercise.id, User.current.id) && (!User.current.admin?) - redirect_to exercise_index_url(:course_id=> @course.id) + respond_to do |format| + format.html {render :layout => 'base_courses'} + end else if !@is_teacher && !has_click_exercise?(@exercise.id, User.current.id) eu = ExerciseUser.create(:user_id => User.current.id, :exercise_id => @exercise.id, :start_at => Time.now, :status => false) end - @can_edit_excercise = (!has_commit_exercise?(@exercise.id,User.current.id)) || User.current.admin? - @exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first + # @percent = get_percent(@exercise,User.current) exercise_questions = @exercise.exercise_questions @exercise_questions = paginateHelper exercise_questions,5 #分页 @@ -433,6 +435,8 @@ class ExerciseController < ApplicationController redirect_to exercise_url(@exercise) # REDO: 提示提交成功 else + # 更新提交状态 + @exercise.exercise_users.first.update_attributes(:status => true) # 答题过程中需要统计完成量 @uncomplete_question = get_uncomplete_question(@exercise, User.current) # 获取改学生的考试得分 @@ -480,16 +484,17 @@ class ExerciseController < ApplicationController score2 = score + question.question_score unless question.question_score.nil? end else - ecs = ExerciseAnswer.where("user_id =? and exercise_question_id =?", user.id, question.id) - arr = [] - ecs.each do |ec| - arr << ec.exercise_choice.choice_position - end - arr.sort - arr = arr.join("") - if arr.to_i == standard_answer.exercise_choice_id - score3 = score + question.question_score unless question.question_score.nil? - end + get_mulscore(question, user, standard_answer) + # ecs = ExerciseAnswer.where("user_id =? and exercise_question_id =?", user.id, question.id) + # arr = [] + # ecs.each do |ec| + # arr << ec.exercise_choice.choice_position + # end + # arr.sort + # arr = arr.join("") + # if arr.to_i == standard_answer.exercise_choice_id + # score3 = score + question.question_score unless question.question_score.nil? + # end end end end @@ -497,6 +502,20 @@ class ExerciseController < ApplicationController end private + # 获取多选的得分 + def get_mulscore(question, user, standard_answer) + ecs = ExerciseAnswer.where("user_id =? and exercise_question_id =?", user.id, question.id) + arr = [] + ecs.each do |ec| + arr << ec.exercise_choice.choice_position + end + arr.sort + arr = arr.join("") + if arr.to_i == standard_answer.exercise_choice_id + score3 = score + question.question_score unless question.question_score.nil? + end + end + # ExerciseUser记录用户是否已提交问卷有对应的记录则已提交,没有则新建一个 def get_exercise_user exercise_id,user_id eu = ExerciseUser.find_by_exercise_id_and_user_id(exercise_id,user_id) diff --git a/app/views/exercise/_exercise_student_result.html.erb b/app/views/exercise/_exercise_student_result.html.erb index c6b9a251c..95ef022d5 100644 --- a/app/views/exercise/_exercise_student_result.html.erb +++ b/app/views/exercise/_exercise_student_result.html.erb @@ -12,9 +12,8 @@
              开始时间:<%=format_time(exercise_user.start_at.to_s) %> 测验时长:<%=exercise.time %>分钟 - <% time = exercise_user.end_at - exercise_user.start_at %> - 测验用时:<%= (time % (24*60*60)) / (60*60)%> 小时 <%= ((time % (24*60*60)) % (60*60)) / 60%> 分钟 <%= ((time % (24*60*60)) % (60*60)) % 60%> 秒 -
              + <%# time = exercise_user.end_at - exercise_user.start_at %> +
              <%= exercise.exercise_description.nil? ? "" : exercise.exercise_description.html_safe%>
              @@ -32,7 +31,7 @@ <% answer = get_user_answer(exercise_question, User.current)%> <% standard_answer = get_user_standard_answer(exercise_question, User.current)%> - <% if answer.exercise_choice_id == standard_answer.exercise_choice_id %> + <% if answer.first.exercise_choice.choice_position == standard_answer.first.exercise_choice_id %> √ <% else %> × @@ -63,7 +62,7 @@
              ">

              多选题

              - <% mcq_question_list.each_wtih_index do |exercise_question, list_index| %> + <% mcq_question_list.each_with_index do |exercise_question, list_index| %>
              @@ -71,7 +70,7 @@ <% answer = get_user_answer(exercise_question, User.current)%> <% standard_answer = get_user_standard_answer(exercise_question, User.current)%> - <% if answer.exercise_choice_id == standard_answer.exercise_choice_id %> + <% if answer.first.exercise_choice_id == standard_answer.first.exercise_choice_id %> √ <% else %> × @@ -110,7 +109,7 @@ <% answer = get_user_answer(exercise_question, User.current)%> <% standard_answer = get_user_standard_answer(exercise_question, User.current)%> - <% if standard_answer.include?(answer.exercise_choice_id) %> + <% if standard_answer.include?(answer.first.answer_text) %> √ <% else %> × From bb726e3475682c509c498ca9bf7179b8b71494a5 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 20 Nov 2015 18:21:31 +0800 Subject: [PATCH 114/191] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E7=AD=94=E6=A1=88?= =?UTF-8?q?=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 18 ++++-------------- app/helpers/exercise_helper.rb | 11 +++++++++++ .../exercise/_exercise_student_result.html.erb | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index cbc6009b1..781ea50cd 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -485,7 +485,10 @@ class ExerciseController < ApplicationController score2 = score + question.question_score unless question.question_score.nil? end else - get_mulscore(question, user, standard_answer) + arr = get_mulscore(question, user) + if arr.to_i == standard_answer.exercise_choice_id + score3 = score + question.question_score unless question.question_score.nil? + end # ecs = ExerciseAnswer.where("user_id =? and exercise_question_id =?", user.id, question.id) # arr = [] # ecs.each do |ec| @@ -503,19 +506,6 @@ class ExerciseController < ApplicationController end private - # 获取多选的得分 - def get_mulscore(question, user, standard_answer) - ecs = ExerciseAnswer.where("user_id =? and exercise_question_id =?", user.id, question.id) - arr = [] - ecs.each do |ec| - arr << ec.exercise_choice.choice_position - end - arr.sort - arr = arr.join("") - if arr.to_i == standard_answer.exercise_choice_id - score3 = score + question.question_score unless question.question_score.nil? - end - end # ExerciseUser记录用户是否已提交问卷有对应的记录则已提交,没有则新建一个 def get_exercise_user exercise_id,user_id diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb index 21c0144b9..bb87f3b82 100644 --- a/app/helpers/exercise_helper.rb +++ b/app/helpers/exercise_helper.rb @@ -36,6 +36,17 @@ module ExerciseHelper end end + # 获取多选的得分 + def get_mulscore(question, user) + ecs = ExerciseAnswer.where("user_id =? and exercise_question_id =?", user.id, question.id) + arr = [] + ecs.each do |ec| + arr << ec.exercise_choice.choice_position + end + arr.sort + arr = arr.join("") + end + # 判断用户是否已经提交了问卷 # status 为0的时候是用户点击试卷。为1表示用户已经提交 def has_commit_exercise?(exercise_id, user_id) diff --git a/app/views/exercise/_exercise_student_result.html.erb b/app/views/exercise/_exercise_student_result.html.erb index 95ef022d5..32cb556b3 100644 --- a/app/views/exercise/_exercise_student_result.html.erb +++ b/app/views/exercise/_exercise_student_result.html.erb @@ -70,7 +70,7 @@ <% answer = get_user_answer(exercise_question, User.current)%> <% standard_answer = get_user_standard_answer(exercise_question, User.current)%> - <% if answer.first.exercise_choice_id == standard_answer.first.exercise_choice_id %> + <% if get_mulscore(exercise_question, User.current).to_i == standard_answer.first.exercise_choice_id %> √ <% else %> × From c9ba57f64bbfaf23fbd057847a65ca0399f40ddb Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 20 Nov 2015 18:29:26 +0800 Subject: [PATCH 115/191] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E3=80=81=E5=AF=BC=E5=85=A5=E7=AD=89=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 10 ++-------- app/views/exercise/_exercise.html.erb | 2 +- app/views/exercise/_exercise_submit.html.erb | 6 +++--- app/views/exercise/index.html.erb | 2 +- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 1a8faff55..6f08cb75f 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -284,13 +284,7 @@ class ExerciseController < ApplicationController @exercise.exercise_status = 2 @exercise.publish_time = Time.now if @exercise.save - if params[:is_remote] - redirect_to exercise_index_url(:course_id => @course.id) - else - respond_to do |format| - format.js - end - end + redirect_to exercise_index_url(:course_id=> @course.id) end end @@ -430,7 +424,7 @@ class ExerciseController < ApplicationController def commit_exercise # 老师不需要提交 if User.current.allowed_to?(:as_teacher,@course) - @exercise.update_attributes(:show_result => params[:exercise][:show_result]) + @exercise.update_attributes(:show_result => params[:show_result]) redirect_to exercise_url(@exercise) # REDO: 提示提交成功 else diff --git a/app/views/exercise/_exercise.html.erb b/app/views/exercise/_exercise.html.erb index 78ca97887..dfcc8d3b4 100644 --- a/app/views/exercise/_exercise.html.erb +++ b/app/views/exercise/_exercise.html.erb @@ -21,7 +21,7 @@ <% if exercise.exercise_status == 1 %>
            • 发布试卷
            • <% else %> -
            • 取消发布
            • +
            • 发布试卷
            • <% end%> <%= link_to(l(:button_delete), exercise,:method => :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml5 mr10") %> diff --git a/app/views/exercise/_exercise_submit.html.erb b/app/views/exercise/_exercise_submit.html.erb index acbbea244..8e2ad74a2 100644 --- a/app/views/exercise/_exercise_submit.html.erb +++ b/app/views/exercise/_exercise_submit.html.erb @@ -1,4 +1,4 @@ -<%= form_for(exercise, +<%= form_for('', :html => { :multipart => true }, :url => {:controller => 'exercise', :action => 'commit_exercise', @@ -7,8 +7,8 @@
              提交
              - <%= f.check_box :show_result, :value => exercise.show_result%> - <%= label_tag 'exercise_show_result', '允许学生查看测验结果' %> + <%= f.check_box 'show_result', :value => exercise.show_result%> + <%= label_tag '_show_result', '允许学生查看测验结果' %>
              diff --git a/app/views/exercise/index.html.erb b/app/views/exercise/index.html.erb index 14db03e09..1e2d6ff34 100644 --- a/app/views/exercise/index.html.erb +++ b/app/views/exercise/index.html.erb @@ -37,7 +37,7 @@ $('#ajax-modal').html("
              " + "
              " + "
              " + - "

              问卷发布后将不能对问卷进行修改,
              是否确定发布该问卷?

              " + + "

              测验发布后将不能对测验进行修改,
              是否确定发布该测验?

              " + "
              " + "确  定" + "取  消" + From c07e2fe2d2ef413787abc95b500234f626e568b9 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 20 Nov 2015 18:38:50 +0800 Subject: [PATCH 116/191] =?UTF-8?q?=E5=8F=91=E5=B8=83=E8=AF=95=E5=8D=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index e34e89cb7..c95458a57 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -40,6 +40,7 @@ class ExerciseController < ApplicationController else if !@is_teacher && !has_click_exercise?(@exercise.id, User.current.id) eu = ExerciseUser.create(:user_id => User.current.id, :exercise_id => @exercise.id, :start_at => Time.now, :status => false) + @exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first end # @percent = get_percent(@exercise,User.current) From aa36c927d3c7c0a4ac88fac7741e68ae90c7115b Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 20 Nov 2015 18:39:35 +0800 Subject: [PATCH 117/191] 0 --- app/controllers/exercise_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 781ea50cd..6699702aa 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -41,7 +41,6 @@ class ExerciseController < ApplicationController if !@is_teacher && !has_click_exercise?(@exercise.id, User.current.id) eu = ExerciseUser.create(:user_id => User.current.id, :exercise_id => @exercise.id, :start_at => Time.now, :status => false) end - # @percent = get_percent(@exercise,User.current) exercise_questions = @exercise.exercise_questions @exercise_questions = paginateHelper exercise_questions,5 #分页 From da55b00da7f1ccaa5662eb01015bb36bd3f0f1bd Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 20 Nov 2015 19:05:39 +0800 Subject: [PATCH 118/191] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=8F=92=E5=85=A5?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 448c9a90a..9c4ce463a 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -269,11 +269,23 @@ class ExerciseController < ApplicationController def delete_exercise_question @exercise_question = ExerciseQuestion.find params[:exercise_question] @exercise = @exercise_question.exercise - exercise_questions = @exercise.exercise_questions.where("question_number > #{@exercise_question.question_number}") - exercise_questions.each do |question| - question.question_number -= 1 - question.save + + if @exercise_question.question_type == 1 + ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 1).update_all(" question_number = question_number - 1") + #@exercise.exercise_questions.where("question_number > #{params[:quest_num].to_i} and question_type == 1").update_all(" question_number = question_number + 1") + elsif @exercise_question.question_type == 2 + ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 2).update_all(" question_number = question_number - 1") + else + ExerciseQuestion.where("question_number>? and question_type=?",params[:quest_num].to_i, 3).update_all(" question_number = question_number - 1") end + # @exercise_question_num = params[:quest_num].to_i + # @exercise_questions.question_number = params[:quest_num].to_i - 1 + # + # exercise_questions = @exercise.exercise_questions.where("question_number > #{@exercise_question.question_number}") + # exercise_questions.each do |question| + # question.question_number -= 1 + # question.save + # end if @exercise_question && @exercise_question.destroy respond_to do |format| format.js @@ -568,7 +580,9 @@ class ExerciseController < ApplicationController exercises = course.exercises.where("exercise_name=?","") unless exercises.empty? exercises.each do |exercise| - exercise.destroy + if exercise.exercise_questions.empty? + exercise.destroy + end end end end From c0dfc17b19e6afd84b76eebbe19ffc391111c57f Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 20 Nov 2015 19:35:32 +0800 Subject: [PATCH 119/191] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 9c4ce463a..28f532db6 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -443,7 +443,8 @@ class ExerciseController < ApplicationController # REDO: 提示提交成功 else # 更新提交状态 - @exercise.exercise_users.first.update_attributes(:status => true) + cur_exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", User.current, @exercise.id).first + cur_exercise_user.update_attributes(:status => 1) # 答题过程中需要统计完成量 @uncomplete_question = get_uncomplete_question(@exercise, User.current) # 获取改学生的考试得分 From 5ac65d86b18b94b53693c1ac7d3857c8c289ed98 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 20 Nov 2015 19:58:25 +0800 Subject: [PATCH 120/191] =?UTF-8?q?=E5=B0=86org=5Fdocument=5Fcomment?= =?UTF-8?q?=E4=B8=AD=E7=9A=84title=E6=94=B9=E6=88=90text=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0151120115137_changecolumn_of_org_document_comments.rb | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 db/migrate/20151120115137_changecolumn_of_org_document_comments.rb diff --git a/db/migrate/20151120115137_changecolumn_of_org_document_comments.rb b/db/migrate/20151120115137_changecolumn_of_org_document_comments.rb new file mode 100644 index 000000000..15cc8fdcd --- /dev/null +++ b/db/migrate/20151120115137_changecolumn_of_org_document_comments.rb @@ -0,0 +1,8 @@ +class ChangecolumnOfOrgDocumentComments < ActiveRecord::Migration + def up + change_column :org_document_comments, :title, :text + end + + def down + end +end From 9ca336a70a926d62ad2fa407fe4c115b238c7354 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 20 Nov 2015 19:59:05 +0800 Subject: [PATCH 121/191] =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=92=8C=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 2 +- app/views/exercise/_exercise.html.erb | 6 ++++-- app/views/exercise/_exercise_form.html.erb | 8 +++++++- app/views/exercise/create_exercise_question.js.erb | 4 +++- app/views/exercise/update_exercise_question.js.erb | 2 +- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 448c9a90a..94a5a8028 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -294,7 +294,7 @@ class ExerciseController < ApplicationController # 重新发布的时候会删除所有的答题 def republish_exercise @exercise.exercise_questions.each do |exercise_question| - exercise_question.exercise_ansers.destroy_all + exercise_question.exercise_answers.destroy_all end @exercise.exercise_users.destroy_all @exercise.exercise_status = 1 diff --git a/app/views/exercise/_exercise.html.erb b/app/views/exercise/_exercise.html.erb index dfcc8d3b4..f5896c5e3 100644 --- a/app/views/exercise/_exercise.html.erb +++ b/app/views/exercise/_exercise.html.erb @@ -20,8 +20,10 @@ <% if exercise.exercise_status == 1 %>
            • 发布试卷
            • - <% else %> -
            • 发布试卷
            • + <% elsif exercise.exercise_status == 2%> +
            • 取消发布
            • + <% else%> +
            • 发布试卷
            • <% end%> <%= link_to(l(:button_delete), exercise,:method => :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "polls_de fr ml5 mr10") %> diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index 22589097a..29ccc685d 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -84,8 +84,11 @@ { var title = $.trim($("#poll_questions_title").val()); var score = $.trim($("#question_score").val()); + var standard_ans = $.trim($("#question_standard_ans").val()); if(title.length == 0 || score.length == 0){ alert("题目标题/分数不能为空"); + }else if(standard_ans.length == 0) { + alert("标准答案不能为空"); }else{ doc.parent().parent().parent().submit();} } @@ -94,8 +97,11 @@ { var title = $.trim($("#poll_questions_title_" + id).val()); var score = $.trim($("#poll_question_score_"+ id).val()); + var standard_ans = $.trim($("#poll_question_standard_answer_" + id).val()); if(title.length == 0 || score.length == 0){ - alert("题目标题不能为空"); + alert("题目标题/分数不能为空"); + }else if(standard_ans.length == 0) { + alert("标准答案不能为空"); }else{ doc.parent().parent().parent().submit();} } diff --git a/app/views/exercise/create_exercise_question.js.erb b/app/views/exercise/create_exercise_question.js.erb index 9047cfeda..326a19ec8 100644 --- a/app/views/exercise/create_exercise_question.js.erb +++ b/app/views/exercise/create_exercise_question.js.erb @@ -1,6 +1,8 @@ <% if @is_insert %> $("#poll_content").html('<%= escape_javascript(render :partial => 'exercise_content', :locals => {:exercise => @exercise})%>'); $("#exercise_submit").html("<%= escape_javascript(render :partial => 'exercise_submit', :locals => {:exercise => @exercise}) %>"); + $("#current_score_div").show(); + $("#current_score").html("<%=get_current_score @exercise %>分"); <% else %> $("#new_exercise_question").html('<%= escape_javascript(render :partial => 'new_question', :locals => {:exercise => @exercise}) %>'); $("#new_poll_question").html(""); @@ -35,6 +37,6 @@ "
              " + "
              "); <% end %> -$("#current_score").html("<%=get_current_score @exercise %>分"); $("#current_score_div").show(); +$("#current_score").html("<%=get_current_score @exercise %>分"); <% end %> diff --git a/app/views/exercise/update_exercise_question.js.erb b/app/views/exercise/update_exercise_question.js.erb index ef9004c06..9e7822cb7 100644 --- a/app/views/exercise/update_exercise_question.js.erb +++ b/app/views/exercise/update_exercise_question.js.erb @@ -16,5 +16,5 @@ $("#poll_questions_<%= @exercise_question.id%>").html("
              {:exercise_question => @exercise_question}) %>" + "<% end%>" + "
              "); -$("#current_score").html("<%=get_current_score @exercise %>分"); +$("#current_score").html("<%=get_current_score @exercise_question.exercise %>分"); $("#exercise_submit").html("<%= escape_javascript(render :partial => 'exercise_submit', :locals => {:exercise => @exercise_question.exercise}) %>"); From 8b29002a0fdf30058186869621b7e0bdbc69920b Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 20 Nov 2015 20:02:57 +0800 Subject: [PATCH 122/191] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BE=97=E5=88=86?= =?UTF-8?q?=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 28f532db6..c15d5ad23 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -21,6 +21,10 @@ class ExerciseController < ApplicationController end def show + unless User.current.member_of_course?(@course) + render_403 + return + end @exercise = Exercise.find params[:id] @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? if @exercise.exercise_status != 2 && (!User.current.allowed_to?(:as_teacher,@course) || User.current.admin?) @@ -485,16 +489,16 @@ class ExerciseController < ApplicationController # 问答题有多个答案 if question.question_type == 3 if standard_answer.include?(answer.first.answer_text) - score1 = score+ question.question_score unless question.question_score.nil? + score1 = score1+ question.question_score unless question.question_score.nil? end elsif question.question_type == 1 if answer.first.exercise_choice.choice_position == standard_answer.exercise_choice_id - score2 = score + question.question_score unless question.question_score.nil? + score2 = score2 + question.question_score unless question.question_score.nil? end else arr = get_mulscore(question, user) if arr.to_i == standard_answer.exercise_choice_id - score3 = score + question.question_score unless question.question_score.nil? + score3 = score3 + question.question_score unless question.question_score.nil? end # ecs = ExerciseAnswer.where("user_id =? and exercise_question_id =?", user.id, question.id) # arr = [] From cc19c345e1a629a26f6789f7dd38085e499fa036 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 20 Nov 2015 20:23:02 +0800 Subject: [PATCH 123/191] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_exercise_form.html.erb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb index 29ccc685d..0d6b8602d 100644 --- a/app/views/exercise/_exercise_form.html.erb +++ b/app/views/exercise/_exercise_form.html.erb @@ -87,9 +87,9 @@ var standard_ans = $.trim($("#question_standard_ans").val()); if(title.length == 0 || score.length == 0){ alert("题目标题/分数不能为空"); - }else if(standard_ans.length == 0) { + }/*else if(standard_ans.length == 0) { alert("标准答案不能为空"); - }else{ + }*/else{ doc.parent().parent().parent().submit();} } //修改标题时确定按钮 @@ -100,9 +100,9 @@ var standard_ans = $.trim($("#poll_question_standard_answer_" + id).val()); if(title.length == 0 || score.length == 0){ alert("题目标题/分数不能为空"); - }else if(standard_ans.length == 0) { + }/*else if(standard_ans.length == 0) { alert("标准答案不能为空"); - }else{ + }*/else{ doc.parent().parent().parent().submit();} } From b10fbcde8c2b3c8fb735d5648a60005462472223 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 20 Nov 2015 20:44:27 +0800 Subject: [PATCH 124/191] =?UTF-8?q?=E5=8F=96=E6=B6=88=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E5=92=8C=E5=8F=91=E5=B8=83=E6=B5=8B=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 7 ++++++- app/views/exercise/_edit_MC.html.erb | 2 +- app/views/exercise/_edit_MCQ.html.erb | 2 +- app/views/exercise/_edit_single.html.erb | 2 +- app/views/exercise/_exercise_form.html.erb | 12 ++++++------ app/views/exercise/_exercises_list.html.erb | 2 +- app/views/exercise/_new_MC.html.erb | 2 +- app/views/exercise/_new_MCQ.html.erb | 2 +- app/views/exercise/_new_single.html.erb | 2 +- app/views/exercise/_show_MC.html.erb | 2 +- app/views/exercise/_show_MCQ.html.erb | 2 +- app/views/exercise/_show_single.html.erb | 2 +- app/views/exercise/index.html.erb | 2 +- app/views/exercise/republish_exercise.js.erb | 2 +- 14 files changed, 24 insertions(+), 19 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index c8e5bf27c..d53dc067c 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -299,16 +299,21 @@ class ExerciseController < ApplicationController # 发布试卷 def publish_exercise + @is_teacher = User.current.allowed_to?(:as_teacher,@course) @exercise.exercise_status = 2 @exercise.publish_time = Time.now if @exercise.save - redirect_to exercise_index_url(:course_id=> @course.id) + #redirect_to exercise_index_url(:course_id=> @course.id) + respond_to do |format| + format.js + end end end # 重新发布试卷 # 重新发布的时候会删除所有的答题 def republish_exercise + @is_teacher = User.current.allowed_to?(:as_teacher,@course) @exercise.exercise_questions.each do |exercise_question| exercise_question.exercise_answers.destroy_all end diff --git a/app/views/exercise/_edit_MC.html.erb b/app/views/exercise/_edit_MC.html.erb index a1c8aa8b1..008c95c24 100644 --- a/app/views/exercise/_edit_MC.html.erb +++ b/app/views/exercise/_edit_MC.html.erb @@ -50,7 +50,7 @@
              diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb index 1ee79e198..08b31087a 100644 --- a/app/views/exercise/_new_single.html.erb +++ b/app/views/exercise/_new_single.html.erb @@ -40,7 +40,7 @@
              diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb index b932eac1e..5c214165a 100644 --- a/app/views/exercise/_show_MC.html.erb +++ b/app/views/exercise/_show_MC.html.erb @@ -90,7 +90,7 @@ ''+ '
              '+ ''+ ''+ ' diff --git a/app/views/exercise/_exercise_student_result.html.erb b/app/views/exercise/_exercise_student_result.html.erb index 32cb556b3..b9306b0d2 100644 --- a/app/views/exercise/_exercise_student_result.html.erb +++ b/app/views/exercise/_exercise_student_result.html.erb @@ -46,7 +46,7 @@ diff --git a/app/views/exercise/_new_question.html.erb b/app/views/exercise/_new_question.html.erb index 6148c9bb9..faadb08a9 100644 --- a/app/views/exercise/_new_question.html.erb +++ b/app/views/exercise/_new_question.html.erb @@ -8,7 +8,9 @@ \ No newline at end of file diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index fdf1e31a3..4f9999277 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -121,10 +121,13 @@
              \ No newline at end of file From ccfbc1e0bdb93425667e9ee776a5ebecc2cf16b1 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 24 Nov 2015 12:50:43 +0800 Subject: [PATCH 146/191] =?UTF-8?q?1.=E7=BB=84=E7=BB=87=E7=BF=BB=E9=A1=B5?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0type=E5=8F=82=E6=95=B0=EF=BC=9B=202.=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E7=BB=84=E7=BB=87=E8=A1=A8=E4=B8=AD=E5=86=97=E4=BD=99?= =?UTF-8?q?=E7=9A=84=E9=A1=B9=E7=9B=AE=E5=8A=A8=E6=80=81=E5=92=8C=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=8A=A8=E6=80=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../organizations/_org_activities.html.erb | 2 +- ...1124032319_delete_useless_org_activities.rb | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20151124032319_delete_useless_org_activities.rb diff --git a/app/views/organizations/_org_activities.html.erb b/app/views/organizations/_org_activities.html.erb index aa48fedf1..33ac13e76 100644 --- a/app/views/organizations/_org_activities.html.erb +++ b/app/views/organizations/_org_activities.html.erb @@ -56,7 +56,7 @@ <% end %> <% if org_act_count == 10 %> -
              展开更多<%=link_to "", organization_path(org,:page => page.to_i + 1),:id => "more_org_activities_link",:remote => "true",:class => "none" %>
              +
              展开更多<%=link_to "", organization_path(org,:page => page.to_i + 1, :type => params[:type]),:id => "more_org_activities_link",:remote => "true",:class => "none" %>
              <%#= link_to "点击展开更多",user_activities_path(@user.id,:type => type,:page => page),:id => "show_more_activities",:remote => "true",:class => "loadMore mt10 f_grey"%> <% end%> diff --git a/db/migrate/20151124032319_delete_useless_org_activities.rb b/db/migrate/20151124032319_delete_useless_org_activities.rb new file mode 100644 index 000000000..705e0dbed --- /dev/null +++ b/db/migrate/20151124032319_delete_useless_org_activities.rb @@ -0,0 +1,18 @@ +class DeleteUselessOrgActivities < ActiveRecord::Migration + def up + OrgActivity.all.each do |act| + if act.container_type == 'Course' + if CourseActivity.where("course_act_type=? and course_act_id =? and course_id =?", act.org_act_type, act.org_act_id, act.container_id).count == 0 + puts "course" + end + else + if act.container_type == 'Project' and ForgeActivity.where("forge_act_type=? and forge_act_id =? and project_id =?", act.org_act_type, act.org_act_id, act.container_id).count == 0 + act.destroy + end + end + end + end + + def down + end +end From 269d2f992eecdbbc426c12184622cc2f5a4bf32e Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 24 Nov 2015 15:02:25 +0800 Subject: [PATCH 147/191] =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E6=A1=86=E8=B0=83=E6=95=B4=E5=90=8E=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_organizations.html.erb | 6 +++--- public/stylesheets/new_user.css | 1 + public/stylesheets/org.css | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/views/users/user_organizations.html.erb b/app/views/users/user_organizations.html.erb index 50bb24000..25a0c4508 100644 --- a/app/views/users/user_organizations.html.erb +++ b/app/views/users/user_organizations.html.erb @@ -6,11 +6,11 @@
              组织列表 - <%= form_tag url_for(:controller => 'users', :action => 'search_user_orgs', :id => User.current.id), :method => 'get', :id => "search_org_form", :class=>"resourcesSearchloadBox", :style=>"float:right; margin-top:-5px;" do %> - + <%#= form_tag url_for(:controller => 'users', :action => 'search_user_orgs', :id => User.current.id), :method => 'get', :id => "search_org_form", :class=>"resourcesSearchloadBox", :style=>"float:right; margin-top:-5px;" do %> + - 搜索 + <% end %>
              diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index d18dd27d8..fd7c0c4d6 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -384,6 +384,7 @@ a.resourcesGrey:hover {font-size:12px; color:#269ac9;} a.uploadText {color:#ffffff; font-size:14px;} .resourcesSearchloadBox {border:1px solid #e6e6e6; width:225px; float:left; background-color:#ffffff;} .searchResource {border:none; outline:none; background-color:#ffffff; width:184px; height:32px; padding-left:10px; display:block; float:left;} +.searchResource:focus {border:none;} .searchIcon{width:31px; height:32px; background-color:#ffffff; background:url(images/resource_icon_list.png) -40px -15px no-repeat; display:block; float:left;} /*.resourcesSearchBanner {height:34px; margin-bottom:10px;}*/ .resourcesSearchBanner {width:710px; height:34px; margin-bottom:10px; margin-top:15px; margin-left:auto; margin-right:auto;} diff --git a/public/stylesheets/org.css b/public/stylesheets/org.css index 914df16b5..daabfc99d 100644 --- a/public/stylesheets/org.css +++ b/public/stylesheets/org.css @@ -37,7 +37,7 @@ a.org_member_btn{ padding:1px 5px; background:#15bccf; color:#fff;} /*项目关联css*/ .relateOrg {width:335px;} .relatedList {width:335px;} -.searchOrg {height:24px; width:200px; color:#9b9b9b9; border:1px solid #15bccf;} +.searchOrg {height:24px; width:200px; color:#9b9b9b; border:1px solid #15bccf;} a.cancelBtn {padding:3px 5px; background-color:#D9D9D9; color:#656565;} a.cancelBtn:hover {background-color:#717171; color:#ffffff;} .relatedList ul li {border-bottom:1px solid #e4e4e4; width:320px; height:22px; vertical-align:middle; line-height:22px;} From ec00b86c15a7eae6a02eba1c2519e6088909bc62 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 24 Nov 2015 15:17:47 +0800 Subject: [PATCH 148/191] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E5=A4=9A=E6=AC=A1?= =?UTF-8?q?=E6=96=B0=E5=BB=BA=E4=BD=9C=E5=93=81=E6=97=B6=E6=8F=90=E9=86=92?= =?UTF-8?q?=E5=AD=A6=E7=94=9F=E4=B8=8D=E8=83=BD=E9=87=8D=E5=A4=8D=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 10 ++++++-- .../student_work/_has_commit_work.html.erb | 24 +++++++++++++++++++ app/views/student_work/create.js.erb | 10 +++++++- 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 app/views/student_work/_has_commit_work.html.erb diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 87d13e169..7eac379e4 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -168,9 +168,15 @@ class StudentWorkController < ApplicationController def create # 提交作品前先判断是否已经提交 + @has_commit = false; if hsd_committed_work?(User.current.id, @homework.id) - flash[:notice] = l(:notice_successful_create) - redirect_to edit_student_work_url(params[:student_work]) + @work = StudentWork.where("user_id =? and homework_common_id =?", User.current.id, @homework.id).first + @has_commit = true; + #flash[:notice] = l(:notice_successful_create) + #redirect_to edit_student_work_url(params[:student_work]) + respond_to do |format| + format.js + end return end if params[:student_work] diff --git a/app/views/student_work/_has_commit_work.html.erb b/app/views/student_work/_has_commit_work.html.erb new file mode 100644 index 000000000..d324f3aaf --- /dev/null +++ b/app/views/student_work/_has_commit_work.html.erb @@ -0,0 +1,24 @@ +
              +
              +

              您已提交过作品,请不要重复提交,如果想修改作品请点击编辑。

              +
              + +
              +
              + + \ No newline at end of file diff --git a/app/views/student_work/create.js.erb b/app/views/student_work/create.js.erb index 42b1db8b8..afd8617aa 100644 --- a/app/views/student_work/create.js.erb +++ b/app/views/student_work/create.js.erb @@ -1,4 +1,12 @@ -<% if @submit_result%> +<% if @has_commit %> + $('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/has_commit_work') %>'); + showModal('ajax-modal', '500px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').before("" + + ""); + $('#ajax-modal').parent().css("top","").css("left",""); + $('#ajax-modal').parent().addClass("anonymos"); +<% elsif @submit_result%> $('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/work_information') %>'); showModal('ajax-modal', '500px'); $('#ajax-modal').siblings().remove(); From e89cb99743e1d8fa8984aa68474ac68964b103b3 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 24 Nov 2015 16:20:29 +0800 Subject: [PATCH 149/191] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E6=B5=8B=E9=AA=8C=E7=BB=93=E6=9E=9C=E9=A1=B5=E9=9D=A2=E7=9A=84?= =?UTF-8?q?=E6=89=B9=E6=AC=A1=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 2 +- app/views/exercise/student_exercise_list.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index d53dc067c..1598030a2 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -328,7 +328,7 @@ class ExerciseController < ApplicationController def student_exercise_list @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? @exercise = Exercise.find params[:id] - @all_exercises = @course.exercises.order("created_at desc") + @all_exercises = @course.exercises.where("exercise_status > 1").order("created_at desc") @exercise_count = @exercise.exercise_users.where('score is not NULL').count if @is_teacher || (!@exercise.exercise_users.where(:user_id => User.current.id).empty? && Time.parse(@exercise.end_time.to_s).strftime("%Y-%m-%d-%H-%M-%S") <= Time.now.strftime("%Y-%m-%d-%H-%M-%S")) @exercise_users_list = @exercise.exercise_users.where('score is not NULL') diff --git a/app/views/exercise/student_exercise_list.html.erb b/app/views/exercise/student_exercise_list.html.erb index 8653836ca..2e51d61af 100644 --- a/app/views/exercise/student_exercise_list.html.erb +++ b/app/views/exercise/student_exercise_list.html.erb @@ -73,7 +73,7 @@
                <% @all_exercises.each_with_index do |exercise,index |%>
              • - <%= link_to "作业#{@all_exercises.count - index}:#{exercise.exercise_name}",''%> + <%= link_to "测验#{@all_exercises.count - index}:#{exercise.exercise_name}",student_exercise_list_exercise_path(exercise.id,:course_id => @course.id)%> <%#= link_to "第#{@homework_commons.count - index}次作业",student_work_index_path(:homework => homework_common.id)%>
              • <% end%> From 0e7cf4b122c7df17684b1a80b8efd08227453ab2 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 24 Nov 2015 16:21:25 +0800 Subject: [PATCH 150/191] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=E6=89=B9=E6=AC=A1=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=8F=AA=E6=98=BE=E7=A4=BA=E5=B7=B2=E5=8F=91=E5=B8=83=E7=9A=84?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 9ad46cd69..3c60fcaed 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -76,7 +76,7 @@ class StudentWorkController < ApplicationController end ################################################################################################################## @order,@b_sort,@name,@group = params[:order] || "score",params[:sort] || "desc",params[:name] || "",params[:group] - @homework_commons = @course.homework_commons.order("created_at desc") + @homework_commons = @course.homework_commons.where("publish_time <= ?",Time.now.strftime("%Y-%m-%d")).order("created_at desc") @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? @is_evaluation = @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status == 2 && !@is_teacher #是不是匿评 @show_all = false From 3a66b1859c716bb9668f6805cb9df1fbadfb2e23 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 24 Nov 2015 16:47:31 +0800 Subject: [PATCH 151/191] =?UTF-8?q?reserved=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/zh.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 4563944c8..ea172b554 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2081,7 +2081,7 @@ zh: label_co_organizer_BHU: 北京航空航天大学 label_co_organizer_CAS: 中国科学院软件研究所 label_co_organizer_InforS: 中创软件 - label_rights_reserved: Copyright 2007~2015, All Rights Riserved + label_rights_reserved: Copyright 2007~2015, All Rights Reserved label_about_us: 关于我们 label_contact_us: 联系我们 label_recruitment_information: 招聘信息 From 85515befc450a1e4ce0f9777c0abb8d466e398a3 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 24 Nov 2015 17:29:57 +0800 Subject: [PATCH 152/191] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E6=A0=8F=E6=95=B0=E5=AD=97=E5=A4=A7=E4=BA=8E0=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=EF=BC=8C=E5=B0=8F=E4=BA=8E0=E9=9A=90=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 4 ++ app/views/courses/_tool_expand.html.erb | 60 +++++++++++++++++++++++++ app/views/layouts/base_courses.html.erb | 21 +++++++++ public/javascripts/course.js | 57 +++++++++++++++++++++++ public/stylesheets/courses.css | 11 ++++- 5 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 app/views/courses/_tool_expand.html.erb diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index caca6fb1e..7c1831d56 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -25,6 +25,10 @@ module CoursesHelper # searchTeacherAndAssistant(project).count end + def show_nav?(count) + count == 0 ? true : false + end + #课程模块需要展示的模块 def course_model @nav_dispaly_course_all_label = 1 diff --git a/app/views/courses/_tool_expand.html.erb b/app/views/courses/_tool_expand.html.erb new file mode 100644 index 000000000..1f793de90 --- /dev/null +++ b/app/views/courses/_tool_expand.html.erb @@ -0,0 +1,60 @@ +<% course_file_num = visable_attachemnts_incourse(@course).count%> +<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %> +<% if show_nav?(@course.course_activities.count) %> + +<% end %> +<% if show_nav?(@course.homework_commons.count) %> + +<% end %> +<% if show_nav?(@course.news.count) %> + +<% end %> +<% if show_nav?(course_file_num) %> + +<% end %> +<% if show_nav?(@course.boards.first ? @course.boards.first.topics.count : 0) %> + +<% end %> +<% if show_nav?(course_feedback_count) %> + +<% end %> +<% if show_nav?(course_poll_count) %> + +<% end %> +<% if show_nav?(User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status=2").count) %> + +<% end %> \ No newline at end of file diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 106aa35a7..8b15e67ea 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -136,21 +136,28 @@
              diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 9f1815695..15968772f 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -1306,3 +1306,60 @@ function cancel_org_course_relation(id, courseId){ // alert('<%= @course.id%>') // }) //}) + +//项目点击展开 +function expand_tools_expand(content) { + if (content == "invit") { + $("#expand_tools_expand_invit").toggleClass("currentDd").siblings(".subNav").removeClass("currentDd"); + $("#expand_tools_expand_invit").toggleClass("currentDt").siblings(".subNav").removeClass("currentDt"); + $("#expand_tools_expand_invit").next(".navContent").slideToggle(500).siblings(".navContent").slideUp(500); + } + else { +// $("#expand_tools_expand").toggleClass("currentDd").siblings(".subNav").removeClass("currentDd"); +// $("#expand_tools_expand").toggleClass("currentDt").siblings(".subNav").removeClass("currentDt"); +// $("#expand_tools_expand").next(".navContent").slideToggle(500).siblings(".navContent").slideUp(500); + $("#navContent").toggle(500); + } + + // 修改数字控制速度, slideUp(500)控制卷起速度 +} + +//通过cookie存储伸开形式 +$(function(){ + var personalized_expand_key = "personalized_expand"; + function personalized_init(){ + var personalized_map = cookieget(personalized_expand_key); + if(personalized_map!=false){ + personalized_map = JSON.parse(personalized_map); + $("*[nhtype='toggle4cookie']").each(function(){ + var personalized_id=$(this).data('id'); + var val = personalized_map[personalized_id]; + if(val!=undefined && val!=$(this).data('val')){ + personalized_click($(this),0); + } + }); + } + } + function personalized_click(obj,timeout){ + var target = $(obj.data('target')); + var oldval = obj.data('val'); + var val=''; + if(oldval=='expand'){val='retract';}else{val='expand';} + obj.data('val',val); + var personalized_map = cookieget(personalized_expand_key); + if(personalized_map == false){ + personalized_map={}; + }else{ + personalized_map = JSON.parse(personalized_map); + } + var personalized_id=obj.data('id'); + personalized_map[personalized_id]=val; + cookiesave(personalized_expand_key,JSON.stringify(personalized_map)); + target.toggle(timeout); + } + $("*[nhtype='toggle4cookie']").on('click',function(){ + personalized_click($(this),500); + }); + + personalized_init(); +}); \ No newline at end of file diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 5ff34a4e1..e71eb975c 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -1166,4 +1166,13 @@ a:hover.testEdit{ background:url(images/icons.png) -21px -272px no-repeat;} .questionEditContainer {border:1px solid #cbcbcb;background:#eeeeee; padding:10px; margin-bottom:10px; margin-top:10px;} .fillInput {border:1px solid #cbcbcb; padding-left:5px; background-color:#ffffff; width:693px; height:30px; color:#888888;} .mr130 {margin-right:130px;} -.ur_button_submit{ display:block; width:106px; height:31px; margin:0 auto; background:#15bccf; color:#fff; font-size:16px; text-align:center; padding-top:4px; margin-bottom:10px; } \ No newline at end of file +.ur_button_submit{ display:block; width:106px; height:31px; margin:0 auto; background:#15bccf; color:#fff; font-size:16px; text-align:center; padding-top:4px; margin-bottom:10px; } + +/*20151123课程排行榜Tim*/ +.courseMenuSetting {background:url(../images/homepage_icon2.png) -190px -365px no-repeat; width:15px; height:15px; margin-top:3px; float:right; margin-right:5px;} +.courseMenuSetting:hover {background:url(../images/homepage_icon2.png) -190px -407px no-repeat;} +.rankList {width:220px; padding:10px; background-color:#ffffff; margin-top:10px;} +.rankList li {width:73px; padding:5px 0px; text-align:center; float:left; position:relative;} +.rankList li p {width:100%; overflow:hidden; white-space:normal; text-overflow:ellipsis; color:#585858;} +.rankPortrait {border-radius:50%; width:35px; height:35px;} +.numIntro {position:absolute; text-align:left; z-index:999; box-shadow:0px 2px 8px rgba(146, 153, 169, 0.5); border:1px solid #eaeaea; background-color:#ffffff; padding:3px 5px; left:15px; width:65px; color:#585858;} \ No newline at end of file From 2dc31637d862c11911ee26004c0f3d81d978f677 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 24 Nov 2015 17:29:58 +0800 Subject: [PATCH 153/191] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=92=8C=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E4=B8=AD=E5=8A=A0=E5=85=A5=E7=BB=84=E7=BB=87=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=A6=82=E6=9E=9C=E5=B7=B2=E7=BB=8F=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E4=BA=86=E6=9F=90=E7=BB=84=E7=BB=87=EF=BC=8C=E5=B0=B1=E4=B8=8D?= =?UTF-8?q?=E8=A6=81=E9=87=8D=E5=A4=8D=E5=8A=A0=E5=85=A5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/org_courses_controller.rb | 4 +++- app/controllers/org_projects_controller.rb | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/org_courses_controller.rb b/app/controllers/org_courses_controller.rb index 3d1d313c5..d054e41de 100644 --- a/app/controllers/org_courses_controller.rb +++ b/app/controllers/org_courses_controller.rb @@ -3,7 +3,9 @@ class OrgCoursesController < ApplicationController org_ids = params[:orgNames] @course = Course.find(params[:course_id]) org_ids.each do |org_id| - OrgCourse.create(:organization_id => org_id.to_i, :course_id => params[:course_id].to_i, :created_at => Time.now) + if OrgCourse.where("organization_id =? and course_id =?", org_id.to_i, params[:course_id].to_i).count == 0 + OrgCourse.create(:organization_id => org_id.to_i, :course_id => params[:course_id].to_i, :created_at => Time.now) + end end respond_to do |format| format.js diff --git a/app/controllers/org_projects_controller.rb b/app/controllers/org_projects_controller.rb index 29e60a62a..a455ce408 100644 --- a/app/controllers/org_projects_controller.rb +++ b/app/controllers/org_projects_controller.rb @@ -3,7 +3,9 @@ class OrgProjectsController < ApplicationController org_ids = params[:orgNames] @project = Project.find(params[:project_id]) org_ids.each do |org_id| - OrgProject.create(:organization_id => org_id.to_i, :project_id => params[:project_id].to_i, :created_at => Time.now) + if OrgProject.where("organization_id =? and project_id =?", org_id.to_i, @project.id).count == 0 + OrgProject.create(:organization_id => org_id.to_i, :project_id => params[:project_id].to_i, :created_at => Time.now) + end end respond_to do |format| format.js From 1ae514ca4857d7e2ad53b338731c1e01f899fb4d Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 25 Nov 2015 09:38:13 +0800 Subject: [PATCH 154/191] =?UTF-8?q?=E6=B5=8B=E9=AA=8C=E7=9A=84=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E6=97=A5=E6=9C=9F=E5=92=8C=E6=B5=8B=E9=AA=8C=E6=97=B6?= =?UTF-8?q?=E9=95=BF=E5=81=9A=E6=88=90=E5=8F=AF=E9=80=89=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 5 +- app/views/exercise/_edit_head.html.erb | 17 +++--- app/views/exercise/_exercise_form.html.erb | 60 +++++++++---------- app/views/exercise/_exercise_teacher.html.erb | 8 ++- app/views/exercise/_show_head.html.erb | 9 ++- public/stylesheets/courses.css | 2 +- 6 files changed, 53 insertions(+), 48 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 1598030a2..6fcbb0c6c 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -65,7 +65,6 @@ class ExerciseController < ApplicationController :end_time => "", :publish_time => "", :exercise_description => "", - :show_result => "", :show_result => 1 } @exercise = Exercise.create option @@ -104,10 +103,10 @@ class ExerciseController < ApplicationController def update @exercise.exercise_name = params[:exercise][:exercise_name] @exercise.exercise_description = params[:exercise][:exercise_description] - @exercise.time = params[:exercise][:time] + @exercise.time = params[:exercise][:time].blank? ? -1 : params[:exercise][:time] @exercise.end_time = params[:exercise][:end_time] @exercise.publish_time = params[:exercise][:publish_time] - @exercise.show_result = params[:exercise][:show_result] + @exercise.show_result = params[:exercise][:show_result].blank? ? 1 : params[:exercise][:show_result] if @exercise.save respond_to do |format| format.js diff --git a/app/views/exercise/_edit_head.html.erb b/app/views/exercise/_edit_head.html.erb index 3090cc2c5..6c357130c 100644 --- a/app/views/exercise/_edit_head.html.erb +++ b/app/views/exercise/_edit_head.html.erb @@ -6,18 +6,17 @@ <%# if edit_mode %> <%# end %> -
              - " > - <%= calendar_for('exercise_publish_time')%> -
              - <%# if edit_mode %> - - <%# end %> +
              - " > + "/> <%= calendar_for('exercise_end_time')%>
              -
              测验时长:分钟
              +
              测验时长:分钟
              + +
              + "/> + <%= calendar_for('exercise_publish_time')%> +