From 4efb66021415c2c0ea717589dbf04a126d109bad Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Thu, 26 Nov 2015 09:57:53 +0800 Subject: [PATCH 001/105] =?UTF-8?q?=E5=85=A8=E7=AB=99=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 7 ++ app/controllers/users_controller.rb | 2 +- app/controllers/welcome_controller.rb | 117 ++++++++++++++---- app/helpers/application_helper.rb | 17 +++ app/models/attachment.rb | 75 ++++++++++- app/models/course.rb | 74 ++++++++++- app/models/project.rb | 54 +++++++- app/models/user.rb | 73 ++++++++++- app/views/kaminari/_paginator.html.erb | 1 - app/views/layouts/_logined_header.html.erb | 64 +++++----- app/views/layouts/_unlogin_header.html.erb | 64 +++++----- .../welcome/_search_all_results.html.erb | 73 +++++++++++ .../_search_attachment_results.html.erb | 20 +++ .../welcome/_search_course_results.html.erb | 20 +++ .../welcome/_search_project_results.html.erb | 24 ++++ .../welcome/_search_user_results.html.erb | 24 ++++ app/views/welcome/search.html.erb | 100 +++++++++++++++ app/views/welcome/search.js.erb | 13 ++ config/initializers/kaminari_config.rb | 6 +- config/routes.rb | 7 +- db/schema.rb | 104 +++++----------- public/images/search_icon_03.png | Bin 0 -> 1186 bytes public/stylesheets/new_user.css | 20 +++ 23 files changed, 773 insertions(+), 186 deletions(-) create mode 100644 app/views/welcome/_search_all_results.html.erb create mode 100644 app/views/welcome/_search_attachment_results.html.erb create mode 100644 app/views/welcome/_search_course_results.html.erb create mode 100644 app/views/welcome/_search_project_results.html.erb create mode 100644 app/views/welcome/_search_user_results.html.erb create mode 100644 app/views/welcome/search.html.erb create mode 100644 app/views/welcome/search.js.erb create mode 100644 public/images/search_icon_03.png diff --git a/Gemfile b/Gemfile index 3027c16cd..a67fcfaea 100644 --- a/Gemfile +++ b/Gemfile @@ -30,6 +30,13 @@ gem 'rails_kindeditor',path:'lib/rails_kindeditor' #gem "rmagick", ">= 2.0.0" gem 'binding_of_caller' gem 'chinese_pinyin' +# gem 'sunspot_rails', '~> 1.3.3' +# gem 'sunspot_solr' +# gem 'sunspot' +# gem 'progress_bar' +gem 'kaminari' +gem 'elasticsearch-model' +gem 'elasticsearch-rails' group :development do gem 'grape-swagger' diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 776e6b7d5..8188ce12e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1856,7 +1856,7 @@ class UsersController < ApplicationController # 根据资源关键字进行搜索 def resource_search search = params[:search].to_s.strip.downcase - if(params[:type].nil? || params[:type] == "1") #全部 + if(params[:type].nil? || params[:type].blank? || params[:type] == "1") #全部 if User.current.id.to_i == params[:id].to_i user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询 @attachments = Attachment.where("((author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 784066378..4b75a3297 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -151,36 +151,101 @@ class WelcomeController < ApplicationController end def search - search_condition = params[:q] - search_type = params[:search_type].to_sym unless search_condition.blank? - search_by = params[:search_by] + @name = params[:q] + @search_type = params[:search_type] + case params[:search_type] + when 'all' + @alls = Elasticsearch::Model.search({ + query: { + multi_match: { + query: @name, + type:"most_fields", + fields: ['login^5', 'firstname','lastname','name^5','description','filename^5'] + } + }, + highlight: { + pre_tags: [''], + post_tags: [''], + fields: { + login: {}, + firstname: {}, + lastname: {}, + name:{}, + description:{}, + filename:{} + } + } + },[User,Course,Attachment,Project] ).page(params[:page] || 1).per(20).results + when 'user' + @users = User.search(@name).page(params[:page] || 1).per(20) + when 'project' + @projects = Project.search(@name).page(params[:page] || 1).per(20).results + when 'course' + @courses = Course.search(@name).page(params[:page] || 1).per(20).results + when 'attachment' + @attachments = Attachment.search(@name).page(params[:page] || 1).per(20).results + else + @alls = Elasticsearch::Model.search({ + query: { + multi_match: { + query: @name, + type:"most_fields", + fields: ['login^5', 'firstname','lastname','name^5','description','filename^5'] + } + }, + highlight: { + pre_tags: [''], + post_tags: [''], + fields: { + login: {}, + firstname: {}, + lastname: {}, + name:{}, + description:{}, + filename:{} + } + } + },[User,Course,Attachment,Project] ).page(params[:page] || 1).per(20).results - if search_type.nil? && params[:contests_search] && params[:name] != "" - search_type = :contests - search_condition = params[:name] end + @users_count = User.search(@name).results.total + + @course_count = Course.search(@name).results.total + @attach_count = Attachment.search(@name).results.total + @project_count = Project.search(@name).results.total + @total_count = Elasticsearch::Model.search({ + query: { + multi_match: { + query: @name, + type:"most_fields", + fields: ['login^5', 'firstname','lastname','name^5','description','filename^5'] + } + }, + highlight: { + pre_tags: [''], + post_tags: [''], + fields: { + login: {}, + firstname: {}, + lastname: {}, + name:{}, + description:{}, + filename:{} + } + } + },[User,Course,Attachment,Project] ).results.total + # search_type = params[:search_type].to_sym unless search_condition.blank? + # search_by = params[:search_by] + # + # if search_type.nil? && params[:contests_search] && params[:name] != "" + # search_type = :contests + # search_condition = params[:name] + # end + respond_to do |format| - format.html{ - case search_type - when :projects - redirect_to projects_search_url(:name => search_condition, - :project_type => Project::ProjectType_project) - when :courses - redirect_to courses_search_url(:name => search_condition) - when :contests - redirect_to contests_url(:name => search_condition) - when :users - redirect_to users_search_url(:name => search_condition,:search_by => search_by) - when :users_teacher - redirect_to users_search_url(:name => search_condition, :search_by => search_by, :role => :teacher) - when :users_student - redirect_to users_search_url(:name => search_condition, :search_by => search_by, :role => :student) - else - #redirect_to home_path, :alert => l(:label_sumbit_empty) - (redirect_to signin_path, :notice => l(:label_sumbit_empty);return) #if params[:name].blank? - end - } + format.js + format.html{ render :layout=>'users_base'} end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f4e0f88ff..15e29f39c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1825,6 +1825,23 @@ module ApplicationHelper s end + def get_user_identity identity + s = "" + case identity + when 0 + s = '教师' + when 1 + s = '学生' + when 2 + s = '组织' + when 3 + s= '开发者' + else + s = '学生' + end + s + end + def get_memo @new_memo = Memo.new @public_forum = Forum.find(1) rescue ActiveRecord::RecordNotFound diff --git a/app/models/attachment.rb b/app/models/attachment.rb index f7fb9b1aa..a98111b4f 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -17,7 +17,7 @@ require "digest/md5" require "fileutils" - +require 'elasticsearch/model' class Attachment < ActiveRecord::Base belongs_to :container, :polymorphic => true belongs_to :project, foreign_key: 'container_id', conditions: "attachments.container_type = 'Project'" @@ -38,6 +38,17 @@ class Attachment < ActiveRecord::Base validates :description, length: {maximum: 254} validate :validate_max_file_size + #elasticsearch + include Elasticsearch::Model + #elasticsearch kaminari init + Kaminari::Hooks.init + Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari + settings index: { number_of_shards: 1 } do + mappings dynamic: 'false' do + indexes :filename, analyzer: 'smartcn',index_options: 'offsets' + end + end + acts_as_taggable acts_as_event :title => :filename, @@ -74,9 +85,9 @@ class Attachment < ActiveRecord::Base @@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails") before_save :files_to_final_location,:act_as_course_activity - after_create :office_conver, :be_user_score,:act_as_forge_activity - after_update :office_conver, :be_user_score - after_destroy :delete_from_disk,:down_user_score + after_create :office_conver, :be_user_score,:act_as_forge_activity,:create_attachment_ealasticsearch_index + after_update :office_conver, :be_user_score,:update_attachment_ealasticsearch_index + after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index # add by nwb # 获取所有可公开的资源文件列表 @@ -92,7 +103,25 @@ class Attachment < ActiveRecord::Base " LEFT JOIN #{News.table_name} ON #{Attachment.table_name}.container_type='News' AND (#{News.table_name}.project_id in "+self.public_project_id + " OR #{News.table_name}.course_id in " + self.public_course_id + ")" + " LEFT JOIN #{HomeworkAttach.table_name} ON #{Attachment.table_name}.container_type='HomeworkAttach' AND #{HomeworkAttach.table_name}.bid_id in "+self.public_bid_id) } - + def self.search(query) + __elasticsearch__.search( + { + query: { + multi_match: { + query: query, + fields: ['filename'] + } + }, + highlight: { + pre_tags: [''], + post_tags: [''], + fields: { + filename: {} + } + } + } + ) + end # add by nwb # 公开的项目id列表 def self.public_project_id @@ -560,4 +589,40 @@ class Attachment < ActiveRecord::Base self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.container_id) end end + + def create_attachment_ealasticsearch_index + if self.is_public == 1 && ( (self.container_type == 'Project' && Project.find(self.container_id).is_public == 1) || + ( self.container_type == 'Course' && Course.find(self.container_id).is_public == 1) || + self.container_type == 'Principal') + self.__elasticsearch__.index_document + end + end + def update_attachment_ealasticsearch_index + if self.is_public == 1 && ( (self.container_type == 'Project' && Project.find(self.container_id).is_public == 1) || + ( self.container_type == 'Course' && Course.find(self.container_id).is_public == 1) || + self.container_type == 'Principal') + self.__elasticsearch__.update_document + end + end + def delete_attachment_ealasticsearch_index + if self.is_public == 1 && ( (self.container_type == 'Project' && Project.find(self.container_id).is_public == 1) || + ( self.container_type == 'Course' && Course.find(self.container_id).is_public == 1) || + self.container_type == 'Principal') + self.__elasticsearch__.delete_document + end + end end + +# Delete the previous articles index in Elasticsearch +# Attachment.__elasticsearch__.client.indices.delete index: Attachment.index_name rescue nil +# +# # Create the new index with the new mapping +# Attachment.__elasticsearch__.client.indices.create \ +# index: Attachment.index_name, +# body: { settings: Attachment.settings.to_hash, mappings: Attachment.mappings.to_hash } + +# Index all article records from the DB to Elasticsearch +#暂时只做公开课程/项目里的公开资源 和其他的公开资源 +Attachment.where('is_public = 1 and ((container_type in ("Principal")) ' + + 'or (container_type = "Course" and container_id in( SELECT `courses`.id FROM `courses` WHERE (courses.status <> 9 AND courses.is_public = 1)) )'+ + 'or (container_type = "Project" and container_id in(SELECT `projects`.id FROM `projects` WHERE (projects.status <> 9 AND projects.is_public = 1) ))' +')').import diff --git a/app/models/course.rb b/app/models/course.rb index 7288c3b3b..1991c00cb 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -1,10 +1,23 @@ - +require 'elasticsearch/model' class Course < ActiveRecord::Base include Redmine::SafeAttributes STATUS_ACTIVE = 1 STATUS_CLOSED = 5 STATUS_ARCHIVED = 9 + + #elasticsearch + include Elasticsearch::Model + + #elasticsearch kaminari init + Kaminari::Hooks.init + Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari + settings index: { number_of_shards: 1 } do + mappings dynamic: 'false' do + indexes :name, analyzer: 'smartcn',index_options: 'offsets' + indexes :description, analyzer: 'smartcn',index_options: 'offsets' + end + end attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period, :open_student, :enterprise_name #belongs_to :project, :class_name => 'Course', :foreign_key => :extra, primary_key: :identifier @@ -51,9 +64,9 @@ class Course < ActiveRecord::Base validates_length_of :description, :maximum => 10000 before_save :self_validate # 公开课程变成私有课程,所有资源都变成私有 - after_update :update_files_public - after_create :create_board_sync, :act_as_course_activity, :act_as_course_message - before_destroy :delete_all_members + after_update :update_files_public,:update_course_ealasticsearch_index + after_create :create_board_sync, :act_as_course_activity, :act_as_course_message,:create_course_ealasticsearch_index + before_destroy :delete_all_members,:delete_course_ealasticsearch_index safe_attributes 'extra', 'time', @@ -96,6 +109,27 @@ class Course < ActiveRecord::Base end } + def self.search(query) + __elasticsearch__.search( + { + query: { + multi_match: { + query: query, + fields: ['name', 'description'] + } + }, + highlight: { + pre_tags: [''], + post_tags: [''], + fields: { + name: {}, + description: {} + } + } + } + ) + end + def visible?(user=User.current) user.allowed_to?(:view_course, self) end @@ -339,6 +373,38 @@ class Course < ActiveRecord::Base #def name # read_attribute('name') || Project.find_by_identifier(self.extra).try(:name) #end + + # after_commit on: [:create] do + # __elasticsearch__.index_document + # end + # + # after_commit on: [:update] do + # __elasticsearch__.update_document + # end + # + # after_commit on: [:destroy] do + # __elasticsearch__.delete_document + # end + def create_course_ealasticsearch_index + self.__elasticsearch__.index_document + end + def update_course_ealasticsearch_index + self.__elasticsearch__.update_document + end + def delete_course_ealasticsearch_index + self.__elasticsearch__.delete_document + end end +# Delete the previous articles index in Elasticsearch +# Course.__elasticsearch__.client.indices.delete index: Course.index_name rescue nil +# +# # Create the new index with the new mapping +# Course.__elasticsearch__.client.indices.create \ +# index: Course.index_name, +# body: { settings: Course.settings.to_hash, mappings: Course.mappings.to_hash } + +# Index all article records from the DB to Elasticsearch +Course.import + diff --git a/app/models/project.rb b/app/models/project.rb index 0b0420920..53e909776 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - +require 'elasticsearch/model' class Project < ActiveRecord::Base include Redmine::SafeAttributes ProjectType_project = 0 @@ -30,6 +30,18 @@ class Project < ActiveRecord::Base # Specific overidden Activities + #elasticsearch + include Elasticsearch::Model + #elasticsearch kaminari init + Kaminari::Hooks.init + Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari + settings index: { number_of_shards: 1 } do + mappings dynamic: 'false' do + indexes :name, analyzer: 'smartcn',index_options: 'offsets' + indexes :description, analyzer: 'smartcn',index_options: 'offsets' + end + end + has_many :student_works has_many :time_entry_activities has_many :members, :include => [:principal, :roles], :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}" @@ -138,8 +150,9 @@ class Project < ActiveRecord::Base #ActiveModel::Dirty 这里有一个changed方法。对任何对象都可以用 after_save :update_inherited_members, :if => Proc.new {|project| project.inherit_members_changed?} # 创建project之后默认创建一个board,之后的board去掉了board的概念 - after_create :create_board_sync,:acts_as_forge_activities - before_destroy :delete_all_members + after_create :create_board_sync,:acts_as_forge_activities,:create_project_ealasticsearch_index + before_destroy :delete_all_members,:delete_project_ealasticsearch_index + after_update :update_project_ealasticsearch_index def remove_references_before_destroy return if self.id.nil? Watcher.delete_all ['watchable_id = ?', id] @@ -172,7 +185,27 @@ class Project < ActiveRecord::Base } scope :project_entities, -> { where(project_type: ProjectType_project) } scope :course_entities, -> { where(project_type: ProjectType_course) } - + + def self.search(query) + __elasticsearch__.search( + { + query: { + multi_match: { + query: query, + fields: ['name','description'] + } + }, + highlight: { + pre_tags: [''], + post_tags: [''], + fields: { + name: {}, + description: {} + } + } + } + ) + end def new_course self.where('project_type = ?', 1) end @@ -1176,5 +1209,18 @@ class Project < ActiveRecord::Base end + def create_project_ealasticsearch_index + self.__elasticsearch__.index_document + end + def update_project_ealasticsearch_index + self.__elasticsearch__.update_document + end + def delete_project_ealasticsearch_index + self.__elasticsearch__.delete_document + end + + end +Project.import + diff --git a/app/models/user.rb b/app/models/user.rb index 85b9e2591..3818e5d47 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -16,7 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. require "digest/sha1" - +require 'elasticsearch/model' class User < Principal TEACHER = 0 STUDENT = 1 @@ -25,6 +25,19 @@ class User < Principal include Redmine::SafeAttributes seems_rateable_rater + #elasticsearch + include Elasticsearch::Model + #elasticsearch kaminari init + Kaminari::Hooks.init + Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari + settings index: { number_of_shards: 1 } do + mappings dynamic: 'false' do + indexes :login, analyzer: 'smartcn',index_options: 'offsets' + indexes :firstname, analyzer: 'smartcn',index_options: 'offsets' + indexes :lastname, analyzer: 'smartcn',index_options: 'offsets' + end + end + # Different ways of displaying/sorting users USER_FORMATS = { :firstname_lastname => { @@ -64,6 +77,7 @@ class User < Principal }, } + #每日一报、一事一报、不报 MAIL_NOTIFICATION_OPTIONS = [ #['week', :label_user_mail_option_week], @@ -154,6 +168,7 @@ class User < Principal ##### has_many :shares ,:dependent => :destroy + # add by zjc has_one :level, :class_name => 'UserLevels', :dependent => :destroy has_many :memos , :foreign_key => 'author_id' @@ -214,12 +229,12 @@ class User < Principal # validates_email_realness_of :mail before_create :set_mail_notification before_save :update_hashed_password - before_destroy :remove_references_before_destroy + before_destroy :remove_references_before_destroy,:delete_user_ealasticsearch_index # added by fq - after_create :act_as_activity, :add_onclick_time, :act_as_principal_activity + after_create :act_as_activity, :add_onclick_time, :act_as_principal_activity,:create_user_ealasticsearch_index # end # 更新邮箱用户或用户名的同事,同步更新邀请信息 - after_update :update_invite_list + after_update :update_invite_list,:upadte_user_ealasticsearch_index include Trustie::Gitlab::ManageUser @@ -250,7 +265,27 @@ class User < Principal end end } - + def self.search(query) + __elasticsearch__.search( + { + query: { + multi_match: { + query: query, + fields: ['login', 'firstname','lastname'] + } + }, + highlight: { + pre_tags: [''], + post_tags: [''], + fields: { + login: {}, + firstname: {}, + lastname: {} + } + } + } + ) + end # ====================================================================== @@ -1145,4 +1180,32 @@ class AnonymousUser < User def destroy false end + + def create_user_ealasticsearch_index + if self.id != 2 && self.id != 4 + self.__elasticsearch__.index_document + end + end + def update_user_ealasticsearch_index + if self.id != 2 && self.id != 4 + self.__elasticsearch__.update_document + end + end + def delete_user_ealasticsearch_index + if self.id != 2 && self.id != 4 + self.__elasticsearch__.delete_document + end + end end + +# Delete the previous articles index in Elasticsearch +# User.__elasticsearch__.client.indices.delete index: User.index_name rescue nil +# +# # Create the new index with the new mapping +# User.__elasticsearch__.client.indices.create \ +# index: User.index_name, +# body: { settings: User.settings.to_hash, mappings: User.mappings.to_hash } + +# Index all article records from the DB to Elasticsearch +# 匿名用户 角色 和 管理员角色不能被索引 +User.where('id not in (2,4)').import diff --git a/app/views/kaminari/_paginator.html.erb b/app/views/kaminari/_paginator.html.erb index b4d5ee4ea..9a2a02ab9 100644 --- a/app/views/kaminari/_paginator.html.erb +++ b/app/views/kaminari/_paginator.html.erb @@ -8,7 +8,6 @@ -%> <%= paginator.render do -%> + +
+
+
+ + +
+ +
+
+ <%#= render :partial => 'search_user_results',:locals => {:users=>@users}%> +
+
+
+
+ +
+
+ +
+
+
+
diff --git a/app/views/welcome/search.js.erb b/app/views/welcome/search.js.erb new file mode 100644 index 000000000..c53c5d219 --- /dev/null +++ b/app/views/welcome/search.js.erb @@ -0,0 +1,13 @@ +<% case @search_type%> +<% when 'all'%> +$("#searchContent_1").html('<%= escape_javascript(render :partial => 'search_all_results',:locals => {:all_results=> @alls})%>'); +<% when 'user'%> +$("#searchContent_2").html('<%= escape_javascript(render :partial => 'search_user_results',:locals => {:users=>@users})%>'); +<% when 'course'%> +$("#searchContent_3").html('<%= escape_javascript(render :partial => 'search_course_results',:locals => {:courses=>@courses})%>'); +<% when 'project'%> +$("#searchContent_5").html('<%= escape_javascript(render :partial => 'search_project_results',:locals => {:projects=>@projects})%>'); +<% when 'attachment'%> +$("#searchContent_4").html('<%= escape_javascript(render :partial => 'search_attachment_results',:locals => {:attachments=>@attachments})%>'); +<%else%> +<%end %> \ No newline at end of file diff --git a/config/initializers/kaminari_config.rb b/config/initializers/kaminari_config.rb index 1f07c0af5..5d1c9b6ad 100644 --- a/config/initializers/kaminari_config.rb +++ b/config/initializers/kaminari_config.rb @@ -23,10 +23,10 @@ Kaminari.configure do |config| # config.default_per_page = 25 # config.max_per_page = nil - config.window = 0 + config.window = 1 # config.outer_window = 3 - # config.left = 2 - # config.right = 2 + config.left = 2 + config.right = 2 # config.page_method_name = :page # config.param_name = :page end diff --git a/config/routes.rb b/config/routes.rb index 69134e666..b684d1382 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -84,7 +84,7 @@ RedmineApp::Application.routes.draw do resources :homework_users resources :no_uses delete 'no_uses', :to => 'no_uses#delete' - + match 'site_search', :to => 'users#site_search', :as => 'site_search', :via => [:get, :post, :put] resources :apply_project_masters delete 'apply_project_masters', :to => 'apply_project_masters#delete' @@ -457,6 +457,11 @@ RedmineApp::Application.routes.draw do end end end + resources :blog_comments do + collection do + get :search + end + end match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback" match 'users/:id/user_projects', :to => 'users#user_projects', :via => :get #消息 diff --git a/db/schema.rb b/db/schema.rb index 8658c302b..ea8e71df6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,6 +10,7 @@ # 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 => 20151117075939) do create_table "activities", :force => true do |t| @@ -528,26 +529,23 @@ ActiveRecord::Schema.define(:version => 20151117075939) 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| @@ -572,60 +570,6 @@ ActiveRecord::Schema.define(:version => 20151117075939) 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_choice_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_choice_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" @@ -871,6 +815,16 @@ ActiveRecord::Schema.define(:version => 20151117075939) 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" @@ -1103,6 +1057,12 @@ ActiveRecord::Schema.define(:version => 20151117075939) 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" diff --git a/public/images/search_icon_03.png b/public/images/search_icon_03.png new file mode 100644 index 0000000000000000000000000000000000000000..15ff587eb1182bb8cd6274aac895e0be75529839 GIT binary patch literal 1186 zcmeAS@N?(olHy`uVBq!ia0vp^96&6v4 zq}24xJX@vryZ0+8WTx0Eg`4^s_!c;)W@LI)6{QAO`Gq7`WhYyvDB0U7*i={n4aiL` zNmQuF&B-gas<2f8n`;GRgM{^!6u?SKvTcwn`GuBNuFf>#!Gt)CP zF*P$Y)KM@pFf`IP03tJ8LlY}gGb`4?pZBPB7%B|o_|H#M)s)5TT^D5IB>nPO#OXkqMZ z>SAK#WbEc@Y6$ecp^K$~ql=4?k)yejs~OA;Y`gLD2*8txIZAW?5>ATTynKn^_fq~-y0Oc5|^ zFwB+u3(QuRJY5_^DsGir+|TV8D01NAb5${~NYVNRUrEm&#ynk}n@%X$iwQNmy45$F zOxY~C=M#Gb?<-!l=06-i=j~b_H@*Co@t)s)&*xS5txuoJqsufyseShSAH7;x=h|2P z^+|kSXR!5BvdbQ!T_;|Dx8#&8eJ`o~W-d#nQJ1Bh#={2wHVyAqyGb)1G|5Iu9Gup& zVO5#CfMV&lL(xLFEEaXDUwW~iamJT~#eGXRIm)np*S;2^(8$&G;brlQgP&$KFN{;T s8^2dbW!o>kf4RlWo=uusTF)xM@cqAftmdKI;Vst01}vu&j0`b literal 0 HcmV?d00001 diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 6ccfc47f6..753d179e7 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -1326,3 +1326,23 @@ a:hover.link_file_a{ background:url(../images/pic_file.png) 0 -25px no-repeat; c span.author { font-size: 0.9em; color: #888; } .ReplyToMessageInputContainer {width: 582px;float: left;} +/*全站搜索*/ +.blocks {padding:15px; background-color:#ffffff; border:1px solid #dddddd;} +#searchBanner {border-bottom:1px solid #d0d0d0;} +#searchBanner li {float:left; width:88px; margin-right:3px; text-align:center; padding-bottom:10px; font-weight:bold;} +#searchTips {padding:10px 5px; background-color:#f5f6f7;} +.searchBannerActive {border-bottom:3px solid #3498db !important;} +.searchBannerNormal {border-bottom:none !important;} +.searchContent {min-height:74px; border-bottom:1px solid #ededed; padding:13px 0px;} +.searchCourseware {min-height:44px; border-bottom:1px solid #ededed; padding:13px 0px; width:968px;} +.searchCourseImage {width:75px; margin-right:10px;} +.searchContentDes {width:883px;} +.searchTag {font-size:12px; color:#ffffff; background-color:#7ec8e4; height:16px; min-height:16px; max-height:16px; float:left; line-height:16px; padding:0px 3px;} +.undis {display:none;} +.dis {display:inline-block;} +.numRed {color:#FF6600;} +.pageRoll {float:right; border-left:1px solid #dddddd; margin-top:15px;} +.pageCell {border:1px solid #dddddd; padding:5px 12px; float:left; margin-left:-1px; position:relative;} +.pageCell:hover {border:1px solid #3498db; z-index:10;} +.pageCellActive {background-color:#3498db; border:1px solid #3498db !important; position:relative; color:#ffffff;} + From dcd441a9db79c7a2fef1bf4a6d50abb8054ee1b1 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Thu, 26 Nov 2015 16:43:10 +0800 Subject: [PATCH 002/105] =?UTF-8?q?=E5=85=A8=E7=AB=99=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/welcome_controller.rb | 9 ++++++--- app/models/attachment.rb | 9 ++++++++- app/models/board.rb | 2 +- app/models/course.rb | 11 +++++++++-- app/models/document.rb | 2 +- app/models/issue.rb | 2 +- app/models/journals_for_message.rb | 3 ++- app/models/message.rb | 2 +- app/models/news.rb | 2 +- app/models/project.rb | 11 +++++++++-- app/models/project_tags.rb | 2 +- app/models/user.rb | 9 ++++++++- config/application.rb | 3 ++- 13 files changed, 50 insertions(+), 17 deletions(-) diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 4b75a3297..815a44839 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -160,7 +160,8 @@ class WelcomeController < ApplicationController multi_match: { query: @name, type:"most_fields", - fields: ['login^5', 'firstname','lastname','name^5','description','filename^5'] + operator: "or", + fields: ['login', 'firstname','lastname','name','description^0.5','filename'] } }, highlight: { @@ -190,7 +191,8 @@ class WelcomeController < ApplicationController multi_match: { query: @name, type:"most_fields", - fields: ['login^5', 'firstname','lastname','name^5','description','filename^5'] + operator: "or", + fields: ['login', 'firstname','lastname','name','description^0.5','filename'] } }, highlight: { @@ -219,7 +221,8 @@ class WelcomeController < ApplicationController multi_match: { query: @name, type:"most_fields", - fields: ['login^5', 'firstname','lastname','name^5','description','filename^5'] + operator: "or", + fields: ['login', 'firstname','lastname','name','description^0.5','filename'] } }, highlight: { diff --git a/app/models/attachment.rb b/app/models/attachment.rb index a98111b4f..3cb2d9057 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -46,6 +46,7 @@ class Attachment < ActiveRecord::Base settings index: { number_of_shards: 1 } do mappings dynamic: 'false' do indexes :filename, analyzer: 'smartcn',index_options: 'offsets' + indexes :downloads, analyzer: 'smartcn',index_options: 'offsets' end end @@ -109,9 +110,15 @@ class Attachment < ActiveRecord::Base query: { multi_match: { query: query, + type:"most_fields", + operator: "or", fields: ['filename'] } }, + sort:{ + downloads: {order:"desc"}, + _score:{order:"desc"} + }, highlight: { pre_tags: [''], post_tags: [''], @@ -625,4 +632,4 @@ end #暂时只做公开课程/项目里的公开资源 和其他的公开资源 Attachment.where('is_public = 1 and ((container_type in ("Principal")) ' + 'or (container_type = "Course" and container_id in( SELECT `courses`.id FROM `courses` WHERE (courses.status <> 9 AND courses.is_public = 1)) )'+ - 'or (container_type = "Project" and container_id in(SELECT `projects`.id FROM `projects` WHERE (projects.status <> 9 AND projects.is_public = 1) ))' +')').import + 'or (container_type = "Project" and container_id in(SELECT `projects`.id FROM `projects` WHERE (projects.status <> 9 AND projects.is_public = 1) ))' +')').import :force=>true diff --git a/app/models/board.rb b/app/models/board.rb index edcbe0c9d..35a7a72d1 100644 --- a/app/models/board.rb +++ b/app/models/board.rb @@ -17,7 +17,7 @@ class Board < ActiveRecord::Base include Redmine::SafeAttributes - belongs_to :project + belongs_to :project,:touch => true belongs_to :course has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL", :order => "#{Message.table_name}.created_on DESC" has_many :messages, :dependent => :destroy, :order => "#{Message.table_name}.created_on DESC" diff --git a/app/models/course.rb b/app/models/course.rb index 1991c00cb..71cd74633 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -16,6 +16,7 @@ class Course < ActiveRecord::Base mappings dynamic: 'false' do indexes :name, analyzer: 'smartcn',index_options: 'offsets' indexes :description, analyzer: 'smartcn',index_options: 'offsets' + indexes :updated_at, analyzer: 'smartcn',index_options: 'offsets' end end @@ -115,9 +116,15 @@ class Course < ActiveRecord::Base query: { multi_match: { query: query, - fields: ['name', 'description'] + type:"most_fields", + operator: "or", + fields: ['name', 'description^0.5'] } }, + sort: { + updated_at:{order:"desc"}, + _score:{order: "desc" } + }, highlight: { pre_tags: [''], post_tags: [''], @@ -405,6 +412,6 @@ end # body: { settings: Course.settings.to_hash, mappings: Course.mappings.to_hash } # Index all article records from the DB to Elasticsearch -Course.import +Course.where('is_public = 1').import :force=>true diff --git a/app/models/document.rb b/app/models/document.rb index 37983d6d4..b45a74775 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -17,7 +17,7 @@ class Document < ActiveRecord::Base include Redmine::SafeAttributes - belongs_to :project + belongs_to :project,:touch=>true belongs_to :user belongs_to :category, :class_name => "DocumentCategory", :foreign_key => "category_id" include UserScoreHelper diff --git a/app/models/issue.rb b/app/models/issue.rb index 2a6da44c5..edce3310a 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -19,7 +19,7 @@ class Issue < ActiveRecord::Base include Redmine::SafeAttributes include Redmine::Utils::DateCalculation include UserScoreHelper - belongs_to :project + belongs_to :project,:touch=> true belongs_to :tracker belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id' belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 5e40267cb..14760a631 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -21,7 +21,8 @@ class JournalsForMessage < ActiveRecord::Base after_destroy :delete_kindeditor_assets belongs_to :project, :foreign_key => 'jour_id', - :conditions => "#{self.table_name}.jour_type = 'Project' " + :conditions => "#{self.table_name}.jour_type = 'Project' ",:touch => true + belongs_to :course, :foreign_key => 'jour_id' diff --git a/app/models/message.rb b/app/models/message.rb index 7af59815b..c5371097a 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -20,7 +20,7 @@ class Message < ActiveRecord::Base include UserScoreHelper include ApplicationHelper has_many_kindeditor_assets :assets, :dependent => :destroy - belongs_to :board + belongs_to :board,:touch => true belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' has_many :praise_tread, as: :praise_tread_object, dependent: :destroy diff --git a/app/models/news.rb b/app/models/news.rb index e9b8b5314..aa5d6df1f 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -17,7 +17,7 @@ class News < ActiveRecord::Base include Redmine::SafeAttributes - belongs_to :project + belongs_to :project,:touch => true include ApplicationHelper has_many_kindeditor_assets :assets, :dependent => :destroy #added by nwb diff --git a/app/models/project.rb b/app/models/project.rb index 53e909776..92e6a4d0b 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -39,6 +39,7 @@ class Project < ActiveRecord::Base mappings dynamic: 'false' do indexes :name, analyzer: 'smartcn',index_options: 'offsets' indexes :description, analyzer: 'smartcn',index_options: 'offsets' + indexes :updated_on, analyzer: 'smartcn',index_options: 'offsets' end end @@ -192,9 +193,15 @@ class Project < ActiveRecord::Base query: { multi_match: { query: query, - fields: ['name','description'] + type:"most_fields", + operator: "and", + fields: ['name','description^0.5'] } }, + sort: { + updated_on:{order: "desc" }, + _score:{order: "desc" } + }, highlight: { pre_tags: [''], post_tags: [''], @@ -1222,5 +1229,5 @@ class Project < ActiveRecord::Base end -Project.import +Project.where('is_public = 1').import :force=>true diff --git a/app/models/project_tags.rb b/app/models/project_tags.rb index 16de1ea45..bcf666fb5 100644 --- a/app/models/project_tags.rb +++ b/app/models/project_tags.rb @@ -2,7 +2,7 @@ class ProjectTags < ActiveRecord::Base attr_accessible :description, :project_id, :tag_id, :user_id ####################################################################################################添加代码 - belongs_to :project + belongs_to :project,:touch => true belongs_to :tag belongs_to :user diff --git a/app/models/user.rb b/app/models/user.rb index 3818e5d47..fc18313a0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -35,6 +35,7 @@ class User < Principal indexes :login, analyzer: 'smartcn',index_options: 'offsets' indexes :firstname, analyzer: 'smartcn',index_options: 'offsets' indexes :lastname, analyzer: 'smartcn',index_options: 'offsets' + indexes :last_login_on, analyzer: 'smartcn',index_options: 'offsets' end end @@ -271,9 +272,15 @@ class User < Principal query: { multi_match: { query: query, + type:"most_fields", + operator: "or", fields: ['login', 'firstname','lastname'] } }, + sort:{ + last_login_on: {order:"desc"}, + _score:{order:"desc"} + }, highlight: { pre_tags: [''], post_tags: [''], @@ -1208,4 +1215,4 @@ end # Index all article records from the DB to Elasticsearch # 匿名用户 角色 和 管理员角色不能被索引 -User.where('id not in (2,4)').import +User.where('id not in (2,4)').import :force=>true diff --git a/config/application.rb b/config/application.rb index 6e4a2983a..14793fcac 100644 --- a/config/application.rb +++ b/config/application.rb @@ -2,7 +2,7 @@ require File.expand_path('../boot', __FILE__) require 'rails/all' require 'sprockets/railtie' - +require 'elasticsearch/model' if defined?(Bundler) # If you precompile assets before deploying to production, use this line Bundler.require(*Rails.groups(:assets => %w(development test))) @@ -73,6 +73,7 @@ module RedmineApp end config.after_initialize do + Elasticsearch::Client.new hosts: ['localhost:9200', 'localhost:9201'], retry_on_failure: true,log:true end if File.exists?(File.join(File.dirname(__FILE__), 'additional_environment.rb')) From ee47187a6148f70157a160faa97ae34c15e6b09b Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 27 Nov 2015 09:52:51 +0800 Subject: [PATCH 003/105] =?UTF-8?q?=E5=85=A8=E7=AB=99=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 2 +- app/models/project.rb | 14 ++++++++++---- app/models/user.rb | 7 ++++--- config/application.rb | 8 +++++++- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/app/models/course.rb b/app/models/course.rb index 71cd74633..e73257033 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -16,7 +16,7 @@ class Course < ActiveRecord::Base mappings dynamic: 'false' do indexes :name, analyzer: 'smartcn',index_options: 'offsets' indexes :description, analyzer: 'smartcn',index_options: 'offsets' - indexes :updated_at, analyzer: 'smartcn',index_options: 'offsets' + indexes :updated_at, analyzer: 'smartcn',index_options: 'offsets',type:"date" end end diff --git a/app/models/project.rb b/app/models/project.rb index 92e6a4d0b..0453f1164 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -39,7 +39,7 @@ class Project < ActiveRecord::Base mappings dynamic: 'false' do indexes :name, analyzer: 'smartcn',index_options: 'offsets' indexes :description, analyzer: 'smartcn',index_options: 'offsets' - indexes :updated_on, analyzer: 'smartcn',index_options: 'offsets' + indexes :updated_on, analyzer: 'smartcn',index_options: 'offsets', type:'date' end end @@ -195,12 +195,12 @@ class Project < ActiveRecord::Base query: query, type:"most_fields", operator: "and", - fields: ['name','description^0.5'] + fields: ['name'] } }, sort: { - updated_on:{order: "desc" }, - _score:{order: "desc" } + _score:{order: "desc" }, + updated_on:{order: "desc" } }, highlight: { pre_tags: [''], @@ -1217,13 +1217,19 @@ class Project < ActiveRecord::Base def create_project_ealasticsearch_index + if self.is_public == 1 self.__elasticsearch__.index_document + end end def update_project_ealasticsearch_index + if self.is_public == 1 self.__elasticsearch__.update_document + end end def delete_project_ealasticsearch_index + if self.is_public == 1 self.__elasticsearch__.delete_document + end end diff --git a/app/models/user.rb b/app/models/user.rb index fc18313a0..15578f6db 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -35,7 +35,8 @@ class User < Principal indexes :login, analyzer: 'smartcn',index_options: 'offsets' indexes :firstname, analyzer: 'smartcn',index_options: 'offsets' indexes :lastname, analyzer: 'smartcn',index_options: 'offsets' - indexes :last_login_on, analyzer: 'smartcn',index_options: 'offsets' + indexes :last_login_on, analyzer: 'smartcn',index_options: 'offsets',type: 'date' + indexes :id, analyzer: 'smartcn',index_options: 'offsets' end end @@ -278,8 +279,8 @@ class User < Principal } }, sort:{ - last_login_on: {order:"desc"}, - _score:{order:"desc"} + _score:{order:"desc"}, + last_login_on: {order:"desc"} }, highlight: { pre_tags: [''], diff --git a/config/application.rb b/config/application.rb index 14793fcac..5f9c9d67e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -73,7 +73,13 @@ module RedmineApp end config.after_initialize do - Elasticsearch::Client.new hosts: ['localhost:9200', 'localhost:9201'], retry_on_failure: true,log:true + if RbConfig::CONFIG['target_os'] == 'mswin32' + Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true + elsif RbConfig::CONFIG['target_os'] == 'linux' && ["testtrustie11","agent12"].include?(`hostname`) + Elasticsearch::Client.new hosts: ['192.168.80.11:9200','192.168.80.12:9200'], retry_on_failure: true + elsif RbConfig::CONFIG['target_os'] == 'linux' && ["trustie168","trustieserver14","trustieserver16","Trustie18"].include?(`hostname`) + Elasticsearch::Client.new hosts: ['192.168.80.168:9200','192.168.80.14:9200','192.168.80.16:9200','192.168.80.18:9200'], retry_on_failure: true + end end if File.exists?(File.join(File.dirname(__FILE__), 'additional_environment.rb')) From 7cb39d1754d500d95eb9cab6a019634a11c01833 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 27 Nov 2015 10:40:58 +0800 Subject: [PATCH 004/105] =?UTF-8?q?=E5=85=A8=E7=AB=99=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 9 ++++++--- app/models/course.rb | 4 ++-- app/models/project.rb | 4 ++-- app/models/user.rb | 4 ++-- lib/tasks/elasticsearch.rake | 1 + 5 files changed, 13 insertions(+), 9 deletions(-) create mode 100644 lib/tasks/elasticsearch.rake diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 3cb2d9057..dea4e404e 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -104,6 +104,9 @@ class Attachment < ActiveRecord::Base " LEFT JOIN #{News.table_name} ON #{Attachment.table_name}.container_type='News' AND (#{News.table_name}.project_id in "+self.public_project_id + " OR #{News.table_name}.course_id in " + self.public_course_id + ")" + " LEFT JOIN #{HomeworkAttach.table_name} ON #{Attachment.table_name}.container_type='HomeworkAttach' AND #{HomeworkAttach.table_name}.bid_id in "+self.public_bid_id) } + scope :indexable,lambda { where('is_public = 1 and ((container_type in ("Principal")) ' + + 'or (container_type = "Course" and container_id in( SELECT `courses`.id FROM `courses` WHERE (courses.status <> 9 AND courses.is_public = 1)) )'+ + 'or (container_type = "Project" and container_id in(SELECT `projects`.id FROM `projects` WHERE (projects.status <> 9 AND projects.is_public = 1) ))' +')')} #用于elastic建索引的scope def self.search(query) __elasticsearch__.search( { @@ -630,6 +633,6 @@ end # Index all article records from the DB to Elasticsearch #暂时只做公开课程/项目里的公开资源 和其他的公开资源 -Attachment.where('is_public = 1 and ((container_type in ("Principal")) ' + - 'or (container_type = "Course" and container_id in( SELECT `courses`.id FROM `courses` WHERE (courses.status <> 9 AND courses.is_public = 1)) )'+ - 'or (container_type = "Project" and container_id in(SELECT `projects`.id FROM `projects` WHERE (projects.status <> 9 AND projects.is_public = 1) ))' +')').import :force=>true +#Attachment.where('is_public = 1 and ((container_type in ("Principal")) ' + +# 'or (container_type = "Course" and container_id in( SELECT `courses`.id FROM `courses` WHERE (courses.status <> 9 AND courses.is_public = 1)) )'+ +# 'or (container_type = "Project" and container_id in(SELECT `projects`.id FROM `projects` WHERE (projects.status <> 9 AND projects.is_public = 1) ))' +')').import :force=>true diff --git a/app/models/course.rb b/app/models/course.rb index e73257033..8f7c990ab 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -109,7 +109,7 @@ class Course < ActiveRecord::Base where(" LOWER(name) LIKE :p ", :p => pattern) end } - + scope :indexable,lambda { where('is_public = 1') } def self.search(query) __elasticsearch__.search( { @@ -412,6 +412,6 @@ end # body: { settings: Course.settings.to_hash, mappings: Course.mappings.to_hash } # Index all article records from the DB to Elasticsearch -Course.where('is_public = 1').import :force=>true +#Course.where('is_public = 1').import :force=>true diff --git a/app/models/project.rb b/app/models/project.rb index 0453f1164..034873596 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -186,7 +186,7 @@ class Project < ActiveRecord::Base } scope :project_entities, -> { where(project_type: ProjectType_project) } scope :course_entities, -> { where(project_type: ProjectType_course) } - + scope :indexable,lambda { where('is_public = 1')} #用于elastic建索引的scope def self.search(query) __elasticsearch__.search( { @@ -1235,5 +1235,5 @@ class Project < ActiveRecord::Base end -Project.where('is_public = 1').import :force=>true +#Project.where('is_public = 1').import :force=>true diff --git a/app/models/user.rb b/app/models/user.rb index 15578f6db..bf2bca6db 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -249,7 +249,7 @@ class User < Principal where("#{User.table_name}.id NOT IN (SELECT gu.user_id FROM #{table_name_prefix}groups_users#{table_name_suffix} gu WHERE gu.group_id = ?)", group_id) } scope :sorted, lambda { order(*User.fields_for_order_statement)} - + scope :indexable,lambda { where('id not in (2,4)')} #用于elastic建索引的scope,id为2是匿名用户,4是管理员,不能被索引 scope :like, lambda {|arg, type| if arg.blank? where(nil) @@ -1216,4 +1216,4 @@ end # Index all article records from the DB to Elasticsearch # 匿名用户 角色 和 管理员角色不能被索引 -User.where('id not in (2,4)').import :force=>true +#User.where('id not in (2,4)').import :force=>true diff --git a/lib/tasks/elasticsearch.rake b/lib/tasks/elasticsearch.rake new file mode 100644 index 000000000..1242abc60 --- /dev/null +++ b/lib/tasks/elasticsearch.rake @@ -0,0 +1 @@ +require 'elasticsearch/rails/tasks/import' \ No newline at end of file From f448b5f8e2ea2129f3d2e1c02e6717b2b893b947 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 27 Nov 2015 11:00:06 +0800 Subject: [PATCH 005/105] =?UTF-8?q?=E5=85=A8=E7=AB=99=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/application.rb b/config/application.rb index 5f9c9d67e..fccf40742 100644 --- a/config/application.rb +++ b/config/application.rb @@ -76,9 +76,9 @@ module RedmineApp if RbConfig::CONFIG['target_os'] == 'mswin32' Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true elsif RbConfig::CONFIG['target_os'] == 'linux' && ["testtrustie11","agent12"].include?(`hostname`) - Elasticsearch::Client.new hosts: ['192.168.80.11:9200','192.168.80.12:9200'], retry_on_failure: true + Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.11:9200','192.168.80.12:9200'], retry_on_failure: true elsif RbConfig::CONFIG['target_os'] == 'linux' && ["trustie168","trustieserver14","trustieserver16","Trustie18"].include?(`hostname`) - Elasticsearch::Client.new hosts: ['192.168.80.168:9200','192.168.80.14:9200','192.168.80.16:9200','192.168.80.18:9200'], retry_on_failure: true + Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.168:9200','192.168.80.14:9200','192.168.80.16:9200','192.168.80.18:9200'], retry_on_failure: true end end From 768aff89da69c187e3db503d138a7a9238b7e29b Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 27 Nov 2015 11:09:01 +0800 Subject: [PATCH 006/105] =?UTF-8?q?=E5=85=A8=E7=AB=99=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/config/application.rb b/config/application.rb index fccf40742..fcf2d97d4 100644 --- a/config/application.rb +++ b/config/application.rb @@ -75,10 +75,14 @@ module RedmineApp config.after_initialize do if RbConfig::CONFIG['target_os'] == 'mswin32' Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true - elsif RbConfig::CONFIG['target_os'] == 'linux' && ["testtrustie11","agent12"].include?(`hostname`) + elsif RbConfig::CONFIG['target_os'] == 'linux' && ["fast76"].include?(`hostname`.gsub("\n","")) + Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true + elsif RbConfig::CONFIG['target_os'] == 'linux' && ["testtrustie11","agent12"].include?(`hostname`.gsub("\n","")) Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.11:9200','192.168.80.12:9200'], retry_on_failure: true - elsif RbConfig::CONFIG['target_os'] == 'linux' && ["trustie168","trustieserver14","trustieserver16","Trustie18"].include?(`hostname`) + elsif RbConfig::CONFIG['target_os'] == 'linux' && ["trustie168","trustieserver14","trustieserver16","Trustie18"].include?(`hostname`.gsub("\n","")) Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.168:9200','192.168.80.14:9200','192.168.80.16:9200','192.168.80.18:9200'], retry_on_failure: true + else + Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true end end From 6be917e052fbe162964bce7372ed1698b0c4206d Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 27 Nov 2015 11:34:42 +0800 Subject: [PATCH 007/105] =?UTF-8?q?=E5=85=A8=E7=AB=99=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/application.rb b/config/application.rb index fcf2d97d4..69b88a76d 100644 --- a/config/application.rb +++ b/config/application.rb @@ -73,10 +73,10 @@ module RedmineApp end config.after_initialize do - if RbConfig::CONFIG['target_os'] == 'mswin32' + if RbConfig::CONFIG['target_os'] == 'mingw32' Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true elsif RbConfig::CONFIG['target_os'] == 'linux' && ["fast76"].include?(`hostname`.gsub("\n","")) - Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true + Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true,log:true elsif RbConfig::CONFIG['target_os'] == 'linux' && ["testtrustie11","agent12"].include?(`hostname`.gsub("\n","")) Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.11:9200','192.168.80.12:9200'], retry_on_failure: true elsif RbConfig::CONFIG['target_os'] == 'linux' && ["trustie168","trustieserver14","trustieserver16","Trustie18"].include?(`hostname`.gsub("\n","")) From bf1c1cf0a1082988d72e5597ed226a387ec7d579 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 27 Nov 2015 13:07:09 +0800 Subject: [PATCH 008/105] =?UTF-8?q?=E5=85=A8=E7=AB=99=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index a67fcfaea..ee1342df5 100644 --- a/Gemfile +++ b/Gemfile @@ -34,6 +34,8 @@ gem 'chinese_pinyin' # gem 'sunspot_solr' # gem 'sunspot' # gem 'progress_bar' +gem 'ansi' +gem 'win32console' gem 'kaminari' gem 'elasticsearch-model' gem 'elasticsearch-rails' From 0992ddd0f6d1d7b98fe089ba88a42edb8c2d243f Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 27 Nov 2015 13:07:25 +0800 Subject: [PATCH 009/105] =?UTF-8?q?=E5=85=A8=E7=AB=99=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index 69b88a76d..61f73ee3d 100644 --- a/config/application.rb +++ b/config/application.rb @@ -74,7 +74,7 @@ module RedmineApp config.after_initialize do if RbConfig::CONFIG['target_os'] == 'mingw32' - Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true + Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true,log:true elsif RbConfig::CONFIG['target_os'] == 'linux' && ["fast76"].include?(`hostname`.gsub("\n","")) Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true,log:true elsif RbConfig::CONFIG['target_os'] == 'linux' && ["testtrustie11","agent12"].include?(`hostname`.gsub("\n","")) From c28b8bab1486ea0025f0127cd79e301b89b23741 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 27 Nov 2015 13:09:20 +0800 Subject: [PATCH 010/105] =?UTF-8?q?=E5=85=A8=E7=AB=99=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index ee1342df5..0125e9d60 100644 --- a/Gemfile +++ b/Gemfile @@ -35,7 +35,7 @@ gem 'chinese_pinyin' # gem 'sunspot' # gem 'progress_bar' gem 'ansi' -gem 'win32console' + gem 'kaminari' gem 'elasticsearch-model' gem 'elasticsearch-rails' @@ -44,6 +44,7 @@ group :development do gem 'grape-swagger' gem 'better_errors', '~> 1.1.0' gem 'rack-mini-profiler', '~> 0.9.3' + gem 'win32console' end group :development, :test do From 3d9f6321055bec0466e02e7676f5c7c9b3d471ca Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 27 Nov 2015 14:42:25 +0800 Subject: [PATCH 011/105] =?UTF-8?q?=E5=85=A8=E7=AB=99=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/elasticsearch_batch_op.rake | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/tasks/elasticsearch_batch_op.rake diff --git a/lib/tasks/elasticsearch_batch_op.rake b/lib/tasks/elasticsearch_batch_op.rake new file mode 100644 index 000000000..fb2c638bc --- /dev/null +++ b/lib/tasks/elasticsearch_batch_op.rake @@ -0,0 +1,31 @@ +namespace :importer do + task :importuser do + ENV['CLASS']='User' + ENV['SCOPE']='indexable' + ENV['FORCE']='y' + ENV['BATCH']='1000' + Rake::Task["elasticsearch:import:model"].invoke + end + task :importproject do + + ENV['CLASS']='Project' + ENV['SCOPE']='indexable' + ENV['FORCE']='y' + ENV['BATCH']='1000' + Rake::Task["elasticsearch:import:model"].invoke + end + task :importcourse do + ENV['CLASS']='Course' + ENV['SCOPE']='indexable' + ENV['FORCE']='y' + ENV['BATCH']='1000' + Rake::Task["elasticsearch:import:model"].invoke + end + task :importattachment do + ENV['CLASS']='Attachment' + ENV['SCOPE']='indexable' + ENV['FORCE']='y' + ENV['BATCH']='1000' + Rake::Task["elasticsearch:import:model"].invoke + end +end \ No newline at end of file From e710f443c2dfc61d8711b872363cca32dab80417 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 27 Nov 2015 15:17:17 +0800 Subject: [PATCH 012/105] =?UTF-8?q?=E5=85=A8=E7=AB=99=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 5 +++-- app/models/course.rb | 12 ++++++++++-- app/models/project.rb | 4 ++-- app/models/user.rb | 1 - 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index dea4e404e..ebabbf944 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -119,8 +119,9 @@ class Attachment < ActiveRecord::Base } }, sort:{ - downloads: {order:"desc"}, - _score:{order:"desc"} + _score:{order:"desc"}, + downloads: {order:"desc"} + }, highlight: { pre_tags: [''], diff --git a/app/models/course.rb b/app/models/course.rb index 8f7c990ab..0bd14d38b 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -122,8 +122,9 @@ class Course < ActiveRecord::Base } }, sort: { - updated_at:{order:"desc"}, - _score:{order: "desc" } + _score:{order: "desc" }, + updated_at:{order:"desc"} + }, highlight: { pre_tags: [''], @@ -393,13 +394,20 @@ class Course < ActiveRecord::Base # __elasticsearch__.delete_document # end def create_course_ealasticsearch_index + if self.is_public == 1 self.__elasticsearch__.index_document + end end def update_course_ealasticsearch_index + if self.is_public == 1 self.__elasticsearch__.update_document + end end def delete_course_ealasticsearch_index + + if self.is_public == 1 self.__elasticsearch__.delete_document + end end end diff --git a/app/models/project.rb b/app/models/project.rb index 034873596..847c536da 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -194,8 +194,8 @@ class Project < ActiveRecord::Base multi_match: { query: query, type:"most_fields", - operator: "and", - fields: ['name'] + operator: "or", + fields: ['name','description^0.5'] } }, sort: { diff --git a/app/models/user.rb b/app/models/user.rb index bf2bca6db..ced747af8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -36,7 +36,6 @@ class User < Principal indexes :firstname, analyzer: 'smartcn',index_options: 'offsets' indexes :lastname, analyzer: 'smartcn',index_options: 'offsets' indexes :last_login_on, analyzer: 'smartcn',index_options: 'offsets',type: 'date' - indexes :id, analyzer: 'smartcn',index_options: 'offsets' end end From c3a27151ca0fb54f2400cfa934749db7b3c0f773 Mon Sep 17 00:00:00 2001 From: "Gan Yi.ang" Date: Fri, 27 Nov 2015 15:21:58 +0800 Subject: [PATCH 013/105] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=5Frevision?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/repositories/_revisions.html.erb | 47 +++++++++++++++------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/app/views/repositories/_revisions.html.erb b/app/views/repositories/_revisions.html.erb index 50c973fb4..b72a05876 100644 --- a/app/views/repositories/_revisions.html.erb +++ b/app/views/repositories/_revisions.html.erb @@ -1,16 +1,16 @@ <%= form_tag( {:controller => 'repositories', :action => 'diff', :id => project, :repository_id => @repository.identifier_param, :path => to_path_param(path)}, - :method => :get + :method => :get ) do %> - - - - - - + + + + + + @@ -24,6 +24,7 @@ <%= textilizable(truncate_at_line_break(changeset.message)) %> +
<%= h truncate(changeset.short_id.to_s, :length => 20) %>
@@ -31,13 +32,29 @@ @@ -50,7 +67,7 @@

    - <%= pagination_links_full commits_pages, commits_count, :per_page_links => false, :remote => false, :flag => true%> + <%= pagination_links_full commits_pages, commits_count, :per_page_links => false, :remote => false, :flag => true %>
<% end %> From d9928096236dc56ca14ff6814fef3989769026c6 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 27 Nov 2015 17:19:05 +0800 Subject: [PATCH 014/105] =?UTF-8?q?=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/schema.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 603ca6857..87342bf9c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -605,7 +605,7 @@ ActiveRecord::Schema.define(:version => 20151127011351) do end create_table "exercise_questions", :force => true do |t| - t.string "question_title" + t.text "question_title" t.integer "question_type" t.integer "question_number" t.integer "exercise_id" @@ -634,7 +634,7 @@ ActiveRecord::Schema.define(:version => 20151127011351) do end create_table "exercises", :force => true do |t| - t.string "exercise_name" + t.text "exercise_name" t.text "exercise_description" t.integer "course_id" t.integer "exercise_status" @@ -1151,10 +1151,6 @@ ActiveRecord::Schema.define(:version => 20151127011351) do create_table "org_members", :force => true do |t| t.integer "user_id" t.integer "organization_id" -<<<<<<< HEAD - t.string "role" -======= ->>>>>>> 1ae514ca4857d7e2ad53b338731c1e01f899fb4d t.datetime "created_at", :null => false t.datetime "updated_at", :null => false end From 879dee0cd6f4ee97b8f43fa6429a991bc187e73d Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 27 Nov 2015 17:27:55 +0800 Subject: [PATCH 015/105] =?UTF-8?q?=E5=85=B3=E9=97=AD=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E5=85=B3=E8=81=94=E9=A1=B9=E7=9B=AE=E6=88=96=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=EF=BC=8C=E5=88=B7=E6=96=B0=E6=95=B4=E4=B8=AA?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/organizations/_join_course_menu.html.erb | 1 + app/views/organizations/_join_project_menu.html.erb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/views/organizations/_join_course_menu.html.erb b/app/views/organizations/_join_course_menu.html.erb index e66d0bcce..d875550de 100644 --- a/app/views/organizations/_join_course_menu.html.erb +++ b/app/views/organizations/_join_course_menu.html.erb @@ -13,6 +13,7 @@ $(".resourcePopupClose").click(function(){ + location.reload(); $(".resourceSharePopup").css("display","none"); }); }); diff --git a/app/views/organizations/_join_project_menu.html.erb b/app/views/organizations/_join_project_menu.html.erb index 765b4b23a..e13e1416e 100644 --- a/app/views/organizations/_join_project_menu.html.erb +++ b/app/views/organizations/_join_project_menu.html.erb @@ -13,6 +13,7 @@ $(".resourcePopupClose").click(function(){ + location.reload(); $(".resourceSharePopup").css("display","none"); }); }); From b6166120326338cb53e5a92d57efbc39bcd186a3 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 27 Nov 2015 17:57:17 +0800 Subject: [PATCH 016/105] =?UTF-8?q?=E6=B5=8B=E9=AA=8C=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E7=9A=84=E8=BF=98=E5=8E=9F=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E6=9A=82=E6=97=B6=E9=9A=90=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_edit_head.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/exercise/_edit_head.html.erb b/app/views/exercise/_edit_head.html.erb index b69f52a56..64f34b5aa 100644 --- a/app/views/exercise/_edit_head.html.erb +++ b/app/views/exercise/_edit_head.html.erb @@ -20,7 +20,7 @@ 保存 - + <%= l(:button_cancel)%> @@ -35,6 +35,6 @@ $("#exercise_time").val("<%=exercise.time if exercise.time!= -1 %>"); $("#exercise_publish_time").val("<%= Time.parse(format_time(exercise.publish_time)).strftime("%Y-%m-%d") if !exercise.publish_time.nil?%>"); /*$("#exercise_description").text("<%#=exercise.exercise_description.html_safe %>");*/ - document.getElementById("exercise_description").innerText = <%=exercise.exercise_description.html_safe %>; + document.getElementById("exercise_description").innerHTML = <%=exercise.exercise_description.html_safe %>; } \ No newline at end of file From e9caf0980a644ec62739b16facdee31e318ed1b0 Mon Sep 17 00:00:00 2001 From: "Gan Yi.ang" Date: Fri, 27 Nov 2015 17:57:43 +0800 Subject: [PATCH 017/105] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E7=94=A8=E6=88=B7syn?= =?UTF-8?q?c=5Fgitlab=5Fuser=EF=BC=8C=E5=8A=A0=E5=BC=82=E5=B8=B8=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/sync_gitlab_user.rake | 34 +++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/tasks/sync_gitlab_user.rake b/lib/tasks/sync_gitlab_user.rake index c932ca36c..fb84f5f08 100644 --- a/lib/tasks/sync_gitlab_user.rake +++ b/lib/tasks/sync_gitlab_user.rake @@ -6,24 +6,30 @@ namespace :gitlab do users = User.find_by_sql("select * from users where gid is null") s = Trustie::Gitlab::Sync.new g = Gitlab.client + logger = Logger.new('./log/add_gid.log', 'daily') #按天生成 users.each do |user| - us = g.get("/users?search=#{user.mail}") - puts user.mail - if us.blank? - puts "55555555555555555" - s.sync_user(user) - else - # 解决查询的时候出现多值的情况,比如:123@163.com和g123@163.com - puts "66666666666666666666" - puts user.id - if Array === us - us.each do |u| - if u.email == user.mail - user.gid = u.id - user.save + begin + us = g.get("/users?search=#{user.mail}") + puts user.mail + if us.blank? + puts "55555555555555555" + s.sync_user(user) + else + # 解决查询的时候出现多值的情况,比如:123@163.com和g123@163.com + puts "66666666666666666666" + puts user.id + if Array === us + us.each do |u| + if u.email == user.mail + user.gid = u.id + user.save + end end end end + rescue => e + logger.error("userid=#{user.id},mail=#{user.mail},login=#{user.login},error=#{e}") + puts e end end end From f91918145dfe9d42d15196d289cdaaa45ec3ac83 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 27 Nov 2015 18:00:26 +0800 Subject: [PATCH 018/105] 0 --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index 55a97ee20..87342bf9c 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 => 20151126160252) do +ActiveRecord::Schema.define(:version => 20151127011351) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false From 487c6bad0923776f37b09a98c533c182fa730f20 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 27 Nov 2015 18:08:38 +0800 Subject: [PATCH 019/105] schema.rb --- db/schema.rb | 51 +++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 603ca6857..6e007d6be 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -543,26 +543,23 @@ ActiveRecord::Schema.define(:version => 20151127011351) 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| @@ -605,7 +602,7 @@ ActiveRecord::Schema.define(:version => 20151127011351) do end create_table "exercise_questions", :force => true do |t| - t.string "question_title" + t.text "question_title" t.integer "question_type" t.integer "question_number" t.integer "exercise_id" @@ -634,7 +631,7 @@ ActiveRecord::Schema.define(:version => 20151127011351) do end create_table "exercises", :force => true do |t| - t.string "exercise_name" + t.text "exercise_name" t.text "exercise_description" t.integer "course_id" t.integer "exercise_status" @@ -892,6 +889,16 @@ ActiveRecord::Schema.define(:version => 20151127011351) 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" @@ -1151,10 +1158,6 @@ ActiveRecord::Schema.define(:version => 20151127011351) do create_table "org_members", :force => true do |t| t.integer "user_id" t.integer "organization_id" -<<<<<<< HEAD - t.string "role" -======= ->>>>>>> 1ae514ca4857d7e2ad53b338731c1e01f899fb4d t.datetime "created_at", :null => false t.datetime "updated_at", :null => false end From ae9f1c704a4a52d26605d070a9ea59778c97daa6 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 27 Nov 2015 18:36:38 +0800 Subject: [PATCH 020/105] =?UTF-8?q?500=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/comment.rb | 6 ++++-- app/models/message.rb | 16 +++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index 9de25c50d..473283dc0 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -81,8 +81,10 @@ class Comment < ActiveRecord::Base # 课程成员得分(英雄榜) def act_as_student_score - unless self.author.allowed_to?(:as_teacher, self.commented.course) - course_member_score(self.commented.course.id, self.author_id, "NewReply") + if self.commented.course + unless self.author.allowed_to?(:as_teacher, self.commented.course) + course_member_score(self.commented.course.id, self.author_id, "NewReply") + end end end diff --git a/app/models/message.rb b/app/models/message.rb index 21e5e1c71..3f9057346 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -287,13 +287,15 @@ class Message < ActiveRecord::Base # 课程成员得分(英雄榜) def act_as_student_score - unless self.author.allowed_to?(:as_teacher, self.course) - if self.parent_id.nil? - # 发帖 - course_member_score(self.course.id, self.author_id, "Message") - else - # 回帖 - course_member_score(self.course.id, self.author_id, "MessageReply") + if self.course + unless self.author.allowed_to?(:as_teacher, self.course) + if self.parent_id.nil? + # 发帖 + course_member_score(self.course.id, self.author_id, "Message") + else + # 回帖 + course_member_score(self.course.id, self.author_id, "MessageReply") + end end end end From 27490669085c39c0b8753b701098a328be303baa Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 27 Nov 2015 18:43:22 +0800 Subject: [PATCH 021/105] =?UTF-8?q?=E5=8D=95=E4=B8=AA=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/sync_sigle_rep.rake b/lib/tasks/sync_sigle_rep.rake index e68e37ee8..57aaaabcb 100644 --- a/lib/tasks/sync_sigle_rep.rake +++ b/lib/tasks/sync_sigle_rep.rake @@ -9,7 +9,7 @@ namespace :sync_rep do 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 + puts project.id unless count > 1 rep.identifier s = Trustie::Gitlab::Sync.new From 96290ad97559cd5067aedfc5866160d0e9600c4f Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 27 Nov 2015 18:47:19 +0800 Subject: [PATCH 022/105] Merge branch 'szzh' into dev_zanle Conflicts: app/models/attachment.rb db/schema.rb --- app/models/course.rb | 26 +- app/models/user.rb | 34 +- db/schema.rb | 3785 +++++++++++++++++++++--------------------- 3 files changed, 1929 insertions(+), 1916 deletions(-) diff --git a/app/models/course.rb b/app/models/course.rb index 77850a89d..edc5e105b 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -400,19 +400,31 @@ class Course < ActiveRecord::Base # end def create_course_ealasticsearch_index if self.is_public == 1 - self.__elasticsearch__.index_document + self.__elasticsearch__.index_document end end def update_course_ealasticsearch_index - if self.is_public == 1 - self.__elasticsearch__.update_document + if self.is_public == 1 #如果是初次更新成为公开的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性 + begin + self.__elasticsearch__.update_document + rescue => e + self.__elasticsearch__.index_document + end + else #如果是更新成为私有的,那么索引就要被删除 + begin + self.__elasticsearch__.delete_document + rescue => e + + end end end - def delete_course_ealasticsearch_index - if self.is_public == 1 - self.__elasticsearch__.delete_document - end + def delete_course_ealasticsearch_index + begin + self.__elasticsearch__.delete_document + rescue => e + + end end end diff --git a/app/models/user.rb b/app/models/user.rb index 17a8f32ba..cdec39a3d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -243,7 +243,7 @@ class User < Principal after_create :act_as_activity, :add_onclick_time, :act_as_principal_activity,:create_user_ealasticsearch_index # end # 更新邮箱用户或用户名的同事,同步更新邀请信息 - after_update :update_invite_list,:upadte_user_ealasticsearch_index + after_update :update_invite_list,:update_user_ealasticsearch_index include Trustie::Gitlab::ManageUser @@ -1161,6 +1161,23 @@ class User < Principal end end + + def create_user_ealasticsearch_index + if self.id != 2 && self.id != 4 + self.__elasticsearch__.index_document + end + end + def update_user_ealasticsearch_index + if self.id != 2 && self.id != 4 + self.__elasticsearch__.update_document + end + end + def delete_user_ealasticsearch_index + if self.id != 2 && self.id != 4 + self.__elasticsearch__.delete_document + end + end + end class AnonymousUser < User @@ -1196,21 +1213,6 @@ class AnonymousUser < User false end - def create_user_ealasticsearch_index - if self.id != 2 && self.id != 4 - self.__elasticsearch__.index_document - end - end - def update_user_ealasticsearch_index - if self.id != 2 && self.id != 4 - self.__elasticsearch__.update_document - end - end - def delete_user_ealasticsearch_index - if self.id != 2 && self.id != 4 - self.__elasticsearch__.delete_document - end - end end # Delete the previous articles index in Elasticsearch diff --git a/db/schema.rb b/db/schema.rb index dd5278d93..0d4135f3d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,4 +1,4 @@ -<<<<<<< HEAD + # 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 @@ -1815,1895 +1815,1894 @@ ActiveRecord::Schema.define(:version => 20151117075939) do 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 => 20151127011351) 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_contributor_scores", :force => true do |t| - t.integer "course_id" - t.integer "user_id" - t.integer "message_num" - t.integer "message_reply_num" - t.integer "news_reply_num" - t.integer "resource_num" - t.integer "journal_num" - t.integer "journal_reply_num" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "total_score" - 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 - t.integer "publish_resource", :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", :force => true do |t| - t.string "IPLineCode" - t.string "Description" - 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", :null => false - t.datetime "updated_at", :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 "exercise_answers", :force => true do |t| - t.integer "user_id" - t.integer "exercise_question_id" - t.integer "exercise_choice_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.text "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 - t.integer "question_score" - end - - create_table "exercise_standard_answers", :force => true do |t| - t.integer "exercise_question_id" - t.integer "exercise_choice_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 - t.datetime "end_at" - t.integer "status" - end - - create_table "exercises", :force => true do |t| - t.text "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 - t.datetime "publish_time" - t.datetime "end_time" - t.integer "show_result" - end - - 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_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" - 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" - t.integer "sticky", :default => 0 - 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_activities", :force => true do |t| - t.integer "user_id" - t.integer "org_act_id" - t.string "org_act_type" - t.integer "container_id" - t.string "container_type" - t.datetime "created_at", :null => false - 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.text "title" - t.text "content" - t.integer "organization_id" - t.integer "creator_id" - t.integer "parent_id" - t.integer "reply_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.boolean "locked", :default => false - t.integer "sticky", :default => 0 - end - - create_table "org_member_roles", :force => true do |t| - t.integer "org_member_id" - t.integer "role_id" - end - - 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 - end - - create_table "org_projects", :force => true do |t| - t.integer "organization_id" - t.integer "project_id" - t.datetime "created_at" - 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 ->>>>>>> szzh +======= +# 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 => 20151127011351) 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_contributor_scores", :force => true do |t| + t.integer "course_id" + t.integer "user_id" + t.integer "message_num" + t.integer "message_reply_num" + t.integer "news_reply_num" + t.integer "resource_num" + t.integer "journal_num" + t.integer "journal_reply_num" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "total_score" + 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 + t.integer "publish_resource", :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", :force => true do |t| + t.string "IPLineCode" + t.string "Description" + 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", :null => false + t.datetime "updated_at", :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 "exercise_answers", :force => true do |t| + t.integer "user_id" + t.integer "exercise_question_id" + t.integer "exercise_choice_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.text "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 + t.integer "question_score" + end + + create_table "exercise_standard_answers", :force => true do |t| + t.integer "exercise_question_id" + t.integer "exercise_choice_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 + t.datetime "end_at" + t.integer "status" + end + + create_table "exercises", :force => true do |t| + t.text "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 + t.datetime "publish_time" + t.datetime "end_time" + t.integer "show_result" + end + + 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_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" + 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" + t.integer "sticky", :default => 0 + 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_activities", :force => true do |t| + t.integer "user_id" + t.integer "org_act_id" + t.string "org_act_type" + t.integer "container_id" + t.string "container_type" + t.datetime "created_at", :null => false + 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.text "title" + t.text "content" + t.integer "organization_id" + t.integer "creator_id" + t.integer "parent_id" + t.integer "reply_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.boolean "locked", :default => false + t.integer "sticky", :default => 0 + end + + create_table "org_member_roles", :force => true do |t| + t.integer "org_member_id" + t.integer "role_id" + end + + 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 + end + + create_table "org_projects", :force => true do |t| + t.integer "organization_id" + t.integer "project_id" + t.datetime "created_at" + 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 From e728dd55ebecc33c9b2792df3c7439f2ec331543 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 27 Nov 2015 19:02:07 +0800 Subject: [PATCH 023/105] Merge branch 'szzh' into dev_zanle Conflicts: app/models/attachment.rb db/schema.rb --- app/models/project.rb | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 847c536da..c68e73369 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -1217,18 +1217,30 @@ class Project < ActiveRecord::Base def create_project_ealasticsearch_index - if self.is_public == 1 + if self.is_public self.__elasticsearch__.index_document end end def update_project_ealasticsearch_index - if self.is_public == 1 - self.__elasticsearch__.update_document + if self.is_public #如果是初次更新成为公开的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性 + begin + self.__elasticsearch__.update_document + rescue => e + self.__elasticsearch__.index_document + end + else #如果是更新成为私有的,那么索引就要被删除 + begin + self.__elasticsearch__.delete_document + rescue => e + + end end end def delete_project_ealasticsearch_index - if self.is_public == 1 - self.__elasticsearch__.delete_document + begin + self.__elasticsearch__.delete_document + rescue => e + end end From 34ac56e0a0f94734e9bf861a61ebf6d5c1ce4332 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 27 Nov 2015 19:07:10 +0800 Subject: [PATCH 024/105] attachment index_document --- app/models/attachment.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index ebabbf944..aa436965b 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -612,14 +612,21 @@ class Attachment < ActiveRecord::Base if self.is_public == 1 && ( (self.container_type == 'Project' && Project.find(self.container_id).is_public == 1) || ( self.container_type == 'Course' && Course.find(self.container_id).is_public == 1) || self.container_type == 'Principal') + begin self.__elasticsearch__.update_document + rescue => e + end + else + begin + self.__elasticsearch__.delete_document + rescue => e + end end end def delete_attachment_ealasticsearch_index - if self.is_public == 1 && ( (self.container_type == 'Project' && Project.find(self.container_id).is_public == 1) || - ( self.container_type == 'Course' && Course.find(self.container_id).is_public == 1) || - self.container_type == 'Principal') + begin self.__elasticsearch__.delete_document + rescue => e end end end From d67fc1898887c987dc7adc38576c815cd7df89ad Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 30 Nov 2015 10:20:47 +0800 Subject: [PATCH 025/105] =?UTF-8?q?=E8=8B=B1=E9=9B=84=E6=A6=9C=E3=80=81?= =?UTF-8?q?=E8=B4=A1=E7=8C=AE=E6=A6=9C=E6=98=BE=E7=A4=BA=E7=9C=9F=E5=AE=9E?= =?UTF-8?q?=E5=A7=93=E5=90=8D=20=E4=B8=BA=E9=9B=B6=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=E4=B8=8D=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_courses.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 603f7febb..c8b5a20b0 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -212,7 +212,7 @@ <% contributor_course_scor(@course.id).each do |contributor_score| %> <% unless contributor_score.total_score ==0 %>
  • <%=link_to image_tag(url_to_avatar(contributor_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(contributor_score.user) %> -

    <%=link_to contributor_score.user, user_path(contributor_score.user), :title => contributor_score.user %>

    +

    <%=link_to contributor_score.user.show_name, user_path(contributor_score.user), :title => contributor_score.user.show_name %>

    <%= contributor_score.total_score.to_i %>

    <%= 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) %> + <% if User.current.admin? || User.current.admin_of_org?(Organization.find(document.organization_id)) || User.current.id == document.creator_id %>
    • @@ -36,7 +32,7 @@ <% end %>
    • - <%= link_to "编辑文章", edit_org_document_comment_path(:id => document.id, :organization_id => document.organization_id, :flag => 0), :class => "postOptionLink" %> + <%= link_to "编辑文章", edit_org_document_comment_path(:id => document.id, :organization_id => document.organization_id, :flag => flag), :class => "postOptionLink" %>
    • <%= link_to "删除文章", org_document_comment_path(:id => document.id, :organization_id => document.organization_id), :method => 'delete', diff --git a/app/views/organizations/cancel_homepage.js.erb b/app/views/organizations/cancel_homepage.js.erb new file mode 100644 index 000000000..bf9eb798c --- /dev/null +++ b/app/views/organizations/cancel_homepage.js.erb @@ -0,0 +1 @@ +window.location.href = "<%= organization_path(@org) %>"; \ No newline at end of file diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb index e44e0778d..9e0fc365c 100644 --- a/app/views/organizations/show.html.erb +++ b/app/views/organizations/show.html.erb @@ -52,14 +52,14 @@
    -<% if !@organization.home_id.nil? and OrgDocumentComment.where("id = ?", @organization.home_id).count > 0 %> +<% 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 %> - <%= render :partial => 'show_org_document', :locals => {:document => OrgDocumentComment.find(@organization.home_id), :home_id => @organization.home_id, :act => act} %> + <%= render :partial => 'show_home_page', :locals => {:document => OrgDocumentComment.find(@organization.home_id), :home_id => @organization.home_id, :act => act} %> <% end %> <% if @org_activities %> <%= render :partial => 'organizations/org_activities', diff --git a/config/routes.rb b/config/routes.rb index d12a38425..bb6d7b940 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -36,6 +36,7 @@ RedmineApp::Application.routes.draw do get 'setting'#, :action => 'settings', :as => 'settings' get 'clear_org_avatar_temp' put 'set_homepage' + put 'cancel_homepage' get 'members' get 'more_org_projects' get 'more_org_courses' diff --git a/db/migrate/20151130032658_create_org_docume_editor.rb b/db/migrate/20151130032658_create_org_docume_editor.rb new file mode 100644 index 000000000..0dc9857ba --- /dev/null +++ b/db/migrate/20151130032658_create_org_docume_editor.rb @@ -0,0 +1,12 @@ +class CreateOrgDocumeEditor < ActiveRecord::Migration + def up + create_table :editor_of_documents do |t| + t.integer :editor_id + t.integer :org_document_comment_id + t.timestamp :created_at + end + end + + def down + end +end diff --git a/db/migrate/20151130064556_copy_document_created_at_for_editor_of_document.rb b/db/migrate/20151130064556_copy_document_created_at_for_editor_of_document.rb new file mode 100644 index 000000000..2361db3dd --- /dev/null +++ b/db/migrate/20151130064556_copy_document_created_at_for_editor_of_document.rb @@ -0,0 +1,12 @@ +class CopyDocumentCreatedAtForEditorOfDocument < ActiveRecord::Migration + def up + OrgDocumentComment.all.each do |doc| + if doc.parent.nil? + EditorOfDocument.create(:editor_id => doc.creator_id, :org_document_comment_id => doc.id, :created_at => doc.updated_at) + end + end + end + + def down + end +end From 3750a49b6541b4201146129f905a2b66d36f6392 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 30 Nov 2015 16:10:29 +0800 Subject: [PATCH 036/105] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E4=B8=8B=E6=8B=89=E6=A1=86=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/organizations/_show_home_page.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/organizations/_show_home_page.html.erb b/app/views/organizations/_show_home_page.html.erb index ade3f7ba8..3628b4929 100644 --- a/app/views/organizations/_show_home_page.html.erb +++ b/app/views/organizations/_show_home_page.html.erb @@ -20,7 +20,7 @@ - <% if User.current.admin? || User.current.admin_of_org?(Organization.find(document.organization_id) || User.current.id == document.creator_id) %> + <% if User.current.admin? || User.current.admin_of_org?(Organization.find(document.organization_id)) || User.current.id == document.creator_id %>
    • From ebeaac5798c0668a5936a63930e6e96fbda2a1f1 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 30 Nov 2015 16:27:26 +0800 Subject: [PATCH 037/105] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=8C=BF=E8=AF=84?= =?UTF-8?q?=E7=9A=84=E7=BB=93=E6=9D=9F=E7=8A=B6=E6=80=81=E6=9C=AA=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/schema.rb | 1 - lib/tasks/delete_evalution.rake | 12 ++++++++++-- lib/tasks/homework_evaluation.rake | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 70b64ec7b..f19c4704f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -963,7 +963,6 @@ ActiveRecord::Schema.define(:version => 20151130033906) do t.integer "course_group_id", :default => 0 end - add_index "members", ["course_id"], :name => "index_members_on_course_id" 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" diff --git a/lib/tasks/delete_evalution.rake b/lib/tasks/delete_evalution.rake index 6d01123e0..94075ae00 100644 --- a/lib/tasks/delete_evalution.rake +++ b/lib/tasks/delete_evalution.rake @@ -2,12 +2,20 @@ namespace :delete_evalution do desc "delete evaluation" task :delete => :environment do homework = HomeworkCommon.where("id = 844").first - homework.homework_detail_manual.update_column('comment_status', 3) + homework_detail_manual = homework.homework_detail_manual + homework_detail_manual.update_column('comment_status', 3) student_work_score = StudentWorksScore.where("student_work_id = 28088 and user_id = 9263").first student_work_score.destroy student_work_9203 = StudentWork.where("id = 28088").first student_work_9263 = StudentWork.where("homework_common_id = 844 and user_id = 9263").first student_work_9203.update_column("student_score",91) - student_work_9263.update_column("absence_penalty",student_work_9263.absence_penalty+homework.homework_detail_manual.absence_penalty) + student_work_9203.update_column("final_score",91) + student_work_9263.update_column("absence_penalty",student_work_9263.absence_penalty+homework_detail_manual.absence_penalty) + work_ids = "(" + homework.student_works.map(&:id).join(",") + ")" + homework.student_works.each do |student_work| + absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count + student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0 + student_work.save + end end end \ No newline at end of file diff --git a/lib/tasks/homework_evaluation.rake b/lib/tasks/homework_evaluation.rake index 84082eb9b..6be2d6a04 100644 --- a/lib/tasks/homework_evaluation.rake +++ b/lib/tasks/homework_evaluation.rake @@ -52,7 +52,7 @@ namespace :homework_evaluation do #自动关闭匿评的任务 task :end_evaluation => :environment do - homework_detail_manuals = HomeworkDetailManual.where("evaluation_end = '#{Date.today}'") + homework_detail_manuals = HomeworkDetailManual.where("evaluation_end <= '#{Date.today}'") homework_detail_manuals.each do |homework_detail_manual| homework_common = homework_detail_manual.homework_common if homework_common.anonymous_comment == 0 && homework_detail_manual.comment_status == 2 #开启匿评状态才可关闭匿评 From b16acda21e8f44bf355ac1ea5b336ca3a99a3a78 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 30 Nov 2015 17:22:03 +0800 Subject: [PATCH 038/105] =?UTF-8?q?=E5=8C=BF=E8=AF=84=E7=BB=93=E6=9D=9F?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=9A=82=E6=97=B6=E4=B8=8D=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/homework_evaluation.rake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/tasks/homework_evaluation.rake b/lib/tasks/homework_evaluation.rake index 6be2d6a04..456de479b 100644 --- a/lib/tasks/homework_evaluation.rake +++ b/lib/tasks/homework_evaluation.rake @@ -65,12 +65,12 @@ namespace :homework_evaluation do end homework_detail_manual.update_column('comment_status', 3) # 匿评关闭消息通知 给所有人发 - course = homework_common.course - course.members.each do |m| - homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 3) - end + #course = homework_common.course + #course.members.each do |m| + # homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 3) + #end # 邮件通知 - Mailer.send_mail_anonymous_comment_close(homework_common).deliver + #Mailer.send_mail_anonymous_comment_close(homework_common).deliver end end end From d6d0acf8bf33bd53861740d2dc7d425ffc72bc7d Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 30 Nov 2015 18:07:29 +0800 Subject: [PATCH 039/105] tip --- config/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index 61f73ee3d..9e6d41abe 100644 --- a/config/application.rb +++ b/config/application.rb @@ -80,7 +80,7 @@ module RedmineApp elsif RbConfig::CONFIG['target_os'] == 'linux' && ["testtrustie11","agent12"].include?(`hostname`.gsub("\n","")) Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.11:9200','192.168.80.12:9200'], retry_on_failure: true elsif RbConfig::CONFIG['target_os'] == 'linux' && ["trustie168","trustieserver14","trustieserver16","Trustie18"].include?(`hostname`.gsub("\n","")) - Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.168:9200','192.168.80.14:9200','192.168.80.16:9200','192.168.80.18:9200'], retry_on_failure: true + Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.168:9200'], retry_on_failure: true else Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true end From 52a0da83c459782e4abd24682ff1b0885b9cf3ee Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Mon, 30 Nov 2015 21:52:05 +0800 Subject: [PATCH 040/105] =?UTF-8?q?=E5=8C=BF=E5=90=8D=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=95=99=E8=A8=80=E9=97=AE=E9=A2=98.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/words_controller.rb | 2 ++ app/models/user.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 6cc622c49..c9c4dcce3 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -3,6 +3,8 @@ class WordsController < ApplicationController include ApplicationHelper before_filter :find_user, :only => [:new, :create, :destroy, :more, :back] + before_filter :require_login, :only => [:create_reply] + def create if params[:new_form][:user_message].size>0 && User.current.logged? unless params[:user_id].nil? diff --git a/app/models/user.rb b/app/models/user.rb index cdec39a3d..12be9b0f9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -477,7 +477,7 @@ class User < Principal end if user # user is already in local database - #return nil unless user.active? + return nil if user.locked? return nil unless user.check_password?(password) else # user is not yet registered, try to authenticate with available sources From 259cb67c5878e26d40d96256fc85ca7b26b24030 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 1 Dec 2015 09:22:01 +0800 Subject: [PATCH 041/105] =?UTF-8?q?rake=E5=91=BD=E4=BB=A4=E7=9A=84?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/delete_evalution.rake | 21 --------------------- lib/tasks/homework_evaluation.rake | 12 ++++++------ lib/tasks/homework_publishtime.rake | 2 +- 3 files changed, 7 insertions(+), 28 deletions(-) delete mode 100644 lib/tasks/delete_evalution.rake diff --git a/lib/tasks/delete_evalution.rake b/lib/tasks/delete_evalution.rake deleted file mode 100644 index 94075ae00..000000000 --- a/lib/tasks/delete_evalution.rake +++ /dev/null @@ -1,21 +0,0 @@ -namespace :delete_evalution do - desc "delete evaluation" - task :delete => :environment do - homework = HomeworkCommon.where("id = 844").first - homework_detail_manual = homework.homework_detail_manual - homework_detail_manual.update_column('comment_status', 3) - student_work_score = StudentWorksScore.where("student_work_id = 28088 and user_id = 9263").first - student_work_score.destroy - student_work_9203 = StudentWork.where("id = 28088").first - student_work_9263 = StudentWork.where("homework_common_id = 844 and user_id = 9263").first - student_work_9203.update_column("student_score",91) - student_work_9203.update_column("final_score",91) - student_work_9263.update_column("absence_penalty",student_work_9263.absence_penalty+homework_detail_manual.absence_penalty) - work_ids = "(" + homework.student_works.map(&:id).join(",") + ")" - homework.student_works.each do |student_work| - absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count - student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0 - student_work.save - end - end -end \ No newline at end of file diff --git a/lib/tasks/homework_evaluation.rake b/lib/tasks/homework_evaluation.rake index 456de479b..84082eb9b 100644 --- a/lib/tasks/homework_evaluation.rake +++ b/lib/tasks/homework_evaluation.rake @@ -52,7 +52,7 @@ namespace :homework_evaluation do #自动关闭匿评的任务 task :end_evaluation => :environment do - homework_detail_manuals = HomeworkDetailManual.where("evaluation_end <= '#{Date.today}'") + homework_detail_manuals = HomeworkDetailManual.where("evaluation_end = '#{Date.today}'") homework_detail_manuals.each do |homework_detail_manual| homework_common = homework_detail_manual.homework_common if homework_common.anonymous_comment == 0 && homework_detail_manual.comment_status == 2 #开启匿评状态才可关闭匿评 @@ -65,12 +65,12 @@ namespace :homework_evaluation do end homework_detail_manual.update_column('comment_status', 3) # 匿评关闭消息通知 给所有人发 - #course = homework_common.course - #course.members.each do |m| - # homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 3) - #end + course = homework_common.course + course.members.each do |m| + homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 3) + end # 邮件通知 - #Mailer.send_mail_anonymous_comment_close(homework_common).deliver + Mailer.send_mail_anonymous_comment_close(homework_common).deliver end end end diff --git a/lib/tasks/homework_publishtime.rake b/lib/tasks/homework_publishtime.rake index 8e231fafd..5eaeb37cb 100644 --- a/lib/tasks/homework_publishtime.rake +++ b/lib/tasks/homework_publishtime.rake @@ -22,7 +22,7 @@ namespace :homework_publishtime do end task :end => :environment do - homework_commons = HomeworkCommon.where("end_time < '#{Date.today}'") + homework_commons = HomeworkCommon.where("end_time = '#{Date.today}'") homework_commons.each do |homework| if homework.anonymous_comment == 1 homework_detail_manual = homework.homework_detail_manual From b2bca65025799a659114a92206526cb2362fccd5 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 1 Dec 2015 10:33:57 +0800 Subject: [PATCH 042/105] =?UTF-8?q?=E5=88=86=E7=89=87=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E4=B8=BA5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 2 +- app/models/course.rb | 2 +- app/models/project.rb | 2 +- app/models/user.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index aa436965b..999cefdaa 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -43,7 +43,7 @@ class Attachment < ActiveRecord::Base #elasticsearch kaminari init Kaminari::Hooks.init Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari - settings index: { number_of_shards: 1 } do + settings index: { number_of_shards: 5 } do mappings dynamic: 'false' do indexes :filename, analyzer: 'smartcn',index_options: 'offsets' indexes :downloads, analyzer: 'smartcn',index_options: 'offsets' diff --git a/app/models/course.rb b/app/models/course.rb index edc5e105b..30a6bb439 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -12,7 +12,7 @@ class Course < ActiveRecord::Base #elasticsearch kaminari init Kaminari::Hooks.init Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari - settings index: { number_of_shards: 1 } do + settings index: { number_of_shards: 5 } do mappings dynamic: 'false' do indexes :name, analyzer: 'smartcn',index_options: 'offsets' indexes :description, analyzer: 'smartcn',index_options: 'offsets' diff --git a/app/models/project.rb b/app/models/project.rb index c68e73369..ff546e098 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -35,7 +35,7 @@ class Project < ActiveRecord::Base #elasticsearch kaminari init Kaminari::Hooks.init Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari - settings index: { number_of_shards: 1 } do + settings index: { number_of_shards: 5 } do mappings dynamic: 'false' do indexes :name, analyzer: 'smartcn',index_options: 'offsets' indexes :description, analyzer: 'smartcn',index_options: 'offsets' diff --git a/app/models/user.rb b/app/models/user.rb index cdec39a3d..e043a5ff9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -30,7 +30,7 @@ class User < Principal #elasticsearch kaminari init Kaminari::Hooks.init Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari - settings index: { number_of_shards: 1 } do + settings index: { number_of_shards: 5 } do mappings dynamic: 'false' do indexes :login, analyzer: 'smartcn',index_options: 'offsets' indexes :firstname, analyzer: 'smartcn',index_options: 'offsets' From 0aba11f175e767f186890f7ec5bcc9c3f0f02b79 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 1 Dec 2015 11:28:33 +0800 Subject: [PATCH 043/105] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=9C=A8360=E6=B5=8F=E8=A7=88=E5=99=A8?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=BC=E5=AE=B9=E7=9A=84=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/organizations/setting.html.erb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/views/organizations/setting.html.erb b/app/views/organizations/setting.html.erb index 82b28fb8a..96fef706a 100644 --- a/app/views/organizations/setting.html.erb +++ b/app/views/organizations/setting.html.erb @@ -45,13 +45,11 @@ <%= render :partial=>"new_org_avatar_form",:locals=> {source:@organization} %> -
      组织名称: - +
      组织名称:
      -
      组织描述: - +
      组织描述:
      From 68a29d813157db74396dbd934d92f2449361306b Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 1 Dec 2015 15:18:14 +0800 Subject: [PATCH 044/105] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=90=8E=E5=8F=AF=E7=82=B9=E5=87=BB=E9=87=8D?= =?UTF-8?q?=E8=AF=95=E9=87=8D=E6=96=B0=E4=B8=8A=E4=BC=A0=E4=BD=9C=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 23 ++++++++++++++++--- .../student_work/_work_information.html.erb | 3 ++- app/views/student_work/create.js.erb | 2 +- app/views/student_work/new.html.erb | 4 ++-- app/views/student_work/retry_work.js.erb | 2 ++ config/routes.rb | 2 ++ 6 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 app/views/student_work/retry_work.js.erb diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index d2aba1386..dd2a5b5fc 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -3,8 +3,8 @@ class StudentWorkController < ApplicationController include StudentWorkHelper require 'bigdecimal' require "base64" - before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule,:forbidden_anonymous_comment] - before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work] + before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule,:forbidden_anonymous_comment,:delete_work] + before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work] before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work] before_filter :author_of_work, :only => [:edit, :update, :destroy] before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :set_score_rule, :forbidden_anonymous_comment] @@ -222,7 +222,7 @@ class StudentWorkController < ApplicationController def edit @user = User.current - if !User.current.admin? && @homework.homework_type == 2 #编程作业不能修改作业 + if (!User.current.admin? && @homework.homework_type == 2) || Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") #编程作业不能修改作业|| 截止日期已到不能修改作业 render_403 else respond_to do |format| @@ -284,6 +284,23 @@ class StudentWorkController < ApplicationController end end + def delete_work + @work = StudentWork.where("user_id =? and homework_common_id =?", User.current.id, @homework.id).first + if @work + @work.destroy + end + redirect_to user_homeworks_user_path(User.current.id) + end + + def retry_work + if @work.destroy + @student_work = StudentWork.new + respond_to do |format| + format.js + end + end + end + #添加评分,已评分则为修改评分 def add_score @is_last = params[:is_last] == "true" diff --git a/app/views/student_work/_work_information.html.erb b/app/views/student_work/_work_information.html.erb index f8a55a03d..90d749af1 100644 --- a/app/views/student_work/_work_information.html.erb +++ b/app/views/student_work/_work_information.html.erb @@ -19,9 +19,10 @@

      - + 确  定 + <%= link_to("重试", retry_work_student_work_path(@student_work.id),:class => "tijiao",:style =>"margin-bottom: 15px;margin-top:15px;",:remote => true)%>
      diff --git a/app/views/student_work/create.js.erb b/app/views/student_work/create.js.erb index afd8617aa..67a1ccb50 100644 --- a/app/views/student_work/create.js.erb +++ b/app/views/student_work/create.js.erb @@ -11,7 +11,7 @@ showModal('ajax-modal', '500px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before("" + - ""); + ""); $('#ajax-modal').parent().css("top","").css("left",""); $('#ajax-modal').parent().addClass("anonymos"); <% else %> diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index 4f9999277..45c26654e 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -111,9 +111,9 @@
    - 确定 + 提交 - <%= link_to "取消", user_homeworks_user_path(User.current.id), :class => "fr mr10 mt3"%> + <%= link_to "取消", delete_work_student_work_index_path(:homework =>@homework.id), :class => "fr mr10 mt3"%>
    <% end%> diff --git a/app/views/student_work/retry_work.js.erb b/app/views/student_work/retry_work.js.erb new file mode 100644 index 000000000..c5fca76d4 --- /dev/null +++ b/app/views/student_work/retry_work.js.erb @@ -0,0 +1,2 @@ +hideModal('#popbox02'); +$("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => {:container => @student_work, :has_program=>false})%>"); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index bfe62bc3f..f6fe95a33 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -206,11 +206,13 @@ RedmineApp::Application.routes.draw do resources :student_work do member do post 'add_score' + get 'retry_work' get 'praise_student_work' get 'forbidden_anonymous_comment' end collection do post 'add_score_reply' + get 'delete_work' get 'destroy_score_reply' get 'student_work_absence_penalty' get 'absence_penalty_list' From 304cc078a74dac906178e418a01c0900fe41e2be Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 1 Dec 2015 15:30:47 +0800 Subject: [PATCH 045/105] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E8=AD=A6=E7=A4=BA?= =?UTF-8?q?=E7=9A=84=E6=84=9F=E5=8F=B9=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user_message_course.html.erb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index c2b1b509f..6e8fda92e 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -126,7 +126,7 @@ <% end %>
    -
  •    截止时间快到了!
  • +
  •    截止时间快到啦
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> @@ -158,7 +158,7 @@
  • 匿评截止:<%= ma.course_message.homework_detail_manual.evaluation_end %>  23:59
  • <% unless User.current.allowed_to?(:as_teacher, ma.course_message.course)%> -

    请您尽早完成匿评!如果您在截止日期前未完成匿评,您的最终成绩将被扣除<%= ma.course_message.homework_detail_manual.absence_penalty %>分乘以缺评份数。

    +

    请您尽早完成匿评,如果您在截止日期前未完成匿评,您的最终成绩将被扣除<%= ma.course_message.homework_detail_manual.absence_penalty %>分乘以缺评份数。

    例如,您缺评了两份作品,则您的最终成绩将被扣除 <%= ma.course_message.homework_detail_manual.absence_penalty %> * 2 = <%= ma.course_message.homework_detail_manual.absence_penalty * 2 %>分

    <% end%> @@ -209,7 +209,7 @@ -
  •   您迟交了作品!
  • +
  •   您成功提交了作品(但被标记为迟交啦)
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> From d4823e7c8b606fac2cf8d81c1d8501670c20dd06 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 1 Dec 2015 15:48:25 +0800 Subject: [PATCH 046/105] =?UTF-8?q?=E8=B4=B4=E5=90=A7=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/forums/_show_topics.html.erb | 2 +- app/views/memos/show.html.erb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/forums/_show_topics.html.erb b/app/views/forums/_show_topics.html.erb index bb8a91b69..dc3a20482 100644 --- a/app/views/forums/_show_topics.html.erb +++ b/app/views/forums/_show_topics.html.erb @@ -16,7 +16,7 @@
    最后回复:<%= author.name%>
    <%= format_date(topic.last_reply.created_at)%>
    <% end%> - + 更新时间:<%= format_date(topic.updated_at)%>
    diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index efcd15a66..c05b63427 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -79,6 +79,8 @@ <%= render :partial => 'attachments_links', :locals => {:attachments => @memo.attachments, :options => options, :is_float => true} %> <% end %>
    +
    + 更新时间:<%= format_date(@memo.updated_at)%>
    From 35b543cd22ad41fb7cd8e2c562f2901bf1d757f0 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 1 Dec 2015 17:23:14 +0800 Subject: [PATCH 047/105] =?UTF-8?q?=E8=AE=BA=E5=9D=9B=E5=8F=91=E5=B8=96=20?= =?UTF-8?q?=E9=87=87=E7=94=A8ajax=E6=8F=90=E4=BA=A4=E3=80=82=E8=BF=99?= =?UTF-8?q?=E6=A0=B7=E5=AD=90=E7=BD=91=E7=BB=9C=E4=B8=8D=E5=A5=BD=E7=9A=84?= =?UTF-8?q?=E6=83=85=E5=86=B5=E5=B0=B1=E4=B8=8D=E4=BC=9A=E4=B8=A2=E5=A4=B1?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=BA=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/memos_controller.rb | 6 +++++- app/views/forums/show.html.erb | 18 ++++++++++++++++-- app/views/layouts/base_forums.html.erb | 2 +- app/views/memos/create.js.erb | 1 + app/views/memos/edit.html.erb | 16 +++++++++++++++- app/views/memos/update.js.erb | 5 +++++ 6 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 app/views/memos/create.js.erb create mode 100644 app/views/memos/update.js.erb diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index 4181090a5..2d2c058d4 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -73,6 +73,7 @@ class MemosController < ApplicationController end end #end + format.js format.html { redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}" } format.json { render json: @memo, status: :created, location: @memo } else @@ -152,6 +153,7 @@ class MemosController < ApplicationController end def update + @flag = false respond_to do |format| if( #@memo.update_column(:subject, params[:memo][:subject]) && @memo.update_column(:content, params[:memo][:content]) && @@ -159,10 +161,12 @@ class MemosController < ApplicationController @memo.update_column(:lock, params[:memo][:lock]) && @memo.update_column(:subject,params[:memo][:subject])) @memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads])) - @memo.save + @flag = @memo.save # @memo.root.update_attribute(:updated_at, @memo.updated_at) + format.js format.html {redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}"} else + format.js format.html { render action: "edit" } format.json { render json: @person.errors, status: :unprocessable_entity } end diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index 05c086ed4..ad9195804 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -3,7 +3,7 @@
    diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index efaed2d9d..cfc098645 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -97,7 +97,7 @@
    - + diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index c2b1b509f..6e8fda92e 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -126,7 +126,7 @@ <% end %> -
  •    截止时间快到了!
  • +
  •    截止时间快到啦
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> @@ -158,7 +158,7 @@
  • 匿评截止:<%= ma.course_message.homework_detail_manual.evaluation_end %>  23:59
  • <% unless User.current.allowed_to?(:as_teacher, ma.course_message.course)%> -

    请您尽早完成匿评!如果您在截止日期前未完成匿评,您的最终成绩将被扣除<%= ma.course_message.homework_detail_manual.absence_penalty %>分乘以缺评份数。

    +

    请您尽早完成匿评,如果您在截止日期前未完成匿评,您的最终成绩将被扣除<%= ma.course_message.homework_detail_manual.absence_penalty %>分乘以缺评份数。

    例如,您缺评了两份作品,则您的最终成绩将被扣除 <%= ma.course_message.homework_detail_manual.absence_penalty %> * 2 = <%= ma.course_message.homework_detail_manual.absence_penalty * 2 %>分

    <% end%> @@ -209,7 +209,7 @@ -
  •   您迟交了作品!
  • +
  •   您成功提交了作品(但被标记为迟交啦)
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> diff --git a/config/application.rb b/config/application.rb index 61f73ee3d..9e6d41abe 100644 --- a/config/application.rb +++ b/config/application.rb @@ -80,7 +80,7 @@ module RedmineApp elsif RbConfig::CONFIG['target_os'] == 'linux' && ["testtrustie11","agent12"].include?(`hostname`.gsub("\n","")) Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.11:9200','192.168.80.12:9200'], retry_on_failure: true elsif RbConfig::CONFIG['target_os'] == 'linux' && ["trustie168","trustieserver14","trustieserver16","Trustie18"].include?(`hostname`.gsub("\n","")) - Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.168:9200','192.168.80.14:9200','192.168.80.16:9200','192.168.80.18:9200'], retry_on_failure: true + Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.168:9200'], retry_on_failure: true else Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true end diff --git a/db/schema.rb b/db/schema.rb index c6ca6a0ce..442ceaab9 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 => 20151130033906) do +ActiveRecord::Schema.define(:version => 20151202064455) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -543,23 +543,26 @@ ActiveRecord::Schema.define(:version => 20151130033906) 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| @@ -735,6 +738,17 @@ ActiveRecord::Schema.define(:version => 20151130033906) do add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id" + create_table "homework_detail_groups", :force => true do |t| + t.integer "homework_common_id" + t.integer "min_num" + t.integer "max_num" + t.integer "base_on_project" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "homework_detail_groups", ["homework_common_id"], :name => "index_homework_detail_groups_on_homework_common_id" + create_table "homework_detail_manuals", :force => true do |t| t.float "ta_proportion" t.integer "comment_status" @@ -891,16 +905,6 @@ ActiveRecord::Schema.define(:version => 20151130033906) 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" diff --git a/public/images/course/hwork_icon.png b/public/images/course/hwork_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..82c78ac60defdaafaf7e2e8c55530e6939b5b86f GIT binary patch literal 4494 zcmb_g2UJtpx<<#LS+D^L48(vKYDj?4g@h!)AfbqWR3QWikOY!o=-B8*PyqphGbkuV zKuV1CQA9x6pfr(yG%2AdAidl$>dd_N?z;EgweDG`{AaKK``iBZzxFw?78s-bf?|R^ zJUshNjFDE{Cz*Rq@bhx-s(>eU+{bY$%8q)LNbx`EnU0|Xq^6%a`9B~r8l^?-la)#l1O z!(brb4;8A99`I{Wc4ig;LlPMWP*+w}!m2Wd^{0|+=G)dZ;r)I_Li!Zg)XU} z+GrG9)ewe6YH6V15C}>gp{}NaRzs<(YH7mZS{fSPu_i0^pCj zYUBTjf4Bxz1*!%|7;0*1a1(}TqP1Ws6*LT?u7cKpXc+>(Vcq|eT7kJifOp97H*$O* z;xcYW{FCb3mp>N^j>ughWbRT3Jtn%ByFA-WkZ|k3zG-?$f@6< z(%QMoi}XF?mYLVel1$e4h=_A*myCrYEbe{aR>r2u24j{PHfC}; zvB{b80zb|_{J~p%|{GROG=I*0~ zFW|C?Oi$?osn$}=+QW%$q?Bs))w-T@xtTLAltYEMXWqAur;<{ z>EfL;sHl*1hw1aqUt~=@i41x4uSi1c=NdZp@XY z%1bN7=KB5oHA|6IOm7j#Jb$NPI`O1l{za$B_FIFmCkM}M11i&Cd-^xM_P0dV`|8MI z?u|BWF*9lEBv?Pg9bAtX?m`Okouu1OJ$uAtZP=m2iZjmyX(Jr-U;N&s1~qb19V#ZX zuT@F?^f4OOp9}+1cMb zrCe%R`1*{7EK^Ya_>Ib$)Y8irGO}fK_-ULdfN9#<$z&iT(>}{7@7`V(EBb--NL6)j zL`s^NM0~?Lx8>+X-FnjjLCdQz&dFbX#ImBBHg1(NtJ!Ypt#-x5zn*g6R5JZRbH#hX zx`79{3%NUH&q0BduhKOxJ^!bK_=B=Mz!Trd`g6MyZk(o!i?>wMpzzT-&_^*=qHR*z?zsvhbMOXMql-X0|Ge||r-`=94X0_-A5N{w zLzC|Lw=d6PhP_@aTs7cKyNEN#=&4h^F*l%6B5`xxtSmYi_u-XV(p`_@$`x#pFD?ZP zR;RVnZn!<3DM-{bjamr*9ICo@G00?pb=VU>tokBYac_lBh45Rmd%2aK@0&Kmt{dMA zF!Ow;fM~Qy%X^ukb!6>%AJdp1-8hz)EAh+op`qMVv^0~~_MD9jL7}Ue-q{kJodZ%; zClFfu1`-2(pPv;K@)h!-%v?Kg{ph%hofkSxR4#X4u2rs@iT&$^euByCS6-&wD^@`@ zl|LdXyY4%lR#QF)8XTOLmA-efS&$tWP}yfuZ#(O3*Kg3xhQ7dNY$-4gn5k7*&)-+D z@Et_0Ns#?J!=j`+PhBj^aexPHx*Zde=VME^{b-Y`AFT_5*H=D7d~tHec}?V{Ry-tI z%VVc(GcT zzc=)Y?zTa|woc&?n0}1@uI=Z|<0tAjY($Uq)_`~?dvzK%s%Kw;e6Z52^xHbN*RS3v zdL^_^Br5PKK3CQ$t^~Jb$0!1hKajmUJi+jP?F$+_;;&Jmte86B#6Ddp+a9_tK7-!8 zHGgXeQg(mif?8rl^a@th;rwW+=oFuey|=#3;owuL$%Le;OA4JFlDJf_e)2++u73G^ zYIW)cMK@}y9#i58S`=Nu8m-CSh^|Eqg8Rirub>JY<)+Z>NIIsed91nIaVs?6@pRS2 zcWZYi%5=bac*lXMLt5+vJ|H37V!qlzXn&+*Cz7h&1$LRfUtdxbwY2}5d4E;G;x0*G ze#R75aZ@#HuoPRO7@LE+`5?J-rYvSWR^WO%#_1Kl^I3?V9Qeajx9Mv6M_jXQ!EAVn zF0ZU7$7y&i8>9R*pFY)+UM*R)dV-Rk>{6MC9Clugki^gUmD{a>MAZ_laF?`ax}BAS z6HGT8nMo5*Ru&Lq^p_o%6Bzc>G90#Y)1IGaD{zlPMcdWi-0gF2((|u*TF3sak=;+q z&ypP0`q=)&08=nYxAds1iI+J3e#<&7SIEfHwlc^K=jBcgq^=_$ICGB1jj3j|Z9zv? z`L@&R$zvT))cnF3@m1L6568`8NoLGpK2L4`7CGx0pT~=fiCx18>F!g4HIME(67_z= zThLTFQpfgPuf@^%S@FFRABv>@-fVW-&e#6+UD_OuGve1>@5iQRE1bkH^-n*Sx|6lt zdTT?xu{i=i{Zn+!v7>RV6EE=c4+wFa(E5@ylrO^J+Z_F+F(kafzGkmjGUa>-m_0!0*qSB%JvbKt)OTNhfyyr$bB0j$9tl))z!5?aZynhAqRNf z+tS1le_4{{o8(vrmWGGt67SgSFnH(a-JE`iPR}QDRJxY}@;65s9Z8c(O=<9;ZZ*eR z{792EaGUOMe5~ivJ2JZ{7~YHt=MbH<2Y-*z4fA%}Y_5ytC;6w8%iCB|T(@r5YElNh zPQ2Hk?-BBeo9(n-FI3#O$-C{bZIZQd@Wz}vg%sHOC<%XZFL{P~zzkv5FrOxYYoNRc zAN3Urx49{?Y!bm1T{P(tg&{{*3LohdhP6i1Go2^ePy&SX*_I>NMuh`ap?=#3PktE_ zYNL~?1{eA}lGkDgN)auKNaAcv|4s8At10aOXV|i zPT6zM>R?J=-td{|d)eoEl^Ts^hklHbh)Wa~3K{2>Ft>S`jhkU}oW~+J*Xfs6eK=yT z`qF&Fd%D=iMg_!|F_?b-6n}i9auyh9!_ ztG}XqbHmjn##msojc1#+%XO>X51cH1;!Oag3G0@pIz1%hJIe^^w1d6argO=;_!-T77=e zV@V&6C2IhPaeg~8ES%b|!djZt{3VIuy-NADk0)g|zND-Qw%DQBMf3Z)T9yBbWu1%a zG0F9op@s#2-fAE7 zUUP`IMx~%cZQ0*rP4ZOX&xl8vcFZE&q6K<5;c3pR0!p}{mCuc-YD#>ok=RcZ)~G*J zl`*b3;WzQwJ3|tbYa0DvYO+W{xT>~m>KeUm^>93AG*lnolU{qiMObpEU9b8)ir2R| ze=ORwq~GvRKAWR(S2v@59JGl*%#Sp~Xhp(PpUyiqI+)!V@l7|)!LV;f^yRe}ZY+te z>s+7CyvrzfNn3x;Aq{O{uD*X7W@xmR>RKG43mZ5=8)n#NvB{~;6p(zcTFnDJjR4P1 zyi|Z{Mk|O6I=aPBST!#zU}eRpn_5n_fs59bJ_irivf$;l4+v!{N`HOFE_}d-WH<}lCu$?yITf1)0Vbwl;R#foTy{ueQzanEf zE*CLN@f>&Oh|u7X#TIusH}nrXywgD`g}e>v_Y90fD=7&r=`qt@Z1fm0>KwzHOdm9t z`@lhCcO@hq%3OvBc~1%#YF^<-*+-tux|mP~{3-pjG!9&eDQr^=hBq|fGZ=4E>EX~r z8PlZTb>2dYDC6tOHMn|F%<#K^-}rXg;{V#r{oidJLMHRSzvKJfdcQX2@9p^i5zEfE m&`vo2Zj1TMe#_y~E}nVbXZnw;Ok{WdkeHw_$U?-0EB^qHH0+cB literal 0 HcmV?d00001 diff --git a/public/images/course/right-arrow.png b/public/images/course/right-arrow.png new file mode 100644 index 0000000000000000000000000000000000000000..b152e9ce9f65165d57377cb50087c2a5ede4f311 GIT binary patch literal 1325 zcmeAS@N?(olHy`uVBq!ia0vp^0zfRs!3HE%f6fyGQj#UE5hcO-X(i=}MX3yqDfvmM z3ZA)%>8U}fi7AzZCsS=07?=ezLn2Bde0{8v^Kf6`()~Xj@TAnpKdC8`Lf!&sHg;q@=(~U%$M( zT(8_%FTW^V-_X+15@d#vkuFe$ZgFK^Nn(X=Ua>OF1ees}t-3#_`hBq$Z(46Le)Ln;eW^@CE2 z^Gl18f$@>14ATq@JNy=b6armi<&vLVnwy$e;^|_m1QgLr$xN{_cXl-~GjTJuw6HWb zG;}q!Ff(&@c6KqcGGjMjE=kNwPKD{sMCdiatJli8C^fMpzbGU>KL-|j z0U7xv`NbLe1q#l=W(wh%c`5nj#h`$Nx-+#Xvn(~mttdZN0UR<`nMk&~S{j>}nz*=` z7`Pc5I~h1TyBfQhIGI?w8oC&onV7gKLG`2{`Iev_eW2y~plC#jR+tblt$>*DL<;1< zlX+?$Fl`qB6Y-fD5;+VEjGH}O978H@EtzWT&Fm=9_T7n#Q-hJUHR4#kg4v>04y79^ zT}g{rnmZB_pP%0#?DB~HQM$0SD@$NN&Xr3>Ym*kX%+U~YstJ3iBDcMGr^SbqzLfjr z<>}wmrsdxD_gd*aqxpN*)>S1D)0V#K?Pd)LL6QkIJ;0Vw8o9DLV^Ga-RJyqPAdvMA0kd`GcmEIn<>CbQS?3X*9 zJpHA}mXka?b*?OlzAqd$dyCf8uFL?wu!ScpS|*-wp2Gih-=TR+SN)H98W=GxE&XTt zk}3C1<(j`Xn17Pnv}V&2Q;FxNogDmkq<+)c`Q+{)lSjUuJs;X;EsZT)>&UlpU4@T8 z{A9HU7o(3vMoc_%L^Ng3Bl+ZAMKfq ew!is*#1a_(E}x^jPDLDCf_b|7xvX Date: Thu, 3 Dec 2015 18:33:08 +0800 Subject: [PATCH 060/105] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BF=AE=E8=AE=A2?= =?UTF-8?q?=E9=99=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../student_work/_revise_attachments.html.erb | 30 +++++++++++++++++++ app/views/student_work/_show.html.erb | 25 ++++++++++++++++ .../20151203030635_add_attachment_type.rb | 9 ++++++ db/schema.rb | 2 +- public/stylesheets/courses.css | 5 ++++ 5 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 app/views/student_work/_revise_attachments.html.erb create mode 100644 db/migrate/20151203030635_add_attachment_type.rb diff --git a/app/views/student_work/_revise_attachments.html.erb b/app/views/student_work/_revise_attachments.html.erb new file mode 100644 index 000000000..1321da368 --- /dev/null +++ b/app/views/student_work/_revise_attachments.html.erb @@ -0,0 +1,30 @@ +
    +
    + + 上传附件 + <%#= button_tag "上传附件", :type=>"button", :onclick=>"$('#_file#{work.id}').click();",:onmouseover => 'this.focus()',:class => 'blueCir ml5' %> + <%= file_field_tag 'attachments[dummy][file]', + :id => "_file#{work.id}", + :class => 'file_selector', + :multiple => true, + :onchange => "addReviseFiles(this, '#{work.id}');", + :style => 'display:none', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :upload_path => uploads_path(:format => 'js'), + :description_placeholder => l(:label_optional_description), + :field_is_public => l(:field_is_public), + :are_you_sure => l(:text_are_you_sure), + :file_count => l(:label_file_count), + :lebel_file_uploding => l(:lebel_file_uploding), + :delete_all_files => l(:text_are_you_sure_all), + :containerid => "#{work.id}" + } %> + + <% content_for :header_tags do %> + <%= javascript_include_tag 'attachments' %> + <% end %> +
    + diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb index 1b0202536..894f9fb39 100644 --- a/app/views/student_work/_show.html.erb +++ b/app/views/student_work/_show.html.erb @@ -61,6 +61,31 @@ + + <%#= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename link_file', :readonly=>'readonly')%> + <%#= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %> + + <%#= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'is_public')%> + <%#= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %> + <%#= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> + +
    <%student_work_scores.each do |student_score|%>
    diff --git a/db/migrate/20151203030635_add_attachment_type.rb b/db/migrate/20151203030635_add_attachment_type.rb new file mode 100644 index 000000000..2c41aa5f2 --- /dev/null +++ b/db/migrate/20151203030635_add_attachment_type.rb @@ -0,0 +1,9 @@ +# encoding: utf-8 +class AddAttachmentType < ActiveRecord::Migration + def up + Attachmentstype.create(typeId:3,typeName:'修订附件') + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 442ceaab9..a7e3224d2 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 => 20151202064455) do +ActiveRecord::Schema.define(:version => 20151203030635) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 57838bdba..584a49a4f 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -1192,3 +1192,8 @@ a:hover.memberBtn{background: url(/images/course/hwork_icon.png) -80px -90px no- .addMemberCP {width:514px; height:auto; border:3px solid #269ac9; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; z-index:1000;} .rightArrow {margin:50px 15px 0px 15px; float:left;} .relateText {font-size:16px; color:#269ac9; line-height:16px; padding-top:20px; display:inline-block; font-weight: bold;} + +.resubAtt {border-top:1px solid #dddddd; position:relative; margin-top:15px;} +.resubTitle {position:absolute; top:-10px; left:5px; background-color:#ffffff; display:block; font-weight:bold; padding:0px 2px;} +a.blueCir{ display:inline-block; padding:2px 5px; background-color:#ffffff;border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;} +a:hover.blueCir{ background:#3598db; color:#fff;} From 838140ada86ec067f2df122edc0441c90b7ba016 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 3 Dec 2015 19:08:15 +0800 Subject: [PATCH 061/105] =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E6=B5=8B=E9=AA=8C?= =?UTF-8?q?=E7=9A=84=E8=87=AA=E5=8A=A8=E5=8F=91=E5=B8=83=E5=92=8C=E6=88=AA?= =?UTF-8?q?=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 16 ++++++++++++++++ lib/tasks/exercise_publish.rake | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 lib/tasks/exercise_publish.rake diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 6d6d429b6..0c794fe33 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -6,6 +6,14 @@ class ExerciseController < ApplicationController include ExerciseHelper def index + publish_exercises = Exercise.where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now) + publish_exercises.each do |exercise| + exercise.update_column('exercise_status', 2) + end + end_exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now) + end_exercises.each do |exercise| + exercise.update_column('exercise_status', 3) + end if @course.is_public == 0 && !User.current.member_of_course?(@course) render_403 return @@ -24,6 +32,14 @@ class ExerciseController < ApplicationController end def show + publish_exercises = Exercise.where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now) + publish_exercises.each do |exercise| + exercise.update_column('exercise_status', 2) + end + end_exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now) + end_exercises.each do |exercise| + exercise.update_column('exercise_status', 3) + end unless User.current.member_of_course?(@course) render_403 return diff --git a/lib/tasks/exercise_publish.rake b/lib/tasks/exercise_publish.rake new file mode 100644 index 000000000..aacd67c1f --- /dev/null +++ b/lib/tasks/exercise_publish.rake @@ -0,0 +1,18 @@ +#coding=utf-8 + +namespace :exercise_publish do + desc "publish exercise and end exercise" + task :publish => :environment do + exercises = Exercise.where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now) + exercises.each do |exercise| + exercise.update_column('exercise_status', 2) + end + end + + task :end => :environment do + exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now) + exercises.each do |exercise| + exercise.update_column('exercise_status', 3) + end + end +end From 4e9e7543baa592c5f2704c7195539a43a5051852 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 3 Dec 2015 19:21:35 +0800 Subject: [PATCH 062/105] =?UTF-8?q?chrome=E6=B5=8F=E8=A7=88=E5=99=A8?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E4=BF=9D=E5=AD=98=E6=B5=8B=E9=AA=8C=E5=A4=B4?= =?UTF-8?q?=E9=83=A8=E4=BF=A1=E6=81=AF=E6=97=A0=E5=8F=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/exercise/_edit_head.html.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/exercise/_edit_head.html.erb b/app/views/exercise/_edit_head.html.erb index 64f34b5aa..a071904ce 100644 --- a/app/views/exercise/_edit_head.html.erb +++ b/app/views/exercise/_edit_head.html.erb @@ -35,6 +35,5 @@ $("#exercise_time").val("<%=exercise.time if exercise.time!= -1 %>"); $("#exercise_publish_time").val("<%= Time.parse(format_time(exercise.publish_time)).strftime("%Y-%m-%d") if !exercise.publish_time.nil?%>"); /*$("#exercise_description").text("<%#=exercise.exercise_description.html_safe %>");*/ - document.getElementById("exercise_description").innerHTML = <%=exercise.exercise_description.html_safe %>; } \ No newline at end of file From 89b8f7783da5be3c75d1594a399403e37cfa50e9 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 4 Dec 2015 08:57:29 +0800 Subject: [PATCH 063/105] =?UTF-8?q?=E6=B7=BB=E5=8A=A0forked=5Fform?= =?UTF-8?q?=E7=9A=84id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/repositories/show.html.erb | 2 +- ..._add_forked_from_project_id_to_projects.rb | 5 ++ db/schema.rb | 63 +++++++++---------- 3 files changed, 35 insertions(+), 35 deletions(-) create mode 100644 db/migrate/20151203072815_add_forked_from_project_id_to_projects.rb diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index e06542cba..324dc6202 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -15,7 +15,7 @@ 版本库地址:<%= @repos_url %> <% else %> 版本库地址:<%= h @repository.url %> - <% end %> + <% end %>-
    diff --git a/db/migrate/20151203072815_add_forked_from_project_id_to_projects.rb b/db/migrate/20151203072815_add_forked_from_project_id_to_projects.rb new file mode 100644 index 000000000..f679eaecd --- /dev/null +++ b/db/migrate/20151203072815_add_forked_from_project_id_to_projects.rb @@ -0,0 +1,5 @@ +class AddForkedFromProjectIdToProjects < ActiveRecord::Migration + def change + add_column :projects, :forked_from_project_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index c6ca6a0ce..886f233a8 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 => 20151130033906) do +ActiveRecord::Schema.define(:version => 20151203072815) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -543,23 +543,26 @@ ActiveRecord::Schema.define(:version => 20151130033906) 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| @@ -891,16 +894,6 @@ ActiveRecord::Schema.define(:version => 20151130033906) 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" @@ -970,6 +963,7 @@ ActiveRecord::Schema.define(:version => 20151130033906) do t.integer "course_group_id", :default => 0 end + add_index "members", ["course_id"], :name => "index_members_on_course_id" 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" @@ -1303,27 +1297,28 @@ ActiveRecord::Schema.define(:version => 20151130033906) do end create_table "projects", :force => true do |t| - t.string "name", :default => "", :null => false + t.string "name", :default => "", :null => false t.text "description" - t.string "homepage", :default => "" - t.boolean "is_public", :default => true, :null => false + 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 "status", :default => 1, :null => false t.integer "lft" t.integer "rgt" - t.boolean "inherit_members", :default => false, :null => false + 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.boolean "hidden_repo", :default => false, :null => false + t.integer "attachmenttype", :default => 1 t.integer "user_id" - t.integer "dts_test", :default => 0 + t.integer "dts_test", :default => 0 t.string "enterprise_name" t.integer "organization_id" t.integer "project_new_type" t.integer "gpid" + t.integer "forked_from_project_id" end add_index "projects", ["lft"], :name => "index_projects_on_lft" From 6553559929f76759cc83849f7bfe772154488058 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 4 Dec 2015 10:56:16 +0800 Subject: [PATCH 064/105] =?UTF-8?q?=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 4 ++ app/controllers/users_controller.rb | 4 +- app/models/exercise.rb | 14 ++++ app/views/users/_user_message_course.html.erb | 70 +++++++++++++++++++ .../exercise_close_to_deadline_warn.rake | 22 ++++++ lib/tasks/exercise_publishtime.rake | 22 ++++++ 6 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 lib/tasks/exercise_close_to_deadline_warn.rake create mode 100644 lib/tasks/exercise_publishtime.rake diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 6d6d429b6..db09c50a5 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -316,6 +316,9 @@ class ExerciseController < ApplicationController @exercise.exercise_status = 2 @exercise.publish_time = Time.now if @exercise.save + @exercise.course.members.each do |m| + @exercise.course_messages << CourseMessage.create(:user_id =>m.user_id, :course_id => @exercise.course.id, :viewed => false,:status=>2) + end #redirect_to exercise_index_url(:course_id=> @course.id) respond_to do |format| format.js @@ -331,6 +334,7 @@ class ExerciseController < ApplicationController @exercise.exercise_questions.each do |exercise_question| exercise_question.exercise_answers.destroy_all end + @exercise.course_messages.destroy_all @exercise.exercise_users.destroy_all @exercise.exercise_status = 1 @exercise.publish_time = nil diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 626bb59fc..834009d71 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -92,7 +92,7 @@ class UsersController < ApplicationController end # 用户消息 - # 说明: homework 发布作业;message:讨论区; news:新闻; poll:问卷;works_reviewers:作品评阅;works_reply:作品回复 + # 说明: homework 发布作业;message:讨论区; news:新闻; poll:问卷;works_reviewers:作品评阅;works_reply:作品回复,exercise:课程测验 # issue:问题;journal:缺陷状态更新; forum:公共贴吧: user_feedback: 用户留言; new_reply:新闻回复(comment) def user_messages if !User.current.logged? @@ -128,7 +128,7 @@ class UsersController < ApplicationController #课程相关消息 when 'homework' - @message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','StudentWork') and user_id =?", @user).order("created_at desc") + @message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','StudentWork','Exercise') and user_id =?", @user).order("created_at desc") when 'course_message' @message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user).order("created_at desc") when 'course_news' diff --git a/app/models/exercise.rb b/app/models/exercise.rb index d23e8f115..c91e59fd9 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -6,4 +6,18 @@ class Exercise < ActiveRecord::Base 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 :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy + after_create :acts_as_course_message + def acts_as_course_message + if self.course + if self.exercise_status == 2 #未发布 + #self.course.members.each do |m| + self.course_messages << CourseMessage.create(:user_id => User.current.id, :course_id => self.course_id, :viewed => false,:status=>2) + #end + # else + # self.course_messages.destroy_all 这里的destory_all值得商榷。因为我这里是通过status来控制不同的status的 + end + end + end end diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index 9f2c9b9ef..566677964 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -612,4 +612,74 @@
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> + + + <% if ma.course_message_type == "Exercise" && ma.status == 2 %> +
      +
    • <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
    • +
    • + <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", + user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>">发布了课程测验 :
    • +
    • + <%= link_to "测验题目:" + ma.course_message.exercise_name, exercise_path(:id => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", + :onmouseover =>"message_titile_show($(this),event)", + :onmouseout => "message_titile_hide($(this))"%> +
    • + + +
    • <%= time_tag(ma.created_at).html_safe %>
    • +
    + <% end %> + + + <% if ma.course_message_type == "Exercise" && ma.status == 3 %> +
      +
    • <%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %>
    • +
    • + <%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师", + user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>">发布的测验:
    • +
    • + <%= link_to "测验题目:" + ma.course_message.exercise_name, exercise_path(:id => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", + :onmouseover =>"message_titile_show($(this),event)", + :onmouseout => "message_titile_hide($(this))"%> + +
    • + + +
    • 截止时间快到啦
    • +
    • <%= time_tag(ma.created_at).html_safe %>
    • +
    + <% end %> <% end %> \ No newline at end of file diff --git a/lib/tasks/exercise_close_to_deadline_warn.rake b/lib/tasks/exercise_close_to_deadline_warn.rake new file mode 100644 index 000000000..2af513ee8 --- /dev/null +++ b/lib/tasks/exercise_close_to_deadline_warn.rake @@ -0,0 +1,22 @@ +#coding=utf-8 + +namespace :exercise_deadline_warn do + desc "exercise deadline warn" + task :deadline_warn => :environment do + exercises = Exercise.where("date_format(end_time,'%Y-%m-%d')= '#{Date.today}'") #截止日期都是当天 23.59分,所以年月日相等的一定是今晚会截止的测验 + exercises.each do |exercise| + if exercise.exercise_status == 2 #发布的作业才能告给学生发截止消息 + course = exercise.course + course.members.each do |m| + #CourseMessage status 1 未发布 status 2 已发布 status 3 已发布快截止了 + exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 3) unless m.user.allowed_to?(:as_teacher,m) + end + # if homework.course_acts.size == 0 + # homework.course_acts << CourseActivity.new(:user_id => homework.user_id,:course_id => homework.course_id) + # end + # 邮件通知 + #Mailer.run.homework_added(homework) + end + end + end +end \ No newline at end of file diff --git a/lib/tasks/exercise_publishtime.rake b/lib/tasks/exercise_publishtime.rake new file mode 100644 index 000000000..6cef511e2 --- /dev/null +++ b/lib/tasks/exercise_publishtime.rake @@ -0,0 +1,22 @@ +#coding=utf-8 + +namespace :exercise_publishtime do + desc "start publish exercise" + task :publish => :environment do + exercises = Exercise.where("date_format(publish_time,'%Y-%m-%d')= '#{Date.today}'") + exercises.each do |exercise| + if exercise.exercise_status == 1 #未发布 + exercise.update_column('exercise_status', 2) #改为发布 + course = exercise.course + course.members.each do |m| + exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2) + end + # if homework.course_acts.size == 0 + # homework.course_acts << CourseActivity.new(:user_id => homework.user_id,:course_id => homework.course_id) + # end + # 邮件通知 + #Mailer.run.homework_added(homework) + end + end + end +end \ No newline at end of file From 2855c0e409e104d66ef612fb88056e117442e5c7 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 4 Dec 2015 10:59:09 +0800 Subject: [PATCH 065/105] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=8A=A8=E6=80=81=EF=BC=8C=E4=BD=BF=E5=85=B6=E4=B8=8E=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=8A=A8=E6=80=81=E5=8F=8A=E4=B8=AA=E4=BA=BA=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E7=9A=84=E6=A0=B7=E5=BC=8F=E4=B8=80=E8=87=B4=EF=BC=8C?= =?UTF-8?q?=E5=8C=85=E6=8B=AC=E6=9C=89=E5=9B=9E=E5=A4=8D=E6=A1=86=E3=80=81?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E8=8F=9C=E5=8D=95=E3=80=81=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E3=80=81=E9=97=B4=E8=B7=9D=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/messages_controller.rb | 5 + app/controllers/projects_controller.rb | 13 +- app/models/forge_activity.rb | 6 +- app/views/comments/create.js.erb | 5 +- app/views/layouts/base_projects.html.erb | 2 +- app/views/projects/_attachment_acts.html.erb | 35 +++++ .../projects/_project_activities.html.erb | 102 ++++++++++++ app/views/projects/_project_create.html.erb | 38 +++++ app/views/projects/_project_news.html.erb | 106 +++++++++++++ app/views/projects/show.html.erb | 145 ++++-------------- app/views/projects/show.js.erb | 1 + 11 files changed, 340 insertions(+), 118 deletions(-) create mode 100644 app/views/projects/_attachment_acts.html.erb create mode 100644 app/views/projects/_project_activities.html.erb create mode 100644 app/views/projects/_project_create.html.erb create mode 100644 app/views/projects/_project_news.html.erb create mode 100644 app/views/projects/show.js.erb diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 9b090de9a..6f173b7c2 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -169,6 +169,11 @@ class MessagesController < ApplicationController course_activity.updated_at = Time.now course_activity.save end + forge_activity = ForgeActivity.where("forge_act_type='Message' and forge_act_id=#{@topic.id}").first + if forge_activity + forge_activity.updated_at = Time.now + forge_activity.save + end user_activity = UserActivity.where("act_type='Message' and act_id =#{@topic.id}").first if user_activity user_activity.updated_at = Time.now diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 715f56d3d..200bd4d69 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -320,9 +320,20 @@ class ProjectsController < ApplicationController @activity.scope_select {|t| !has["show_#{t}"].nil?} =end + @page = params[:page] ? params[:page].to_i + 1 : 0 # 根据私密性,取出符合条件的所有数据 if User.current.member_of?(@project) || User.current.admin? - @events_pages = ForgeActivity.where("project_id = ? and forge_act_type != ?",@project, "Document" ).order("created_at desc").page(params['page'|| 1]).per(20); + case params[:type] + when nil + @events_pages = ForgeActivity.where("project_id = ? and forge_act_type in ('Issue', 'Message','News', 'ProjectCreateInfo')",@project).order("updated_at desc").limit(10).offset(@page * 10) + when 'issue' + @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Issue'",@project).order("updated_at desc").limit(10).offset(@page * 10) + when 'news' + @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'News'",@project).order("updated_at desc").limit(10).offset(@page * 10) + when 'message' + @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Message'",@project).order("updated_at desc").limit(10).offset(@page * 10) + end + #events = @activity.events(@date_from, @date_to) else @events_pages = ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public diff --git a/app/models/forge_activity.rb b/app/models/forge_activity.rb index bb5f30442..115575289 100644 --- a/app/models/forge_activity.rb +++ b/app/models/forge_activity.rb @@ -48,8 +48,10 @@ class ForgeActivity < ActiveRecord::Base def add_org_activity 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 + if org_activity + org_activity.created_at = self.created_at + org_activity.save + end else OrgActivity.create(:user_id => self.user_id, :org_act_id => self.forge_act_id, diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb index ea904a63f..b0354b53f 100644 --- a/app/views/comments/create.js.erb +++ b/app/views/comments/create.js.erb @@ -1,3 +1,6 @@ +<% if @course %> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>"); - +<% else %> +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'projects/project_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>"); +<% end %> init_activity_KindEditor_data('<%= @user_activity_id%>',"","87%"); diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 9e9bd688f..1d68c9fa0 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -12,7 +12,7 @@ <%= favicon %> <%= javascript_heads %> <%= heads_for_theme %> - <%= stylesheet_link_tag 'public', 'pleft', 'project','prettify','jquery/jquery-ui-1.9.2','header','repository' %> + <%= stylesheet_link_tag 'public', 'pleft', 'project','courses','prettify','jquery/jquery-ui-1.9.2','header','repository' %> <%= javascript_include_tag 'cookie','project', 'header','prettify','select_list_move','attachments' %> <%= call_hook :view_layouts_base_html_head %> diff --git a/app/views/projects/_attachment_acts.html.erb b/app/views/projects/_attachment_acts.html.erb new file mode 100644 index 000000000..2baa8791a --- /dev/null +++ b/app/views/projects/_attachment_acts.html.erb @@ -0,0 +1,35 @@ +
    +
    +
    + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> +
    +
    +
    + <% if activity.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.project.name.to_s+" | 项目附件", project_news_index_path(activity.project), :class => "newsBlue ml15" %> +
    + +
    +
    + 发布时间:<%= format_time(activity.created_on) %> +
    +

    <%= textAreailizable act, :description %>

    +
    +
    + <%#= activity.description.html_safe %> +
    +
    +
    + +
    +
    +
    + +
    \ No newline at end of file diff --git a/app/views/projects/_project_activities.html.erb b/app/views/projects/_project_activities.html.erb new file mode 100644 index 000000000..f97646d3c --- /dev/null +++ b/app/views/projects/_project_activities.html.erb @@ -0,0 +1,102 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor", '/assets/kindeditor/pasteimg', "init_activity_KindEditor" %> + +<% unless forge_acts.empty? %> + <% forge_acts.each do |activity| -%> + + + <% case activity.forge_act_type %> + <% when "ProjectCreateInfo" %> + <%= render :partial => 'projects/project_create', :locals => {:activity => activity, :user_activity_id => activity.id} %> + + <% when "Issue" %> + <%= render :partial => 'users/project_issue', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id} %> + + + <% when "Message" %> + <%= render :partial => 'users/project_message', :locals => {:activity => activity.forge_act,:user_activity_id =>activity.id} %> + + <% when "News" %> + <% if !activity.forge_act.nil? and activity.forge_act.project %> + <%= render :partial => 'projects/project_news', :locals => {:activity=>activity.forge_act, :user_activity_id=>activity.id} %> + <% end %> + + <% when "Attachment" %> + <%= render :partial => 'projects/attachment_acts', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id } %> + + + + + + + + + <%#= link_to format_activity_title("#{l(:label_attachment)}: #{act.filename}"), {:controller => 'attachments', :action => 'show', :id => act.id}, :class => "problem_tit fl fb" %> + + + + + + + + + <% end %> + <% end %> +<% end %> + +<% if forge_acts.count == 10 %> +
    展开更多<%= link_to "", project_path(@project.id, :type => type, :page => page), :id => "more_forge_activities_link", :remote => "true", :class => "none" %>
    +<% end %> + + \ No newline at end of file diff --git a/app/views/projects/_project_create.html.erb b/app/views/projects/_project_create.html.erb new file mode 100644 index 000000000..d966d8e18 --- /dev/null +++ b/app/views/projects/_project_create.html.erb @@ -0,0 +1,38 @@ +<% project = Project.find(activity.project_id) %> +<% user = User.find(project.user_id)%> +
    +
    +
    + <%= link_to image_tag(url_to_avatar(user), :width => "50", :height => "50"), user_path(user), :alt => "用户头像" %> +
    +
    +
    + <% if user.try(:realname) == ' ' %> + <%= link_to user, user_path(user), :class => "newsBlue mr15" %> + <% else %> + <%= link_to user.try(:realname), user_path(user), :class => "newsBlue mr15" %> + <% end %> + TO + <%= link_to project.to_s+" | 项目", project_path(project.id,:host=>Setting.host_course), :class => "newsBlue ml15" %> +
    +
    + <%= link_to project.name, project_path(project.id,:host=>Setting.host_course), :class => "postGrey" %> +
    +
    + 创建时间:<%= format_time(project.created_on) %> +
    + +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/projects/_project_news.html.erb b/app/views/projects/_project_news.html.erb new file mode 100644 index 000000000..919abc11e --- /dev/null +++ b/app/views/projects/_project_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 activity.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.project.name.to_s+" | 项目新闻", project_news_index_path(activity.project), :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/projects/show.html.erb b/app/views/projects/show.html.erb index a3a2845f8..a58aeb281 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -1,114 +1,33 @@ -<%= javascript_include_tag "jquery.infinitescroll.js" %> -
    -

    <%= l(:label_activity) %>

    -
    - -<% unless @events_pages.empty? %> - <% @events_pages.each do |e| -%> - - <% if e.forge_act_type == "ProjectCreateInfo"%> -
    - <%= image_tag(url_to_avatar(e.user), :width => "42", :height => "42") %> -
    - <%= link_to e.user, user_path(e.user), :class => "problem_name c_orange fl" %> <%= l(:label_project_create) %> : - <%= link_to e.project.name,{} ,:class => "problem_tit fl fb" %>
    -


    <%= l :label_create_time %> :<%= format_time(e.project.created_on) %>

    -
    -
    -
    - <% end %> - <% next if e.forge_act_type.safe_constantize.nil? - act = e.forge_act; - next if act.nil? %> - - <% if e.forge_act_type == "Issue" %> - - - <% elsif e.forge_act_type == "Journal" %> - - - <% elsif e.forge_act_type == "Message" %> -
    - <%= image_tag(url_to_avatar(e.user), :width => "42", :height => "42") %> -
    - - <%= h(e.project) if @project.nil? || @project.id != e.project_id %> - <%= link_to h(e.user), user_path(e.user_id), :class => "problem_name c_orange fl" %> <%= l(:label_new_activity) %> : +<%#= stylesheet_link_tag 'courses' %> + + +
    +
    +
    项目动态
    +
      +
    • +
        +
      • +
          +
        • <%= link_to "全部动态", {:controller => "projects", :action => "show", :type => nil}, :class => "homepagePostTypeAll postTypeGrey" %>
        • +
        • <%= link_to "问题动态", {:controller => "projects", :action => "show", :type => "issue"}, :class => "homepagePostTypeMessage postTypeGrey" %>
        • + +
        • <%= link_to "新闻动态", {:controller => "projects", :action => "show", :type => "news"}, :class => "homepagePostTypeNotice postTypeGrey" %>
        • + +
        • <%= link_to "讨论区动态", {:controller => "projects", :action => "show", :type => "message"}, :class => "homepagePostTypeForum postTypeGrey" %>
        • + +
        +
      • +
      +
    • +
    + - <%= link_to format_activity_title("#{act.board.name}: #{act.subject}"), - project_boards_path(@project,:topic_id => act.id), - :class => "problem_tit fl fb " %> -
    -

    <%= textAreailizable act,:content %>
    -

    - <%= l :label_create_time %> :<%= format_activity_day(act.created_on) %> <%= format_time(act.created_on, false) %>

    -
    -
    -
    - - <% elsif e.forge_act_type == "News" %> - - - - <% elsif e.forge_act_type == "Attachment" %> -
    - <%= image_tag(url_to_avatar(e.user), :width => "42", :height => "42") %> -
    - - <%= h(e.project) if @project.nil? || @project.id != e.project_id %> - <%= link_to h(e.user), user_path(e.user_id), :class => "problem_name c_orange fl" %> <%= l(:label_new_activity) %> : - <%= link_to format_activity_title("#{l(:label_attachment)}: #{act.filename}"), {:controller => 'attachments', :action => 'show', :id => act.id}, :class => "problem_tit fl fb" %>
    -

    <%= textAreailizable act,:description %>
    - <%= l :label_create_time %> :<%= format_activity_day(act.created_on) %> <%= format_time(act.created_on, false) %>

    -
    -
    -
    - <% end %> - <% end %> -<% end %> -<%= paginate @events_pages, :left => 3, :right => 3 %> +
    + <%= render :partial => "project_activities", :locals => {:forge_acts => @events_pages, :page => 0, :type => @type} %> +
    \ No newline at end of file diff --git a/app/views/projects/show.js.erb b/app/views/projects/show.js.erb new file mode 100644 index 000000000..384c111d1 --- /dev/null +++ b/app/views/projects/show.js.erb @@ -0,0 +1 @@ +$("#show_more_forge_activities").replaceWith("<%= escape_javascript( render :partial => 'projects/project_activities',:locals => {:forge_acts => @events_pages, :page => @page,:type => @type} )%>"); From 03588ca88ded7a776c16339d4bc6a65ad542ac35 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 4 Dec 2015 11:21:41 +0800 Subject: [PATCH 066/105] =?UTF-8?q?=E5=8F=91=E5=B8=83=E6=B5=8B=E9=AA=8C?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=E5=8F=91=E5=B8=83=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/exercise_publish.rake | 4 ++++ lib/tasks/exercise_publishtime.rake | 22 ---------------------- 2 files changed, 4 insertions(+), 22 deletions(-) delete mode 100644 lib/tasks/exercise_publishtime.rake diff --git a/lib/tasks/exercise_publish.rake b/lib/tasks/exercise_publish.rake index aacd67c1f..a27c6a6fb 100644 --- a/lib/tasks/exercise_publish.rake +++ b/lib/tasks/exercise_publish.rake @@ -6,6 +6,10 @@ namespace :exercise_publish do exercises = Exercise.where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now) exercises.each do |exercise| exercise.update_column('exercise_status', 2) + course = exercise.course + course.members.each do |m| + exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2) + end end end diff --git a/lib/tasks/exercise_publishtime.rake b/lib/tasks/exercise_publishtime.rake deleted file mode 100644 index 6cef511e2..000000000 --- a/lib/tasks/exercise_publishtime.rake +++ /dev/null @@ -1,22 +0,0 @@ -#coding=utf-8 - -namespace :exercise_publishtime do - desc "start publish exercise" - task :publish => :environment do - exercises = Exercise.where("date_format(publish_time,'%Y-%m-%d')= '#{Date.today}'") - exercises.each do |exercise| - if exercise.exercise_status == 1 #未发布 - exercise.update_column('exercise_status', 2) #改为发布 - course = exercise.course - course.members.each do |m| - exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2) - end - # if homework.course_acts.size == 0 - # homework.course_acts << CourseActivity.new(:user_id => homework.user_id,:course_id => homework.course_id) - # end - # 邮件通知 - #Mailer.run.homework_added(homework) - end - end - end -end \ No newline at end of file From 06122dab1dfad02ea5d9c36a2c36b08655153b72 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 4 Dec 2015 11:24:24 +0800 Subject: [PATCH 067/105] =?UTF-8?q?=E5=BD=93=E5=A4=A9=E6=88=AA=E6=AD=A2?= =?UTF-8?q?=E7=9A=84=E6=B5=8B=E9=AA=8C=E9=9C=80=E8=A6=81=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E6=88=AA=E6=AD=A2=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/exercise_close_to_deadline_warn.rake | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/tasks/exercise_close_to_deadline_warn.rake b/lib/tasks/exercise_close_to_deadline_warn.rake index 2af513ee8..890191167 100644 --- a/lib/tasks/exercise_close_to_deadline_warn.rake +++ b/lib/tasks/exercise_close_to_deadline_warn.rake @@ -3,9 +3,8 @@ namespace :exercise_deadline_warn do desc "exercise deadline warn" task :deadline_warn => :environment do - exercises = Exercise.where("date_format(end_time,'%Y-%m-%d')= '#{Date.today}'") #截止日期都是当天 23.59分,所以年月日相等的一定是今晚会截止的测验 + exercises = Exercise.where("exercise_status = 2 and date_format(end_time,'%Y-%m-%d')= '#{Date.today}'") #截止日期都是当天 23.59分,所以年月日相等的一定是今晚会截止的测验 exercises.each do |exercise| - if exercise.exercise_status == 2 #发布的作业才能告给学生发截止消息 course = exercise.course course.members.each do |m| #CourseMessage status 1 未发布 status 2 已发布 status 3 已发布快截止了 @@ -16,7 +15,6 @@ namespace :exercise_deadline_warn do # end # 邮件通知 #Mailer.run.homework_added(homework) - end end end end \ No newline at end of file From e2f5dcc3f977536513ea8e8becf4d705a5226472 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 4 Dec 2015 13:39:17 +0800 Subject: [PATCH 068/105] =?UTF-8?q?=E5=BD=93=E5=A4=A9=E6=88=AA=E6=AD=A2?= =?UTF-8?q?=E7=9A=84=E6=B5=8B=E9=AA=8C=E9=9C=80=E8=A6=81=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E6=88=AA=E6=AD=A2=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/exercise_close_to_deadline_warn.rake | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tasks/exercise_close_to_deadline_warn.rake b/lib/tasks/exercise_close_to_deadline_warn.rake index 890191167..2deb7204e 100644 --- a/lib/tasks/exercise_close_to_deadline_warn.rake +++ b/lib/tasks/exercise_close_to_deadline_warn.rake @@ -3,6 +3,7 @@ namespace :exercise_deadline_warn do desc "exercise deadline warn" task :deadline_warn => :environment do + #exercise_status 1 未发布 2 已发布 3已截止 exercises = Exercise.where("exercise_status = 2 and date_format(end_time,'%Y-%m-%d')= '#{Date.today}'") #截止日期都是当天 23.59分,所以年月日相等的一定是今晚会截止的测验 exercises.each do |exercise| course = exercise.course From dbfc4969e071b8dea30c9861414aea22d643ea92 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 4 Dec 2015 15:36:19 +0800 Subject: [PATCH 069/105] =?UTF-8?q?=E6=B5=8B=E9=AA=8C=E6=B6=88=E6=81=AFbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 12 ++++++++++++ app/views/users/_user_message_course.html.erb | 6 +++--- lib/tasks/exercise_close_to_deadline_warn.rake | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 55daf0562..a99ab32ec 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -9,6 +9,10 @@ class ExerciseController < ApplicationController publish_exercises = Exercise.where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now) publish_exercises.each do |exercise| exercise.update_column('exercise_status', 2) + course = exercise.course + course.members.each do |m| + exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2) + end end end_exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now) end_exercises.each do |exercise| @@ -35,6 +39,10 @@ class ExerciseController < ApplicationController publish_exercises = Exercise.where("publish_time is not null and exercise_status = 1 and publish_time <=?",Time.now) publish_exercises.each do |exercise| exercise.update_column('exercise_status', 2) + course = exercise.course + course.members.each do |m| + exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2) + end end end_exercises = Exercise.where("end_time <=? and exercise_status = 2",Time.now) end_exercises.each do |exercise| @@ -504,6 +512,10 @@ class ExerciseController < ApplicationController @exercise.update_attributes(:show_result => params[:show_result]) @exercise.update_attributes(:exercise_status => 2) @exercise.update_attributes(:publish_time => Time.now) + course = @exercise.course + course.members.each do |m| + @exercise.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 2) + end redirect_to exercise_url(@exercise) return elsif @exercise.publish_time > Time.now diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index 566677964..640f98b1f 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -640,9 +640,9 @@
  • 截止时间:<%= ma.course_message.end_time.to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S") %>
  • -
  • 答题时间:<%= ma.course_message.time == 0 ? '不限时' : ma.course_message.time.to_s + '分钟' %>
  • +
  • 答题时长:<%= ma.course_message.time == -1 ? '不限时' : ma.course_message.time.to_s + '分钟' %>
  • <% if !User.current.allowed_to?(:as_teacher,ma.course_message.course)%> -

    请记得在截止时间前完成测验噢,辛苦啦!

    +

    请记得在截止时间前完成测验噢,辛苦啦!

    <% end %>
    @@ -674,7 +674,7 @@
  • 课程名称:<%= ma.course_message.course.name %>(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)
  • 测验标题:<%= ma.course_message.exercise_name %>
  • 截止时间:<%= ma.course_message.end_time.to_s.gsub("+0800","").to_datetime.strftime("%Y-%m-%d %H:%M:%S") %>
  • -
  • 答题时间:<%= ma.course_message.time == 0 ? '无限制' : ma.course_message.time.to_s + '分钟' %>
  • +
  • 答题时长:<%= ma.course_message.time == -1 ? '无限制' : ma.course_message.time.to_s + '分钟' %>
  • 请及时完成课程测验,辛苦啦!

    diff --git a/lib/tasks/exercise_close_to_deadline_warn.rake b/lib/tasks/exercise_close_to_deadline_warn.rake index 2deb7204e..e2808818f 100644 --- a/lib/tasks/exercise_close_to_deadline_warn.rake +++ b/lib/tasks/exercise_close_to_deadline_warn.rake @@ -1,5 +1,5 @@ #coding=utf-8 - +#需要在0点以后执行 namespace :exercise_deadline_warn do desc "exercise deadline warn" task :deadline_warn => :environment do From c1747ab2172f695174736d68546129ccbb33e3c3 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 4 Dec 2015 15:49:05 +0800 Subject: [PATCH 070/105] =?UTF-8?q?fork=E9=87=8D=E5=90=8D=EF=BC=8C?= =?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/controllers/repositories_controller.rb | 63 ++++++++++++------- app/views/repositories/show.html.erb | 6 +- ...1204062220_add_forked_count_to_projects.rb | 5 ++ db/schema.rb | 14 +---- lib/gitlab-cli/lib/gitlab/client/projects.rb | 5 +- 5 files changed, 56 insertions(+), 37 deletions(-) create mode 100644 db/migrate/20151204062220_add_forked_count_to_projects.rb diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 2bd54954a..c1e124063 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -64,32 +64,53 @@ class RepositoriesController < ApplicationController end def forked - # 被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.gid}") - if gproject - copy_project(@project, gproject) - end + # 如果当前用户已经fork过该项目,不会新fork项目,则跳至已fork的项 + unless has_forked?(@project, User.current) + project = project_from_current_project(@project.id, User.current.id) + redirect_to project_path(project) else - flash[:notice] = l(:project_gitlab_fork_double_message) - redirect_to settings_project_url(@project, :tab => 'repositories') + # 单个用户只能拥有一个名字一样的版本库,否则不能fork + # if is_sigle_identifier?(User.current, @repository.identifier) + # REDO: 那些人有权限forked项目 + g = Gitlab.client + gproject = g.fork(@project.gpid, User.current.gid) + if gproject + copy_project(@project, gproject) + forked_count = @project.forked_count.to_i + 1 + @project.update_attributes(:forked_count => forked_count) + end + # else + # flash[:notice] = l(:project_gitlab_fork_double_message) + # redirect_to settings_project_url(@project, :tab => 'repositories') + # end end + + end + + # 判断用户是否已经fork过该项目 + def has_forked?(project, user) + projects = Project.where("user_id =?", user) + projects.map(&:forked_from_project_id).detect{|s| s == @project.id}.nil? ? true : false + end + + # 获取当前用户fork过的项目 + def project_from_current_project(project, user) + project = Project.where("user_id =? and forked_from_project_id =?",user, project).first end # copy a project for fork - def copy_project(project, gproject) + def copy_project(tproject, gproject) project = Project.new - 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.name = tproject.name + project.is_public = tproject.is_public + project.status = tproject.status + project.description = tproject.description + project.hidden_repo = tproject.hidden_repo project.user_id = User.current.id project.project_type = 0 - project.project_new_type = @project.project_new_type + project.project_new_type = tproject.project_new_type project.gpid = gproject.id + project.forked_from_project_id = tproject.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]) @@ -124,16 +145,16 @@ class RepositoriesController < ApplicationController def copy_repository(project, gproject) # 避免 - if is_sigle_identifier?(project.user_id, 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 + # else + # flash[:notice] = l(:project_gitlab_create_double_message) + # end end def newrepo diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 324dc6202..d8b7c4625 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -25,8 +25,10 @@ -
    Fork 0
    - + + +
    <%= link_to "Fork", :controller => 'repositories', :action => 'forked'%> + <%= @project.forked_count.to_i %>
    <% if @changesets && !@changesets.empty? %> diff --git a/db/migrate/20151204062220_add_forked_count_to_projects.rb b/db/migrate/20151204062220_add_forked_count_to_projects.rb new file mode 100644 index 000000000..79fdc2573 --- /dev/null +++ b/db/migrate/20151204062220_add_forked_count_to_projects.rb @@ -0,0 +1,5 @@ +class AddForkedCountToProjects < ActiveRecord::Migration + def change + add_column :projects, :forked_count, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 6ad6c585f..a1e14c3bd 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 => 20151203072815) do +ActiveRecord::Schema.define(:version => 20151204062220) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -738,17 +738,6 @@ ActiveRecord::Schema.define(:version => 20151203072815) do add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id" - create_table "homework_detail_groups", :force => true do |t| - t.integer "homework_common_id" - t.integer "min_num" - t.integer "max_num" - t.integer "base_on_project" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "homework_detail_groups", ["homework_common_id"], :name => "index_homework_detail_groups_on_homework_common_id" - create_table "homework_detail_manuals", :force => true do |t| t.float "ta_proportion" t.integer "comment_status" @@ -1330,6 +1319,7 @@ ActiveRecord::Schema.define(:version => 20151203072815) do t.integer "project_new_type" t.integer "gpid" t.integer "forked_from_project_id" + t.integer "forked_count" end add_index "projects", ["lft"], :name => "index_projects_on_lft" diff --git a/lib/gitlab-cli/lib/gitlab/client/projects.rb b/lib/gitlab-cli/lib/gitlab/client/projects.rb index 3fab4347f..8d91edd06 100644 --- a/lib/gitlab-cli/lib/gitlab/client/projects.rb +++ b/lib/gitlab-cli/lib/gitlab/client/projects.rb @@ -241,8 +241,9 @@ class Gitlab::Client # 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}") + def fork(gpid, gid) + post ("/projects/fork/#{gpid}?user_id=#{gid}") + # post("/projects/fork/#{id}") end # Mark this project as forked from the other From 4a41039fa62546d4b7953507cc3378ef493250a0 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 4 Dec 2015 15:58:56 +0800 Subject: [PATCH 071/105] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=8B=B1=E9=9B=84?= =?UTF-8?q?=E6=A6=9C=E6=94=B9=E6=88=90=E8=AF=BE=E7=A8=8B=E6=B4=BB=E8=B7=83?= =?UTF-8?q?=E5=BA=A6?= 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 981d44ce7..c37af0dc1 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -208,7 +208,7 @@
    <% unless contributor_course_scor(@course.id).count == 0 %>
      -

      课程贡献榜

      +

      课程活跃度

      <% contributor_course_scor(@course.id).each do |contributor_score| %> <% unless contributor_score.total_score ==0 %>
    • <%=link_to image_tag(url_to_avatar(contributor_score.user), :width => "35", :height => "35", :class=> "rankPortrait"),user_path(contributor_score.user) %> From dfa9b4cf743f5f5165f3d5105683e97a5f0ce718 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 4 Dec 2015 16:13:55 +0800 Subject: [PATCH 072/105] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/member.html.erb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/views/courses/member.html.erb b/app/views/courses/member.html.erb index ce336373b..e906bf778 100644 --- a/app/views/courses/member.html.erb +++ b/app/views/courses/member.html.erb @@ -1,9 +1,10 @@ -
      -

      <%= @subPage_title%>

      -
      -<% if @subPage_title == l(:label_student_list)%> - <%= render :partial => 'course_student', :locals => {:members => @members} %> -<% else%> - <%= render :partial => 'course_teacher', :locals => {:members => @members} %> -<% end%> - +
      +

      <%= @subPage_title%>

      + 修改角色 +
      +<% if @subPage_title == l(:label_student_list)%> + <%= render :partial => 'course_student', :locals => {:members => @members} %> +<% else%> + <%= render :partial => 'course_teacher', :locals => {:members => @members} %> +<% end%> + From 8fe53468e1e1ba3988370ae99d486951104dcc65 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 4 Dec 2015 16:21:11 +0800 Subject: [PATCH 073/105] =?UTF-8?q?=E4=BD=9C=E5=93=81=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E9=99=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 14 ++- app/helpers/student_work_helper.rb | 11 ++ app/models/student_work.rb | 1 + app/views/attachments/destroy.js.erb | 9 ++ .../_programing_work_show.html.erb | 29 ++++- .../student_work/_revise_attachment.html.erb | 28 +++++ .../student_work/_revise_attachments.html.erb | 30 ----- app/views/student_work/_show.html.erb | 57 +++++---- .../student_work/_upload_attachment.html.erb | 50 ++++++++ .../student_work/revise_attachment.js.erb | 2 + config/routes.rb | 1 + public/javascripts/attachments.js | 118 ++++++++++++++++++ public/stylesheets/courses.css | 18 +++ public/stylesheets/public.css | 2 +- public/stylesheets/public_new.css | 2 +- 15 files changed, 311 insertions(+), 61 deletions(-) create mode 100644 app/views/student_work/_revise_attachment.html.erb delete mode 100644 app/views/student_work/_revise_attachments.html.erb create mode 100644 app/views/student_work/_upload_attachment.html.erb create mode 100644 app/views/student_work/revise_attachment.js.erb diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index dd2a5b5fc..5e71b0114 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -4,7 +4,7 @@ class StudentWorkController < ApplicationController require 'bigdecimal' require "base64" before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule,:forbidden_anonymous_comment,:delete_work] - before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work] + before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work,:revise_attachment] before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work] before_filter :author_of_work, :only => [:edit, :update, :destroy] before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :set_score_rule, :forbidden_anonymous_comment] @@ -527,6 +527,18 @@ class StudentWorkController < ApplicationController @course_activity = params[:course_activity].to_i end + def revise_attachment + Attachment.attach_filesex(@work, params[:attachments], params[:attachment_type]) + revise_attachments = @work.attachments.where("attachtype = 7").reorder("created_on desc") + if revise_attachments.count == 2 + revise_attachments.last.destroy + end + #@attachment = @work.attachments.where("attachtype = 7").order("created_on desc").first + respond_to do |format| + format.js + end + end + private def hsd_committed_work?(user, homework) sw = StudentWork.where("user_id =? and homework_common_id =?", user, homework).first diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb index e1cf3464e..df5c872f8 100644 --- a/app/helpers/student_work_helper.rb +++ b/app/helpers/student_work_helper.rb @@ -126,4 +126,15 @@ module StudentWorkHelper end type end + + def revise_attachment_status homework, attach + date = Time.parse(format_time(attach.created_on.to_s)).strftime("%Y-%m-%d") + status = "" + if homework.homework_detail_manual && ((homework.anonymous_comment == 0 &&homework.homework_detail_manual.evaluation_start.to_s <= date) || (homework.anonymous_comment == 1 && homework.end_time < date)) + status = "此时其他同学作品已公开" + else + status = "此时其他同学作品尚未公开" + end + return status + end end \ No newline at end of file diff --git a/app/models/student_work.rb b/app/models/student_work.rb index 010ede635..884f4a089 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -10,6 +10,7 @@ class StudentWork < ActiveRecord::Base has_many :student_work_tests, order: 'id desc' # course's message has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy + has_many :attachments, :dependent => :destroy before_destroy :delete_praise before_save :set_program_score, :set_src diff --git a/app/views/attachments/destroy.js.erb b/app/views/attachments/destroy.js.erb index d23422e24..cfbe68085 100644 --- a/app/views/attachments/destroy.js.erb +++ b/app/views/attachments/destroy.js.erb @@ -1,5 +1,9 @@ <% if @is_destroy%> $("#attachment_<%= @attachment.id%>").remove(); + if(document.getElementById("uploadReviseBox")) { + $("#uploadReviseBox").removeClass('disable_link'); + $("#choose_revise_attach").attr("onclick","_file.click();"); + } <%else%> var attachment_html_obj = $('#attachments_<%= j params[:attachment_id] %>'); //modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 start @@ -26,5 +30,10 @@ $('#upload_file_count'+containerid).html(""+count+""+"个文件"+"已上传"); } } + + if(document.getElementById("uploadReviseBox")) { + $("#uploadReviseBox").removeClass('disable_link'); + $("#choose_revise_attach").attr("onclick","_file.click();"); + } //modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 end <% end%> \ No newline at end of file diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb index fd541c643..fc246ab8b 100644 --- a/app/views/student_work/_programing_work_show.html.erb +++ b/app/views/student_work/_programing_work_show.html.erb @@ -89,6 +89,11 @@
    +
    + <%= render :partial => 'student_work/revise_attachment', :locals => {:work => work} %> +
    +
    +
    <%student_work_scores.each do |student_score|%>
    @@ -99,4 +104,26 @@ 收起
    -
    \ No newline at end of file +
    + diff --git a/app/views/student_work/_revise_attachment.html.erb b/app/views/student_work/_revise_attachment.html.erb new file mode 100644 index 000000000..968a4853b --- /dev/null +++ b/app/views/student_work/_revise_attachment.html.erb @@ -0,0 +1,28 @@ +<% revise_attachment = work.attachments.where("attachtype = 7").first %> +<% if @homework.end_time < Date.today %> + <% if revise_attachment && @is_teacher %> +
    + 追加修订附件 +
    +
    + 追加附件: + <%= render :partial => 'work_attachments_status', :locals => {:attachments => work.attachments.where("attachtype = 7"), :status => 2} %> + 追加时间:<%=format_time revise_attachment.created_on.to_s %>  (<%=revise_attachment_status @homework,revise_attachment %>) +
    + <% end %> + <% if work.user == User.current %> +
    + 追加修订附件 +
    + <% if revise_attachment %> +
    + 追加附件: + <%= render :partial => 'work_attachments_status', :locals => {:attachments => work.attachments.where("attachtype = 7"), :status => 1} %> + 追加时间:<%=format_time revise_attachment.created_on.to_s %> +
    + <% end %> + + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/student_work/_revise_attachments.html.erb b/app/views/student_work/_revise_attachments.html.erb deleted file mode 100644 index 1321da368..000000000 --- a/app/views/student_work/_revise_attachments.html.erb +++ /dev/null @@ -1,30 +0,0 @@ -
    -
    - - 上传附件 - <%#= button_tag "上传附件", :type=>"button", :onclick=>"$('#_file#{work.id}').click();",:onmouseover => 'this.focus()',:class => 'blueCir ml5' %> - <%= file_field_tag 'attachments[dummy][file]', - :id => "_file#{work.id}", - :class => 'file_selector', - :multiple => true, - :onchange => "addReviseFiles(this, '#{work.id}');", - :style => 'display:none', - :data => { - :max_file_size => Setting.attachment_max_size.to_i.kilobytes, - :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), - :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, - :upload_path => uploads_path(:format => 'js'), - :description_placeholder => l(:label_optional_description), - :field_is_public => l(:field_is_public), - :are_you_sure => l(:text_are_you_sure), - :file_count => l(:label_file_count), - :lebel_file_uploding => l(:lebel_file_uploding), - :delete_all_files => l(:text_are_you_sure_all), - :containerid => "#{work.id}" - } %> - - <% content_for :header_tags do %> - <%= javascript_include_tag 'attachments' %> - <% end %> -
    - diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb index 894f9fb39..993b0f2aa 100644 --- a/app/views/student_work/_show.html.erb +++ b/app/views/student_work/_show.html.erb @@ -41,17 +41,18 @@
  • 附件: - <% if work.attachments.empty?%> + <% com_attachments = work.attachments.where("attachtype IS NULL OR attachtype <> 7") %> + <% if com_attachments.empty?%> 尚未提交附件 <% else%>
    - <%= render :partial => 'work_attachments_status', :locals => {:attachments => work.attachments, :status => @homework.homework_detail_manual.comment_status} %> + <%= render :partial => 'work_attachments_status', :locals => {:attachments => com_attachments, :status => @homework.homework_detail_manual.comment_status} %>
    <% end%>
  • - <% if @is_teacher || (@homework.homework_detail_manual.comment_status == 2 && work.user != User.current )%> + <% if @is_teacher || (@homework.homework_detail_manual.comment_status == 2 && work.user != User.current)%>
    <%= render :partial => 'add_score',:locals => {:work => work,:score => score}%> @@ -61,30 +62,10 @@
  • - - <%#= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename link_file', :readonly=>'readonly')%> - <%#= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %> - - <%#= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'is_public')%> - <%#= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %> - <%#= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> - +
    <%student_work_scores.each do |student_score|%> @@ -96,4 +77,26 @@ 收起
    -
    \ No newline at end of file +
    + \ No newline at end of file diff --git a/app/views/student_work/_upload_attachment.html.erb b/app/views/student_work/_upload_attachment.html.erb new file mode 100644 index 000000000..d9c69fc17 --- /dev/null +++ b/app/views/student_work/_upload_attachment.html.erb @@ -0,0 +1,50 @@ + +上传附件 + +
    + <%= form_tag(revise_attachment_student_work_path(work.id), :multipart => true,:remote => !ie8?,:name=>"upload_form",:id=>'upload_form') do %> +
    + + +
    +
    + + + 选择文件 + <%= file_field_tag 'attachments[dummy][file]', + :id => '_file', + :class => ie8? ? '':'file_selector', + :multiple => true, + :onchange => 'addReviseInputFiles(this,"'+'upload_files_submit_btn'+'");', + :style => ie8? ? '': 'display:none', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :upload_path => uploads_path(:format => 'js'), + :description_placeholder => l(:label_optional_description), + :field_is_public => l(:field_is_public), + :are_you_sure => l(:text_are_you_sure), + :file_count => l(:label_file_count), + :lebel_file_uploding => l(:lebel_file_uploding), + :delete_all_files => l(:text_are_you_sure_all) + } %> +
    + + +
    +
    +
    最多只能上传一个小于50MB的附件
    +
    +
    +
    +
    + <%= submit_tag '确定',:onclick=>'submit_files();',:onfocus=>'this.blur()',:id=>'upload_files_submit_btn',:class=>'sendSourceText' %> +
    +
    + 取消 +
    +
    + <% end %> +
    +
    diff --git a/app/views/student_work/revise_attachment.js.erb b/app/views/student_work/revise_attachment.js.erb new file mode 100644 index 000000000..74813d27b --- /dev/null +++ b/app/views/student_work/revise_attachment.js.erb @@ -0,0 +1,2 @@ +closeModal(); +$("#revise_attachment").html('<%= escape_javascript( render :partial => 'revise_attachment' ,:locals=>{ :work => @work})%>'); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index f6fe95a33..59eb29d70 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -206,6 +206,7 @@ RedmineApp::Application.routes.draw do resources :student_work do member do post 'add_score' + post 'revise_attachment' get 'retry_work' get 'praise_student_work' get 'forbidden_anonymous_comment' diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js index d7b49c8be..b60b6ad28 100644 --- a/public/javascripts/attachments.js +++ b/public/javascripts/attachments.js @@ -154,6 +154,73 @@ function addFile(inputEl, file, eagerUpload,btnId) { } addFile.nextAttachmentId = 1; +function addReviseFile(inputEl, file, eagerUpload,btnId) { + + var attachments_frame = '#attachments_fields'; + if ($(attachments_frame).children().length < 30) { + deleteallfiles = $(inputEl).data('deleteAllFiles'); + var attachmentId = addFile.nextAttachmentId++; + + var fileSpan = $('', { + 'id': 'attachments_' + attachmentId, + 'class': 'attachment' + }); + + fileSpan.append( + $('', { + 'type': 'text', + 'class': 'upload_filename readonly', + 'name': 'attachments[' + attachmentId + '][filename]', + 'readonly': 'readonly' + }).val(file.name), +// $('', { +// 'type': 'text', +// 'class': 'description', +// 'name': 'attachments[' + attachmentId + '][description]', +// 'maxlength': 254, +// 'placeholder': $(inputEl).data('descriptionPlaceholder') +// }).toggle(!eagerUpload), +// $('' + $(inputEl).data('fieldIsPublic') + ':').attr({ +// 'class': 'ispublic-label' +// }), +// $('', { +// 'type': 'checkbox', +// 'class': 'is_public_checkbox', +// 'value': 1, +// 'name': 'attachments[' + attachmentId + '][is_public_checkbox]', +// checked: 'checked' +// }).toggle(!eagerUpload), + $(' ').attr({ + 'href': "#", + 'class': 'remove-upload' + }).click(function() { + if (confirm($(inputEl).data('areYouSure'))) { + removeReviseFile(); + if (!eagerUpload) { + (function(e) { + reload(e); + })(fileSpan); + } + } + + }).toggle(!eagerUpload), + $('
    ', { + 'class': 'div_attachments', + 'name': 'div_' + 'attachments_' + attachmentId + }) + ).appendTo('#attachments_fields'); + + $("#uploadReviseBox").addClass('disable_link'); + $("#choose_revise_attach").attr("onclick","return false;"); + + if (eagerUpload) { + ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId); + } + return attachmentId; + } + return null; +} + function ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId) { //上传开始调用函数 function onLoadstart(e) { @@ -293,6 +360,13 @@ function removeFile() { return false; } +function removeReviseFile() { + $(this).parent('span').remove(); + $("#uploadReviseBox").removeClass('disable_link'); + $("#choose_revise_attach").attr("onclick","_file.click();"); + return false; +} + //gcm delete all file //modify by yutao 2015-5-14 ��1��ҳ����ڶ���ϴ��ؼ�ʱ�˿�������bug �ʸ�֮ start function removeAll(containerid) { @@ -346,6 +420,30 @@ function uploadBlob(blob, uploadUrl, attachmentId, options) { }); } +function addReviseInputFiles(inputEl,btnId) { + // var clearedFileInput = $(inputEl).clone().val(''); + if (inputEl.files) { + uploadAndAttachReviseFiles(inputEl.files, inputEl,btnId); + // $(inputEl).remove(); + } else { + // browser not supporting the file API, upload on form submission + var attachmentId; + var aFilename = inputEl.value.split(/\/|\\/); + var count = $('#attachments_fields>span').length; + attachmentId = addReviseFile(inputEl, { + name: aFilename[aFilename.length - 1] + }, false); + if (attachmentId) { + $(inputEl).attr({ + name: 'attachments[' + attachmentId + '][file]' + }).hide(); + if (count <= 0) count = 1; + } + } + + //clearedFileInput.insertAfter('#attachments_fields'); +} + function addInputFiles(inputEl,btnId) { // var clearedFileInput = $(inputEl).clone().val(''); if (inputEl.files) { @@ -405,6 +503,26 @@ function addInputFiles_board(inputEl, id,btnId) { //clearedFileInput.insertAfter('#attachments_fields'); } +function uploadAndAttachReviseFiles(files, inputEl,btnId) { + + var maxFileSize = $(inputEl).data('max-file-size'); + var maxFileSizeExceeded = $(inputEl).data('max-file-size-message'); + + var sizeExceeded = false; + $.each(files, function() { + if (this.size && maxFileSize != null && this.size > parseInt(maxFileSize)) { + sizeExceeded = true; + } + }); + if (sizeExceeded) { + window.alert(maxFileSizeExceeded); + } else { + $.each(files, function() { + addReviseFile(inputEl, this, true,btnId); + }); + } +} + function uploadAndAttachFiles(files, inputEl,btnId) { var maxFileSize = $(inputEl).data('max-file-size'); diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 584a49a4f..c2132c3fa 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -1197,3 +1197,21 @@ a:hover.memberBtn{background: url(/images/course/hwork_icon.png) -80px -90px no- .resubTitle {position:absolute; top:-10px; left:5px; background-color:#ffffff; display:block; font-weight:bold; padding:0px 2px;} a.blueCir{ display:inline-block; padding:2px 5px; background-color:#ffffff;border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;} a:hover.blueCir{ background:#3598db; color:#fff;} + +/*上传资源弹窗*/ +.resourceUploadPopup {width:400px; height:auto; border:3px solid #269ac9 !important; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-200px; z-index:1000;} +.uploadDialogText {font-size:16px; color:#269ac9; line-height:16px; padding-top:20px; width:140px; display:inline-block; font-weight: bold;} +.uploadBoxContainer {height:33px; line-height:33px; margin-top:10px; position:relative} +.uploadBox {width:100px; height:33px; line-height:33px; text-align:center; vertical-align:middle; background-color:#269ac9; border-radius:3px; float:left; margin-right:12px;} +a.uploadBoxIcon {background:url(images/resource_icon_list.png) -35px 10px no-repeat; float:left; display:block; width:81px; height:30px; padding-left:22px; font-size:14px; color:#ffffff;} +a.uploadIcon {background:url(images/resource_icon_list.png) 8px -60px no-repeat; width:100px; height:33px;} +.chooseFile {color:#ffffff; display:block; margin-left:32px;} +.uploadResourceIntr {width:250px; height:33px; float:left; line-height:33px; font-size:12px;} +.uploadResourceName {width:250px; display:inline-block; line-height:15px; font-size:12px; color:#444444; margin-bottom:2px;} +.uploadResourceIntr2 {width:250px; display:inline-block; line-height:15px; font-size:12px; color:#444444;} +.uploadType {margin:10px 0; border:1px solid #e6e6e6; width:100px; height:30px; outline:none; font-size:12px; color:#888888;} +.uploadKeyword {margin-bottom:10px; outline:none; border:1px solid #e6e6e6; height:30px; width:280px;} +.mb10 {margin-bottom: 10px} +.mb15 {margin-bottom: 15px} +div.disable_link {background-color: #c1c1c1 !important;} +div.disable_link :hover {background-color: #c1c1c1} \ No newline at end of file diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index a1dfe3f4d..70aad2cbe 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -410,7 +410,7 @@ a:hover.search_btn{ background: #0fa9bb;} .resourcesSendTo {float:left; height:20px; margin-top:15px;} .resourcesSendType {border:1px solid #e6e6e6; width:60px; height:24px; outline:none; font-size:14px; color:#888888;} .resourcePopupClose {width:20px; height:20px; display:inline-block; float:right;} -.resourceClose {background:url(../images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block;} +.resourceClose {background:url(images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block; position: absolute; z-index: 1000;} .resourcesSearchBox {border:1px solid #e6e6e6; width:225px; height:25px; background-color:#ffffff; margin-top:12px; margin-bottom:15px;} .searchResourcePopup {border:none; outline:none; background-color:#ffffff; width:184px; height:25px; padding-left:10px; display:inline-block; float:left;} .courseSend {width:260px; height:15px; line-height:15px; margin-bottom:10px;} diff --git a/public/stylesheets/public_new.css b/public/stylesheets/public_new.css index db2d021d9..c60adf460 100644 --- a/public/stylesheets/public_new.css +++ b/public/stylesheets/public_new.css @@ -566,7 +566,7 @@ a.uploadIcon {background:url(images/resource_icon_list.png) 8px -60px no-repeat; .resourceSharePopup {width:300px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-150px; z-index:1000;} .sendText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:100px; display:inline-block;} .resourcePopupClose {width:20px; height:20px; display:inline-block; float:right;} -.resourceClose {background:url(images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block;} +.resourceClose {background:url(images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block; position: absolute; z-index: 1000;} .resourcesSearchBox {border:1px solid #e6e6e6; width:225px; height:25px; background-color:#ffffff; margin-top:12px; margin-bottom:15px;} .searchResourcePopup {border:none; outline:none; background-color:#ffffff; width:184px; height:25px; padding-left:10px; display:inline-block; float:left;} .searchIconPopup{width:31px; height:25px; background-color:#ffffff; background:url(images/resource_icon_list.png) -40px -18px no-repeat; display:inline-block; float:left;} From b6edabed9c059ccd07750876799310c6f378f319 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 4 Dec 2015 16:21:48 +0800 Subject: [PATCH 074/105] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A7=92=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 1 + app/views/courses/settings.html.erb | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index cd1de16fc..5da9db395 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -374,6 +374,7 @@ class CoursesController < ApplicationController def settings if User.current.allowed_to?(:as_teacher,@course) + @issue_custom_fields = IssueCustomField.sorted.all @issue_category ||= IssueCategory.new @member ||= @course.members.new diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb index 5c3918f00..8d3454776 100644 --- a/app/views/courses/settings.html.erb +++ b/app/views/courses/settings.html.erb @@ -1,6 +1,13 @@

    <%= l(:label_course_modify_settings)%>

    +
      @@ -118,4 +125,4 @@ } $("#time_selected").click(select); $("#term_selected").click(select); - + From 9716e99533600417b6b4f0b2b98ba9b2664e3560 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 4 Dec 2015 16:33:56 +0800 Subject: [PATCH 075/105] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=88=90=E5=91=98?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E2=80=9C=E4=BF=AE=E6=94=B9=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 2 +- app/views/courses/member.html.erb | 6 +++++- app/views/courses/settings.html.erb | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 5da9db395..0c61c449e 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -374,7 +374,7 @@ class CoursesController < ApplicationController def settings if User.current.allowed_to?(:as_teacher,@course) - + @select_tab = params[:tab] @issue_custom_fields = IssueCustomField.sorted.all @issue_category ||= IssueCategory.new @member ||= @course.members.new diff --git a/app/views/courses/member.html.erb b/app/views/courses/member.html.erb index e906bf778..3aa7d4b57 100644 --- a/app/views/courses/member.html.erb +++ b/app/views/courses/member.html.erb @@ -1,6 +1,10 @@

      <%= @subPage_title%>

      - 修改角色 + <% if User.current.allowed_to?(:as_teacher,@course) %> + + <%=link_to "修改角色", :controller => 'courses', :action => 'settings', :id => @course.id, :tab=>'member' %> + + <% end %>
      <% if @subPage_title == l(:label_student_list)%> <%= render :partial => 'course_student', :locals => {:members => @members} %> diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb index 8d3454776..3456634d5 100644 --- a/app/views/courses/settings.html.erb +++ b/app/views/courses/settings.html.erb @@ -3,7 +3,7 @@
    \ No newline at end of file diff --git a/app/views/student_work/update.js.erb b/app/views/student_work/update.js.erb index 79733db31..f485cb8cc 100644 --- a/app/views/student_work/update.js.erb +++ b/app/views/student_work/update.js.erb @@ -1,5 +1,5 @@ <% if @submit_result%> -$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/work_information') %>'); +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/work_edit_information') %>'); showModal('ajax-modal', '500px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before("" + From 6fad26cabf1c16c7cd566b59d931dae4ca7158b9 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 4 Dec 2015 17:32:56 +0800 Subject: [PATCH 080/105] =?UTF-8?q?=E5=8E=BB=E6=AD=BB=E5=A5=A5placebold?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/repositories/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index c41945885..ca62b9664 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -22,7 +22,7 @@ <% else %> <%= render :partial => 'navigation' %>
    克隆网址:
    - + From ab4d0e46785d92818b0f5771426d72f3f7787b4d Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 4 Dec 2015 17:34:48 +0800 Subject: [PATCH 081/105] =?UTF-8?q?=E7=BB=84=E7=BB=87=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=86=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javascripts/org_subfields.js.coffee | 3 + app/assets/stylesheets/org_subfields.css.scss | 3 + app/controllers/org_subfields_controller.rb | 19 ++++++ app/helpers/org_subfields_helper.rb | 2 + app/models/org_subfield.rb | 3 + app/models/organization.rb | 1 + app/views/layouts/base_org.html.erb | 55 +---------------- app/views/org_subfields/create.js.erb | 4 ++ app/views/org_subfields/destroy.js.erb | 4 ++ app/views/org_subfields/update.js.erb | 1 + .../_org_left_subfield_list.html.erb | 60 +++++++++++++++++++ .../organizations/_subfield_list.html.erb | 51 ++++++++++++++++ app/views/organizations/setting.html.erb | 27 ++++++++- config/routes.rb | 4 ++ .../20151204030143_create_org_subfields.rb | 13 ++++ public/stylesheets/org.css | 12 +++- .../org_subfields_controller_spec.rb | 5 ++ 17 files changed, 211 insertions(+), 56 deletions(-) create mode 100644 app/assets/javascripts/org_subfields.js.coffee create mode 100644 app/assets/stylesheets/org_subfields.css.scss create mode 100644 app/controllers/org_subfields_controller.rb create mode 100644 app/helpers/org_subfields_helper.rb create mode 100644 app/models/org_subfield.rb create mode 100644 app/views/org_subfields/create.js.erb create mode 100644 app/views/org_subfields/destroy.js.erb create mode 100644 app/views/org_subfields/update.js.erb create mode 100644 app/views/organizations/_org_left_subfield_list.html.erb create mode 100644 app/views/organizations/_subfield_list.html.erb create mode 100644 db/migrate/20151204030143_create_org_subfields.rb create mode 100644 spec/controllers/org_subfields_controller_spec.rb diff --git a/app/assets/javascripts/org_subfields.js.coffee b/app/assets/javascripts/org_subfields.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/org_subfields.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_subfields.css.scss b/app/assets/stylesheets/org_subfields.css.scss new file mode 100644 index 000000000..19263385e --- /dev/null +++ b/app/assets/stylesheets/org_subfields.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the org_subfields 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/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb new file mode 100644 index 000000000..da20b6fcf --- /dev/null +++ b/app/controllers/org_subfields_controller.rb @@ -0,0 +1,19 @@ +class OrgSubfieldsController < ApplicationController + def create + @subfield = OrgSubfield.create(:name => params[:name]) + @organization = Organization.find(params[:organization_id]) + @organization.org_subfields << @subfield + @subfield.update_attributes(:priority => @subfield.id) + end + + def destroy + @subfield = OrgSubfield.find(params[:id]) + @organization = Organization.find(@subfield.organization_id) + @subfield.destroy + end + + def update + @subfield = OrgSubfield.find(params[:id]) + @subfield.update_attributes(:name => params[:name]) + end +end diff --git a/app/helpers/org_subfields_helper.rb b/app/helpers/org_subfields_helper.rb new file mode 100644 index 000000000..a9f8a396f --- /dev/null +++ b/app/helpers/org_subfields_helper.rb @@ -0,0 +1,2 @@ +module OrgSubfieldsHelper +end diff --git a/app/models/org_subfield.rb b/app/models/org_subfield.rb new file mode 100644 index 000000000..1660310f8 --- /dev/null +++ b/app/models/org_subfield.rb @@ -0,0 +1,3 @@ +class OrgSubfield < ActiveRecord::Base + belongs_to :organization, :foreign_key => :organization_id +end \ No newline at end of file diff --git a/app/models/organization.rb b/app/models/organization.rb index a35f68c26..350dc3080 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -6,6 +6,7 @@ class Organization < ActiveRecord::Base has_many :courses, :through => :org_courses has_many :org_document_comments, :dependent => :destroy has_many :org_courses, :dependent => :destroy + has_many :org_subfields, :dependent => :destroy has_many :users, :through => :org_members validates_uniqueness_of :name after_create :save_as_org_activity diff --git a/app/views/layouts/base_org.html.erb b/app/views/layouts/base_org.html.erb index b071a7c3b..aa46c35ee 100644 --- a/app/views/layouts/base_org.html.erb +++ b/app/views/layouts/base_org.html.erb @@ -81,59 +81,8 @@ <%= link_to '成员', members_organization_path(@organization.id) %> (<%= link_to @organization.org_members.count, members_organization_path(@organization.id), :id => 'org_members_count_id', :class => "linkBlue" %>)
    -
    -
    - <%= link_to "动态",organization_path(@organization), :class => "homepageMenuText" %> -
    -
    - 项目 - <%=link_to "", join_project_menu_organization_path(@organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联项目"%> - - - - - - - - - - - - - -
    -
    -
      - <%= render :partial => 'layouts/org_projects',:locals=>{:projects=>@organization.projects.reorder('created_at').uniq.limit(5),:org_id=>@organization.id,:page=>1}%> - - - - -
    -
    -
    - 课程 - <%=link_to "", join_course_menu_organization_path(@organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%> - <%#= link_to "关联课程",join_course_menu_organization_path(@organization),:remote => true,:class => "menuGrey",:method => "post"%> - - - - - - - - - - - - - -
    -
    -
      - <%= render :partial => 'layouts/org_courses',:locals=>{:courses=>@organization.courses.reorder('created_at').uniq.limit(5),:org_id=>@organization.id,:page=>1}%> -
    -
    +
    + <%= render :partial => "organizations/org_left_subfield_list", :locals => {:organization => @organization} %>
    diff --git a/app/views/org_subfields/create.js.erb b/app/views/org_subfields/create.js.erb new file mode 100644 index 000000000..8a676e93e --- /dev/null +++ b/app/views/org_subfields/create.js.erb @@ -0,0 +1,4 @@ +$("#org_subfield_list").html(""); +$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list',:locals => {:subfields => @organization.org_subfields }) %>"); +$("#sub_field_left_lists").html(""); +$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); \ No newline at end of file diff --git a/app/views/org_subfields/destroy.js.erb b/app/views/org_subfields/destroy.js.erb new file mode 100644 index 000000000..8a676e93e --- /dev/null +++ b/app/views/org_subfields/destroy.js.erb @@ -0,0 +1,4 @@ +$("#org_subfield_list").html(""); +$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list',:locals => {:subfields => @organization.org_subfields }) %>"); +$("#sub_field_left_lists").html(""); +$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); \ No newline at end of file diff --git a/app/views/org_subfields/update.js.erb b/app/views/org_subfields/update.js.erb new file mode 100644 index 000000000..2def5c5f8 --- /dev/null +++ b/app/views/org_subfields/update.js.erb @@ -0,0 +1 @@ +$("#subfield_show_<%= @subfield.id %>").html("<%= @subfield.name %>"); \ No newline at end of file diff --git a/app/views/organizations/_org_left_subfield_list.html.erb b/app/views/organizations/_org_left_subfield_list.html.erb new file mode 100644 index 000000000..7c30aa600 --- /dev/null +++ b/app/views/organizations/_org_left_subfield_list.html.erb @@ -0,0 +1,60 @@ +
    + <%= link_to "动态",organization_path(organization), :class => "homepageMenuText" %> +
    +
    + 项目 + <%=link_to "", join_project_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联项目"%> + + + + + + + + + + + + + +
    +
    +
      + <%= render :partial => 'layouts/org_projects',:locals=>{:projects=>organization.projects.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> + + + + +
    +
    +
    + 课程 + <%=link_to "", join_course_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%> + <%#= link_to "关联课程",join_course_menu_organization_path(organization),:remote => true,:class => "menuGrey",:method => "post"%> + + + + + + + + + + + + + +
    +
    +
      + <%= render :partial => 'layouts/org_courses',:locals=>{:courses=>organization.courses.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> +
    +
    +<% organization.org_subfields.each do |field| %> +
    + <%= field.name %> + <%=link_to "", :title => "关联#{field.name}"%> +
    +
    +
    +<% end %> \ No newline at end of file diff --git a/app/views/organizations/_subfield_list.html.erb b/app/views/organizations/_subfield_list.html.erb new file mode 100644 index 000000000..f148fc561 --- /dev/null +++ b/app/views/organizations/_subfield_list.html.erb @@ -0,0 +1,51 @@ + +
      +
    • 已有栏目
    • +
    • 状态
    • +
      +
    +
      +
    • 动态
    • +
    • 默认
    • +
      +
    +
      +
    • 项目
    • +
    • 默认
    • +
      +
    +
      +
    • 课程
    • +
    • 默认
    • +
      +
    + <% subfields.each do |field| %> +
      +
    • <%= field.name %>
    • +
    • 新增
    • + <%= link_to "删除",org_subfield_path(field), :method => 'delete',:remote => true, :confirm => "您确定删除吗?", :class => "linkBlue fr mr5" %> + 编辑 +
      +
    + <% end %> + + \ No newline at end of file diff --git a/app/views/organizations/setting.html.erb b/app/views/organizations/setting.html.erb index 96fef706a..138a7993a 100644 --- a/app/views/organizations/setting.html.erb +++ b/app/views/organizations/setting.html.erb @@ -2,7 +2,7 @@ function g(o){return document.getElementById(o);} function HoverLi(n){ //如果有N个标签,就将i<=N; - for(var i=1;i<=2;i++){ + for(var i=1;i<=3;i++){ g('orgSetting_'+i).className='orgSettingOp'; g('orgContent_'+i).className='undis';} g('orgContent_'+n).className='dis ml15 mr15'; @@ -34,6 +34,7 @@
    • 信息
    • 成员
    • +
    • 分栏
    @@ -104,4 +105,26 @@
    - \ No newline at end of file +
    +
    + <%= render :partial => 'organizations/subfield_list', :locals => {:subfields => @organization.org_subfields } %> +
    +
    +
    +

    新增栏目

    + <%= form_tag url_for(:controller => 'org_subfields', :action => 'create', :organization_id => @organization.id), :id=> 'add_subfield_form',:remote => true do %> + +
    + 确定 + <% end %> +
    +
    +
    +
    + + \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index bb6d7b940..27e9d7861 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -70,6 +70,10 @@ RedmineApp::Application.routes.draw do end end + resources :org_subfields do + + end + resources :org_document_comments do member do post 'add_reply' diff --git a/db/migrate/20151204030143_create_org_subfields.rb b/db/migrate/20151204030143_create_org_subfields.rb new file mode 100644 index 000000000..2727cdef0 --- /dev/null +++ b/db/migrate/20151204030143_create_org_subfields.rb @@ -0,0 +1,13 @@ +class CreateOrgSubfields < ActiveRecord::Migration + def up + create_table :org_subfields do |t| + t.integer :organization_id + t.integer :priority + t.string :name + t.timestamps + end + end + + def down + end +end diff --git a/public/stylesheets/org.css b/public/stylesheets/org.css index a0118b263..897eb8734 100644 --- a/public/stylesheets/org.css +++ b/public/stylesheets/org.css @@ -54,4 +54,14 @@ a.cancelBtn:hover {background-color:#717171; color:#ffffff;} /*关联项目弹窗*/ .projectRelate {float:left; max-height:118px;margin-right:16px;margin-bottom:10px; overflow:auto; overflow-x:hidden; width:288px;} -.relateText {font-size:16px; color:#269ac9; line-height:16px; padding-top:20px; display:inline-block; font-weight: bold;} \ No newline at end of file +.relateText {font-size:16px; color:#269ac9; line-height:16px; padding-top:20px; display:inline-block; font-weight: bold;} + +/*组织首页新151204Tim*/ +.orgNav {width:1000px; height:30px; background-color:#cfcfcf; margin:0 auto;} +.orgContainer {width:100%; margin:0 auto; background-color:#cfcfcf;} +.navOrgLogo {width:21px; height:30px; margin-left:2px; margin-right:15px;} +.navOrgMenu {display:inline-block;height:30px; line-height:30px; vertical-align:middle;} +a.linkGrey8 {color:#888888;} +a.linkGrey8:hover {color:#585858;} +.orgBorder {width:583px; height:21px; border-bottom:3px solid #e4e4e4; float:left;} +.orgListRow {border-bottom:1px solid #e4e4e4; padding-bottom:5px; color:#555555;} \ No newline at end of file diff --git a/spec/controllers/org_subfields_controller_spec.rb b/spec/controllers/org_subfields_controller_spec.rb new file mode 100644 index 000000000..4bc89dae0 --- /dev/null +++ b/spec/controllers/org_subfields_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe OrgSubfieldsController, :type => :controller do + +end From 4cb58211ad9a79696c3648f21ef398494160e021 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 4 Dec 2015 17:44:46 +0800 Subject: [PATCH 082/105] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E8=AF=AD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/mailer/send_mail_anonymous_comment_open.html.erb | 2 +- config/locales/mailers/zh.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/mailer/send_mail_anonymous_comment_open.html.erb b/app/views/mailer/send_mail_anonymous_comment_open.html.erb index 5409ade55..3aa3d1c21 100644 --- a/app/views/mailer/send_mail_anonymous_comment_open.html.erb +++ b/app/views/mailer/send_mail_anonymous_comment_open.html.erb @@ -2,7 +2,7 @@
    • <%= l(:mail_issue_content)%> -

      <%=link_to @author, user_url(@author) %> 发布的作业:<%=link_to @anonymous_comment_close_name, @anonymous_comment_close_url%> 已经开启匿评了!

      +

      <%=link_to @author, user_url(@author) %> 发布的作业:<%=link_to @anonymous_comment_close_name, @anonymous_comment_close_url%> 已经开启匿评了,请您关注!

    diff --git a/config/locales/mailers/zh.yml b/config/locales/mailers/zh.yml index 97f0029ea..7b56011b1 100644 --- a/config/locales/mailers/zh.yml +++ b/config/locales/mailers/zh.yml @@ -26,6 +26,6 @@ zh: mail_attention: "请您关注!" mail_homework_endtime: "作业截止时间快到了!" mail_homework: "作业:" - mail_anonymous_comment_close: "作业匿评已经关闭!" + mail_anonymous_comment_close: "作业匿评已经关闭,请您关注!" mail_anonymous_comment_open: "作业匿评已经开启,请您关注!" - mail_anonymous_comment_failed: "作业匿评开启失败!" \ No newline at end of file + mail_anonymous_comment_failed: "作业匿评开启失败,请您关注!" \ No newline at end of file From 5b0bdb5069f7f5c4faae4853187890ae1545da5c Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 4 Dec 2015 18:19:35 +0800 Subject: [PATCH 083/105] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E6=A0=8F=E7=9B=AE=E7=9A=84=E5=86=85=E5=AE=B9=E5=8F=8A=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../organizations/_org_left_subfield_list.html.erb | 4 ++-- app/views/organizations/_subfield_list.html.erb | 11 ++++++++--- app/views/organizations/setting.html.erb | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/views/organizations/_org_left_subfield_list.html.erb b/app/views/organizations/_org_left_subfield_list.html.erb index 7c30aa600..52201fd52 100644 --- a/app/views/organizations/_org_left_subfield_list.html.erb +++ b/app/views/organizations/_org_left_subfield_list.html.erb @@ -45,7 +45,7 @@ -
    +
      <%= render :partial => 'layouts/org_courses',:locals=>{:courses=>organization.courses.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%>
    @@ -55,6 +55,6 @@ <%= field.name %> <%=link_to "", :title => "关联#{field.name}"%>
    -
    + <% end %> \ No newline at end of file diff --git a/app/views/organizations/_subfield_list.html.erb b/app/views/organizations/_subfield_list.html.erb index f148fc561..6ba60245a 100644 --- a/app/views/organizations/_subfield_list.html.erb +++ b/app/views/organizations/_subfield_list.html.erb @@ -34,7 +34,12 @@ function edit(show_id, edit_id){ $(show_id).toggle(); $(edit_id).toggle(); - $(edit_id).focus(); + $(edit_id).find('input').focus(); + $(edit_id).find('input').on('keypress',function(e){ + if(e.keyCode == 13){ + this.blur(); + } + }) } function update_subfield(show_id, edit_id, field_id, input_value) { if ($(show_id).html().trim() != input_value.trim()) { @@ -44,8 +49,8 @@ type :'put' }); } - $(show_id).show(); - $(edit_id).hide(); + $(show_id).show(); + $(edit_id).hide(); // $(edit_id).focus(); } \ No newline at end of file diff --git a/app/views/organizations/setting.html.erb b/app/views/organizations/setting.html.erb index 138a7993a..e0f262b99 100644 --- a/app/views/organizations/setting.html.erb +++ b/app/views/organizations/setting.html.erb @@ -34,7 +34,7 @@
    • 信息
    • 成员
    • -
    • 分栏
    • +
    • 栏目
    From 01b82e59d80d0ad3e5cf1381b68f8f2e5b682bef Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Sat, 5 Dec 2015 11:30:05 +0800 Subject: [PATCH 084/105] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/org_subfields_controller.rb | 1 + app/controllers/organizations_controller.rb | 13 +- app/views/layouts/base_organization.html.erb | 113 ++++++++++++++++++ app/views/org_subfields/update.js.erb | 4 +- .../_org_left_subfield_list.html.erb | 34 +----- app/views/organizations/show.html.erb | 4 +- public/images/home_logo.png | Bin 0 -> 1213 bytes 7 files changed, 134 insertions(+), 35 deletions(-) create mode 100644 app/views/layouts/base_organization.html.erb create mode 100644 public/images/home_logo.png diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index da20b6fcf..6fdf0ae40 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -14,6 +14,7 @@ class OrgSubfieldsController < ApplicationController def update @subfield = OrgSubfield.find(params[:id]) + @organization = Organization.find(@subfield.organization_id) @subfield.update_attributes(:name => params[:name]) end end diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 85f57917b..47a0930a5 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -94,7 +94,11 @@ class OrganizationsController < ApplicationController end @page = params[:page] respond_to do |format| - format.html + format.html { + if !params[:show_homepage].nil? + render :layout => 'base_organization' + end + } format.js end else @@ -102,6 +106,13 @@ class OrganizationsController < ApplicationController end end + def homepage + @organization = Organization.find(params[:id]) + respond_to do |format| + format.html {render :layout => 'base_organization'} + end + end + def update @organization = Organization.find(params[:id]) @organization.name = params[:organization][:name] diff --git a/app/views/layouts/base_organization.html.erb b/app/views/layouts/base_organization.html.erb new file mode 100644 index 000000000..653708bab --- /dev/null +++ b/app/views/layouts/base_organization.html.erb @@ -0,0 +1,113 @@ + + +<%= stylesheet_link_tag 'pleft','prettify','jquery/jquery-ui-1.9.2','header','new_user','repository','org' %> +<%= javascript_include_tag 'cookie','project', 'header','prettify','select_list_move','org'%> + + + 课程主页 + + + + + + + + + +
    +
    + + + +
    +
    +
    +
    +
    +
    + + + +
    + <%= link_to @organization.name, organization_path(@organization.id), :class=>"pr_info_name fl c_dark fb break_word" %> + <% if @organization.is_public? %> + <%= l(:label_public)%> + <% else %> + <%= l(:label_private)%> + <% end %> +
    + + <% if User.current.admin_of_org?(@organization) and params[:show_homepage].nil? %> + 配置 + <% end %> + +
    +
    + <%= link_to '文章', organization_org_document_comments_path(@organization) %> ( + <%= link_to OrgDocumentComment.where("organization_id =? and parent_id is null", @organization.id).count, organization_org_document_comments_path(@organization), :class => "linkBlue" %> + ) |  + <%= link_to '成员', members_organization_path(@organization.id) %> (<%= link_to @organization.org_members.count, members_organization_path(@organization.id), :id => 'org_members_count_id', :class => "linkBlue" %>) +
    +
    +
    + <%= render :partial => "organizations/org_left_subfield_list", :locals => {:organization => @organization} %> +
    +
    +
    + <%= render_flash_messages %> + <%= yield %> + <%= call_hook :view_layouts_base_content %> +
    +
    +
    +
    +
    + + + diff --git a/app/views/org_subfields/update.js.erb b/app/views/org_subfields/update.js.erb index 2def5c5f8..06982ccfc 100644 --- a/app/views/org_subfields/update.js.erb +++ b/app/views/org_subfields/update.js.erb @@ -1 +1,3 @@ -$("#subfield_show_<%= @subfield.id %>").html("<%= @subfield.name %>"); \ No newline at end of file +$("#subfield_show_<%= @subfield.id %>").html("<%= @subfield.name %>"); +$("#sub_field_left_lists").html(""); +$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); \ No newline at end of file diff --git a/app/views/organizations/_org_left_subfield_list.html.erb b/app/views/organizations/_org_left_subfield_list.html.erb index 52201fd52..3bfabf5ae 100644 --- a/app/views/organizations/_org_left_subfield_list.html.erb +++ b/app/views/organizations/_org_left_subfield_list.html.erb @@ -1,49 +1,21 @@ +
    + <%= link_to "组织首页",organization_path(@organization, :show_homepage => 1), :class => 'homepageMenuText', :target => '_blank' %> +
    <%= link_to "动态",organization_path(organization), :class => "homepageMenuText" %>
    项目 <%=link_to "", join_project_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联项目"%> - - - - - - - - - - - - -
      <%= render :partial => 'layouts/org_projects',:locals=>{:projects=>organization.projects.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> - - - -
    课程 <%=link_to "", join_course_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%> - <%#= link_to "关联课程",join_course_menu_organization_path(organization),:remote => true,:class => "menuGrey",:method => "post"%> - - - - - - - - - - - - -
      diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb index 9e0fc365c..9ee9d11c0 100644 --- a/app/views/organizations/show.html.erb +++ b/app/views/organizations/show.html.erb @@ -12,6 +12,7 @@ .homepagePostReplyInputContainer .ke-inline-block {display: none;} .homepagePostReplyInputContainer .ke-container {float: left;} +<% if params[:show_homepage].nil? %>
      最新动态
        @@ -49,9 +50,8 @@
    -
    - +<% end %> <% if !@organization.home_id.nil? and OrgDocumentComment.where("id = ?", @organization.home_id).count > 0 %> + +
    - +
      - + <% if User.current.logged? %> <% else %> @@ -73,10 +87,12 @@
      <%= link_to @organization.name, organization_path(@organization.id), :class=>"pr_info_name fl c_dark fb break_word" %> - <% if @organization.is_public? %> - <%= l(:label_public)%> - <% else %> - <%= l(:label_private)%> + <% if User.current.logged? %> + <% if @organization.is_public? %> + <%= l(:label_public)%> + <% else %> + <%= l(:label_private)%> + <% end %> <% end %>
      @@ -95,10 +111,17 @@
      - <%= link_to '文章', organization_org_document_comments_path(@organization) %> ( - <%= link_to OrgDocumentComment.where("organization_id =? and parent_id is null", @organization.id).count, organization_org_document_comments_path(@organization), :class => "linkBlue" %> - ) |  - <%= link_to '成员', members_organization_path(@organization.id) %> (<%= link_to @organization.org_members.count, members_organization_path(@organization.id), :id => 'org_members_count_id', :class => "linkBlue" %>) + <%= link_to '文章', organization_org_document_comments_path(@organization) %>  + <% if User.current.logged? %> + ( + <%= link_to OrgDocumentComment.where("organization_id =? and parent_id is null", @organization.id).count, organization_org_document_comments_path(@organization), :class => "linkBlue" %> + ) + <% end %> +  |  + <%= link_to '成员', members_organization_path(@organization.id) %>  + <% if User.current.logged? %> + (<%= link_to @organization.org_members.count, members_organization_path(@organization.id), :id => 'org_members_count_id', :class => "linkBlue" %>) + <% end %>
    @@ -152,6 +175,17 @@ $("#projectMenu").mouseleave(function(){ $("#topnav_project_menu").hide(); }); + + function show_homepage(id, has_homepage){ + if (has_homepage == 1) + { + window.location.href = "/organizations/" + id + "?show_homepage=1"; + } + else + { + alert("您还没有设置首页! 您可以把您喜欢的文章设为组织首页。"); + } + } diff --git a/app/views/organizations/_join_course_menu.html.erb b/app/views/organizations/_join_course_menu.html.erb index d875550de..fa507db28 100644 --- a/app/views/organizations/_join_course_menu.html.erb +++ b/app/views/organizations/_join_course_menu.html.erb @@ -22,11 +22,10 @@ -
    +
    请选择关联到组织的课程
    -
    <%=form_tag url_for(:controller => 'organizations', :action => 'join_courses', :organization_id => organization_id),:method => 'post', :id => 'join_courses_form', :remote => true,:class=>"resourcesSearchBox" do %> @@ -42,7 +41,7 @@
    -
    + + $(document).ready(function(){ + $("#orgUser,#orgSwitch").click(function(){ + $(".org_login_list").toggle(); + if($("#orgArrow").attr("class") == "orgMenuArrow"){ + $("#orgArrow").attr("class","orgMenuArrow2"); + } + else { + $("#orgArrow").attr("class","orgMenuArrow") ; + } + }); + if($(".org_login_list").children().click){ + $(".org_login_list").css("display","none"); + $("#orgArrow").attr("class","orgMenuArrow"); + }; + }); + diff --git a/public/stylesheets/org.css b/public/stylesheets/org.css index 897eb8734..220120346 100644 --- a/public/stylesheets/org.css +++ b/public/stylesheets/org.css @@ -64,4 +64,8 @@ a.cancelBtn:hover {background-color:#717171; color:#ffffff;} a.linkGrey8 {color:#888888;} a.linkGrey8:hover {color:#585858;} .orgBorder {width:583px; height:21px; border-bottom:3px solid #e4e4e4; float:left;} -.orgListRow {border-bottom:1px solid #e4e4e4; padding-bottom:5px; color:#555555;} \ No newline at end of file +.orgListRow {border-bottom:1px solid #e4e4e4; padding-bottom:5px; color:#555555;} +.orgMenuArrow {background:url(../images/nav_icon.png) -10px -165px no-repeat; position:relative; display:inline-block; width:20px; height:30px;} +.orgMenuArrow2 {background:url(../images/nav_icon.png) -10px -132px no-repeat; position:relative; display:inline-block; width:20px; height:30px;} +.org_login_list{ border:1px solid #eaeaea; background:#fff; padding-left:10px; padding-bottom:10px; padding-top:8px; width:60px; left:-53px; position:absolute; z-index:9999; line-height:2; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); margin-top: 30px;} +#orgUserName {max-width:50px; overflow:hidden; white-space: nowrap; text-overflow: ellipsis; display:inline-block;} \ No newline at end of file From 9f30c7a44e9ebb1309950642e25d11fa51c8c64e Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 7 Dec 2015 14:37:35 +0800 Subject: [PATCH 097/105] =?UTF-8?q?=E5=A6=82=E6=9E=9C=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E7=99=BB=E9=99=86=EF=BC=8C=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E5=9C=A8=E7=BB=84=E7=BB=87=E9=A1=B5=E9=9D=A2=E4=B8=AD=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=A1=B9=E7=9B=AE=E6=88=96=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/organizations/_org_left_subfield_list.html.erb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/organizations/_org_left_subfield_list.html.erb b/app/views/organizations/_org_left_subfield_list.html.erb index 065d362d6..cb604f6ba 100644 --- a/app/views/organizations/_org_left_subfield_list.html.erb +++ b/app/views/organizations/_org_left_subfield_list.html.erb @@ -3,7 +3,9 @@
    项目 - <%=link_to "", join_project_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联项目"%> + <% if User.current.logged? %> + <%=link_to "", join_project_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联项目"%> + <% end %>
      @@ -12,7 +14,9 @@
    课程 - <%=link_to "", join_course_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%> + <% if User.current.logged? %> + <%=link_to "", join_course_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%> + <% end %>
      From 5eb249515c7244cdcc2600e4a68d70e463c02d60 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 7 Dec 2015 15:12:30 +0800 Subject: [PATCH 098/105] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/repositories/show.html.erb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index be303a2ab..259e8c185 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -28,10 +28,9 @@ <% unless User.current.id == @project.user_id %>
      <%= link_to "".html_safe+"Fork", {:controller => 'repositories', :action => 'forked'}, :class=>"vl_btn"%> + <%= @project.forked_count.to_i %> +
      <% end %> - <%#= link_to "My span #{@user.profile.my_data}".html_safe, "#", class: 'button white' %> - - <%= @project.forked_count.to_i %>
    <% if @changesets && !@changesets.empty? %> @@ -53,12 +52,14 @@ - <%=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}"} %> 提交 - + <%=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 %> -
    + <% if !@entries.nil? && authorize_for('repositories', 'browse') %> @@ -67,14 +68,14 @@ <%# end %> <%= render :partial => 'dir_list' %> <% end %> -<%= render_properties(@properties) %> +<%#= render_properties(@properties) %> -<%= render_properties(@properties) %> +<%#= render_properties(@properties) %> 如何提交代码 - +
    <% content_for :header_tags do %> <%= stylesheet_link_tag "scm" %> <% end %> From 8e999ed9f00a5bff6f67d5c5e0f58b5b8c02e7ae Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 7 Dec 2015 15:18:32 +0800 Subject: [PATCH 099/105] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E7=9A=84=E5=9B=9E=E5=A4=8D=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=8F=AA=E5=9C=A8=E9=BC=A0=E6=A0=87=E8=BF=9B=E5=85=A5=E6=97=B6?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_course_homework.html.erb | 12 +++++++----- app/views/users/_user_homework_detail.html.erb | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index 4e8553ee8..309b8b95a 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -142,7 +142,7 @@ }); <% 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 => "用户头像" %>
    @@ -154,10 +154,12 @@ <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(comment.created_on) %> - <% if User.current.admin? ||is_teacher || comment.user == User.current%> - <%= link_to('删除', {:controller => 'words', :action => 'destroy', :object_id => comment, :user_id => comment.user,:user_activity_id => user_activity_id, :is_in_course => -1,:course_activity=>course_activity}, - :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "replyGrey fr ml10", :title => l(:button_delete)) %> - <% end %> +
  • <%= comment.notes.html_safe %>
    diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index 23f65e03e..5bf406c59 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -149,7 +149,7 @@ }); <% 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 => "用户头像" %>
    @@ -161,10 +161,12 @@ <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> <% end %> <%= format_time(comment.created_on) %> - <% if User.current.admin? ||is_teacher || comment.user == User.current%> - <%= link_to('删除', {:controller => 'words', :action => 'destroy', :object_id => comment, :user_id => comment.user,:is_in_course => is_in_course,:course_activity=>-1}, - :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "replyGrey fr ml10", :title => l(:button_delete)) %> - <% end %> +
  • <%= comment.notes.html_safe %>
    From c26778b41ccc3f8ee0b0a301ea72c505fd059393 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 8 Dec 2015 17:36:35 +0800 Subject: [PATCH 100/105] =?UTF-8?q?=E5=88=86=E7=BB=84=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=85=B3=E8=81=94=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/new_student_work_project.js.erb | 0 app/views/student_work/student_work_project.js.erb | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 app/views/student_work/new_student_work_project.js.erb create mode 100644 app/views/student_work/student_work_project.js.erb diff --git a/app/views/student_work/new_student_work_project.js.erb b/app/views/student_work/new_student_work_project.js.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/student_work/student_work_project.js.erb b/app/views/student_work/student_work_project.js.erb new file mode 100644 index 000000000..e69de29bb From a9f6e817b49929e9e274de6dc14077bcab44dd87 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 8 Dec 2015 17:37:15 +0800 Subject: [PATCH 101/105] =?UTF-8?q?=E5=88=86=E7=BB=84=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=85=B3=E8=81=94=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 39 +++++- app/helpers/application_helper.rb | 19 +++ app/models/homework_common.rb | 1 + app/models/project.rb | 1 + app/models/student_work.rb | 1 + app/models/student_work_project.rb | 7 ++ app/models/user.rb | 1 + .../_choose_group_member.html.erb | 85 ++++++------- .../student_work/_relate_project.html.erb | 113 +++++++++++++----- app/views/student_work/new.html.erb | 69 +++++------ .../new_student_work_project.js.erb | 5 + app/views/users/_course_homework.html.erb | 5 + config/routes.rb | 2 + ...1208025236_create_student_work_projects.rb | 13 ++ ...32013_add_index_to_student_work_project.rb | 8 ++ db/schema.rb | 19 ++- public/stylesheets/courses.css | 6 +- public/stylesheets/new_user.css | 5 +- spec/factories/student_work_projects.rb | 6 + spec/models/student_work_project_spec.rb | 5 + 20 files changed, 297 insertions(+), 113 deletions(-) create mode 100644 app/models/student_work_project.rb create mode 100644 db/migrate/20151208025236_create_student_work_projects.rb create mode 100644 db/migrate/20151208032013_add_index_to_student_work_project.rb create mode 100644 spec/factories/student_work_projects.rb create mode 100644 spec/models/student_work_project_spec.rb diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 77868c689..6b5573026 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -3,7 +3,7 @@ class StudentWorkController < ApplicationController include StudentWorkHelper require 'bigdecimal' require "base64" - before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule,:forbidden_anonymous_comment,:delete_work] + before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project] before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work,:revise_attachment] before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work] before_filter :author_of_work, :only => [:edit, :update, :destroy] @@ -540,6 +540,43 @@ class StudentWorkController < ApplicationController end end + def new_student_work_project + @user_activity_id = params[:user_activity_id].to_i + @is_in_course = params[:is_in_course].to_i + @course_activity = params[:course_activity].to_i + respond_to do |format| + format.js + end + end + + #创建作业的关联项目 + def student_work_project + projects = cur_user_projects_for_homework @homework + if projects.nil? + @project = StudentWorkProject.new + @project.homework_common_id = @homework.id + @project.project_id = (Project.find params[:project_id]).id + @project.user_id = User.current.id + if @project.save + @user_activity_id = params[:user_activity_id].to_i + @is_in_course = params[:is_in_course].to_i + @course_activity = params[:course_activity].to_i + respond_to do |format| + format.js + end + end + end + end + + #查找学生创建的项目列表 + def search_user_projects + condition = '%%' + if !params[:name].nil? + condition = "%#{params[:name].strip}%".gsub(" ","") + end + project_ids = Project.where("user_id = #{User.current.id} and ") + end + private def hsd_committed_work?(user, homework) sw = StudentWork.where("user_id =? and homework_common_id =?", user, homework).first diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 46a20dd4c..174d33f40 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2459,6 +2459,21 @@ module ApplicationHelper end + def relate_project homework,is_teacher,is_in_course,user_activity_id,course_activity + if User.current.member_of_course?(homework.course) + if is_teacher + link_to "项目(#{homework.student_work_projects.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" + else + projects = cur_user_projects_for_homework homework + if projects.nil? + link_to "关联项目(#{homework.student_work_projects.count})", new_student_work_project_student_work_index_path(:homework => homework.id,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity),remote: true,:class=> 'c_blue', :title=> '请选择分组作业关联的项目' + else + link_to "已关联项目(#{homework.student_work_projects.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" + end + end + end + end + def student_anonymous_comment homework if homework.homework_detail_manual case homework.homework_detail_manual.comment_status @@ -2476,6 +2491,10 @@ module ApplicationHelper def cur_user_works_for_homework homework homework.student_works.where("user_id = ?",User.current).first end + #获取当前用户在指定作业下关联的项目的集合 + def cur_user_projects_for_homework homework + homework.student_work_projects.where("user_id = ?",User.current).first + end def file_preview_tag(file, html_options={}) if %w(pdf pptx doc docx xls xlsx).any?{|x| file.filename.downcase.end_with?(x)} diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 461c7d35b..a665909e2 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -10,6 +10,7 @@ class HomeworkCommon < ActiveRecord::Base has_one :homework_detail_manual, :dependent => :destroy has_one :homework_detail_programing, :dependent => :destroy has_one :homework_detail_group, :dependent => :destroy + has_many :student_work_projects has_many :homework_tests, :dependent => :destroy has_many :student_works, :dependent => :destroy, :conditions => "is_test=0" has_many :student_works_evaluation_distributions, :through => :student_works #一个作业的分配的匿评列表 diff --git a/app/models/project.rb b/app/models/project.rb index ff546e098..3e494a4f0 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -43,6 +43,7 @@ class Project < ActiveRecord::Base end end + has_many :student_work_projects has_many :student_works has_many :time_entry_activities has_many :members, :include => [:principal, :roles], :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}" diff --git a/app/models/student_work.rb b/app/models/student_work.rb index 884f4a089..59b98b9b2 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -4,6 +4,7 @@ class StudentWork < ActiveRecord::Base belongs_to :homework_common belongs_to :user + has_one :student_work_project has_many :student_works_evaluation_distributions, :dependent => :destroy has_many :student_works_scores, :dependent => :destroy belongs_to :project diff --git a/app/models/student_work_project.rb b/app/models/student_work_project.rb new file mode 100644 index 000000000..676071817 --- /dev/null +++ b/app/models/student_work_project.rb @@ -0,0 +1,7 @@ +class StudentWorkProject < ActiveRecord::Base + # attr_accessible :title, :body + belongs_to :homework_common + belongs_to :student_work + belongs_to :project + belongs_to :user +end diff --git a/app/models/user.rb b/app/models/user.rb index 9c437a186..fa6f005b6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -107,6 +107,7 @@ class User < Principal has_many :student_works, :dependent => :destroy has_many :student_works_evaluation_distributions, :dependent => :destroy has_many :student_works_scores, :dependent => :destroy + has_many :student_work_projects #end has_and_belongs_to_many :groups, :after_add => Proc.new {|user, group| group.user_added(user)}, diff --git a/app/views/student_work/_choose_group_member.html.erb b/app/views/student_work/_choose_group_member.html.erb index c14e8a06e..4671dd2a5 100644 --- a/app/views/student_work/_choose_group_member.html.erb +++ b/app/views/student_work/_choose_group_member.html.erb @@ -1,41 +1,44 @@ -
    请添加小组成员
    - -
    -
    -
    - - -
    -
    -
      -
    • - 同学一(061530301) -
    • -
    • - 同学二同学二(061530302) -
    • -
    • - 同学三(061530303) -
    • -
    • - 同学四同学四(061530304) -
    • -
    • - 同学五同学五(061530305) -
    • -
    • - 同学六同学六(061530306) -
    • -
    • - 同学七同学七(061530307) -
    • -
    -
    -
      -
    • TimTang(040930319)×
    • -
    • suntao(060930106)×
    • -
    -
    - - -
    \ No newline at end of file +
    +
    +
    请添加小组成员
    +
    +
    +
    +
    +
    + + +
    +
      +
    • + 同学一(061530301) +
    • +
    • + 同学二同学二(061530302) +
    • +
    • + 同学三(061530303) +
    • +
    • + 同学四同学四(061530304) +
    • +
    • + 同学五同学五(061530305) +
    • +
    • + 同学六同学六(061530306) +
    • +
    • + 同学七同学七(061530307) +
    • +
    +
    +
      +
    • TimTang(040930319)×
    • +
    • suntao(060930106)×
    • +
    +
    + + +
    +
    \ No newline at end of file diff --git a/app/views/student_work/_relate_project.html.erb b/app/views/student_work/_relate_project.html.erb index 06649baba..2db43ec59 100644 --- a/app/views/student_work/_relate_project.html.erb +++ b/app/views/student_work/_relate_project.html.erb @@ -1,30 +1,83 @@ -
    关联项目 -
    - - -
      -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    - - -
    -
    \ No newline at end of file +
    + 关联项目 + + <%=form_tag url_for(:controller=>'student_work',:action=>'student_work_project',:course_id=>@course_id,:user_activity_id=>@user_activity_id,:is_in_course=>@is_in_course),:id =>'student_work_relate_project',:class=>'resourcesSearchBox',:remote => true do %> + + +
    +
      +
    • + +
    • +
    • + +
    • +
    • + +
    • +
    • + +
    • +
    + + +
    + <% end %> +
    + \ 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 995126cb5..d14da5fa2 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -34,6 +34,34 @@ ) } } + // 添加组成员 + function show_group_member() { + $('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/choose_group_member',:locals => {:homework=>@homework}) %>'); + showModal('ajax-modal', '528px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').parent().css("top","").css("left",""); + $('#ajax-modal').parent().addClass("addMemberCP"); + } + // 关联项目 + function show_project() { + $('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/relate_project',:locals => {:homework=>@homework}) %>'); + showModal('ajax-modal', '320px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').parent().css("top","").css("left",""); + $('#ajax-modal').parent().addClass("groupPopUp"); + } + // 作品校验 + function popupRegex(){ + if(regexStudentWorkName()&®exStudentWorkDescription()) + { + $('#ajax-modal').html("

    作品信息完整性校验中,请稍等...

    "); + showModal('ajax-modal', '500px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').parent().css("top","").css("left",""); + $('#ajax-modal').parent().addClass("anonymos"); + } + } +
    @@ -98,22 +126,15 @@ <%= render :partial => 'users/user_homework_attachment', :locals => {:container => @student_work, :has_program=>false,:has_group=>false} %>
    - <% if @homework.homework_type == 3 %> -
    + <%# if @homework.homework_type == 3 %> + + <%# end %> -
    + -
    - \ No newline at end of file +
    \ No newline at end of file diff --git a/app/views/student_work/new_student_work_project.js.erb b/app/views/student_work/new_student_work_project.js.erb index e69de29bb..51df45f13 100644 --- a/app/views/student_work/new_student_work_project.js.erb +++ b/app/views/student_work/new_student_work_project.js.erb @@ -0,0 +1,5 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/relate_project') %>'); +showModal('ajax-modal', '320px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("groupPopUp"); \ No newline at end of file diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index 309b8b95a..9f2beedd0 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -45,6 +45,11 @@ <% end%> <% end%>
    + <% if activity.homework_type == 3%> +
    + <%= relate_project(activity,is_teacher,-1,user_activity_id,course_activity) %> +
    + <% end %>
    <% is_teacher = User.current.allowed_to?(:as_teacher,activity.course) %> <%= user_for_homework_common activity,is_teacher %> diff --git a/config/routes.rb b/config/routes.rb index 4e64ca505..b375053fd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -218,6 +218,8 @@ RedmineApp::Application.routes.draw do end collection do post 'add_score_reply' + post 'student_work_project' + get 'new_student_work_project' get 'delete_work' get 'destroy_score_reply' get 'student_work_absence_penalty' diff --git a/db/migrate/20151208025236_create_student_work_projects.rb b/db/migrate/20151208025236_create_student_work_projects.rb new file mode 100644 index 000000000..134823377 --- /dev/null +++ b/db/migrate/20151208025236_create_student_work_projects.rb @@ -0,0 +1,13 @@ +class CreateStudentWorkProjects < ActiveRecord::Migration + def change + create_table :student_work_projects do |t| + t.integer :homework_common_id + t.integer :student_work_id + t.integer :project_id + t.integer :user_id + t.integer :is_leader + + t.timestamps + end + end +end diff --git a/db/migrate/20151208032013_add_index_to_student_work_project.rb b/db/migrate/20151208032013_add_index_to_student_work_project.rb new file mode 100644 index 000000000..b55c313ff --- /dev/null +++ b/db/migrate/20151208032013_add_index_to_student_work_project.rb @@ -0,0 +1,8 @@ +class AddIndexToStudentWorkProject < ActiveRecord::Migration + def change + add_index :student_work_projects, :homework_common_id + add_index :student_work_projects, :user_id + add_index :student_work_projects, :project_id + add_index :student_work_projects, :student_work_id + end +end diff --git a/db/schema.rb b/db/schema.rb index f130c5c39..4aeed2409 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,8 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20151130033906) do +ActiveRecord::Schema.define(:version => 20151208032013) do + create_table "activities", :force => true do |t| t.integer "act_id", :null => false t.string "act_type", :null => false @@ -979,7 +980,6 @@ ActiveRecord::Schema.define(:version => 20151130033906) do t.integer "course_group_id", :default => 0 end - add_index "members", ["course_id"], :name => "index_members_on_course_id" 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" @@ -1508,6 +1508,21 @@ ActiveRecord::Schema.define(:version => 20151130033906) do t.integer "project_id" end + create_table "student_work_projects", :force => true do |t| + t.integer "homework_common_id" + t.integer "student_work_id" + t.integer "project_id" + t.integer "user_id" + t.integer "is_leader" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "student_work_projects", ["homework_common_id"], :name => "index_student_work_projects_on_homework_common_id" + add_index "student_work_projects", ["project_id"], :name => "index_student_work_projects_on_project_id" + add_index "student_work_projects", ["student_work_id"], :name => "index_student_work_projects_on_student_work_id" + add_index "student_work_projects", ["user_id"], :name => "index_student_work_projects_on_user_id" + create_table "student_work_tests", :force => true do |t| t.integer "student_work_id" t.datetime "created_at", :null => false diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 54e550426..0373f24bc 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -1182,17 +1182,17 @@ a:hover.testBtn{background: url(/images/course/hwork_icon.png) -81px -5px no-rep a.groupBtn{ background: url(/images/course/hwork_icon.png) -2px -61px no-repeat !important; height:20px; display:block; padding-left:20px; color:#888888; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} a:hover.groupBtn{background: url(/images/course/hwork_icon.png) -80px -61px no-repeat !important; color:#3598db; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} .markInput { outline:none; border:1px solid #e6e6e6; height:30px; width:50px; color:#3d3c3c; margin-right:5px; text-align:center; padding-left:0px;} -.groupPopUp {width:290px; height:auto; padding:15px; background-color:#ffffff; z-index:1000; position:relative;} +.groupPopUp {border:3px solid #269ac9; width:290px; height:auto; padding:15px; background-color:#ffffff; position:fixed !important;left:50%;top:50%;margin:-100px 0 0 -150px; -moz-border-radius:5px;} .popClose {background:url(/images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block; position: absolute; z-index: 1000; right:2px; top:3px;} a.memberBtn{ background: url(/images/course/hwork_icon.png) -7px -90px no-repeat !important; height:20px; display:block; padding-left:20px; color:#888888; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} a:hover.memberBtn{background: url(/images/course/hwork_icon.png) -80px -90px no-repeat !important; color:#3598db; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} .addMemberC {float:left; max-height:150px; margin-bottom:10px; overflow:auto; overflow-x:hidden; width:227px; background-color:#f1f1f1; min-height:150px; padding-top:10px;} .addMemberC li {padding-left:10px; line-height:18px;} .addMemberC li:hover {cursor:pointer; background-color:#cccccc;} -.addMemberCP {width:514px; height:auto; border:3px solid #269ac9; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; z-index:1000;} +.addMemberCP {width:514px; height:auto; border:3px solid #269ac9; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:fixed !important;left:50%;top:50%;margin:-100px 0 0 -150px; -moz-border-radius:5px;} .rightArrow {margin:50px 15px 0px 15px; float:left;} .relateText {font-size:16px; color:#269ac9; line-height:16px; padding-top:20px; display:inline-block; font-weight: bold;} - +.maxHeight100 {max-height:100px; overflow-x:hidden; overflow-y:auto;} .resubAtt {border-top:1px solid #dddddd; position:relative; margin-top:15px;} .resubTitle {position:absolute; top:-10px; left:5px; background-color:#ffffff; display:block; font-weight:bold; padding:0px 2px;} a.blueCir{ display:inline-block; padding:2px 5px; background-color:#ffffff;border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;} diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index a9edee92d..199b38305 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -1355,13 +1355,14 @@ a:hover.testBtn{background: url(/images/course/hwork_icon.png) -81px -5px no-rep a.groupBtn{ background: url(/images/course/hwork_icon.png) -2px -61px no-repeat !important; height:20px; display:block; padding-left:20px; color:#888888; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} a:hover.groupBtn{background: url(/images/course/hwork_icon.png) -80px -61px no-repeat !important; color:#3598db; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} .markInput { outline:none; border:1px solid #e6e6e6; height:30px; width:50px; color:#3d3c3c; margin-right:5px; text-align:center; padding-left:0px;} -.groupPopUp {width:290px; height:auto; padding:15px; background-color:#ffffff; z-index:1000; position:relative;} +.groupPopUp {border:3px solid #269ac9; width:290px; height:auto; padding:15px; background-color:#ffffff;position:fixed !important;left:50%;top:50%;margin:-100px 0 0 -150px; -moz-border-radius:5px;} .popClose {background:url(/images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block; position: absolute; z-index: 1000; right:2px; top:3px;} a.memberBtn{ background: url(/images/course/hwork_icon.png) -7px -90px no-repeat !important; height:20px; display:block; padding-left:20px; color:#888888; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} a:hover.memberBtn{background: url(/images/course/hwork_icon.png) -80px -90px no-repeat !important; color:#3598db; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} .addMemberC {float:left; max-height:150px; margin-bottom:10px; overflow:auto; overflow-x:hidden; width:227px; background-color:#f1f1f1; min-height:150px; padding-top:10px;} .addMemberC li {padding-left:10px; line-height:18px;} .addMemberC li:hover {cursor:pointer; background-color:#cccccc;} -.addMemberCP {width:514px; height:auto; border:3px solid #269ac9; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; z-index:1000;} +.addMemberCP {width:514px; height:auto; border:3px solid #269ac9; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:fixed !important;left:50%;top:50%;margin:-100px 0 0 -150px; -moz-border-radius:5px;} .rightArrow {margin:50px 15px 0px 15px; float:left;} .relateText {font-size:16px; color:#269ac9; line-height:16px; padding-top:20px; display:inline-block; font-weight: bold;} +.maxHeight100 {max-height:100px; overflow-x:hidden; overflow-y:auto;} diff --git a/spec/factories/student_work_projects.rb b/spec/factories/student_work_projects.rb new file mode 100644 index 000000000..d6ecb2657 --- /dev/null +++ b/spec/factories/student_work_projects.rb @@ -0,0 +1,6 @@ +# Read about factories at https://github.com/thoughtbot/factory_girl + +FactoryGirl.define do + factory :student_work_project do + end +end diff --git a/spec/models/student_work_project_spec.rb b/spec/models/student_work_project_spec.rb new file mode 100644 index 000000000..42a65b35e --- /dev/null +++ b/spec/models/student_work_project_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe StudentWorkProject, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 53f9141cf1490db365b422f876850f2c864bba69 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 9 Dec 2015 10:29:54 +0800 Subject: [PATCH 102/105] =?UTF-8?q?=E5=88=86=E7=BB=84=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 30 ++++++----- app/helpers/application_helper.rb | 6 +-- .../student_work/_relate_project.html.erb | 51 +++++++++---------- .../student_work/search_user_projects.js.erb | 9 ++++ .../student_work/student_work_project.js.erb | 8 +++ app/views/users/_course_homework.html.erb | 4 ++ config/routes.rb | 1 + public/stylesheets/courses.css | 11 ++++ public/stylesheets/new_user.css | 15 ++++++ 9 files changed, 91 insertions(+), 44 deletions(-) create mode 100644 app/views/student_work/search_user_projects.js.erb diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 6b5573026..2ee357f82 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -551,21 +551,19 @@ class StudentWorkController < ApplicationController #创建作业的关联项目 def student_work_project - projects = cur_user_projects_for_homework @homework - if projects.nil? - @project = StudentWorkProject.new - @project.homework_common_id = @homework.id - @project.project_id = (Project.find params[:project_id]).id - @project.user_id = User.current.id - if @project.save - @user_activity_id = params[:user_activity_id].to_i - @is_in_course = params[:is_in_course].to_i - @course_activity = params[:course_activity].to_i - respond_to do |format| - format.js - end + @project = StudentWorkProject.new + @project.homework_common_id = @homework.id + @project.project_id = (Project.find params[:projectName].to_i).id + @project.user_id = User.current.id + if @project.save + @user_activity_id = params[:user_activity_id].to_i + @is_in_course = params[:is_in_course].to_i + @course_activity = params[:course_activity].to_i + respond_to do |format| + format.js end end + end #查找学生创建的项目列表 @@ -574,7 +572,11 @@ class StudentWorkController < ApplicationController if !params[:name].nil? condition = "%#{params[:name].strip}%".gsub(" ","") end - project_ids = Project.where("user_id = #{User.current.id} and ") + @project_ids = Project.where("user_id = #{User.current.id} and name like '#{condition}'") + @first = params[:first].to_i + respond_to do |format| + format.js + end end private diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 174d33f40..cb90947df 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2462,13 +2462,13 @@ module ApplicationHelper def relate_project homework,is_teacher,is_in_course,user_activity_id,course_activity if User.current.member_of_course?(homework.course) if is_teacher - link_to "项目(#{homework.student_work_projects.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" + link_to "已关联(#{homework.student_work_projects.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" else projects = cur_user_projects_for_homework homework if projects.nil? - link_to "关联项目(#{homework.student_work_projects.count})", new_student_work_project_student_work_index_path(:homework => homework.id,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity),remote: true,:class=> 'c_blue', :title=> '请选择分组作业关联的项目' + link_to "关联项目",new_student_work_project_student_work_index_path(:homework => homework.id,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity),remote: true,:class=> 'c_blue', :title=> '请选择分组作业关联的项目' else - link_to "已关联项目(#{homework.student_work_projects.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" + link_to "取消关联",cancel_relate_project_student_work_index_path(:homework => homework.id,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity),remote: true,:class => "c_blue", :title=> '取消关联项目' end end end diff --git a/app/views/student_work/_relate_project.html.erb b/app/views/student_work/_relate_project.html.erb index 2db43ec59..bcfd9eb8e 100644 --- a/app/views/student_work/_relate_project.html.erb +++ b/app/views/student_work/_relate_project.html.erb @@ -1,11 +1,13 @@
    关联项目 - <%=form_tag url_for(:controller=>'student_work',:action=>'student_work_project',:course_id=>@course_id,:user_activity_id=>@user_activity_id,:is_in_course=>@is_in_course),:id =>'student_work_relate_project',:class=>'resourcesSearchBox',:remote => true do %> - - -
    -
      + <%=form_tag url_for(:controller=>'student_work',:action=>'student_work_project',:homework=>@homework.id,:user_activity_id=>@user_activity_id,:is_in_course=>@is_in_course,:course_activity =>@course_activity),:id =>'student_work_relate_project',:class=>'resourcesSearchBox',:remote => true do %> + +
      + +
        +

        + + +
        <% end %>
      \ No newline at end of file diff --git a/app/views/student_work/search_user_projects.js.erb b/app/views/student_work/search_user_projects.js.erb new file mode 100644 index 000000000..7751821a5 --- /dev/null +++ b/app/views/student_work/search_user_projects.js.erb @@ -0,0 +1,9 @@ +<% if @first == 1 && @project_ids.empty? %> + $("#no_search_result").show(); +<% else %> + $("#search_project_list").html(""); + <% @project_ids.each do |project|%> + link = "
    • "; + $("#search_project_list").append(link ); + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/student_work/student_work_project.js.erb b/app/views/student_work/student_work_project.js.erb index e69de29bb..dbf66acd3 100644 --- a/app/views/student_work/student_work_project.js.erb +++ b/app/views/student_work/student_work_project.js.erb @@ -0,0 +1,8 @@ +hideModal("#popbox02"); +<% if @user_activity_id != -1 %> + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity => @course_activity}) %>"); + init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); +<% else%> + $("#homework_common_<%= @homework_common_id %>").replaceWith("<%= escape_javascript(render :partial => 'users/user_homework_detail', :locals => {:homework_common => @homework,:is_in_course => @is_in_course}) %>"); + init_activity_KindEditor_data(<%= @homework_common_id%>,"","87%"); +<% end %> \ No newline at end of file diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index 9f2beedd0..ef4bf8a22 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -44,6 +44,10 @@ 教师评阅中 <% end%> <% end%> +
      + <% if activity.homework_type == 3%> + 系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"c_red",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合! + <% end %>
      <% if activity.homework_type == 3%>
      diff --git a/config/routes.rb b/config/routes.rb index b375053fd..62ed2eae1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -220,6 +220,7 @@ RedmineApp::Application.routes.draw do post 'add_score_reply' post 'student_work_project' get 'new_student_work_project' + get 'search_user_projects' get 'delete_work' get 'destroy_score_reply' get 'student_work_absence_penalty' diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 0373f24bc..f13e6ef84 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -1197,6 +1197,17 @@ a:hover.memberBtn{background: url(/images/course/hwork_icon.png) -80px -90px no- .resubTitle {position:absolute; top:-10px; left:5px; background-color:#ffffff; display:block; font-weight:bold; padding:0px 2px;} a.blueCir{ display:inline-block; padding:2px 5px; background-color:#ffffff;border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;} a:hover.blueCir{ background:#3598db; color:#fff;} +.proList {background-color:#eaeaea; padding:5px 10px; display:block; max-width:655px; float:left;} + +.borderRadius {border-radius:5px;} +.maxHeight100 {max-height:100px; overflow-x:hidden; overflow-y:auto;} +.proRelateWrap {width:38px; height:38px; border:1px solid #cecece; border-radius:3px; background-color:#f1f1f1;} +.mt7 {margin-top:7px;} +.ml7 {margin-left:7px;} +.tac {text-align:center;} +.proHelp {background:url(/images/course/hwork_icon.png) -5px -124px no-repeat; display:inline-block; width:15px; height:15px; display:inline-block;} +.hworkPrName {width:110px; max-width:110px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; float:left; height:18px; line-height:18px; font-size:12px; color:#888888; text-align:center;} +.mr150 {margin-right:150px;} /*上传资源弹窗*/ .resourceUploadPopup {width:400px; height:auto; border:3px solid #269ac9 !important; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-200px; z-index:1000;} diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 199b38305..0ed4df627 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -1366,3 +1366,18 @@ a:hover.memberBtn{background: url(/images/course/hwork_icon.png) -80px -90px no- .rightArrow {margin:50px 15px 0px 15px; float:left;} .relateText {font-size:16px; color:#269ac9; line-height:16px; padding-top:20px; display:inline-block; font-weight: bold;} .maxHeight100 {max-height:100px; overflow-x:hidden; overflow-y:auto;} +.resubAtt {border-top:1px solid #dddddd; position:relative; margin-top:15px;} +.resubTitle {position:absolute; top:-10px; left:5px; background-color:#ffffff; display:block; font-weight:bold; padding:0px 2px;} +a.blueCir{ display:inline-block; padding:2px 5px; background-color:#ffffff;border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;} +a:hover.blueCir{ background:#3598db; color:#fff;} +.proList {background-color:#eaeaea; padding:5px 10px; display:block; max-width:655px; float:left;} + +.borderRadius {border-radius:5px;} +.maxHeight100 {max-height:100px; overflow-x:hidden; overflow-y:auto;} +.proRelateWrap {width:38px; height:38px; border:1px solid #cecece; border-radius:3px; background-color:#f1f1f1;} +.mt7 {margin-top:7px;} +.ml7 {margin-left:7px;} +.tac {text-align:center;} +.proHelp {background:url(/images/course/hwork_icon.png) -5px -124px no-repeat; display:inline-block; width:15px; height:15px; display:inline-block;} +.hworkPrName {width:110px; max-width:110px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; float:left; height:18px; line-height:18px; font-size:12px; color:#888888; text-align:center;} +.mr150 {margin-right:150px;} From 4e04df7a8afc76e1479d395dd0292d9b60d0f559 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 9 Dec 2015 16:33:48 +0800 Subject: [PATCH 103/105] =?UTF-8?q?=E5=88=86=E7=BB=84=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=9A=84=E5=8A=A8=E6=80=81=E6=98=BE=E7=A4=BA=E5=8F=8A=E5=85=B3?= =?UTF-8?q?=E8=81=94=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 14 ++++++++- app/helpers/application_helper.rb | 7 +++-- app/models/project.rb | 1 + .../student_work/cancel_relate_project.js.erb | 7 +++++ .../student_work/student_work_project.js.erb | 4 +-- app/views/users/_course_homework.html.erb | 19 ++++++++++++ .../users/_user_homework_detail.html.erb | 29 ++++++++++++++++++- config/routes.rb | 1 + 8 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 app/views/student_work/cancel_relate_project.js.erb diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 2ee357f82..b50f6ea0f 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -3,7 +3,7 @@ class StudentWorkController < ApplicationController include StudentWorkHelper require 'bigdecimal' require "base64" - before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project] + before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project] before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work,:revise_attachment] before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work] before_filter :author_of_work, :only => [:edit, :update, :destroy] @@ -579,6 +579,18 @@ class StudentWorkController < ApplicationController end end + def cancel_relate_project + relate_pro = StudentWorkProject.where("user_id = #{User.current.id} and homework_common_id = #{@homework.id}").first + if relate_pro.destroy + @user_activity_id = params[:user_activity_id].to_i + @is_in_course = params[:is_in_course].to_i + @course_activity = params[:course_activity].to_i + respond_to do |format| + format.js + end + end + end + private def hsd_committed_work?(user, homework) sw = StudentWork.where("user_id =? and homework_common_id =?", user, homework).first diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index cb90947df..a19d44997 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2465,10 +2465,13 @@ module ApplicationHelper link_to "已关联(#{homework.student_work_projects.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" else projects = cur_user_projects_for_homework homework - if projects.nil? + works = cur_user_works_for_homework homework + if works.nil? && projects.nil? link_to "关联项目",new_student_work_project_student_work_index_path(:homework => homework.id,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity),remote: true,:class=> 'c_blue', :title=> '请选择分组作业关联的项目' + elsif works.nil? + link_to "取消关联",cancel_relate_project_student_work_index_path(:homework => homework.id,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity), :confirm => "您确定要取消关联吗?", remote: true,:class => "c_blue", :title=> '取消关联项目' else - link_to "取消关联",cancel_relate_project_student_work_index_path(:homework => homework.id,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity),remote: true,:class => "c_blue", :title=> '取消关联项目' + link_to "已关联(#{homework.student_work_projects.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" end end end diff --git a/app/models/project.rb b/app/models/project.rb index 3e494a4f0..a80982413 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -87,6 +87,7 @@ class Project < ActiveRecord::Base # end #ADDED BY NIE + has_one :project_score, :dependent => :destroy has_many :project_infos, :dependent => :destroy has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy has_many :user_grades, :class_name => "UserGrade", :dependent => :destroy diff --git a/app/views/student_work/cancel_relate_project.js.erb b/app/views/student_work/cancel_relate_project.js.erb new file mode 100644 index 000000000..3aa853a00 --- /dev/null +++ b/app/views/student_work/cancel_relate_project.js.erb @@ -0,0 +1,7 @@ +<% if @user_activity_id != -1 %> +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity => @course_activity}) %>"); +init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); +<% else%> +$("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => 'users/user_homework_detail', :locals => {:homework_common => @homework,:is_in_course => @is_in_course}) %>"); +init_activity_KindEditor_data(<%= @homework.id%>,"","87%"); +<% end %> \ No newline at end of file diff --git a/app/views/student_work/student_work_project.js.erb b/app/views/student_work/student_work_project.js.erb index dbf66acd3..405dccca4 100644 --- a/app/views/student_work/student_work_project.js.erb +++ b/app/views/student_work/student_work_project.js.erb @@ -3,6 +3,6 @@ hideModal("#popbox02"); $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity => @course_activity}) %>"); init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); <% else%> - $("#homework_common_<%= @homework_common_id %>").replaceWith("<%= escape_javascript(render :partial => 'users/user_homework_detail', :locals => {:homework_common => @homework,:is_in_course => @is_in_course}) %>"); - init_activity_KindEditor_data(<%= @homework_common_id%>,"","87%"); + $("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => 'users/user_homework_detail', :locals => {:homework_common => @homework,:is_in_course => @is_in_course}) %>"); + init_activity_KindEditor_data(<%= @homework.id%>,"","87%"); <% end %> \ No newline at end of file diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index ef4bf8a22..31b5b3e57 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -86,6 +86,25 @@ <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => activity.attachments} %>
      + <% if activity.homework_type == 3 && !activity.student_work_projects.empty? %> +
      +
      + +
      + <% activity.student_work_projects.each do |pro| %> +
      + <% project = Project.find pro.project_id %> + <% if project.is_public || project.user_id == User.current.id %> + <%= link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_path(project.id,:host=>Setting.host_name),:alt =>"项目头像" %> + <% else %> + <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius") %> + <% end %> +

      <%=project.project_score.score.to_i %>

      +
      + <% end %> +
      + <% end %> +
      <% if is_teacher%> <% comment_status = activity.homework_detail_manual.comment_status %>
      diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index 5bf406c59..8e01ee908 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -44,8 +44,16 @@ 教师评阅中 <% end%> <% end%> - +
      + <% if homework_common.homework_type == 3%> + 系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"c_red",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合! + <% end %>
      + <% if homework_common.homework_type == 3%> +
      + <%= relate_project(homework_common,is_teacher,is_in_course,-1,-1) %> +
      + <% end %>
      <%= user_for_homework_common homework_common,is_teacher %>
      @@ -82,6 +90,25 @@ <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => homework_common.attachments} %>
      + <% if homework_common.homework_type == 3 && !homework_common.student_work_projects.empty? %> +
      +
      + +
      + <% homework_common.student_work_projects.each do |pro| %> +
      + <% project = Project.find pro.project_id %> + <% if project.is_public == 1 %> + <%=link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_path(project.id,:host=>Setting.host_name) %> + <% else %> + <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius") %> + <% end %> +

      <%=project.project_score.score.to_i %>

      +
      + <% end %> +
      + <% end %> +
      <% if is_teacher%> <% comment_status = homework_common.homework_detail_manual.comment_status%>
      diff --git a/config/routes.rb b/config/routes.rb index 62ed2eae1..2be4f7221 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -221,6 +221,7 @@ RedmineApp::Application.routes.draw do post 'student_work_project' get 'new_student_work_project' get 'search_user_projects' + get 'cancel_relate_project' get 'delete_work' get 'destroy_score_reply' get 'student_work_absence_penalty' From ba5d72b3155c7e4deb945c2f0c6a043614d3afc4 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 11 Dec 2015 09:18:12 +0800 Subject: [PATCH 104/105] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=E5=9C=A8=E7=BA=BF=E6=B5=8B=E9=AA=8C=E7=9A=84=E6=9D=83?= =?UTF-8?q?=E9=99=90?= 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 a99ab32ec..2a75d0580 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -18,13 +18,13 @@ class ExerciseController < ApplicationController end_exercises.each do |exercise| exercise.update_column('exercise_status', 3) end - if @course.is_public == 0 && !User.current.member_of_course?(@course) + if @course.is_public == 0 && !(User.current.member_of_course?(@course)||User.current.admin?) render_403 return end remove_invalid_exercise(@course) @is_teacher = User.current.allowed_to?(:as_teacher,@course) - if @is_teacher + if @is_teacher || User.current.admin? exercises = @course.exercises.order("created_at asc") else exercises = @course.exercises.where(:exercise_status => 2).order("created_at asc") @@ -48,13 +48,13 @@ class ExerciseController < ApplicationController end_exercises.each do |exercise| exercise.update_column('exercise_status', 3) end - unless User.current.member_of_course?(@course) + unless User.current.member_of_course?(@course) || User.current.admin? 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?) + if @exercise.exercise_status != 2 && (!(User.current.allowed_to?(:as_teacher,@course) || User.current.admin?)) render_403 return end From f880ccd749c81a99b2c2a23687de47f93522ffad Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 11 Dec 2015 14:57:09 +0800 Subject: [PATCH 105/105] =?UTF-8?q?=E5=88=86=E7=BB=84=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 39 +++-- app/controllers/student_work_controller.rb | 144 +++++++++++++++++- app/helpers/application_helper.rb | 28 +++- app/models/homework_common.rb | 2 +- app/models/project.rb | 2 +- app/models/student_work.rb | 2 +- app/models/user.rb | 2 +- .../_choose_group_member.html.erb | 108 +++++++++---- .../student_work/_evaluation_title.html.erb | 8 +- .../_evaluation_un_title.html.erb | 8 +- .../student_work/_evaluation_un_work.html.erb | 24 ++- .../student_work/_evaluation_work.html.erb | 55 ++++--- .../student_work/_relate_project.html.erb | 24 +-- app/views/student_work/_show.html.erb | 32 +++- .../student_work/_student_work_list.html.erb | 7 +- app/views/student_work/new.html.erb | 38 +++-- .../search_course_students.js.erb | 33 ++++ app/views/users/_course_homework.html.erb | 32 ++-- .../users/_user_homework_attachment.html.erb | 20 ++- .../users/_user_homework_detail.html.erb | 28 ++-- config/routes.rb | 1 + lib/tasks/homework_evaluation.rake | 35 ++++- public/images/course/proRelated.png | Bin 0 -> 1249 bytes public/javascripts/course.js | 22 ++- public/javascripts/new_user.js | 22 ++- 25 files changed, 562 insertions(+), 154 deletions(-) create mode 100644 app/views/student_work/search_course_students.js.erb create mode 100644 public/images/course/proRelated.png diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 67499655f..a8d6dfe8f 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -126,14 +126,33 @@ class HomeworkCommonController < ApplicationController if @homework_detail_manual.comment_status == 1 student_works = @homework.student_works if student_works && student_works.size >= 2 - student_works.each_with_index do |work, index| - user = work.user - n = @homework_detail_manual.evaluation_num - n = n < student_works.size ? n : student_works.size - 1 - assigned_homeworks = get_assigned_homeworks(student_works, n, index) - assigned_homeworks.each do |h| - student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id) - student_works_evaluation_distributions.save + if @homework.homework_type == 3 + student_work_projects = @homework.student_work_projects.where("student_work_id is not null") + student_work_projects.each_with_index do |pro_work, pro_index| + n = @homework_detail_manual.evaluation_num + n = n < student_works.size ? n : student_works.size - 1 + work_index = -1 + student_works.each_with_index do |stu_work, stu_index| + if stu_work.id.to_i == pro_work.student_work_id.to_i + work_index = stu_index + end + end + assigned_homeworks = get_assigned_homeworks(student_works, n, work_index) + assigned_homeworks.each do |h| + student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id) + student_works_evaluation_distributions.save + end + end + else + student_works.each_with_index do |work, index| + user = work.user + n = @homework_detail_manual.evaluation_num + n = n < student_works.size ? n : student_works.size - 1 + assigned_homeworks = get_assigned_homeworks(student_works, n, index) + assigned_homeworks.each do |h| + student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id) + student_works_evaluation_distributions.save + end end end @homework_detail_manual.update_column('comment_status', 2) @@ -143,7 +162,8 @@ class HomeworkCommonController < ApplicationController Mailer.send_mail_anonymous_comment_open(@homework).deliver else @statue = 2 - end + + end else @statue = 3 end @@ -277,6 +297,7 @@ class HomeworkCommonController < ApplicationController @homework = HomeworkCommon.find params[:id] @homework_detail_manual = @homework.homework_detail_manual @homework_detail_programing = @homework.homework_detail_programing + @homework_detail_group = @homework.homework_detail_group @course = @homework.course rescue render_404 diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index b50f6ea0f..f79646ade 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -3,7 +3,7 @@ class StudentWorkController < ApplicationController include StudentWorkHelper require 'bigdecimal' require "base64" - before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project] + before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project,:search_course_students] before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work,:revise_attachment] before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work] before_filter :author_of_work, :only => [:edit, :update, :destroy] @@ -95,12 +95,27 @@ class StudentWorkController < ApplicationController @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name @show_all = true elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的 - @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + if @homework.homework_type == 3 + pro = @homework.student_work_projects.where(:user_id => User.current.id).first + @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + else + @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + end elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表 - my_work = @homework.student_works.where(:user_id => User.current.id) + if @homework.homework_type == 3 + pro = @homework.student_work_projects.where(:user_id => User.current.id).first + my_work = @homework.student_works.where(:id => pro.student_work_id) + else + my_work = @homework.student_works.where(:user_id => User.current.id) + end @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id} elsif @homework.homework_detail_manual.comment_status == 3 #学生 && 关闭匿评 未提交作品之前列表为空,提交了作品看到所有的 - my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + if @homework.homework_type == 3 + pro = @homework.student_work_projects.where(:user_id => User.current.id).first + my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + else + my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + end if my_work.empty? @stundet_works = [] else @@ -116,12 +131,27 @@ class StudentWorkController < ApplicationController @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name @show_all = true elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的 - @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + if @homework.homework_type == 3 + pro = @homework.student_work_projects.where(:user_id => User.current.id).first + @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + else + @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + end elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表 - my_work = @homework.student_works.where(:user_id => User.current.id) + if @homework.homework_type == 3 + pro = @homework.student_work_projects.where(:user_id => User.current.id).first + my_work = @homework.student_works.where(:id => pro.student_work_id) + else + my_work = @homework.student_works.where(:user_id => User.current.id) + end @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id} elsif @homework.homework_detail_manual.comment_status == 3 #学生 && 关闭匿评 未提交作品之前列表为空,提交了作品看到所有的 - my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + if @homework.homework_type == 3 + pro = @homework.student_work_projects.where(:user_id => User.current.id).first + my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + else + my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + end if my_work.empty? @stundet_works = [] else @@ -190,6 +220,10 @@ class StudentWorkController < ApplicationController student_work.user_id = User.current.id student_work.save_attachments(params[:attachments]) render_attachment_warning_if_needed(student_work) + if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 + @student_work_project = @homework.student_work_projects.where("user_id = #{User.current.id}").first + student_work.project_id = @student_work_project.project_id + end #提交作品时,计算是否迟交 if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") student_work.late_penalty = @homework.late_penalty @@ -197,6 +231,35 @@ class StudentWorkController < ApplicationController student_work.late_penalty = 0 end if student_work.save + if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 + @student_work_project.student_work_id = student_work.id + @student_work_project.save + members = params[:group_member_ids].split(',') + for i in 1 .. members.count-1 + stu_project = StudentWorkProject.new + stu_project.homework_common_id = @homework.id + stu_project.student_work_id = student_work.id + stu_project.project_id = @student_work_project.project_id + stu_project.user_id = members[i].to_i + stu_project.is_leader = 0 + stu_project.save + end + elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0 + members = params[:group_member_ids].split(',') + for i in 0 .. members.count-1 + stu_project = StudentWorkProject.new + stu_project.homework_common_id = @homework.id + stu_project.student_work_id = student_work.id + stu_project.project_id = -1 + stu_project.user_id = members[i].to_i + if i == 0 + stu_project.is_leader = 1 + else + stu_project.is_leader = 0 + end + stu_project.save + end + end course_activity = CourseActivity.where("course_act_type='HomeworkCommon' and course_act_id =#{@homework.id}").first if course_activity course_activity.updated_at = Time.now @@ -276,6 +339,18 @@ class StudentWorkController < ApplicationController def destroy if @work.destroy + if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 + pros = @work.student_work_projects.where("is_leader = 0") + pros.each do |pro| + pro.destroy + end + project = @work.student_work_projects.where("is_leader = 1").first + project.update_attributes(:student_work_id => nil) + elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0 + @work.student_work_projects.each do |pro2| + pro2.destroy + end + end respond_to do |format| format.html { redirect_to student_work_index_url(:homework => @homework.id) @@ -288,12 +363,36 @@ class StudentWorkController < ApplicationController @work = StudentWork.where("user_id =? and homework_common_id =?", User.current.id, @homework.id).first if @work @work.destroy + if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 + pros = @work.student_work_projects.where("is_leader = 0") + pros.each do |pro| + pro.destroy + end + project = @work.student_work_projects.where("is_leader = 1").first + project.update_attributes(:student_work_id => nil) + elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0 + @work.student_work_projects.each do |pro2| + pro2.destroy + end + end end redirect_to user_homeworks_user_path(User.current.id) end def retry_work if @work.destroy + if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 + pros = @work.student_work_projects.where("is_leader = 0") + pros.each do |pro| + pro.destroy + end + project = @work.student_work_projects.where("is_leader = 1").first + project.update_attributes(:student_work_id => nil) + elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0 + @work.student_work_projects.each do |pro2| + pro2.destroy + end + end @student_work = StudentWork.new respond_to do |format| format.js @@ -555,6 +654,7 @@ class StudentWorkController < ApplicationController @project.homework_common_id = @homework.id @project.project_id = (Project.find params[:projectName].to_i).id @project.user_id = User.current.id + @project.is_leader = 1 if @project.save @user_activity_id = params[:user_activity_id].to_i @is_in_course = params[:is_in_course].to_i @@ -579,6 +679,20 @@ class StudentWorkController < ApplicationController end end + #查找课程的学生 + def search_course_students + name = "" + unless params[:name].nil? + name = params[:name] + end + all_student_ids = "(" + @homework.course.student.map{|student| student.student_id}.join(",") + ")" + all_students = User.where("id in #{all_student_ids}") + @users = searchstudent_by_name all_students,name + respond_to do |format| + format.js + end + end + def cancel_relate_project relate_pro = StudentWorkProject.where("user_id = #{User.current.id} and homework_common_id = #{@homework.id}").first if relate_pro.destroy @@ -592,6 +706,22 @@ class StudentWorkController < ApplicationController end private + def searchstudent_by_name users, name + mems = [] + if name != "" + name = name.to_s.downcase + users.each do |m| + username = m.lastname.to_s.downcase + m.firstname.to_s.downcase + if(m.login.to_s.downcase.include?(name) || m.user_extensions[:student_id].to_s.downcase.include?(name) || username.include?(name)) + mems << m + end + end + else + mems = users + end + mems + end + def hsd_committed_work?(user, homework) sw = StudentWork.where("user_id =? and homework_common_id =?", user, homework).first sw.nil? ? result = false : result = true diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a19d44997..8f4679c67 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2435,10 +2435,19 @@ module ApplicationHelper link_to "作品(#{homework.student_works.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" else #学生显示提交作品、修改作品等按钮 work = cur_user_works_for_homework homework + project = cur_user_projects_for_homework homework if work.nil? && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") - link_to "提交作品(#{homework.student_works.count})", new_student_work_path(:homework => homework.id),:class => 'c_blue' + if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1 + link_to "提交作品(#{homework.student_works.count})","javascript:void(0)", :class => 'c_grey',:style=>"cursor:not-allowed",:title => '请先关联项目再提交作品' + else + link_to "提交作品(#{homework.student_works.count})", new_student_work_path(:homework => homework.id),:class => 'c_blue' + end elsif work.nil? && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") - link_to "补交作品(#{homework.student_works.count})", new_student_work_path(:homework => homework.id),:class => 'c_red' + if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1 + link_to "补交作品(#{homework.student_works.count})","javascript:void(0)", :class => 'c_grey',:style=>"cursor:not-allowed",:title => '请先关联项目再补交作品' + else + link_to "补交作品(#{homework.student_works.count})", new_student_work_path(:homework => homework.id),:class => 'c_red' + end else if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 2 #匿评作业,且作业状态不是在开启匿评之前 link_to "作品匿评", student_work_index_path(:homework => homework.id), :class => 'c_blue', :title => "开启匿评后不可修改作品" @@ -2462,7 +2471,7 @@ module ApplicationHelper def relate_project homework,is_teacher,is_in_course,user_activity_id,course_activity if User.current.member_of_course?(homework.course) if is_teacher - link_to "已关联(#{homework.student_work_projects.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" + #link_to "已关联(#{homework.student_work_projects.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" else projects = cur_user_projects_for_homework homework works = cur_user_works_for_homework homework @@ -2471,7 +2480,7 @@ module ApplicationHelper elsif works.nil? link_to "取消关联",cancel_relate_project_student_work_index_path(:homework => homework.id,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity), :confirm => "您确定要取消关联吗?", remote: true,:class => "c_blue", :title=> '取消关联项目' else - link_to "已关联(#{homework.student_work_projects.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" + #link_to "已关联(#{homework.student_work_projects.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" end end end @@ -2492,7 +2501,16 @@ module ApplicationHelper #获取当前用户在指定作业下提交的作业的集合 def cur_user_works_for_homework homework - homework.student_works.where("user_id = ?",User.current).first + work = homework.student_works.where("user_id = ?",User.current).first + if homework.homework_type == 3 + pro = homework.student_work_projects.where("user_id = #{User.current.id}").first + if pro.nil? || pro.student_work_id == "" || pro.student_work_id.nil? + work = nil + else + work = StudentWork.find pro.student_work_id + end + end + work end #获取当前用户在指定作业下关联的项目的集合 def cur_user_projects_for_homework homework diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index a665909e2..0ad667bd1 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -10,7 +10,7 @@ class HomeworkCommon < ActiveRecord::Base has_one :homework_detail_manual, :dependent => :destroy has_one :homework_detail_programing, :dependent => :destroy has_one :homework_detail_group, :dependent => :destroy - has_many :student_work_projects + has_many :student_work_projects, :dependent => :destroy has_many :homework_tests, :dependent => :destroy has_many :student_works, :dependent => :destroy, :conditions => "is_test=0" has_many :student_works_evaluation_distributions, :through => :student_works #一个作业的分配的匿评列表 diff --git a/app/models/project.rb b/app/models/project.rb index a80982413..44b9a7912 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -43,7 +43,7 @@ class Project < ActiveRecord::Base end end - has_many :student_work_projects + has_many :student_work_projects,:dependent => :destroy has_many :student_works has_many :time_entry_activities has_many :members, :include => [:principal, :roles], :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}" diff --git a/app/models/student_work.rb b/app/models/student_work.rb index 59b98b9b2..c6e2a6584 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -4,7 +4,7 @@ class StudentWork < ActiveRecord::Base belongs_to :homework_common belongs_to :user - has_one :student_work_project + has_many :student_work_projects has_many :student_works_evaluation_distributions, :dependent => :destroy has_many :student_works_scores, :dependent => :destroy belongs_to :project diff --git a/app/models/user.rb b/app/models/user.rb index fa6f005b6..1c5d1b0c8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -107,7 +107,7 @@ class User < Principal has_many :student_works, :dependent => :destroy has_many :student_works_evaluation_distributions, :dependent => :destroy has_many :student_works_scores, :dependent => :destroy - has_many :student_work_projects + has_many :student_work_projects, :dependent => :destroy #end has_and_belongs_to_many :groups, :after_add => Proc.new {|user, group| group.user_added(user)}, diff --git a/app/views/student_work/_choose_group_member.html.erb b/app/views/student_work/_choose_group_member.html.erb index 4671dd2a5..1ec8ed0fa 100644 --- a/app/views/student_work/_choose_group_member.html.erb +++ b/app/views/student_work/_choose_group_member.html.erb @@ -9,36 +9,88 @@
      -
        -
      • - 同学一(061530301) -
      • -
      • - 同学二同学二(061530302) -
      • -
      • - 同学三(061530303) -
      • -
      • - 同学四同学四(061530304) -
      • -
      • - 同学五同学五(061530305) -
      • -
      • - 同学六同学六(061530306) -
      • -
      • - 同学七同学七(061530307) -
      • -
      +
        -
          -
        • TimTang(040930319)×
        • -
        • suntao(060930106)×
        • +
            +
          • <%=User.current.show_name %> + <% unless User.current.user_extensions.student_id == "" %> + (<%=User.current.user_extensions.student_id %>) + <% end %> +
          - +
          -
        \ No newline at end of file +
        + \ No newline at end of file diff --git a/app/views/student_work/_evaluation_title.html.erb b/app/views/student_work/_evaluation_title.html.erb index cfd9632c2..7398dbee1 100644 --- a/app/views/student_work/_evaluation_title.html.erb +++ b/app/views/student_work/_evaluation_title.html.erb @@ -1,8 +1,12 @@
        • 作品名称 - 姓名 - 学号 + <% if @homework.homework_type != 3 %> + 姓名 + 学号 + <% elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %> + 关联项目 + <% end %>
        • diff --git a/app/views/student_work/_evaluation_un_title.html.erb b/app/views/student_work/_evaluation_un_title.html.erb index 4ed0a538a..9988bd6e0 100644 --- a/app/views/student_work/_evaluation_un_title.html.erb +++ b/app/views/student_work/_evaluation_un_title.html.erb @@ -1,8 +1,12 @@
          • 作品名称 - 姓名 - 学号 + <% if @homework.homework_type != 3 %> + 姓名 + 学号 + <% elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %> + 关联项目 + <% end %>
          • diff --git a/app/views/student_work/_evaluation_un_work.html.erb b/app/views/student_work/_evaluation_un_work.html.erb index 2a0962244..641405fe4 100644 --- a/app/views/student_work/_evaluation_un_work.html.erb +++ b/app/views/student_work/_evaluation_un_work.html.erb @@ -13,14 +13,22 @@
      • -
          -
        • - <%= student_work.user.show_name%> -
        • -
        • - <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%> -
        • -
        + <% if @homework.homework_type != 3 %> +
          +
        • + <%= student_work.user.show_name%> +
        • +
        • + <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%> +
        • +
        + <% elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %> +
          +
        • + <%= student_work.project.name %> +
        • +
        + <% end %>
      • diff --git a/app/views/student_work/_evaluation_work.html.erb b/app/views/student_work/_evaluation_work.html.erb index e336b0282..58f611b55 100644 --- a/app/views/student_work/_evaluation_work.html.erb +++ b/app/views/student_work/_evaluation_work.html.erb @@ -1,6 +1,11 @@
          - <% is_my_work = student_work.user == User.current%> + <% if @homework.homework_type != 3 %> + <% is_my_work = student_work.user == User.current%> + <% else %> + <% pro = @homework.student_work_projects.where(:user_id => User.current.id).first %> + <% is_my_work = pro && pro.student_work_id == student_work.id%> + <% end %>
          • <% if is_my_work%> @@ -14,14 +19,22 @@
          • -
              -
            • - <%= student_work.user.show_name%> -
            • -
            • - <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%> -
            • -
            + <% if @homework.homework_type != 3 %> +
              +
            • + <%= student_work.user.show_name%> +
            • +
            • + <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%> +
            • +
            + <% elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %> +
              +
            • + <%= student_work.project.name %> +
            • +
            + <% end %>
          • <% else%>
          • @@ -33,14 +46,22 @@
          • -
              -
            • - 匿名 -
            • -
            • - -- -
            • -
            + <% if @homework.homework_type != 3 %> +
              +
            • + 匿名 +
            • +
            • + -- +
            • +
            + <% elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %> +
              +
            • + 匿名 +
            • +
            + <% end %>
          • <% end%> diff --git a/app/views/student_work/_relate_project.html.erb b/app/views/student_work/_relate_project.html.erb index bcfd9eb8e..43f59c9c9 100644 --- a/app/views/student_work/_relate_project.html.erb +++ b/app/views/student_work/_relate_project.html.erb @@ -7,28 +7,6 @@

              -
              @@ -56,7 +34,7 @@ },500); } - //查询组织 + //查询项目 $("input[name='project']").on('input', function (e) { throttle(search_pros,window,e); }); diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb index 993b0f2aa..801c252cb 100644 --- a/app/views/student_work/_show.html.erb +++ b/app/views/student_work/_show.html.erb @@ -1,5 +1,12 @@
              + <% is_teacher = User.current.allowed_to?(:as_teacher, @homework.course) || User.current.admin? %> + <% if @homework.homework_type != 3 %> + <% is_my_work = work.user == User.current%> + <% else %> + <% pro = @homework.student_work_projects.where(:user_id => User.current.id).first %> + <% is_my_work = pro && pro.student_work_id == work.id%> + <% end %>
              • 上交时间: @@ -15,7 +22,7 @@ <%= link_to "",edit_student_work_path(work),:class => "pic_edit",:title => "修改"%>
              • <% end%> - <% if @homework.homework_detail_manual.comment_status == 3 && work.user != User.current%> + <% if @homework.homework_detail_manual.comment_status == 3 && !is_my_work %>
              • <%= render :partial => 'student_work_praise' %> @@ -25,11 +32,24 @@ - <% if work.project%> -
              • - 关联项目: - <%= link_to( work.project.name, project_path(work.project.id), :class => "linkBlue" )%> + <% if @homework.homework_type == 3 && work.student_work_projects && (@homework.homework_detail_manual.comment_status != 2 || is_my_work || is_teacher ) %> +
                +
              • + 参与人员: + <%= link_to(work.user.show_name+"(组长)", user_path(work.user.id), :class => "linkBlue" )%> + <% members = work.student_work_projects.where("is_leader = 0") %> + <% members.each do |member| if !members.empty? %> + 、<%=link_to((User.find member.user_id).show_name, user_path(member.user.id), :class => "linkBlue" ) %> + <% end %> + <% end %>
              • + <% if @homework.homework_detail_group.base_on_project == 1 %> +
              • + 关联项目: + <%= link_to( work.project.name, project_path(work.project.id), :class => "linkBlue" )%> + (综合评分:<%=work.project.project_score.score.to_i %>) +
              • + <% end %> <% end%>
              • @@ -52,7 +72,7 @@
              • - <% if @is_teacher || (@homework.homework_detail_manual.comment_status == 2 && work.user != User.current)%> + <% if @is_teacher || (@homework.homework_detail_manual.comment_status == 2 && !is_my_work)%>
                <%= render :partial => 'add_score',:locals => {:work => work,:score => score}%> diff --git a/app/views/student_work/_student_work_list.html.erb b/app/views/student_work/_student_work_list.html.erb index e9b056c84..5598092e9 100644 --- a/app/views/student_work/_student_work_list.html.erb +++ b/app/views/student_work/_student_work_list.html.erb @@ -40,12 +40,17 @@ <% end%>
                - <% if student_work.user == User.current && !@is_evaluation %> + <% if @homework.homework_type != 3 && 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 %> + <% elsif @homework.homework_type == 3 %> + <% pro = @homework.student_work_projects.where(:user_id => User.current.id).first %> + <% if pro && pro.student_work_id == student_work.id && !@is_evaluation %> + <%=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 %>
                diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index d14da5fa2..c3a61d4c8 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -54,11 +54,21 @@ function popupRegex(){ if(regexStudentWorkName()&®exStudentWorkDescription()) { - $('#ajax-modal').html("

                作品信息完整性校验中,请稍等...

                "); - showModal('ajax-modal', '500px'); - $('#ajax-modal').siblings().remove(); - $('#ajax-modal').parent().css("top","").css("left",""); - $('#ajax-modal').parent().addClass("anonymos"); + if($("#group_member_ids").length > 0) { + if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) { + $('#ajax-modal').html("

                作品信息完整性校验中,请稍等...

                "); + showModal('ajax-modal', '500px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').parent().css("top","").css("left",""); + $('#ajax-modal').parent().addClass("anonymos"); + } + } else { + $('#ajax-modal').html("

                作品信息完整性校验中,请稍等...

                "); + showModal('ajax-modal', '500px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').parent().css("top","").css("left",""); + $('#ajax-modal').parent().addClass("anonymos"); + } } } @@ -106,7 +116,11 @@ 提示:作品名称和描述中不要出现真实的姓名信息
                - + <% if @homework.homework_type == 3 %> + + + <%=hidden_field_tag 'group_member_ids', params[:group_member_ids], :value=>User.current.id %> + <% end %>
                <%= f.text_field "name", :required => true, :size => 60, :class => "InputBox W700", :maxlength => 200, :placeholder => "请简洁的概括作品的功能或特性", :onkeyup => "regexStudentWorkName();" %>
                @@ -125,12 +139,16 @@
                <%= render :partial => 'users/user_homework_attachment', :locals => {:container => @student_work, :has_program=>false,:has_group=>false} %>
                +
                +
                +
                +
                - <%# if @homework.homework_type == 3 %> - - <%# end %> +
                + <% end %> + 已关联项目:
              - <% activity.student_work_projects.each do |pro| %> + <% activity.student_work_projects.where("is_leader = 1").each do |pro| %>
              - <% project = Project.find pro.project_id %> + <% project = Project.find pro.project_id || User.current.member_of?(project) || User.current.admin? %> <% if project.is_public || project.user_id == User.current.id %> <%= link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_path(project.id,:host=>Setting.host_name),:alt =>"项目头像" %> <% else %> diff --git a/app/views/users/_user_homework_attachment.html.erb b/app/views/users/_user_homework_attachment.html.erb index f1c0ae97e..7aefbd0b0 100644 --- a/app/views/users/_user_homework_attachment.html.erb +++ b/app/views/users/_user_homework_attachment.html.erb @@ -43,7 +43,25 @@ :lebel_file_uploding => l(:lebel_file_uploding), :delete_all_files => l(:text_are_you_sure_all) } %> - + +
              + +
              + <% if @homework && @homework.homework_type == 3 %> + + 合作成员:<%=User.current.show_name %>(组长) + + + <% end %> +
              + + <% if @homework %> + <% unless @homework.student_work_projects.where("user_id = #{User.current.id}").empty? %> + <% project = Project.find @homework.student_work_projects.where("user_id = #{User.current.id}").first.project_id %> + 关联项目:<%=project.name %> + <% end %> + <% end %> +
              diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index 8e01ee908..57fe57c07 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -49,10 +49,19 @@ 系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"c_red",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合! <% end %>
              - <% if homework_common.homework_type == 3%> -
              - <%= relate_project(homework_common,is_teacher,is_in_course,-1,-1) %> -
              + <% if homework_common.homework_type == 3 && !is_teacher && homework_common.homework_detail_group.base_on_project == 1%> + <% projects = cur_user_projects_for_homework homework_common %> + <% works = cur_user_works_for_homework homework_common %> + <% if works.nil? && projects.nil? %> +
              + <%=link_to "关联项目",new_student_work_project_student_work_index_path(:homework => homework_common.id,:is_in_course=>is_in_course,:user_activity_id=>-1,:course_activity=>-1),remote: true,:class=> 'c_blue', :title=> '请选择分组作业关联的项目' %> + <%#= relate_project(activity,is_teacher,-1,user_activity_id,course_activity) %> +
              + <% elsif works.nil? %> +
              + <%=link_to "取消关联",cancel_relate_project_student_work_index_path(:homework => homework_common.id,:is_in_course=>is_in_course,:user_activity_id=>-1,:course_activity=>-1), :confirm => "您确定要取消关联吗?", remote: true,:class => "c_blue", :title=> '取消关联项目' %> +
              + <% end %> <% end %>
              <%= user_for_homework_common homework_common,is_teacher %> @@ -90,15 +99,16 @@ <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => homework_common.attachments} %>
              - <% if homework_common.homework_type == 3 && !homework_common.student_work_projects.empty? %> + <% if homework_common.homework_type == 3 && !homework_common.student_work_projects.empty? && homework_common.homework_detail_group.base_on_project == 1 %>
              -
              - +
              + + 已关联项目:
              - <% homework_common.student_work_projects.each do |pro| %> + <% homework_common.student_work_projects.where("is_leader = 1").each do |pro| %>
              <% project = Project.find pro.project_id %> - <% if project.is_public == 1 %> + <% if project.is_public == 1 || User.current.member_of?(project) || User.current.admin? %> <%=link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_path(project.id,:host=>Setting.host_name) %> <% else %> <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius") %> diff --git a/config/routes.rb b/config/routes.rb index 2be4f7221..db63fe3ee 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -221,6 +221,7 @@ RedmineApp::Application.routes.draw do post 'student_work_project' get 'new_student_work_project' get 'search_user_projects' + get 'search_course_students' get 'cancel_relate_project' get 'delete_work' get 'destroy_score_reply' diff --git a/lib/tasks/homework_evaluation.rake b/lib/tasks/homework_evaluation.rake index 84082eb9b..585d91737 100644 --- a/lib/tasks/homework_evaluation.rake +++ b/lib/tasks/homework_evaluation.rake @@ -14,14 +14,33 @@ namespace :homework_evaluation do if homework_common.anonymous_comment == 0 && homework_detail_manual.comment_status == 1 #新建状态才可开启匿评 student_works = homework_common.student_works if student_works && student_works.size >= 2 - student_works.each_with_index do |work, index| - user = work.user - n = homework_detail_manual.evaluation_num - n = n < student_works.size ? n : student_works.size - 1 - assigned_homeworks = get_assigned_homeworks(student_works, n, index) - assigned_homeworks.each do |h| - student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id) - student_works_evaluation_distributions.save + if homework_common.homework_type == 3 + student_work_projects = homework_common.student_work_projects.where("student_work_id is not null") + student_work_projects.each_with_index do |pro_work, pro_index| + n = homework_detail_manual.evaluation_num + n = n < student_works.size ? n : student_works.size - 1 + work_index = -1 + student_works.each_with_index do |stu_work, stu_index| + if stu_work.id.to_i == pro_work.student_work_id.to_i + work_index = stu_index + end + end + assigned_homeworks = get_assigned_homeworks(student_works, n, work_index) + assigned_homeworks.each do |h| + student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id) + student_works_evaluation_distributions.save + end + end + else + student_works.each_with_index do |work, index| + user = work.user + n = homework_detail_manual.evaluation_num + n = n < student_works.size ? n : student_works.size - 1 + assigned_homeworks = get_assigned_homeworks(student_works, n, index) + assigned_homeworks.each do |h| + student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id) + student_works_evaluation_distributions.save + end end end homework_detail_manual.update_column('comment_status', 2) diff --git a/public/images/course/proRelated.png b/public/images/course/proRelated.png new file mode 100644 index 0000000000000000000000000000000000000000..2cc1252cc0918a854d382c3bc6aebb1211f2a3b9 GIT binary patch literal 1249 zcmeAS@N?(olHy`uVBq!ia0vp^8X(NU1|)m_?Z^dEk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+m<2LJB1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxSU1_g&``n5OwZ87 z)XdCKN5ROz&`93^h|F{iO{`4Ktc=VRpg;*|TTx1yRgjAt)Gi>;Rw<*Tq`*pFzr4I$ zuiRKKzbIYb(9+TpWQLKEE>MMTab;dfVufyAu`kBtHuNWFoz#!AFNG#Ad)HBe}%?0@jth%@)C>7xhtg4GcDhpEegHnt0 zON)|$@sXws(+mtd{1$-}0$pR}lAm0fo0?bR>0+w{6wyn`OtEq^b#rwzaCEYCb~ZLN zbTxHyb2e~wGIcU?HaB*5bTNkM^~@_SNz6-5h3U;i=yk-a*UGslHL)bWC?r2W2Nrt) z8Tlpo#Toep3eLf13gMY~Df#8apn!$CGqotQEH%ZgC_h&L95Pm!NVYqfIXYT6ni!fG z8CV*cIU1Nd8JnBBS{j==n;1B`8kj3V^`s#AmY^Pepym3YXhe!um=G|nfSB+^3gp0( zd1@XoZ5II(@xN_dJq!$t>7Fi*Ar-gITu)rrtiZ$YVC$ljyZ@iubJjS}+HjYJ@|FvS zGB(L`UCuuU$yrBd9~dkS*MTK1eatgSYG3OtKT^*h>mFd(F1GN 0) { + if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) { + $("#new_student_work").submit(); + $("#ajax-indicator").hide(); + } + } else { + $("#new_student_work").submit(); + $("#ajax-indicator").hide(); + } } } diff --git a/public/javascripts/new_user.js b/public/javascripts/new_user.js index dcd8a35ca..d375a90ee 100644 --- a/public/javascripts/new_user.js +++ b/public/javascripts/new_user.js @@ -251,8 +251,15 @@ function new_student_work() { if(regexStudentWorkName()&®exStudentWorkDescription()) { - $("#new_student_work").submit(); - $("#ajax-indicator").hide(); + if($("#group_member_ids").length > 0) { + if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) { + $("#new_student_work").submit(); + $("#ajax-indicator").hide(); + } + } else { + $("#new_student_work").submit(); + $("#ajax-indicator").hide(); + } } } @@ -298,6 +305,17 @@ function regexStudentWorkDescription() } } +function regexStudentWorkMember(min, max) { + var members = $.trim($("#group_member_ids").val()).split(','); + if ( min <= members.length && members.length <= max ){ + $("#student_work_group_textarea").text(""); + return true; + } else { + $("#student_work_group_textarea").text("合作成员人数应为:"+min+"-"+max+"人"); + return false; + } +} + //学生作品 function show_project() {