From 4e815a38b63878d41a033e0f094ed1b955443c3a Mon Sep 17 00:00:00 2001 From: nwb Date: Thu, 29 May 2014 15:21:22 +0800 Subject: [PATCH 001/183] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=EF=BC=8C=E8=AF=BE=E7=A8=8B=E7=8B=AC=E7=AB=8B=E5=87=BA=E6=9D=A5?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E5=86=8D=E5=8C=85=E5=90=AB=E5=9C=A8=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{projects => courses}/_course.html.erb | 0 .../_course_form.html.erb | 0 config/routes.rb | 21 ++++++++++++++----- 3 files changed, 16 insertions(+), 5 deletions(-) rename app/views/{projects => courses}/_course.html.erb (100%) rename app/views/{projects => courses}/_course_form.html.erb (100%) diff --git a/app/views/projects/_course.html.erb b/app/views/courses/_course.html.erb similarity index 100% rename from app/views/projects/_course.html.erb rename to app/views/courses/_course.html.erb diff --git a/app/views/projects/_course_form.html.erb b/app/views/courses/_course_form.html.erb similarity index 100% rename from app/views/projects/_course_form.html.erb rename to app/views/courses/_course_form.html.erb diff --git a/config/routes.rb b/config/routes.rb index 05041ac9..c3239154 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -261,8 +261,6 @@ RedmineApp::Application.routes.draw do end resources :projects do member do - post 'finishcourse' - post 'restartcourse' get 'settings(/:tab)', :action => 'settings', :as => 'settings' #by young get 'member', :controller => 'projects', :action => 'member', :as => 'member' @@ -539,6 +537,20 @@ RedmineApp::Application.routes.draw do end end + # add by nwb + # 课程路由设置 + resources :course do + member do + # 之前在项目 + post 'finishcourse' + post 'restartcourse' + end + end + #match 'project/enterprise_course', :to => 'projects#enterprise_course' + #match 'project/course_enterprise', :to => 'projects#course_enterprise' + #match 'project/course', :to => 'projects#course', :as => 'course' + + match 'workflows', :controller => 'workflows', :action => 'index', :via => :get match 'workflows/edit', :controller => 'workflows', :action => 'edit', :via => [:get, :post] match 'workflows/permissions', :controller => 'workflows', :action => 'permissions', :via => [:get, :post] @@ -590,8 +602,7 @@ RedmineApp::Application.routes.draw do match 'calls/:id/homework_statistics', :to => 'bids#homework_statistics' match 'calls/:id/fork', :to => 'bids#fork', :as => 'fork' match 'calls/:id/create_fork', :to => 'bids#create_fork' - match 'project/enterprise_course', :to => 'projects#enterprise_course' - match 'project/course_enterprise', :to => 'projects#course_enterprise' + match 'calls/:id/show_course', :to => 'bids#show_course', :as => 'show_course' match 'calls/:id/show_bid_project', :to => 'bids#show_bid_project', :as => 'show_bid_project' match 'calls/:id/show_bid_user', :to => 'bids#show_bid_user', :as => 'show_bid_user' @@ -611,7 +622,7 @@ RedmineApp::Application.routes.draw do match 'new_join_in_contest', :to => 'bids#new_join', :as => 'try_join_in_contest' match 'projects/:id/respond', :to => 'projects#project_respond', :via => :post match 'calls/:id/manage',:to => 'bids#manage',:via => [:get,:post] - match 'project/course', :to => 'projects#course', :as => 'course' + #added by william # match 'calls/:id/set_results',:controller => 'bids', :action => 'set_results',:via => [:get,:post],:as => 'set_results' From f936c30ec93df7c0a85a494e82791392c48bdf04 Mon Sep 17 00:00:00 2001 From: nwb Date: Thu, 29 May 2014 16:35:34 +0800 Subject: [PATCH 002/183] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=8Ecourse.index?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E7=9A=84control=E3=80=81view=E3=80=81help?= =?UTF-8?q?=E7=AD=89=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/contests_controller.rb | 2 +- app/controllers/courses_controller.rb | 178 ++++++++++++++++++++++++- app/helpers/application_helper.rb | 50 ++++++- app/helpers/contests_helper.rb | 5 +- app/helpers/courses_helper.rb | 29 ++++ app/models/course.rb | 71 +++++++++- app/views/courses/index.html.erb | 63 +++++++++ config/routes.rb | 2 +- 8 files changed, 390 insertions(+), 10 deletions(-) create mode 100644 app/views/courses/index.html.erb diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index e7490f5b..cd6d5abb 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -73,7 +73,7 @@ class ContestsController < ApplicationController end end - def show_contest + def show_contest @user = @contest.author @jours = @contest.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') @limit = 10 diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 215dd3a5..6cbec854 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1,9 +1,19 @@ class CoursesController < ApplicationController include CoursesHelper - + + menu_item l(:label_sort_by_time), :only => :index + menu_item l(:label_sort_by_active), :only => :index + menu_item l(:label_sort_by_influence), :only => :index + + before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches] + before_filter :authorize, :only => [:show, :settings, :edit, :update, :modules, :close, :reopen,:view_homework_attaches,:course] + before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches] + before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar] + before_filter :require_login, :only => [:join, :unjoin] before_filter :allow_join, :only => [:join] - + + def join if User.current.logged? course = Project.find(params[:object_id]) @@ -59,4 +69,168 @@ class CoursesController < ApplicationController end end + + def course12 + @project_type = params[:project_type] + @school_id = params[:school_id] + per_page_option = 10 + if @school_id == "0" or @school_id.nil? + @projects_all = Project.active.visible. + joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id"). + where("#{Project.table_name}.project_type = ? ", Project::ProjectType_course) + else + @projects_all = Project.active.visible. + joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id"). + joins(:course_extra). + where("#{Project.table_name}.project_type = ? AND #{Course.table_name}.school_id = ?", Project::ProjectType_course, @school_id) + end + + @project_count = @projects_all.count + @project_pages = Paginator.new @project_count, per_page_option, params['page'] + + #gcm activity count + + @project_activity_count=Hash.new + #count initialize + @projects_all.each do |project| + @project_activity_count[project.id]=0 + end + + #@project_activity_count=get_project_activity @projects_all,@project_activity_count + #gcm end + + + case params[:project_sort_type] + when '0' + @projects = @projects_all.order("created_on desc") + @s_type = 0 + @projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page) + + #gcm + @project_activity_count=get_project_activity @projects,@project_activity_count + #gcmend + + when '1' + @projects = @projects_all.order("course_ac_para desc") + @s_type = 1 + @projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page) + + #gcm + @project_activity_count=get_project_activity @projects,@project_activity_count + #gcmend + + when '2' + @projects = @projects_all.order("watchers_count desc") + @s_type = 2 + @projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page) + + #gcm + @project_activity_count=get_project_activity @projects,@project_activity_count + #gcmend + + #gcm + when '3' + + #gcm + @project_activity_count=get_project_activity @projects_all,@project_activity_count + #gcmend + + @projects=handle_project @projects_all,@project_activity_count + @s_type = 3 + @projects = @projects[@project_pages.offset, @project_pages.per_page] + else + @s_type = 0 + @projects = @projects_all.order("created_on desc") + @projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page) + + #gcm + @project_activity_count=get_project_activity @projects,@project_activity_count + #gcmend + + end + + respond_to do |format| + format.html { + render :layout => 'base' + } + format.api { + # @offset, @limit = api_offset_and_limit + # @project_count = Project.visible.count + # @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all + } + format.atom { + projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all + render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}") + } + end + end + + + def index + + per_page_option = 10 + + @courses_all = Course.active.visible. + joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.couse_id") + + @course_count = @courses_all.count + @course_pages = Paginator.new @course_count, per_page_option, params['page'] + +#gcm activity count + + @course_activity_count=Hash.new + + @courses_all.each do |course| + @course_activity_count[course.id]=0 + end + + @course_activity_count=get_course_activity @courses_all,@course_activity_count + +#gcm end + + case params[:course_sort_type] + when '0' + @courses = @courses_all.order("created_on desc") + @s_type = 0 + when '1' + @courses = @courses_all.order("grade desc") + @s_type = 1 + when '2' + @courses = @courses_all.order("watchers_count desc") + @s_type = 2 + + #gcm + when '3' + #@courses=desc_sort_course_by_avtivity(@course_activity_count_array,@course_all_array) + @courses=handle_course @courses_all,@course_activity_count + @s_type = 3 + @courses = @courses[@course_pages.offset, @course_pages.per_page] + + else + @courses = @courses = @courses_all.order("grade desc") + @s_type = 1 + end + @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page) + + respond_to do |format| + format.html { + render :layout => 'base' + # scope = Project + # unless params[:closed] + # scope = scope.active + # end + } + format.api { + # @offset, @limit = api_offset_and_limit + # @course_count = Project.visible.count + # @courses = Project.visible.offset(@offset).limit(@limit).order('lft').all + } + format.atom { + courses = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all + render_feed(courses, :title => "#{Setting.app_title}: #{l(:label_course_latest)}") + } + end + end + + end \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7dc4b555..f89023b7 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -170,6 +170,18 @@ module ApplicationHelper end end + def link_to_course(course, options={}, html_options = nil) + if course.archived? + h(course.name) + elsif options.key?(:action) + ActiveSupport::Deprecation.warn "#link_to_course with :action option is deprecated and will be removed in Redmine 3.0." + url = {:controller => 'courses', :action => 'show', :id => project}.merge(options) + link_to course.name, url, html_options + else + link_to course.name, course_path(course, options), html_options + end + end + # Generates a link to a project settings if active def link_to_project_settings(project, options={}, html_options=nil) if project.active? @@ -297,7 +309,41 @@ module ApplicationHelper @project = original_project end s.html_safe + end + + def render_course_nested_lists(courses) + s = '' + if courses.any? + ancestors = [] + original_course = @course + #modified by nie + courses.each do |course| + # set the project environment to please macros. + @course = course + if (ancestors.empty? || course.is_descendant_of?(ancestors.last)) + s << "\n" + end + end + classes = (ancestors.empty? ? 'root' : 'child') + s << "
  • " + + s << (render :partial => 'courses/course', :locals => {:course => course}).to_s + s << "
    \n" + ancestors << course + end + s << ("
  • \n" * ancestors.size) + @course = original_course + end + s.html_safe end + + #added by young def render_project_nested_lists_new(projects) s = '' @@ -1639,9 +1685,9 @@ module ApplicationHelper main_project_link = link_to l(:label_project_deposit), {:controller => 'welcome', :action => 'index', :host => Setting.project_domain} main_contest_link = link_to l(:label_contest_innovate), {:controller => 'welcome', :action => 'index', :host => Setting.contest_domain} - course_all_course_link = link_to l(:label_course_all), {:controller => 'projects', :action => 'course', :project_type => 1, :host => Setting.course_domain} + course_all_course_link = link_to l(:label_course_all), {:controller => 'courses', :action => 'index', :host => Setting.course_domain} course_teacher_all_link = link_to l(:label_teacher_all), {:controller => 'users', :action => 'index', :role => 'teacher', :host => Setting.course_domain} - courses_link = link_to l(:label_course_practice), {:controller => 'projects', :action => 'course', :project_type => 1, :host => Setting.course_domain} + courses_link = link_to l(:label_course_practice), {:controller => 'courses', :action => 'index',:host => Setting.course_domain} projects_link = link_to l(:label_project_deposit), {:controller => 'projects', :action => 'index', :project_type => 0, :host => Setting.project_domain} users_link = link_to l(:label_software_user), {:controller => 'users', :action => 'index', :host => Setting.user_domain} contest_link = link_to l(:label_contest_innovate), {:controller => 'contests', :action => 'index'} diff --git a/app/helpers/contests_helper.rb b/app/helpers/contests_helper.rb index 8206a8ff..184fc7c4 100644 --- a/app/helpers/contests_helper.rb +++ b/app/helpers/contests_helper.rb @@ -55,8 +55,9 @@ module ContestsHelper content_tag('div', content, :class => "tabs_enterprise") end #end - - + + + #huang def sort_contest(state) content = ''.html_safe diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 959d36cb..bcd45ac0 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -82,6 +82,35 @@ module CoursesHelper members end + def sort_courses(state) + content = ''.html_safe + case state + when 0 + + content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:courses_sort_type => '1'))) + content << content_tag('li', link_to(l(:label_sort_by_influence), courses_path(:courses_sort_type => '2'))) + content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:courses_sort_type => '0'), :class=>"selected"), :class=>"selected") + when 1 + + content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:courses_sort_type => '1'), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_influence), courses_path(:courses_sort_type => '2'))) + content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:courses_sort_type => '0'))) + when 2 + content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:courses_sort_type => '1'))) + content << content_tag('li', link_to(l(:label_sort_by_influence), courses_path(:courses_sort_type => '2'), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:courses_sort_type => '0'))) + end + content = content_tag('ul', content) + content_tag('div', content, :class => "tabs") + end + + def render_course_hierarchy(courses) + render_course_nested_lists(courses) do |course| + s = link_to_course(course, {}, :class => "#{course.css_classes} #{User.current.member_of?(course) ? 'my-course' : nil}").html_safe + s + end + end + #useless def searchMembersByRole project, role_id members = [] diff --git a/app/models/course.rb b/app/models/course.rb index de383a1f..0bc93c81 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -1,8 +1,12 @@ class Course < ActiveRecord::Base include Redmine::SafeAttributes + + STATUS_ACTIVE = 1 + STATUS_CLOSED = 5 + STATUS_ARCHIVED = 9 attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password - belongs_to :project, :class_name => 'Project', :foreign_key => :extra, primary_key: :identifier + belongs_to :project, :class_name => 'Course', :foreign_key => :extra, primary_key: :identifier belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表 belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school,该方法通过school_id来调用School表 has_many :bid @@ -19,7 +23,24 @@ class Course < ActiveRecord::Base 'term', 'password' - #自定义验证 + scope :active, lambda { where(:status => STATUS_ACTIVE) } + scope :status, lambda {|arg| where(arg.blank? ? nil : {:status => arg.to_i}) } + scope :all_public, lambda { where(:is_public => true) } + scope :visible, lambda {|*args| where(Course.visible_condition(args.shift || User.current, *args)) } + scope :allowed_to, lambda {|*args| + user = User.current + permission = nil + if args.first.is_a?(Symbol) + permission = args.shift + else + user = args.shift + permission = args.shift + end + where(Course.allowed_to_condition(user, permission, *args)) + } + + + #自定义验证 def validate if !class_period.match([0-9]) errors.add_to_base("class period can only digital") @@ -47,4 +68,50 @@ class Course < ActiveRecord::Base return time end end + + def self.allowed_to_condition(user, permission, options={}) + perm = Redmine::AccessControl.permission(permission) + base_statement = (perm && perm.read? ? "#{Course.table_name}.status <> #{Course::STATUS_ARCHIVED}" : "#{Course.table_name}.status = #{Course::STATUS_ACTIVE}") + if perm && perm.project_module + # If the permission belongs to a project module, make sure the module is enabled + base_statement << " AND #{Course.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name='#{perm.project_module}')" + end + if options[:project] + project_statement = "#{Course.table_name}.id = #{options[:project].id}" + project_statement << " OR (#{Course.table_name}.lft > #{options[:project].lft} AND #{Course.table_name}.rgt < #{options[:project].rgt})" if options[:with_subprojects] + base_statement = "(#{project_statement}) AND (#{base_statement})" + end + + if user.admin? + base_statement + else + statement_by_role = {} + unless options[:member] + role = user.logged? ? Role.non_member : Role.anonymous + if role.allowed_to?(permission) + statement_by_role[role] = "#{Course.table_name}.is_public = #{connection.quoted_true}" + end + end + if user.logged? + user.projects_by_role.each do |role, projects| + if role.allowed_to?(permission) && projects.any? + statement_by_role[role] = "#{Course.table_name}.id IN (#{projects.collect(&:id).join(',')})" + end + end + end + if statement_by_role.empty? + "1=0" + else + if block_given? + statement_by_role.each do |role, statement| + if s = yield(role, user) + statement_by_role[role] = "(#{statement} AND (#{s}))" + end + end + end + "((#{base_statement}) AND (#{statement_by_role.values.join(' OR ')}))" + end + end + end + end diff --git a/app/views/courses/index.html.erb b/app/views/courses/index.html.erb new file mode 100644 index 00000000..87ef6886 --- /dev/null +++ b/app/views/courses/index.html.erb @@ -0,0 +1,63 @@ +<% content_for :header_tags do %> +<%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %> +<% end %> + +
    + <%= form_tag(projects_search_path, :method => :get) do %> + + + + + + + + + + + +
    <%= l(:label_project_deposit) %><%= l(:label_user_location) %> : + <% if User.current.logged? %> + <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new', :course => 0, :project_type =>( @project_type||=0)}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %> + <% end %> + + +
    <%= link_to request.host()+"/projects", :controller => 'projects', :action => 'index', :project_type => 0 %> <%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_project_deposit), :controller => 'projects', :action => 'index', :project_type => 0 %>
    + <% end %> +
    +<%= sort_courses(@s_type) %> +
    + <%= render_course_hierarchy(@projects)%> +
    + + + +<% if User.current.logged? %> +

    + <%= l(:label_my_projects) %> +

    +<% end %> + +<% other_formats_links do |f| %> +<%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> +<% end %> + +<% content_for :sidebar do %> + +<%= form_tag({}, :method => :get) do %> +

    <%= l(:label_project_plural) %>

    + +

    + <%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %> +

    +<% end %> +<% end %> + +<% html_title(l(:label_project_plural)) -%> diff --git a/config/routes.rb b/config/routes.rb index c3239154..4ccd4195 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -539,7 +539,7 @@ RedmineApp::Application.routes.draw do # add by nwb # 课程路由设置 - resources :course do + resources :courses do member do # 之前在项目 post 'finishcourse' From ea3b80fdc6cde4cff835e49d9a7c7ceed8cdae6a Mon Sep 17 00:00:00 2001 From: nwb Date: Thu, 29 May 2014 16:47:32 +0800 Subject: [PATCH 003/183] =?UTF-8?q?=E6=B7=BB=E5=8A=A0CourseStatus=E8=A1=A8?= =?UTF-8?q?=E5=92=8Cmodel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course_status.rb | 3 +++ db/migrate/20140529084427_create_course_statuses.rb | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 app/models/course_status.rb create mode 100644 db/migrate/20140529084427_create_course_statuses.rb diff --git a/app/models/course_status.rb b/app/models/course_status.rb new file mode 100644 index 00000000..d5a01ac4 --- /dev/null +++ b/app/models/course_status.rb @@ -0,0 +1,3 @@ +class CourseStatus < ActiveRecord::Base + attr_accessible :changesets_count, :course_ac_para, :course_id, :grade, :watchers_count +end diff --git a/db/migrate/20140529084427_create_course_statuses.rb b/db/migrate/20140529084427_create_course_statuses.rb new file mode 100644 index 00000000..1244425d --- /dev/null +++ b/db/migrate/20140529084427_create_course_statuses.rb @@ -0,0 +1,13 @@ +class CreateCourseStatuses < ActiveRecord::Migration + def change + create_table :course_statuses do |t| + t.integer :changesets_count + t.integer :watchers_count + t.integer :course_id + t.float :grade ,default:0 + t.integer :course_ac_para ,default:0 + + t.timestamps + end + end +end From e15bad74622d469ff8761928d11f379243bf86de Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 30 May 2014 10:48:06 +0800 Subject: [PATCH 004/183] =?UTF-8?q?course=E6=96=B0=E5=A2=9E=E5=88=97?= =?UTF-8?q?=E5=B9=B6=E6=9B=B4=E6=94=B9=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 2 +- app/views/courses/_course.html.erb | 4 +- app/views/courses/index.html.erb | 28 +- .../20140530102015_stored_course_procedure.rb | 392 ++++++++++++++++++ .../20140530102016_add_status_to_course.rb | 9 + 5 files changed, 418 insertions(+), 17 deletions(-) create mode 100644 db/migrate/20140530102015_stored_course_procedure.rb create mode 100644 db/migrate/20140530102016_add_status_to_course.rb diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 6cbec854..e54d5010 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -171,7 +171,7 @@ class CoursesController < ApplicationController per_page_option = 10 @courses_all = Course.active.visible. - joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.couse_id") + joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.couse_id") @course_count = @courses_all.count @course_pages = Paginator.new @course_count, per_page_option, params['page'] diff --git a/app/views/courses/_course.html.erb b/app/views/courses/_course.html.erb index 6ea80203..4fd807b6 100644 --- a/app/views/courses/_course.html.erb +++ b/app/views/courses/_course.html.erb @@ -15,8 +15,8 @@

    <%= content_tag('span', "#{l(:label_institution_name)}:", :class => "course-font")%> <% @admin = @project.project_infos%> - <%if @admin&&@admin.first&&@admin.first.user&&@admin.first.user.user_extensions%> - + <%if @admin&&@adadminmin.first&&@admin.first.user&&@admin.first.user.user_extensions%> + <%# unless @project.course_extra.school.nil? %> <%= @project.course_extra.teacher.user_extensions.school.try(:name) %> <%# end %> diff --git a/app/views/courses/index.html.erb b/app/views/courses/index.html.erb index 87ef6886..9b1cf841 100644 --- a/app/views/courses/index.html.erb +++ b/app/views/courses/index.html.erb @@ -3,45 +3,45 @@ <% end %>

    - <%= form_tag(projects_search_path, :method => :get) do %> + <%= form_tag(courses_search_path, :method => :get) do %> - + - - + +
    <%= l(:label_project_deposit) %><%= l(:label_course_deposit) %> <%= l(:label_user_location) %> : <% if User.current.logged? %> - <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new', :course => 0, :project_type =>( @project_type||=0)}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %> + <%= link_to(l(:label_course_new), {:controller => 'courses', :action => 'new', :course => 0, :course_type =>( @course_type||=0)}, :class => 'icon icon-add') if User.current.allowed_to?(:add_course, nil, :global => true) %> <% end %> -
    <%= link_to request.host()+"/projects", :controller => 'projects', :action => 'index', :project_type => 0 %> <%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_project_deposit), :controller => 'projects', :action => 'index', :project_type => 0 %><%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index', :course_type => 0 %> <%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_course_deposit), :controller => 'courses', :action => 'index', :course_type => 0 %>
    <% end %>
    <%= sort_courses(@s_type) %> -
    - <%= render_course_hierarchy(@projects)%> +
    + <%= render_course_hierarchy(@courses)%>
    <% if User.current.logged? %>

    - <%= l(:label_my_projects) %> + <%= l(:label_my_courses) %>

    <% end %> @@ -52,12 +52,12 @@ <% content_for :sidebar do %> <%= form_tag({}, :method => :get) do %> -

    <%= l(:label_project_plural) %>

    - +

    <%= l(:label_course_plural) %>

    +

    <%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %>

    <% end %> <% end %> -<% html_title(l(:label_project_plural)) -%> +<% html_title(l(:label_course_plural)) -%> diff --git a/db/migrate/20140530102015_stored_course_procedure.rb b/db/migrate/20140530102015_stored_course_procedure.rb new file mode 100644 index 00000000..0c4defc0 --- /dev/null +++ b/db/migrate/20140530102015_stored_course_procedure.rb @@ -0,0 +1,392 @@ +class StoredCourseProcedure < ActiveRecord::Migration + def up + # 需要完成的数据导入: + # project中所有的课程导入至course + # Project_status导入至course_status + # + def self.up + Project.find_all.each do |project| + if project.project_type == 1 + course = Course.find_by_extra(project.identifier) + if course + course.name = project.name + + end + Course.new do |comment| + comment.name = 'Welcome.' + comment.body = "Article '#{article.name}' is open for comments." + ments << comment + comment.save + article.save + end + end + end + end + + + execute " +CREATE PROCEDURE `sp_course_data_change` () +BEGIN + DECLARE user_uid bigint(22); + DECLARE user_changesets_count int(10); + DECLARE _done tinyint(1) DEFAULT 0; + DECLARE cur_user CURSOR FOR + SELECT + users.id + FROM users + WHERE users.type = 'User' AND users.status = 1 AND users.admin = 0; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET _done = 1; + OPEN cur_user; +loop_xxx: +LOOP + FETCH cur_user INTO user_uid ; + IF _done = 1 THEN + LEAVE loop_xxx; + END IF; + BEGIN + DECLARE journals_for_messages_count int(10); + DECLARE journals_count int(10); + DECLARE comments_count int(10); + DECLARE messages_count int(10); + DECLARE news_count int(10); + DECLARE wiki_contents_count int(10); + DECLARE activities_count int(10); + DECLARE total_count numeric(8, 2); + + SELECT + COUNT(*) INTO journals_for_messages_count + FROM journals_for_messages + WHERE user_id = user_uid ; + SELECT + COUNT(*) INTO journals_count + FROM journals + WHERE user_id = user_uid; + SELECT + COUNT(*) INTO comments_count + FROM comments + WHERE author_id = user_uid; + SELECT + COUNT(*) INTO messages_count + FROM messages + WHERE author_id = user_uid; + SELECT + COUNT(*) INTO news_count + FROM news + WHERE author_id = user_uid; + SELECT + COUNT(*) INTO wiki_contents_count + FROM wiki_contents + WHERE author_id = user_uid; + SELECT + COUNT(*) INTO activities_count + FROM activities + WHERE user_id = user_uid; + SELECT + COUNT(*) INTO user_changesets_count + FROM changesets + WHERE changesets.user_id = user_uid; + + + + SET total_count = journals_for_messages_count * 0.05 + + journals_count * 0.1 + + comments_count * 0.1 + + messages_count * 0.05 + + news_count * 0.1 + + wiki_contents_count * 0.1 + + activities_count * 0.2 + + user_changesets_count * 0.3; + + UPDATE user_statuses + SET changesets_count = user_changesets_count, + grade = total_count + WHERE user_id = user_uid; + COMMIT; + END; +END LOOP; +END; +" + execute " + CREATE EVENT IF NOT EXISTS e_test +ON SCHEDULE EVERY 1 DAY STARTS '2013-08-27 01:50:00' +ON COMPLETION PRESERVE +DO CALL `sp_user_status_cursor`(); +" + execute " + CREATE PROCEDURE `sp_project_status_cursor` () +BEGIN + DECLARE project_uid bigint(22); + DECLARE project_changesets_count int(10); + DECLARE _done tinyint(1) DEFAULT 0; + + DECLARE cur_project CURSOR FOR + SELECT + projects.id + FROM projects + WHERE projects.status <> 9 + AND projects.is_public = 1 AND projects.project_type = 0 ; + + DECLARE CONTINUE HANDLER FOR NOT FOUND SET _done = 1; + OPEN cur_project; +loop_xxx: +LOOP + FETCH cur_project INTO project_uid; + IF _done = 1 THEN + LEAVE loop_xxx; + END IF; + + BEGIN + DECLARE total_count numeric(8, 2); + DECLARE news_id int(10); + DECLARE issues_id int(10); + DECLARE issues_count int(10); + DECLARE news_count int(10); + DECLARE time_entries_count int(10); + DECLARE documents_count int(10); + DECLARE issues_jour_count_total int(10) DEFAULT 0; + DECLARE issues_jour_count int(10); + DECLARE news_jour_count_total int(10) DEFAULT 0; + DECLARE news_jour_count int(10); + DECLARE boards_messages_count int(10); + + DECLARE cur_user_id int(10); + DECLARE cur_user_issues_journals_count int(10); + DECLARE cur_user_news_journals_count int(10); + DECLARE cur_user_issues_count int(10); + DECLARE cur_user_news_count int(10); + DECLARE cur_user_issues_id int(10); + DECLARE cur_user_news_id int(10); + + + + + DECLARE _inner_done_one tinyint(1) DEFAULT 0; + DECLARE cur_issues CURSOR FOR + SELECT + issues.id + FROM issues + WHERE project_id = project_uid; + DECLARE cur_news CURSOR FOR + SELECT + news.id + FROM news + WHERE project_id = project_uid; + DECLARE cur_user CURSOR FOR + SELECT + members.user_id + FROM members + INNER JOIN users + ON members.user_id = users.id + WHERE members.project_id = project_uid + AND (users.type = 'User' AND users.status = 1); + DECLARE CONTINUE HANDLER FOR NOT FOUND SET _inner_done_one = 1; + + OPEN cur_issues; + loop_issues: + LOOP + FETCH cur_issues INTO issues_id; + IF _inner_done_one = 1 THEN + LEAVE loop_issues; + END IF; + + BEGIN + SELECT + COUNT(*) INTO issues_jour_count + FROM `journals` + WHERE `journals`.`journalized_id` = issues_id AND `journals`.`journalized_type` = 'Issue'; + SET issues_jour_count_total = issues_jour_count_total + issues_jour_count; + END; + END LOOP; + -- CLOSE cur_issues; + + SET _inner_done_one = 0; + + OPEN cur_news; + loop_news: + LOOP + FETCH cur_news INTO news_id; + IF _inner_done_one = 1 THEN + LEAVE loop_news; + END IF; + + BEGIN + SELECT + COUNT(*) INTO news_jour_count + FROM `journals` + WHERE `journals`.`journalized_id` = news_id AND `journals`.`journalized_type` = 'News'; + SET news_jour_count_total = news_jour_count_total + news_jour_count; + END; + END LOOP; + -- CLOSE cur_news; + + SET _inner_done_one = 0; + + OPEN cur_user; + loop_user: + LOOP + FETCH cur_user INTO cur_user_id; + IF _inner_done_one = 1 THEN + LEAVE loop_user; + END IF; + + BEGIN + DECLARE total_cur_user_issues_journals_count int(10) DEFAULT 0; + DECLARE total_cur_user_news_journals_count int(10) DEFAULT 0; + DECLARE cur_user_changesets_count INT(10); + DECLARE user_total_count numeric(8, 2); + DECLARE _inner_inner_done tinyint(1) DEFAULT 0; + DECLARE cur_user_issues CURSOR FOR + SELECT + issues.id + FROM issues + WHERE project_id = project_uid AND author_id = cur_user_id; + DECLARE cur_user_news CURSOR FOR + SELECT + news.id + FROM news + WHERE project_id = project_uid AND author_id = cur_user_id; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET _inner_inner_done = 1; + + OPEN cur_user_issues; + loop_user_issues: + LOOP + FETCH cur_issues INTO cur_user_issues_id; + IF _inner_inner_done = 1 THEN + LEAVE loop_user_issues; + END IF; + + BEGIN + SELECT + COUNT(*) INTO cur_user_issues_journals_count + FROM journals + WHERE journalized_id = cur_user_issues_id AND user_id = cur_user_id + AND journalized_type = 'Issues'; + SET total_cur_user_issues_journals_count = total_cur_user_issues_journals_count + + cur_user_issues_journals_count; + END; + END LOOP; + + -- CLOSE cur_user_issues; + + SET _inner_inner_done = 0; + + OPEN cur_user_news; + loop_user_news: + LOOP + FETCH cur_user_news INTO cur_user_news_id; + IF _inner_inner_done = 1 THEN + LEAVE loop_user_news; + END IF; + + BEGIN + SELECT + COUNT(*) INTO cur_user_news_journals_count + FROM journals + WHERE journalized_id = cur_user_news_id AND user_id = cur_user_id AND journalized_type = 'News'; + SET total_cur_user_news_journals_count = total_cur_user_news_journals_count + + cur_user_news_journals_count; + END; + END LOOP; + + SELECT + COUNT(*) INTO cur_user_issues_count + FROM issues + WHERE project_id = project_uid AND author_id = cur_user_id; + SELECT + COUNT(*) INTO cur_user_news_count + FROM news + WHERE project_id = project_uid AND author_id = cur_user_id; + SELECT + COUNT(*) INTO cur_user_changesets_count + FROM changesets + WHERE user_id = cur_user_id AND + repository_id IN (SELECT + id + FROM repositories + WHERE project_id = project_uid); + SET user_total_count = cur_user_issues_count*0.2 + + cur_user_news_count*0.2 + + total_cur_user_issues_journals_count*0.1 + + total_cur_user_news_journals_count*0.1 + + cur_user_changesets_count*0.4; + UPDATE user_grades + SET grade = user_total_count + WHERE user_id = cur_user_id AND project_id = project_uid; + COMMIT; + END; + END LOOP; + + SELECT + COUNT(*) INTO issues_count + FROM issues + WHERE project_id = project_uid; + SELECT + COUNT(*) INTO news_count + FROM news + WHERE project_id = project_uid; + SELECT + COUNT(*) INTO documents_count + FROM documents + WHERE project_id = project_uid; + SELECT + SUM(boards.messages_count) INTO boards_messages_count + FROM boards + WHERE project_id = project_uid; + SELECT + COUNT(*) INTO project_changesets_count + FROM `changesets` + INNER JOIN `repositories` ON `changesets`.`repository_id` = `repositories`.`id` + WHERE `repositories`.`project_id` = project_uid AND (is_default = 1); + + SET total_count = issues_count * 0.2 + + issues_jour_count_total * 0.1 + + news_count * 0.1 + + news_jour_count_total * 0.1 + + documents_count * 0.1 + + project_changesets_count * 0.3 + + boards_messages_count * 0.1; + + + IF total_count IS NOT NULL THEN + + UPDATE project_statuses + SET changesets_count = project_changesets_count, + grade = total_count + WHERE project_id = project_uid; + ELSE + UPDATE project_statuses + SET changesets_count = project_changesets_count, + grade = 0 + WHERE project_id = project_uid; + END IF; + + COMMIT; + END; +END LOOP; +END; +" + execute " + CREATE EVENT IF NOT EXISTS e_project_status_test +ON SCHEDULE EVERY 1 DAY STARTS '2013-08-27 01:50:00' +ON COMPLETION PRESERVE +DO CALL `sp_project_status_cursor`(); +" + execute " + SET GLOBAL event_scheduler = ON; +" + end + + def down + execute " DROP PROCEDURE IF EXISTS `sp_user_status_cursor`; + " + execute " + DROP EVENT IF EXISTS e_test; + " + execute " + DROP PROCEDURE IF EXISTS `sp_project_status_cursor`; + " + execute " + DROP EVENT IF EXISTS e_project_status_test; + " + end +end diff --git a/db/migrate/20140530102016_add_status_to_course.rb b/db/migrate/20140530102016_add_status_to_course.rb new file mode 100644 index 00000000..0cca18c7 --- /dev/null +++ b/db/migrate/20140530102016_add_status_to_course.rb @@ -0,0 +1,9 @@ +class AddStatusToCourse < ActiveRecord::Migration + def change + add_column :courses, :description, :text + add_column :courses, :status, :int ,default: 1 + add_column :courses, :attachmenttype, :int ,default: 2 + add_column :courses, :lft, :int + add_column :courses, :rgt, :int + end +end From 77006198a12a3cde3d438c48ef2c1d32316a77ce Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 30 May 2014 11:01:20 +0800 Subject: [PATCH 005/183] =?UTF-8?q?1.=E5=AF=BC=E5=85=A5=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E8=A1=A8=E4=B8=AD=E5=B7=B2=E6=9C=89=E8=AF=BE=E7=A8=8B=E8=87=B3?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=A1=A8=202.=E5=AF=BC=E5=85=A5=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E7=8A=B6=E6=80=81=E8=A1=A8=E8=87=B3=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20140530102015_stored_course_procedure.rb | 401 +----------------- 1 file changed, 23 insertions(+), 378 deletions(-) diff --git a/db/migrate/20140530102015_stored_course_procedure.rb b/db/migrate/20140530102015_stored_course_procedure.rb index 0c4defc0..4489791d 100644 --- a/db/migrate/20140530102015_stored_course_procedure.rb +++ b/db/migrate/20140530102015_stored_course_procedure.rb @@ -1,392 +1,37 @@ class StoredCourseProcedure < ActiveRecord::Migration - def up + def self.up # 需要完成的数据导入: # project中所有的课程导入至course # Project_status导入至course_status # - def self.up - Project.find_all.each do |project| - if project.project_type == 1 - course = Course.find_by_extra(project.identifier) - if course - course.name = project.name + Project.find_all.each do |project| + if project.project_type == 1 + course = Course.find_by_extra(project.identifier) + if course + course.name = project.name + course.description = project.description + course.status = project.status + course.attachmenttype = 2 + course.lft = project.lft + course.rgt = project.rgt + course.save - end - Course.new do |comment| - comment.name = 'Welcome.' - comment.body = "Article '#{article.name}' is open for comments." - ments << comment - comment.save - article.save + # 更新状态表 + projectstatus = ProjectStatus.find_by_project_id(project.id) + if projectstatus + courseStatus = CourseStatus.new + courseStatus.course_id = course.id + courseStatus.changesets_count = projectstatus.changesets_count + courseStatus.watchers_count = projectstatus.watchers_count + courseStatus.grade = projectstatus.grade + courseStatus.course_ac_para = projectstatus.course_ac_para + courseStatus.save end end end end - - - execute " -CREATE PROCEDURE `sp_course_data_change` () -BEGIN - DECLARE user_uid bigint(22); - DECLARE user_changesets_count int(10); - DECLARE _done tinyint(1) DEFAULT 0; - DECLARE cur_user CURSOR FOR - SELECT - users.id - FROM users - WHERE users.type = 'User' AND users.status = 1 AND users.admin = 0; - DECLARE CONTINUE HANDLER FOR NOT FOUND SET _done = 1; - OPEN cur_user; -loop_xxx: -LOOP - FETCH cur_user INTO user_uid ; - IF _done = 1 THEN - LEAVE loop_xxx; - END IF; - BEGIN - DECLARE journals_for_messages_count int(10); - DECLARE journals_count int(10); - DECLARE comments_count int(10); - DECLARE messages_count int(10); - DECLARE news_count int(10); - DECLARE wiki_contents_count int(10); - DECLARE activities_count int(10); - DECLARE total_count numeric(8, 2); - - SELECT - COUNT(*) INTO journals_for_messages_count - FROM journals_for_messages - WHERE user_id = user_uid ; - SELECT - COUNT(*) INTO journals_count - FROM journals - WHERE user_id = user_uid; - SELECT - COUNT(*) INTO comments_count - FROM comments - WHERE author_id = user_uid; - SELECT - COUNT(*) INTO messages_count - FROM messages - WHERE author_id = user_uid; - SELECT - COUNT(*) INTO news_count - FROM news - WHERE author_id = user_uid; - SELECT - COUNT(*) INTO wiki_contents_count - FROM wiki_contents - WHERE author_id = user_uid; - SELECT - COUNT(*) INTO activities_count - FROM activities - WHERE user_id = user_uid; - SELECT - COUNT(*) INTO user_changesets_count - FROM changesets - WHERE changesets.user_id = user_uid; - - - - SET total_count = journals_for_messages_count * 0.05 + - journals_count * 0.1 + - comments_count * 0.1 + - messages_count * 0.05 + - news_count * 0.1 + - wiki_contents_count * 0.1 + - activities_count * 0.2 + - user_changesets_count * 0.3; - - UPDATE user_statuses - SET changesets_count = user_changesets_count, - grade = total_count - WHERE user_id = user_uid; - COMMIT; - END; -END LOOP; -END; -" - execute " - CREATE EVENT IF NOT EXISTS e_test -ON SCHEDULE EVERY 1 DAY STARTS '2013-08-27 01:50:00' -ON COMPLETION PRESERVE -DO CALL `sp_user_status_cursor`(); -" - execute " - CREATE PROCEDURE `sp_project_status_cursor` () -BEGIN - DECLARE project_uid bigint(22); - DECLARE project_changesets_count int(10); - DECLARE _done tinyint(1) DEFAULT 0; - - DECLARE cur_project CURSOR FOR - SELECT - projects.id - FROM projects - WHERE projects.status <> 9 - AND projects.is_public = 1 AND projects.project_type = 0 ; - - DECLARE CONTINUE HANDLER FOR NOT FOUND SET _done = 1; - OPEN cur_project; -loop_xxx: -LOOP - FETCH cur_project INTO project_uid; - IF _done = 1 THEN - LEAVE loop_xxx; - END IF; - - BEGIN - DECLARE total_count numeric(8, 2); - DECLARE news_id int(10); - DECLARE issues_id int(10); - DECLARE issues_count int(10); - DECLARE news_count int(10); - DECLARE time_entries_count int(10); - DECLARE documents_count int(10); - DECLARE issues_jour_count_total int(10) DEFAULT 0; - DECLARE issues_jour_count int(10); - DECLARE news_jour_count_total int(10) DEFAULT 0; - DECLARE news_jour_count int(10); - DECLARE boards_messages_count int(10); - - DECLARE cur_user_id int(10); - DECLARE cur_user_issues_journals_count int(10); - DECLARE cur_user_news_journals_count int(10); - DECLARE cur_user_issues_count int(10); - DECLARE cur_user_news_count int(10); - DECLARE cur_user_issues_id int(10); - DECLARE cur_user_news_id int(10); - - - - - DECLARE _inner_done_one tinyint(1) DEFAULT 0; - DECLARE cur_issues CURSOR FOR - SELECT - issues.id - FROM issues - WHERE project_id = project_uid; - DECLARE cur_news CURSOR FOR - SELECT - news.id - FROM news - WHERE project_id = project_uid; - DECLARE cur_user CURSOR FOR - SELECT - members.user_id - FROM members - INNER JOIN users - ON members.user_id = users.id - WHERE members.project_id = project_uid - AND (users.type = 'User' AND users.status = 1); - DECLARE CONTINUE HANDLER FOR NOT FOUND SET _inner_done_one = 1; - - OPEN cur_issues; - loop_issues: - LOOP - FETCH cur_issues INTO issues_id; - IF _inner_done_one = 1 THEN - LEAVE loop_issues; - END IF; - - BEGIN - SELECT - COUNT(*) INTO issues_jour_count - FROM `journals` - WHERE `journals`.`journalized_id` = issues_id AND `journals`.`journalized_type` = 'Issue'; - SET issues_jour_count_total = issues_jour_count_total + issues_jour_count; - END; - END LOOP; - -- CLOSE cur_issues; - - SET _inner_done_one = 0; - - OPEN cur_news; - loop_news: - LOOP - FETCH cur_news INTO news_id; - IF _inner_done_one = 1 THEN - LEAVE loop_news; - END IF; - - BEGIN - SELECT - COUNT(*) INTO news_jour_count - FROM `journals` - WHERE `journals`.`journalized_id` = news_id AND `journals`.`journalized_type` = 'News'; - SET news_jour_count_total = news_jour_count_total + news_jour_count; - END; - END LOOP; - -- CLOSE cur_news; - - SET _inner_done_one = 0; - - OPEN cur_user; - loop_user: - LOOP - FETCH cur_user INTO cur_user_id; - IF _inner_done_one = 1 THEN - LEAVE loop_user; - END IF; - - BEGIN - DECLARE total_cur_user_issues_journals_count int(10) DEFAULT 0; - DECLARE total_cur_user_news_journals_count int(10) DEFAULT 0; - DECLARE cur_user_changesets_count INT(10); - DECLARE user_total_count numeric(8, 2); - DECLARE _inner_inner_done tinyint(1) DEFAULT 0; - DECLARE cur_user_issues CURSOR FOR - SELECT - issues.id - FROM issues - WHERE project_id = project_uid AND author_id = cur_user_id; - DECLARE cur_user_news CURSOR FOR - SELECT - news.id - FROM news - WHERE project_id = project_uid AND author_id = cur_user_id; - DECLARE CONTINUE HANDLER FOR NOT FOUND SET _inner_inner_done = 1; - - OPEN cur_user_issues; - loop_user_issues: - LOOP - FETCH cur_issues INTO cur_user_issues_id; - IF _inner_inner_done = 1 THEN - LEAVE loop_user_issues; - END IF; - - BEGIN - SELECT - COUNT(*) INTO cur_user_issues_journals_count - FROM journals - WHERE journalized_id = cur_user_issues_id AND user_id = cur_user_id - AND journalized_type = 'Issues'; - SET total_cur_user_issues_journals_count = total_cur_user_issues_journals_count + - cur_user_issues_journals_count; - END; - END LOOP; - - -- CLOSE cur_user_issues; - - SET _inner_inner_done = 0; - - OPEN cur_user_news; - loop_user_news: - LOOP - FETCH cur_user_news INTO cur_user_news_id; - IF _inner_inner_done = 1 THEN - LEAVE loop_user_news; - END IF; - - BEGIN - SELECT - COUNT(*) INTO cur_user_news_journals_count - FROM journals - WHERE journalized_id = cur_user_news_id AND user_id = cur_user_id AND journalized_type = 'News'; - SET total_cur_user_news_journals_count = total_cur_user_news_journals_count + - cur_user_news_journals_count; - END; - END LOOP; - - SELECT - COUNT(*) INTO cur_user_issues_count - FROM issues - WHERE project_id = project_uid AND author_id = cur_user_id; - SELECT - COUNT(*) INTO cur_user_news_count - FROM news - WHERE project_id = project_uid AND author_id = cur_user_id; - SELECT - COUNT(*) INTO cur_user_changesets_count - FROM changesets - WHERE user_id = cur_user_id AND - repository_id IN (SELECT - id - FROM repositories - WHERE project_id = project_uid); - SET user_total_count = cur_user_issues_count*0.2 + - cur_user_news_count*0.2 + - total_cur_user_issues_journals_count*0.1 + - total_cur_user_news_journals_count*0.1 + - cur_user_changesets_count*0.4; - UPDATE user_grades - SET grade = user_total_count - WHERE user_id = cur_user_id AND project_id = project_uid; - COMMIT; - END; - END LOOP; - - SELECT - COUNT(*) INTO issues_count - FROM issues - WHERE project_id = project_uid; - SELECT - COUNT(*) INTO news_count - FROM news - WHERE project_id = project_uid; - SELECT - COUNT(*) INTO documents_count - FROM documents - WHERE project_id = project_uid; - SELECT - SUM(boards.messages_count) INTO boards_messages_count - FROM boards - WHERE project_id = project_uid; - SELECT - COUNT(*) INTO project_changesets_count - FROM `changesets` - INNER JOIN `repositories` ON `changesets`.`repository_id` = `repositories`.`id` - WHERE `repositories`.`project_id` = project_uid AND (is_default = 1); - - SET total_count = issues_count * 0.2 + - issues_jour_count_total * 0.1 + - news_count * 0.1 + - news_jour_count_total * 0.1 + - documents_count * 0.1 + - project_changesets_count * 0.3 + - boards_messages_count * 0.1; - - - IF total_count IS NOT NULL THEN - - UPDATE project_statuses - SET changesets_count = project_changesets_count, - grade = total_count - WHERE project_id = project_uid; - ELSE - UPDATE project_statuses - SET changesets_count = project_changesets_count, - grade = 0 - WHERE project_id = project_uid; - END IF; - - COMMIT; - END; -END LOOP; -END; -" - execute " - CREATE EVENT IF NOT EXISTS e_project_status_test -ON SCHEDULE EVERY 1 DAY STARTS '2013-08-27 01:50:00' -ON COMPLETION PRESERVE -DO CALL `sp_project_status_cursor`(); -" - execute " - SET GLOBAL event_scheduler = ON; -" end - def down - execute " DROP PROCEDURE IF EXISTS `sp_user_status_cursor`; - " - execute " - DROP EVENT IF EXISTS e_test; - " - execute " - DROP PROCEDURE IF EXISTS `sp_project_status_cursor`; - " - execute " - DROP EVENT IF EXISTS e_project_status_test; - " + def self.down end end From e490f7979d60713bdf6def7d305c9d7a32bb84e3 Mon Sep 17 00:00:00 2001 From: nwb Date: Tue, 3 Jun 2014 09:39:33 +0800 Subject: [PATCH 006/183] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=BE=E7=A8=8Bind?= =?UTF-8?q?ex=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 71 +++++++-------- app/views/courses/index.html.erb | 89 ++++++++++--------- config/routes.rb | 1 + ...=> 20140530102014_add_status_to_course.rb} | 0 .../20140530102015_stored_course_procedure.rb | 2 +- db/schema.rb | 26 ++++-- 6 files changed, 107 insertions(+), 82 deletions(-) rename db/migrate/{20140530102016_add_status_to_course.rb => 20140530102014_add_status_to_course.rb} (100%) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index e54d5010..3060d1f0 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -70,81 +70,81 @@ class CoursesController < ApplicationController end - def course12 - @project_type = params[:project_type] + def index + @course_type = params[:course_type] @school_id = params[:school_id] per_page_option = 10 if @school_id == "0" or @school_id.nil? - @projects_all = Project.active.visible. - joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id"). - where("#{Project.table_name}.project_type = ? ", Project::ProjectType_course) + @courses_all = Project.active.visible. + joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.course_id"). + where("#{Project.table_name}.course_type = ? ", Project::ProjectType_course) else - @projects_all = Project.active.visible. - joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.project_id"). + @courses_all = Project.active.visible. + joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.course_id"). joins(:course_extra). - where("#{Project.table_name}.project_type = ? AND #{Course.table_name}.school_id = ?", Project::ProjectType_course, @school_id) + where("#{Project.table_name}.course_type = ? AND #{Course.table_name}.school_id = ?", Project::ProjectType_course, @school_id) end - @project_count = @projects_all.count - @project_pages = Paginator.new @project_count, per_page_option, params['page'] + @course_count = @courses_all.count + @course_pages = Paginator.new @course_count, per_page_option, params['page'] #gcm activity count - @project_activity_count=Hash.new + @course_activity_count=Hash.new #count initialize - @projects_all.each do |project| - @project_activity_count[project.id]=0 + @courses_all.each do |course| + @course_activity_count[course.id]=0 end - #@project_activity_count=get_project_activity @projects_all,@project_activity_count + #@course_activity_count=get_course_activity @courses_all,@course_activity_count #gcm end - case params[:project_sort_type] + case params[:course_sort_type] when '0' - @projects = @projects_all.order("created_on desc") + @courses = @courses_all.order("created_on desc") @s_type = 0 - @projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page) + @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page) #gcm - @project_activity_count=get_project_activity @projects,@project_activity_count + @course_activity_count=get_course_activity @courses,@course_activity_count #gcmend when '1' - @projects = @projects_all.order("course_ac_para desc") + @courses = @courses_all.order("course_ac_para desc") @s_type = 1 - @projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page) + @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page) #gcm - @project_activity_count=get_project_activity @projects,@project_activity_count + @course_activity_count=get_course_activity @courses,@course_activity_count #gcmend when '2' - @projects = @projects_all.order("watchers_count desc") + @courses = @courses_all.order("watchers_count desc") @s_type = 2 - @projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page) + @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page) #gcm - @project_activity_count=get_project_activity @projects,@project_activity_count + @course_activity_count=get_course_activity @courses,@course_activity_count #gcmend #gcm when '3' #gcm - @project_activity_count=get_project_activity @projects_all,@project_activity_count + @course_activity_count=get_course_activity @courses_all,@course_activity_count #gcmend - @projects=handle_project @projects_all,@project_activity_count + @courses=handle_course @courses_all,@course_activity_count @s_type = 3 - @projects = @projects[@project_pages.offset, @project_pages.per_page] + @courses = @courses[@course_pages.offset, @course_pages.per_page] else @s_type = 0 - @projects = @projects_all.order("created_on desc") - @projects = @projects.offset(@project_pages.offset).limit(@project_pages.per_page) + @courses = @courses_all.order("created_on desc") + @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page) #gcm - @project_activity_count=get_project_activity @projects,@project_activity_count + @course_activity_count=get_course_activity @courses,@course_activity_count #gcmend end @@ -155,21 +155,22 @@ class CoursesController < ApplicationController } format.api { # @offset, @limit = api_offset_and_limit - # @project_count = Project.visible.count - # @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all + # @course_count = Project.visible.count + # @courses = Project.visible.offset(@offset).limit(@limit).order('lft').all } format.atom { - projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all - render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}") + courses = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all + render_feed(courses, :title => "#{Setting.app_title}: #{l(:label_course_latest)}") } end end - def index + def index1 per_page_option = 10 + #当前所有的活动课程 @courses_all = Course.active.visible. joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.couse_id") diff --git a/app/views/courses/index.html.erb b/app/views/courses/index.html.erb index 9b1cf841..1492264c 100644 --- a/app/views/courses/index.html.erb +++ b/app/views/courses/index.html.erb @@ -1,63 +1,70 @@ <% content_for :header_tags do %> -<%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %> + <%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %> <% end %>
    - <%= form_tag(courses_search_path, :method => :get) do %> - - - - - - - - - - - -
    <%= l(:label_course_deposit) %><%= l(:label_user_location) %> : - <% if User.current.logged? %> - <%= link_to(l(:label_course_new), {:controller => 'courses', :action => 'new', :course => 0, :course_type =>( @course_type||=0)}, :class => 'icon icon-add') if User.current.allowed_to?(:add_course, nil, :global => true) %> - <% end %> - - -
    <%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index', :course_type => 0 %> <%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_course_deposit), :controller => 'courses', :action => 'index', :course_type => 0 %>
    - <% end %> + <%= form_tag(courses_search_path, :method => :get) do %> + + + + + + + + + + + +
    <%= l(:label_course_all) %><%= l(:label_user_location) %> : + <% if User.current.logged? %> + <%= link_to(l(:label_course_new), {:controller => 'courses', :action => 'new', :course => 0, :course_type => (@course_type||=0)}, :class => 'icon icon-add') if User.current.allowed_to?(:add_course, nil, :global => true) %> + <% end %> + + +
    + <%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index', :course_type => 0 %> + <%= link_to l(:field_homepage), home_path %> + > <%= link_to l(:label_course_all), :controller => 'courses', :action => 'index', :course_type => 0 %>
    + <% end %>
    <%= sort_courses(@s_type) %>
    - <%= render_course_hierarchy(@courses)%> + <% if @courses %> + <%= render_course_hierarchy(@courses) %> + <% end %>
    <% if User.current.logged? %> -

    - <%= l(:label_my_courses) %> -

    +

    + <%= l(:label_my_courses) %> +

    <% end %> <% other_formats_links do |f| %> -<%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> + <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> <% end %> <% content_for :sidebar do %> -<%= form_tag({}, :method => :get) do %> -

    <%= l(:label_course_plural) %>

    - -

    - <%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %> -

    -<% end %> + <%= form_tag({}, :method => :get) do %> +

    <%= l(:label_course_all) %>

    + +

    + <%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %> +

    + <% end %> <% end %> -<% html_title(l(:label_course_plural)) -%> +<% html_title(l(:label_course_all)) -%> diff --git a/config/routes.rb b/config/routes.rb index 4ccd4195..b9b44d76 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -546,6 +546,7 @@ RedmineApp::Application.routes.draw do post 'restartcourse' end end + match '/courses/search', :controller => 'courses', :action => 'search', :via => [:get, :post] #match 'project/enterprise_course', :to => 'projects#enterprise_course' #match 'project/course_enterprise', :to => 'projects#course_enterprise' #match 'project/course', :to => 'projects#course', :as => 'course' diff --git a/db/migrate/20140530102016_add_status_to_course.rb b/db/migrate/20140530102014_add_status_to_course.rb similarity index 100% rename from db/migrate/20140530102016_add_status_to_course.rb rename to db/migrate/20140530102014_add_status_to_course.rb diff --git a/db/migrate/20140530102015_stored_course_procedure.rb b/db/migrate/20140530102015_stored_course_procedure.rb index 4489791d..6c31279e 100644 --- a/db/migrate/20140530102015_stored_course_procedure.rb +++ b/db/migrate/20140530102015_stored_course_procedure.rb @@ -4,7 +4,7 @@ class StoredCourseProcedure < ActiveRecord::Migration # project中所有的课程导入至course # Project_status导入至course_status # - Project.find_all.each do |project| + Project.all.each do |project| if project.project_type == 1 course = Course.find_by_extra(project.identifier) if course diff --git a/db/schema.rb b/db/schema.rb index 12bcab88..8c3bdca4 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 => 20140522025721) do +ActiveRecord::Schema.define(:version => 20140530102015) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -220,6 +220,16 @@ ActiveRecord::Schema.define(:version => 20140522025721) do t.datetime "updated_on", :null => false 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" @@ -227,8 +237,8 @@ ActiveRecord::Schema.define(:version => 20140522025721) do t.string "code" t.integer "time" t.string "extra" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "location" t.string "term" t.string "string" @@ -237,6 +247,11 @@ ActiveRecord::Schema.define(:version => 20140522025721) do 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" end create_table "custom_fields", :force => true do |t| @@ -482,12 +497,13 @@ ActiveRecord::Schema.define(:version => 20140522025721) do t.text "notes" t.integer "status" t.integer "reply_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false + 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 "member_roles", :force => true do |t| From 9f948c971fd8c3f952aee3b32a873014a6698c48 Mon Sep 17 00:00:00 2001 From: nwb Date: Tue, 3 Jun 2014 09:56:54 +0800 Subject: [PATCH 007/183] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 34 +++++++++++++++++++ app/views/courses/_course.html.erb | 4 +-- app/views/courses/index.html.erb | 54 +++++++++++++----------------- 3 files changed, 60 insertions(+), 32 deletions(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index bcd45ac0..6a348a1e 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -122,6 +122,40 @@ module CoursesHelper members end + def sort_course(state, school_id) + content = ''.html_safe + case state + when 0 + content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:course_sort_type => '0'), :school_id => school_id, :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:course_sort_type => '1', :school_id => school_id))) + # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:course_sort_type => '2'))) + content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:course_sort_type => '3', :school_id => school_id))) + + when 1 + content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:course_sort_type => '0', :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:course_sort_type => '1', :school_id => school_id), :class=>"selected"), :class=>"selected") + # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:course_sort_type => '2'))) + content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:course_sort_type => '3', :school_id => school_id))) + + when 2 + content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:course_sort_type => '0', :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:course_sort_type => '1', :school_id => school_id))) + # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:course_sort_type => '2'), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:course_sort_type => '3', :school_id => school_id))) + + #gcm + when 3 + content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:course_sort_type => '0', :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:course_sort_type => '1', :school_id => school_id))) + # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:course_sort_type => '2'))) + content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:course_sort_type => '3', :school_id => school_id), :class=>"selected"), :class=>"selected") + end + #gcmend + + content = content_tag('ul', content) + content_tag('div', content, :class => "tabs") + end + def findCourseTime project str = "" begin diff --git a/app/views/courses/_course.html.erb b/app/views/courses/_course.html.erb index 4fd807b6..6ea80203 100644 --- a/app/views/courses/_course.html.erb +++ b/app/views/courses/_course.html.erb @@ -15,8 +15,8 @@

    <%= content_tag('span', "#{l(:label_institution_name)}:", :class => "course-font")%> <% @admin = @project.project_infos%> - <%if @admin&&@adadminmin.first&&@admin.first.user&&@admin.first.user.user_extensions%> - + <%if @admin&&@admin.first&&@admin.first.user&&@admin.first.user.user_extensions%> + <%# unless @project.course_extra.school.nil? %> <%= @project.course_extra.teacher.user_extensions.school.try(:name) %> <%# end %> diff --git a/app/views/courses/index.html.erb b/app/views/courses/index.html.erb index 1492264c..a74668dc 100644 --- a/app/views/courses/index.html.erb +++ b/app/views/courses/index.html.erb @@ -6,49 +6,44 @@ <%= form_tag(courses_search_path, :method => :get) do %> - + + <% end %> <% end %> - - - + + + - - + +
    <%= l(:label_course_all) %><%= l(:label_course_practice) %> <%= l(:label_user_location) %> : - <% if User.current.logged? %> - <%= link_to(l(:label_course_new), {:controller => 'courses', :action => 'new', :course => 0, :course_type => (@course_type||=0)}, :class => 'icon icon-add') if User.current.allowed_to?(:add_course, nil, :global => true) %> + <% if User.current.logged?%> + <% if User.current.user_extensions.identity == 0 %> + <%= link_to(l(:label_course_new), {:controller => 'courses', :action => 'new', :course => 1}, :class => 'icon icon-add') if User.current.allowed_to?(:add_course, nil, :global => true) %> - -
    + +
    - <%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index', :course_type => 0 %> - <%= link_to l(:field_homepage), home_path %> - > <%= link_to l(:label_course_all), :controller => 'courses', :action => 'index', :course_type => 0 %><%= link_to request.host()+"/course", :controller => 'courses', :action => 'course', :course_type => 1 %> <%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_course_practice), :controller => 'courses', :action => 'course', :course_type => 1 %>
    <% end %>

    -<%= sort_courses(@s_type) %> -
    - <% if @courses %> - <%= render_course_hierarchy(@courses) %> - <% end %> +<%= sort_course(@s_type, @course_type, @school_id)%> + +
    + <%= render_project_hierarchy(@projects)%>
    <% if User.current.logged? %>

    - <%= l(:label_my_courses) %> + <%= l(:label_my_course) %>

    <% end %> @@ -57,14 +52,13 @@ <% end %> <% content_for :sidebar do %> - <%= form_tag({}, :method => :get) do %> -

    <%= l(:label_course_all) %>

    - +

    <%= l(:label_project_plural) %>

    +

    <%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %>

    <% end %> <% end %> -<% html_title(l(:label_course_all)) -%> +<% html_title(l(:label_new_course)) -%> From 7d3d406c006e91f9296277550951b19974493838 Mon Sep 17 00:00:00 2001 From: nwb Date: Tue, 3 Jun 2014 11:16:06 +0800 Subject: [PATCH 008/183] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=83=A8=E5=88=86?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=89=80=E9=9C=80=E7=9A=84=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 94 ++++++++++++++++++--------- app/helpers/application_helper.rb | 4 +- app/models/course.rb | 8 +++ app/views/courses/index.html.erb | 12 ++-- 4 files changed, 82 insertions(+), 36 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 3060d1f0..3ebd3369 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -52,37 +52,19 @@ class CoursesController < ApplicationController end end - private - - def allow_join - if course_endTime_timeout? Project.find(params[:object_id]) - respond_to do |format| - format.js{ - @state = 2 - render :partial => 'set_join', - :locals => {:user => User.current, - :course => Project.find(params[:object_id]), - :object_id => params[:object_id] - } - } - end - end - end - def index @course_type = params[:course_type] @school_id = params[:school_id] per_page_option = 10 if @school_id == "0" or @school_id.nil? - @courses_all = Project.active.visible. - joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.course_id"). - where("#{Project.table_name}.course_type = ? ", Project::ProjectType_course) + @courses_all = Course.active.visible. + joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id") else - @courses_all = Project.active.visible. - joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.course_id"). + @courses_all = Course.active.visible. + joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id"). joins(:course_extra). - where("#{Project.table_name}.course_type = ? AND #{Course.table_name}.school_id = ?", Project::ProjectType_course, @school_id) + where("#{Course.table_name}.course_type = ? AND #{Course.table_name}.school_id = ?", Course::CourseType_course, @school_id) end @course_count = @courses_all.count @@ -153,18 +135,72 @@ class CoursesController < ApplicationController format.html { render :layout => 'base' } - format.api { - # @offset, @limit = api_offset_and_limit - # @course_count = Project.visible.count - # @courses = Project.visible.offset(@offset).limit(@limit).order('lft').all - } format.atom { - courses = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all + courses = Course.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all render_feed(courses, :title => "#{Setting.app_title}: #{l(:label_course_latest)}") } end end + def get_course_activity courses,activities + @course_ids=activities.keys() + + days = Setting.activity_days_default.to_i + date_to ||= Date.today + 1 + date_from = date_to - days-1.years + + #file_count + Attachment.where(container_id: @course_ids, container_type: Project).where("created_on>?",date_from).each do |attachment| + activities[attachment.container_id]+=1 + end + + #message_count + Board.where(course_id: @course_ids).each do |board| +# activities[board.course_id]+=1 + activities[board.course_id]+=board.messages.where("updated_on>?",date_from).count + end + + #time_entry_count + TimeEntry.where(course_id: @course_ids).where("updated_on>?",date_from).each do |timeentry| + activities[timeentry.course_id]+=1 + end + + #feedbackc_count + JournalsForMessage.where(jour_id: @course_ids, jour_type: Project).each do |jourformess| + activities[jourformess.jour_id]+=1 + end + + #activities!=0 + i=0; + courses.each do |course| + id=course.id + if activities[id]==0 + activities[id]=1 + end + end + + return activities + end + + private + + def allow_join + if course_endTime_timeout? Project.find(params[:object_id]) + respond_to do |format| + format.js{ + @state = 2 + render :partial => 'set_join', + :locals => {:user => User.current, + :course => Project.find(params[:object_id]), + :object_id => params[:object_id] + } + } + end + end + end + + + def index1 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f89023b7..da674bb5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1685,9 +1685,9 @@ module ApplicationHelper main_project_link = link_to l(:label_project_deposit), {:controller => 'welcome', :action => 'index', :host => Setting.project_domain} main_contest_link = link_to l(:label_contest_innovate), {:controller => 'welcome', :action => 'index', :host => Setting.contest_domain} - course_all_course_link = link_to l(:label_course_all), {:controller => 'courses', :action => 'index', :host => Setting.course_domain} + course_all_course_link = link_to l(:label_course_all), {:controller => 'courses', :action => 'index'} course_teacher_all_link = link_to l(:label_teacher_all), {:controller => 'users', :action => 'index', :role => 'teacher', :host => Setting.course_domain} - courses_link = link_to l(:label_course_practice), {:controller => 'courses', :action => 'index',:host => Setting.course_domain} + courses_link = link_to l(:label_course_practice), {:controller => 'courses', :action => 'index'} projects_link = link_to l(:label_project_deposit), {:controller => 'projects', :action => 'index', :project_type => 0, :host => Setting.project_domain} users_link = link_to l(:label_software_user), {:controller => 'users', :action => 'index', :host => Setting.user_domain} contest_link = link_to l(:label_contest_innovate), {:controller => 'contests', :action => 'index'} diff --git a/app/models/course.rb b/app/models/course.rb index 0bc93c81..0c5abd5c 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -39,6 +39,14 @@ class Course < ActiveRecord::Base where(Course.allowed_to_condition(user, permission, *args)) } + def visible?(user=User.current) + user.allowed_to?(:view_course, self) + end + + def self.visible_condition(user, options={}) + allowed_to_condition(user, :view_course, options) + end + #自定义验证 def validate diff --git a/app/views/courses/index.html.erb b/app/views/courses/index.html.erb index a74668dc..ea32d386 100644 --- a/app/views/courses/index.html.erb +++ b/app/views/courses/index.html.erb @@ -29,21 +29,23 @@ <% end %>
    -<%= sort_course(@s_type, @course_type, @school_id)%> +<%= sort_course(@s_type, @school_id)%> -
    - <%= render_project_hierarchy(@projects)%> +
    + <%if @courses%> + <%= render_course_hierarchy(@courses)%> + <%end%>
    <% if User.current.logged? %>

    - <%= l(:label_my_course) %> + <%= l(:label_my_course) %>

    <% end %> From 846034404303f51113ca3d6da51832034002e979 Mon Sep 17 00:00:00 2001 From: nwb Date: Tue, 3 Jun 2014 11:52:44 +0800 Subject: [PATCH 009/183] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E9=80=BB=E8=BE=91=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20140603033359_add_boards_type_to_boards.rb | 13 +++++++++++++ db/schema.rb | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20140603033359_add_boards_type_to_boards.rb diff --git a/db/migrate/20140603033359_add_boards_type_to_boards.rb b/db/migrate/20140603033359_add_boards_type_to_boards.rb new file mode 100644 index 00000000..598f5b51 --- /dev/null +++ b/db/migrate/20140603033359_add_boards_type_to_boards.rb @@ -0,0 +1,13 @@ +class AddBoardsTypeToBoards < ActiveRecord::Migration + def change + add_column :boards, :course_id, :int + + Board.all.each do |board| + project = Project.find_by_id(board.project_id) + if project && project.project_type == 1 + board.course_id = board.project_id + board.save + end + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 8c3bdca4..9178151a 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 => 20140530102015) do +ActiveRecord::Schema.define(:version => 20140603033360) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -119,6 +119,7 @@ ActiveRecord::Schema.define(:version => 20140530102015) do 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" From cd10dd54335e7d540ab5a918c0d877f5ba80b5a1 Mon Sep 17 00:00:00 2001 From: nwb Date: Tue, 3 Jun 2014 16:21:00 +0800 Subject: [PATCH 010/183] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=9D=83=E9=99=90?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E5=8F=98=E6=9B=B4=EF=BC=8C=E4=BB=8E=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=9D=83=E9=99=90=E5=88=86=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 39 +++++++++++++++---- app/helpers/courses_helper.rb | 28 ++++++------- app/models/course.rb | 19 +++++---- ...3081801_add_courseid_to_enabled_modules.rb | 13 +++++++ lib/redmine.rb | 3 +- 5 files changed, 68 insertions(+), 34 deletions(-) create mode 100644 db/migrate/20140603081801_add_courseid_to_enabled_modules.rb diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 3ebd3369..12f730e0 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -52,11 +52,40 @@ class CoursesController < ApplicationController end end + def handle_course courses,activities + course_activity_count_array=activities.values() + + course_array=[] + i=0; + courses.each do |course| + course_array[i]=course + i=i+1 + end + + courses=desc_sort_course_by_avtivity(course_activity_count_array,course_array) + + return courses + end + + def desc_sort_course_by_avtivity(activity_count,courses) + return courses if activity_count.size<2 + (activity_count.size-2).downto(0) do |i| + (0..i).each do |j| + if activity_count[j]?",date_from).count end - #time_entry_count - TimeEntry.where(course_id: @course_ids).where("updated_on>?",date_from).each do |timeentry| - activities[timeentry.course_id]+=1 - end - #feedbackc_count JournalsForMessage.where(jour_id: @course_ids, jour_type: Project).each do |jourformess| activities[jourformess.jour_id]+=1 diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 6a348a1e..4c27af48 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -126,29 +126,25 @@ module CoursesHelper content = ''.html_safe case state when 0 - content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:course_sort_type => '0'), :school_id => school_id, :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:course_sort_type => '1', :school_id => school_id))) - # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:course_sort_type => '2'))) - content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:course_sort_type => '3', :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:course_sort_type => '0'), :school_id => school_id, :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:course_sort_type => '1', :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_activity), courses_path(:course_sort_type => '3', :school_id => school_id))) when 1 - content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:course_sort_type => '0', :school_id => school_id))) - content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:course_sort_type => '1', :school_id => school_id), :class=>"selected"), :class=>"selected") - # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:course_sort_type => '2'))) - content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:course_sort_type => '3', :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:course_sort_type => '0', :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:course_sort_type => '1', :school_id => school_id), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_activity), courses_path(:course_sort_type => '3', :school_id => school_id))) when 2 - content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:course_sort_type => '0', :school_id => school_id))) - content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:course_sort_type => '1', :school_id => school_id))) - # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:course_sort_type => '2'), :class=>"selected"), :class=>"selected") - content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:course_sort_type => '3', :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:course_sort_type => '0', :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:course_sort_type => '1', :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_activity), courses_path(:course_sort_type => '3', :school_id => school_id))) #gcm when 3 - content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:course_sort_type => '0', :school_id => school_id))) - content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:course_sort_type => '1', :school_id => school_id))) - # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:course_sort_type => '2'))) - content << content_tag('li', link_to(l(:label_sort_by_activity), course_path(:course_sort_type => '3', :school_id => school_id), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:course_sort_type => '0', :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:course_sort_type => '1', :school_id => school_id))) + content << content_tag('li', link_to(l(:label_sort_by_activity), courses_path(:course_sort_type => '3', :school_id => school_id), :class=>"selected"), :class=>"selected") end #gcmend diff --git a/app/models/course.rb b/app/models/course.rb index 0c5abd5c..0df09dd3 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -78,16 +78,15 @@ class Course < ActiveRecord::Base end def self.allowed_to_condition(user, permission, options={}) - perm = Redmine::AccessControl.permission(permission) + perm = Redmine::AccessControl.permission(permission) base_statement = (perm && perm.read? ? "#{Course.table_name}.status <> #{Course::STATUS_ARCHIVED}" : "#{Course.table_name}.status = #{Course::STATUS_ACTIVE}") - if perm && perm.project_module - # If the permission belongs to a project module, make sure the module is enabled + if perm && perm.course_module base_statement << " AND #{Course.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name='#{perm.project_module}')" end - if options[:project] - project_statement = "#{Course.table_name}.id = #{options[:project].id}" - project_statement << " OR (#{Course.table_name}.lft > #{options[:project].lft} AND #{Course.table_name}.rgt < #{options[:project].rgt})" if options[:with_subprojects] - base_statement = "(#{project_statement}) AND (#{base_statement})" + if options[:course] + course_statement = "#{Course.table_name}.id = #{options[:course].id}" + course_statement << " OR (#{Course.table_name}.lft > #{options[:course].lft} AND #{Course.table_name}.rgt < #{options[:course].rgt})" if options[:with_subcourses] + base_statement = "(#{course_statement}) AND (#{base_statement})" end if user.admin? @@ -101,9 +100,9 @@ class Course < ActiveRecord::Base end end if user.logged? - user.projects_by_role.each do |role, projects| - if role.allowed_to?(permission) && projects.any? - statement_by_role[role] = "#{Course.table_name}.id IN (#{projects.collect(&:id).join(',')})" + user.courses_by_role.each do |role, courses| + if role.allowed_to?(permission) && courses.any? + statement_by_role[role] = "#{Course.table_name}.id IN (#{courses.collect(&:id).join(',')})" end end end diff --git a/db/migrate/20140603081801_add_courseid_to_enabled_modules.rb b/db/migrate/20140603081801_add_courseid_to_enabled_modules.rb new file mode 100644 index 00000000..cefc3825 --- /dev/null +++ b/db/migrate/20140603081801_add_courseid_to_enabled_modules.rb @@ -0,0 +1,13 @@ +class AddCourseidToEnabledModules < ActiveRecord::Migration + def change + add_column :enabled_modules, :course_id, :int + + EnabledModule.all.each do |enablemodule| + project = Project.find_by_id(enablemodule.project_id) + if project && project.project_type == 1 + enablemodule.course_id = board.project_id + enablemodule.save + end + end + end +end diff --git a/lib/redmine.rb b/lib/redmine.rb index f5386029..7703b2b2 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -180,7 +180,8 @@ Redmine::AccessControl.map do |map| #课程权限模块 map.project_module :course do - map.permission :view_courses,{:projects => [:course]},:read => true + map.permission :view_course, {:courses => [:show], :activities => [:index]}, :public => true, :read => true + map.permission :view_courses,{:courses => [:course]},:read => true end #作业模块权限 From d87b52bedd524086c8efad93f803c743aad58c43 Mon Sep 17 00:00:00 2001 From: nwb Date: Wed, 4 Jun 2014 09:19:01 +0800 Subject: [PATCH 011/183] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=88=90=E5=91=98?= =?UTF-8?q?=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 2 +- app/models/user.rb | 20 +++++++++++++++++++ ...0140603033359_add_boards_type_to_boards.rb | 1 + ...3081801_add_courseid_to_enabled_modules.rb | 3 ++- ...140604011630_add_courseid_to_to_members.rb | 15 ++++++++++++++ db/schema.rb | 3 ++- lib/redmine.rb | 12 +++++------ lib/redmine/access_control.rb | 8 +++++++- 8 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 db/migrate/20140604011630_add_courseid_to_to_members.rb diff --git a/app/models/course.rb b/app/models/course.rb index 0df09dd3..b611261c 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -81,7 +81,7 @@ class Course < ActiveRecord::Base perm = Redmine::AccessControl.permission(permission) base_statement = (perm && perm.read? ? "#{Course.table_name}.status <> #{Course::STATUS_ARCHIVED}" : "#{Course.table_name}.status = #{Course::STATUS_ACTIVE}") if perm && perm.course_module - base_statement << " AND #{Course.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name='#{perm.project_module}')" + base_statement << " AND #{Course.table_name}.id IN (SELECT em.course_id FROM #{EnabledModule.table_name} em WHERE em.name='#{perm.course_module}')" end if options[:course] course_statement = "#{Course.table_name}.id = #{options[:course].id}" diff --git a/app/models/user.rb b/app/models/user.rb index edf70387..d376cd85 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -276,6 +276,7 @@ class User < Principal def reload(*args) @name = nil @projects_by_role = nil + @courses_by_role = nil @membership_by_project_id = nil base_reload(*args) end @@ -634,6 +635,25 @@ class User < Principal @projects_by_role end + # 课程的角色权限 + def courses_by_role + return @courses_by_role if @courses_by_role + + @courses_by_role = Hash.new([]) + memberships.each do |membership| + if membership.course + membership.roles.each do |role| + @courses_by_role[role] = [] unless @courses_by_role.key?(role) + @courses_by_role[role] << membership.course + end + end + end + @courses_by_role.each do |role, courses| + courses.uniq! + end + + @courses_by_role + end # Returns true if user is arg or belongs to arg def is_or_belongs_to?(arg) if arg.is_a?(User) diff --git a/db/migrate/20140603033359_add_boards_type_to_boards.rb b/db/migrate/20140603033359_add_boards_type_to_boards.rb index 598f5b51..76193b64 100644 --- a/db/migrate/20140603033359_add_boards_type_to_boards.rb +++ b/db/migrate/20140603033359_add_boards_type_to_boards.rb @@ -6,6 +6,7 @@ class AddBoardsTypeToBoards < ActiveRecord::Migration project = Project.find_by_id(board.project_id) if project && project.project_type == 1 board.course_id = board.project_id + board.project_id = nil board.save end end diff --git a/db/migrate/20140603081801_add_courseid_to_enabled_modules.rb b/db/migrate/20140603081801_add_courseid_to_enabled_modules.rb index cefc3825..baa1ef81 100644 --- a/db/migrate/20140603081801_add_courseid_to_enabled_modules.rb +++ b/db/migrate/20140603081801_add_courseid_to_enabled_modules.rb @@ -5,7 +5,8 @@ class AddCourseidToEnabledModules < ActiveRecord::Migration EnabledModule.all.each do |enablemodule| project = Project.find_by_id(enablemodule.project_id) if project && project.project_type == 1 - enablemodule.course_id = board.project_id + enablemodule.course_id = enablemodule.project_id + enablemodule.project_id = nil enablemodule.save end end diff --git a/db/migrate/20140604011630_add_courseid_to_to_members.rb b/db/migrate/20140604011630_add_courseid_to_to_members.rb new file mode 100644 index 00000000..14111c1b --- /dev/null +++ b/db/migrate/20140604011630_add_courseid_to_to_members.rb @@ -0,0 +1,15 @@ +class AddCourseidToToMembers < ActiveRecord::Migration + def change + add_column :members, :course_id, :int + + # 课程成员数据迁移 + Member.all.each do |member| + project = Project.find_by_id(member.project_id) + if project && project.project_type == 1 + member.course_id = member.project_id + member.project_id = nil + member.save + end + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 9178151a..34629bc0 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 => 20140603033360) do +ActiveRecord::Schema.define(:version => 20140603081801) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -315,6 +315,7 @@ ActiveRecord::Schema.define(:version => 20140603033360) do 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" diff --git a/lib/redmine.rb b/lib/redmine.rb index 7703b2b2..ff2dd2bb 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -98,6 +98,12 @@ Redmine::AccessControl.map do |map| map.permission :add_subprojects, {:projects => [:new, :create]}, :require => :member map.permission :view_journals_for_messages, {:gantts => [:show, :update]}, :read => true + #课程权限模块 + map.course_module :course do + map.permission :view_course, {:courses => [:show], :activities => [:index]}, :public => true, :read => true + map.permission :view_courses,{:courses => [:course]},:read => true + end + map.project_module :issue_tracking do |map| # Issue categories map.permission :manage_categories, {:projects => :settings, :issue_categories => [:index, :show, :new, :create, :edit, :update, :destroy]}, :require => :member @@ -178,12 +184,6 @@ Redmine::AccessControl.map do |map| map.permission :manage_related_issues, {:repositories => [:add_related_issue, :remove_related_issue]} end - #课程权限模块 - map.project_module :course do - map.permission :view_course, {:courses => [:show], :activities => [:index]}, :public => true, :read => true - map.permission :view_courses,{:courses => [:course]},:read => true - end - #作业模块权限 map.project_module :bids do |map| map.permission :view_homework_attaches, {:bids => [:show, :show_project, :revision]}, :read => true diff --git a/lib/redmine/access_control.rb b/lib/redmine/access_control.rb index 7c4a5a5e..0158a05e 100644 --- a/lib/redmine/access_control.rb +++ b/lib/redmine/access_control.rb @@ -76,6 +76,7 @@ module Redmine class Mapper def initialize @project_module = nil + @course_module = nil end def permission(name, hash, options={}) @@ -90,13 +91,18 @@ module Redmine @project_module = nil end + def course_module(name, options={}) + @course_module = name + yield self + @course_module = nil + end def mapped_permissions @permissions end end class Permission - attr_reader :name, :actions, :project_module + attr_reader :name, :actions, :project_module ,:course_module def initialize(name, hash, options) @name = name From c43bf84e424e6642c6256c485daf61518e3c0590 Mon Sep 17 00:00:00 2001 From: nwb Date: Wed, 4 Jun 2014 11:32:32 +0800 Subject: [PATCH 012/183] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=89=80=E5=8C=85?= =?UTF-8?q?=E5=90=AB=E7=9A=84=E5=AD=90=E5=8A=9F=E8=83=BD=E6=A8=A1=E5=9D=97?= =?UTF-8?q?(enabled=5Fmodules)=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/member.rb | 3 ++- app/models/project.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/member.rb b/app/models/member.rb index de4d6768..8901ec52 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -22,8 +22,9 @@ class Member < ActiveRecord::Base has_many :roles, :through => :member_roles belongs_to :project + belongs_to :course - validates_presence_of :principal, :project + validates_presence_of :principal validates_uniqueness_of :user_id, :scope => :project_id validate :validate_role diff --git a/app/models/project.rb b/app/models/project.rb index b8e11d99..45e251f5 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -38,7 +38,7 @@ class Project < ActiveRecord::Base :conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})" has_many :users, :through => :members has_many :principals, :through => :member_principals, :source => :principal - has_many :enabled_modules, :dependent => :delete_all + has_many :enabled_modules, :dependent => :delete_all has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position" has_many :issues, :dependent => :destroy, :include => [:status, :tracker] has_many :issue_changes, :through => :issues, :source => :journals From d4bc8139a3e6799cfa38896815176d0520e64646 Mon Sep 17 00:00:00 2001 From: nwb Date: Wed, 4 Jun 2014 11:59:26 +0800 Subject: [PATCH 013/183] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20140401004102_create_relative_memos.rb | 2 +- ...0140603033359_add_boards_type_to_boards.rb | 20 ++++++++++------- ...3081801_add_courseid_to_enabled_modules.rb | 19 +++++++++------- ...140604011630_add_courseid_to_to_members.rb | 22 ++++++++++++------- db/schema.rb | 16 ++++++-------- 5 files changed, 45 insertions(+), 34 deletions(-) diff --git a/db/migrate/20140401004102_create_relative_memos.rb b/db/migrate/20140401004102_create_relative_memos.rb index 6f0d776d..04b8862a 100644 --- a/db/migrate/20140401004102_create_relative_memos.rb +++ b/db/migrate/20140401004102_create_relative_memos.rb @@ -4,7 +4,7 @@ class CreateRelativeMemos < ActiveRecord::Migration t.integer :osp_id, :null => true t.integer :parent_id, null: true t.string :subject, null: false - t.mediumtext :content, null: false + t.text :content, null: false t.integer :author_id t.integer :replies_count, default: 0 t.integer :last_reply_id diff --git a/db/migrate/20140603033359_add_boards_type_to_boards.rb b/db/migrate/20140603033359_add_boards_type_to_boards.rb index 76193b64..ea06cc20 100644 --- a/db/migrate/20140603033359_add_boards_type_to_boards.rb +++ b/db/migrate/20140603033359_add_boards_type_to_boards.rb @@ -2,13 +2,17 @@ class AddBoardsTypeToBoards < ActiveRecord::Migration def change add_column :boards, :course_id, :int - Board.all.each do |board| - project = Project.find_by_id(board.project_id) - if project && project.project_type == 1 - board.course_id = board.project_id - board.project_id = nil - board.save - end - end + Board.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all("course_id = project_id") + Board.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all(project_id: -1) + + #Board.all.each do |board| + # project = Project.find_by_id(board.project_id) + # if project && project.project_type == 1 + # board.course_id = board.project_id + # board.project_id = -1 + # board.save + # end + # end + end end diff --git a/db/migrate/20140603081801_add_courseid_to_enabled_modules.rb b/db/migrate/20140603081801_add_courseid_to_enabled_modules.rb index baa1ef81..e31c3f95 100644 --- a/db/migrate/20140603081801_add_courseid_to_enabled_modules.rb +++ b/db/migrate/20140603081801_add_courseid_to_enabled_modules.rb @@ -2,13 +2,16 @@ class AddCourseidToEnabledModules < ActiveRecord::Migration def change add_column :enabled_modules, :course_id, :int - EnabledModule.all.each do |enablemodule| - project = Project.find_by_id(enablemodule.project_id) - if project && project.project_type == 1 - enablemodule.course_id = enablemodule.project_id - enablemodule.project_id = nil - enablemodule.save - end - end + EnabledModule.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all("course_id = project_id") + EnabledModule.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all(project_id: -1) + + #EnabledModule.all.each do |enablemodule| + # project = Project.find_by_id(enablemodule.project_id) + # if project && project.project_type == 1 + # enablemodule.course_id = enablemodule.project_id + # enablemodule.project_id = -1 + # enablemodule.save + # end + #end end end diff --git a/db/migrate/20140604011630_add_courseid_to_to_members.rb b/db/migrate/20140604011630_add_courseid_to_to_members.rb index 14111c1b..b52a2692 100644 --- a/db/migrate/20140604011630_add_courseid_to_to_members.rb +++ b/db/migrate/20140604011630_add_courseid_to_to_members.rb @@ -1,15 +1,21 @@ class AddCourseidToToMembers < ActiveRecord::Migration def change add_column :members, :course_id, :int + change_column_null(:members, :project_id, true) + remove_index :members, name: 'index_members_on_user_id_and_project_id' + add_index "members", ["user_id", "project_id","course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true + + Member.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all("course_id = project_id") + Member.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all(project_id: -1) # 课程成员数据迁移 - Member.all.each do |member| - project = Project.find_by_id(member.project_id) - if project && project.project_type == 1 - member.course_id = member.project_id - member.project_id = nil - member.save - end - end + #Member.all.each do |member| + # project = Project.find_by_id(member.project_id) + # if project && project.project_type == 1 + # member.course_id = member.project_id + # member.project_id = -1 + # member.save + # end + #end end end diff --git a/db/schema.rb b/db/schema.rb index 34629bc0..470440fc 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 => 20140603081801) do +ActiveRecord::Schema.define(:version => 20140604011630) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -57,14 +57,11 @@ ActiveRecord::Schema.define(:version => 20140603081801) do 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", :id => false, :force => true do |t| - t.integer "id", :null => false - t.integer "typeId" + create_table "attachmentstypes", :force => true do |t| + t.integer "typeId", :null => false t.string "typeName", :limit => 50 end - add_index "attachmentstypes", ["id"], :name => "id" - create_table "auth_sources", :force => true do |t| t.string "type", :limit => 30, :default => "", :null => false t.string "name", :limit => 60, :default => "", :null => false @@ -519,13 +516,14 @@ ActiveRecord::Schema.define(:version => 20140603081801) do create_table "members", :force => true do |t| t.integer "user_id", :default => 0, :null => false - t.integer "project_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" end add_index "members", ["project_id"], :name => "index_members_on_project_id" - add_index "members", ["user_id", "project_id"], :name => "index_members_on_user_id_and_project_id", :unique => true + 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 "memos", :force => true do |t| @@ -710,7 +708,7 @@ ActiveRecord::Schema.define(:version => 20140603081801) do end create_table "relative_memos", :force => true do |t| - t.integer "osp_id", :null => false + t.integer "osp_id" t.integer "parent_id" t.string "subject", :null => false t.text "content", :null => false From 0f5c99627854528f582352a3606356cb4bccccc0 Mon Sep 17 00:00:00 2001 From: nwb Date: Wed, 4 Jun 2014 14:09:37 +0800 Subject: [PATCH 014/183] =?UTF-8?q?=E6=96=B0=E5=BB=BA=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 12 ++++++++++++ app/views/courses/new.html.erb | 9 +++++++++ 2 files changed, 21 insertions(+) create mode 100644 app/views/courses/new.html.erb diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 12f730e0..ddeb4253 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -67,6 +67,18 @@ class CoursesController < ApplicationController return courses end + def new + @course_type = params[:course_type] ||= params[:course] + @issue_custom_fields = IssueCustomField.sorted.all + @trackers = Tracker.sorted.all + + @course = Course.new + @course.safe_attributes = params[:course] + + render :layout => 'base' + end + + def desc_sort_course_by_avtivity(activity_count,courses) return courses if activity_count.size<2 (activity_count.size-2).downto(0) do |i| diff --git a/app/views/courses/new.html.erb b/app/views/courses/new.html.erb new file mode 100644 index 00000000..81e6ec37 --- /dev/null +++ b/app/views/courses/new.html.erb @@ -0,0 +1,9 @@ +<%= labelled_form_for @course do |f| %> +

    <%=l(:label_course_new)%>

    +
    + <%= render :partial => 'course_form', :locals => { :f => f } %> + <%= submit_tag l(:button_create), :class => "enterprise"%> + + <%= javascript_tag "$('#course_name').focus();" %> +
    +<% end %> From fb36a0d5ba8a373623d82de9fcba659ddc7efd34 Mon Sep 17 00:00:00 2001 From: nwb Date: Wed, 4 Jun 2014 15:47:09 +0800 Subject: [PATCH 015/183] =?UTF-8?q?1.=E8=AF=BE=E7=A8=8Bcontrol=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0create=E6=96=B9=E6=B3=95=202.=E8=AF=BE=E7=A8=8Bmodel?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=83=A8=E5=88=86=E6=96=B0=E5=88=97=E5=8F=8A?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 150 ++++++++++++------ app/models/course.rb | 7 + app/views/courses/_course_form.html.erb | 49 +++--- app/views/users/_my_course.html.erb | 2 +- ...20140604071623_add_is_public_to_courses.rb | 6 + db/schema.rb | 32 +++- 6 files changed, 160 insertions(+), 86 deletions(-) create mode 100644 db/migrate/20140604071623_add_is_public_to_courses.rb diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index ddeb4253..9f823ab9 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -5,10 +5,9 @@ class CoursesController < ApplicationController menu_item l(:label_sort_by_active), :only => :index menu_item l(:label_sort_by_influence), :only => :index - before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches] - before_filter :authorize, :only => [:show, :settings, :edit, :update, :modules, :close, :reopen,:view_homework_attaches,:course] - before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches] - before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar] + before_filter :authorize, :only => [:show, :settings, :edit, :update, :modules, :close, :reopen, :view_homework_attaches, :course] + before_filter :authorize_global, :only => [:view_homework_attaches] #:new,:create] + before_filter :require_admin, :only => [:copy, :archive, :unarchive, :destroy, :calendar] before_filter :require_login, :only => [:join, :unjoin] before_filter :allow_join, :only => [:join] @@ -22,7 +21,7 @@ class CoursesController < ApplicationController members = [] members << Member.new(:role_ids => [10], :user_id => User.current.id) course.members << members - + StudentsForCourse.create(:student_id => User.current.id, :course_id => params[:object_id]) @state = 0 else @@ -34,13 +33,13 @@ class CoursesController < ApplicationController format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Project.find(params[:object_id]), :object_id => params[:object_id]} } end end - + def unjoin if User.current.logged? - + @member = Member.where('project_id = ? and user_id = ?', params[:object_id], User.current.id) @member.first.destroy - + joined = StudentsForCourse.where('student_id = ? and course_id = ?', User.current.id, params[:object_id]) joined.each do |join| join.delete @@ -52,7 +51,7 @@ class CoursesController < ApplicationController end end - def handle_course courses,activities + def handle_course courses, activities course_activity_count_array=activities.values() course_array=[] @@ -62,30 +61,87 @@ class CoursesController < ApplicationController i=i+1 end - courses=desc_sort_course_by_avtivity(course_activity_count_array,course_array) + courses=desc_sort_course_by_avtivity(course_activity_count_array, course_array) return courses end - def new - @course_type = params[:course_type] ||= params[:course] - @issue_custom_fields = IssueCustomField.sorted.all - @trackers = Tracker.sorted.all + def create + if User.current.user_extensions.identity + @course = Course.new + @course.extra='course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s + @course.safe_attributes = params[:course] + @course.tea_id = User.current.id + # added by bai + @course.term = params[:term] + @course.time = params[:time] + #@course.school_id = params[:occupation] + @course.school_id = User.current.user_extensions.school_id + @course.setup_time = params[:setup_time] + @course.endup_time = params[:endup_time] + @course.class_period = params[:class_period] + end - @course = Course.new - @course.safe_attributes = params[:course] + @issue_custom_fields = IssueCustomField.sorted.all + @trackers = Tracker.sorted.all + + if User.current.user_extensions.identity == 0 + if @course.save + unless User.current.admin? + 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]) + #course = ProjectInfo.new(:user_id => User.current.id, :course_id => @course.id) + user_grades = UserGrade.create(:user_id => User.current.id, :course_id => @course.id) + if params[:course][:is_public] == '1' + course_status = CourseStatus.create(:course_id => @course.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :course_type => @course_tag) + end + @course.members << m + #@course.course_infos << course + end + respond_to do |format| + format.html { + flash[:notice] = l(:notice_successful_create) + if params[:continue] + redirect_to new_course_path(attrs, :course => '0') + elsif params[:course_continue] + redirect_to new_course_path(:course => '1') + else + redirect_to settings_course_path(@course, :course_type => 1) + end + } + format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'courses', :action => 'show', :id => @course.id) } + end + else + @course.destroy + respond_to do |format| + format.html { render :action => 'new', :layout => 'base' } #Added by young + format.api { render_validation_errors(@course) } + end + end + end + + end + + + def new + @course_type = params[:course_type] ||= params[:course] + @issue_custom_fields = IssueCustomField.sorted.all + @trackers = Tracker.sorted.all + + @course = Course.new + @course.safe_attributes = params[:course] render :layout => 'base' end - def desc_sort_course_by_avtivity(activity_count,courses) + def desc_sort_course_by_avtivity(activity_count, courses) return courses if activity_count.size<2 (activity_count.size-2).downto(0) do |i| (0..i).each do |j| if activity_count[j]?",date_from).each do |attachment| + Attachment.where(container_id: @course_ids, container_type: Project).where("created_on>?", date_from).each do |attachment| activities[attachment.container_id]+=1 end #message_count Board.where(course_id: @course_ids).each do |board| # activities[board.course_id]+=1 - activities[board.course_id]+=board.messages.where("updated_on>?",date_from).count + activities[board.course_id]+=board.messages.where("updated_on>?", date_from).count end #feedbackc_count @@ -224,21 +280,19 @@ class CoursesController < ApplicationController def allow_join if course_endTime_timeout? Project.find(params[:object_id]) respond_to do |format| - format.js{ + format.js { @state = 2 - render :partial => 'set_join', - :locals => {:user => User.current, - :course => Project.find(params[:object_id]), - :object_id => params[:object_id] - } + render :partial => 'set_join', + :locals => {:user => User.current, + :course => Project.find(params[:object_id]), + :object_id => params[:object_id] + } } end end end - - def index1 per_page_option = 10 @@ -258,13 +312,13 @@ class CoursesController < ApplicationController @course_activity_count[course.id]=0 end - @course_activity_count=get_course_activity @courses_all,@course_activity_count + @course_activity_count=get_course_activity @courses_all, @course_activity_count #gcm end case params[:course_sort_type] when '0' - @courses = @courses_all.order("created_on desc") + @courses = @courses_all.order("created_on desc") @s_type = 0 when '1' @courses = @courses_all.order("grade desc") @@ -276,15 +330,15 @@ class CoursesController < ApplicationController #gcm when '3' #@courses=desc_sort_course_by_avtivity(@course_activity_count_array,@course_all_array) - @courses=handle_course @courses_all,@course_activity_count + @courses=handle_course @courses_all, @course_activity_count @s_type = 3 - @courses = @courses[@course_pages.offset, @course_pages.per_page] + @courses = @courses[@course_pages.offset, @course_pages.per_page] else @courses = @courses = @courses_all.order("grade desc") @s_type = 1 end - @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page) + @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page) respond_to do |format| format.html { @@ -294,7 +348,7 @@ class CoursesController < ApplicationController # scope = scope.active # end } - format.api { + format.api { # @offset, @limit = api_offset_and_limit # @course_count = Project.visible.count # @courses = Project.visible.offset(@offset).limit(@limit).order('lft').all diff --git a/app/models/course.rb b/app/models/course.rb index b611261c..d0273fa7 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -23,6 +23,8 @@ class Course < ActiveRecord::Base 'term', 'password' + acts_as_customizable + scope :active, lambda { where(:status => STATUS_ACTIVE) } scope :status, lambda {|arg| where(arg.blank? ? nil : {:status => arg.to_i}) } scope :all_public, lambda { where(:is_public => true) } @@ -43,6 +45,11 @@ class Course < ActiveRecord::Base user.allowed_to?(:view_course, self) end + def extra_frozen? + errors[:extra].blank? && !(new_record? || extra.blank?) + end + + def self.visible_condition(user, options={}) allowed_to_condition(user, :view_course, options) end diff --git a/app/views/courses/_course_form.html.erb b/app/views/courses/_course_form.html.erb index 017c4e6e..66054a93 100644 --- a/app/views/courses/_course_form.html.erb +++ b/app/views/courses/_course_form.html.erb @@ -17,21 +17,21 @@ <% object = [] %> -<% object << 'project' %> +<% object << 'course' %> <% object << 'course' %> <%= error_messages_for object %> - -<% unless @project.new_record? %> -

    <%= render :partial=>"avatar/avatar_form",:locals=> {source:@project} %>

    + +<% unless @course.new_record? %> +

    <%= render :partial=>"avatar/avatar_form",:locals=> {source:@course} %>

    <% end %> -

    +

    - @@ -294,46 +294,33 @@ -

    +

    <%= l(:text_command) %> <% end %> -

    +

    <%= f.check_box :is_public, :style => "margin-left:10px;" %><%= l(:label_public_info) %>

    -

    <%= f.text_field :project_type, :value => 1 %>

    +

    <%= f.text_field :course_type, :value => 1 %>

    -<%= wikitoolbar_for 'project_description' %> +<%= wikitoolbar_for 'course_description' %> -<% @project.custom_field_values.each do |value| %> -

    <%= custom_field_tag_with_label :project, value %>

    +<% @course.custom_field_values.each do |value| %> +

    <%= custom_field_tag_with_label :course, value %>

    <% end %> -<%= call_hook(:view_projects_form, :project => @project, :form => f) %> +<%= call_hook(:view_courses_form, :course => @course, :form => f) %> - + -<% unless @project.identifier_frozen? %> +<% unless @course.extra_frozen? %> <% content_for :header_tags do %> - <%= javascript_include_tag 'project_identifier' %> + <%= javascript_include_tag 'course_identifier' %> <% end %> <% end %> -<% if !User.current.admin? && @project.inherit_members? && @project.parent && User.current.member_of?(@project.parent) %> - <%= javascript_tag do %> - $(document).ready(function() { - $("#project_inherit_members").change(function(){ - if (!$(this).is(':checked')) { - if (!confirm("<%= escape_javascript(l(:text_own_membership_delete_confirmation)) %>")) { - $("#project_inherit_members").attr("checked", true); - } - } - }); - }); - <% end %> -<% end %> diff --git a/app/views/users/_my_course.html.erb b/app/views/users/_my_course.html.erb index 26cfd48e..85f455b1 100644 --- a/app/views/users/_my_course.html.erb +++ b/app/views/users/_my_course.html.erb @@ -7,7 +7,7 @@ <% else %>

    - <%= l(:label_project_course_unadd) %><%= link_to "#{l(:label_course_new)}", {:controller => 'projects', :action => 'new', :course => 1, :project_type => 1}, :class => 'icon icon-add' %> + <%= l(:label_project_course_unadd) %><%= link_to "#{l(:label_course_new)}", {:controller => 'courses', :action => 'new'}, :class => 'icon icon-add' %>

    <% end %> <% else %> diff --git a/db/migrate/20140604071623_add_is_public_to_courses.rb b/db/migrate/20140604071623_add_is_public_to_courses.rb new file mode 100644 index 00000000..48aa6b5d --- /dev/null +++ b/db/migrate/20140604071623_add_is_public_to_courses.rb @@ -0,0 +1,6 @@ +class AddIsPublicToCourses < ActiveRecord::Migration + def change + add_column :courses, :is_public, :tinyint,:default => 1 + add_column :courses, :inherit_members, :tinyint,:default => 1 + end +end diff --git a/db/schema.rb b/db/schema.rb index 721945ed..4f3398eb 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 => 20140527060344) do +ActiveRecord::Schema.define(:version => 20140604071624) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -116,6 +116,7 @@ ActiveRecord::Schema.define(:version => 20140527060344) do 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" @@ -217,6 +218,16 @@ ActiveRecord::Schema.define(:version => 20140527060344) do t.datetime "updated_on", :null => false 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" @@ -224,8 +235,8 @@ ActiveRecord::Schema.define(:version => 20140527060344) do t.string "code" t.integer "time" t.string "extra" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "location" t.string "term" t.string "string" @@ -234,6 +245,13 @@ ActiveRecord::Schema.define(:version => 20140527060344) do 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.boolean "is_public", :default => true + t.integer "inherit_members", :limit => 1, :default => 1 end create_table "custom_fields", :force => true do |t| @@ -296,6 +314,7 @@ ActiveRecord::Schema.define(:version => 20140527060344) do 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" @@ -499,13 +518,14 @@ ActiveRecord::Schema.define(:version => 20140527060344) do create_table "members", :force => true do |t| t.integer "user_id", :default => 0, :null => false - t.integer "project_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" end add_index "members", ["project_id"], :name => "index_members_on_project_id" - add_index "members", ["user_id", "project_id"], :name => "index_members_on_user_id_and_project_id", :unique => true + 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 "memos", :force => true do |t| @@ -690,7 +710,7 @@ ActiveRecord::Schema.define(:version => 20140527060344) do end create_table "relative_memos", :force => true do |t| - t.integer "osp_id", :null => false + t.integer "osp_id" t.integer "parent_id" t.string "subject", :null => false t.text "content", :null => false From 0d99644fa7acc72e7af9722a215fef79d2ea9623 Mon Sep 17 00:00:00 2001 From: nwb Date: Wed, 4 Jun 2014 16:45:20 +0800 Subject: [PATCH 016/183] =?UTF-8?q?1.=E7=94=A8=E6=88=B7=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E8=A1=A8=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9=202.=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0link=5Fto=5Fcourse=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 12 ++++++++++-- app/controllers/users_controller.rb | 8 ++++---- app/helpers/courses_helper.rb | 2 +- app/models/course.rb | 16 ++++++++++++++-- app/models/member_role.rb | 14 ++++++++------ app/models/principal.rb | 1 + app/views/courses/_course_form.html.erb | 2 -- app/views/users/_course_form.html.erb | 22 +++++++++++----------- config/routes.rb | 2 +- 9 files changed, 50 insertions(+), 29 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 9f823ab9..bff99f35 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -6,7 +6,7 @@ class CoursesController < ApplicationController menu_item l(:label_sort_by_influence), :only => :index before_filter :authorize, :only => [:show, :settings, :edit, :update, :modules, :close, :reopen, :view_homework_attaches, :course] - before_filter :authorize_global, :only => [:view_homework_attaches] #:new,:create] + #before_filter :authorize_global, :only => [:view_homework_attaches, :new,:create] before_filter :require_admin, :only => [:copy, :archive, :unarchive, :destroy, :calendar] before_filter :require_login, :only => [:join, :unjoin] @@ -66,6 +66,13 @@ class CoursesController < ApplicationController return courses end + def settings + @issue_custom_fields = IssueCustomField.sorted.all + @issue_category ||= IssueCategory.new + @member ||= @courses.members.new + @trackers = Tracker.sorted.all + end + def create if User.current.user_extensions.identity @course = Course.new @@ -80,6 +87,7 @@ class CoursesController < ApplicationController @course.setup_time = params[:setup_time] @course.endup_time = params[:endup_time] @course.class_period = params[:class_period] + @course.description = params[:description] end @issue_custom_fields = IssueCustomField.sorted.all @@ -91,7 +99,7 @@ class CoursesController < ApplicationController 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]) #course = ProjectInfo.new(:user_id => User.current.id, :course_id => @course.id) - user_grades = UserGrade.create(:user_id => User.current.id, :course_id => @course.id) + #user_grades = UserGrade.create(:user_id => User.current.id, :course_id => @course.id) if params[:course][:is_public] == '1' course_status = CourseStatus.create(:course_id => @course.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :course_type => @course_tag) end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6452bcc8..c508234a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -200,19 +200,19 @@ class UsersController < ApplicationController end end - membership = @user.memberships.all(:conditions => Project.visible_condition(User.current)) + membership = @user.coursememberships.all(:conditions => Course.visible_condition(User.current)) membership.sort! {|older, newer| newer.created_on <=> older.created_on } @memberships = [] membership.collect { |e| - @memberships.push(e) if(e.project.project_type == 1) + @memberships.push(e) } ## 判断课程是否过期 [需封装] @memberships_doing = [] @memberships_done = [] now_time = Time.now.year @memberships.map { |e| - end_time = e.project.course_extra.get_time.year - isDone = course_endTime_timeout?(e.project) + end_time = e.course.get_time.year + isDone = course_endTime_timeout?(e.course) if isDone @memberships_done.push e else diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 70029a55..8f3e4eb7 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -182,7 +182,7 @@ module CoursesHelper end # 截至到2014-03-17 这个是最终的判断课程是否过期的方法 def course_endTime_timeout? project - end_time_str = Course.find_by_extra(project.try(:identifier)).try(:endup_time) + end_time_str = Course.find_by_extra(project.try(:extra)).try(:endup_time) begin cTime = Time.parse(end_time_str.to_s) rescue TypeError,ArgumentError diff --git a/app/models/course.rb b/app/models/course.rb index d0273fa7..9b2e0d84 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -10,6 +10,14 @@ class Course < ActiveRecord::Base belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表 belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school,该方法通过school_id来调用School表 has_many :bid + + has_many :members, :include => [:principal, :roles], :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}" + has_many :memberships, :class_name => 'Member' + has_many :member_principals, :class_name => 'Member', + :include => :principal, + :conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})" + has_many :users, :through => :members + validates_presence_of :password, :term validates_format_of :class_period, :message => "class period can only digital!", :with =>/^[1-9]\d*$/ safe_attributes 'extra', @@ -21,7 +29,8 @@ class Course < ActiveRecord::Base 'tea_id', 'password', 'term', - 'password' + 'password', + 'description' acts_as_customizable @@ -49,8 +58,11 @@ class Course < ActiveRecord::Base errors[:extra].blank? && !(new_record? || extra.blank?) end + def archived? + self.status == STATUS_ARCHIVED + end - def self.visible_condition(user, options={}) + def self.visible_condition(user, options={}) allowed_to_condition(user, :view_course, options) end diff --git a/app/models/member_role.rb b/app/models/member_role.rb index 29ad6563..67122a63 100644 --- a/app/models/member_role.rb +++ b/app/models/member_role.rb @@ -54,14 +54,16 @@ class MemberRole < ActiveRecord::Base end def add_role_to_subprojects - member.project.children.each do |subproject| - if subproject.inherit_members? - child_member = Member.find_or_new(subproject.id, member.user_id) - child_member.member_roles << MemberRole.new(:role => role, :inherited_from => id) - child_member.save! + if member.project + member.project.children.each do |subproject| + if subproject.inherit_members? + child_member = Member.find_or_new(subproject.id, member.user_id) + child_member.member_roles << MemberRole.new(:role => role, :inherited_from => id) + child_member.save! + end end end - end + end def remove_inherited_roles MemberRole.where(:inherited_from => id).all.group_by(&:member).each do |member, member_roles| diff --git a/app/models/principal.rb b/app/models/principal.rb index 15cebdf5..6681855b 100644 --- a/app/models/principal.rb +++ b/app/models/principal.rb @@ -26,6 +26,7 @@ class Principal < ActiveRecord::Base has_many :members, :foreign_key => 'user_id', :dependent => :destroy has_many :memberships, :class_name => 'Member', :foreign_key => 'user_id', :include => [ :project, :roles ], :conditions => "#{Project.table_name}.status<>#{Project::STATUS_ARCHIVED}", :order => "#{Project.table_name}.name" + has_many :coursememberships, :class_name => 'Member', :foreign_key => 'user_id', :include => [ :course, :roles ], :conditions => "#{Course.table_name}.status<>#{Course::STATUS_ARCHIVED}", :order => "#{Course.table_name}.name" has_many :projects, :through => :memberships has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify diff --git a/app/views/courses/_course_form.html.erb b/app/views/courses/_course_form.html.erb index 66054a93..4f2f5a79 100644 --- a/app/views/courses/_course_form.html.erb +++ b/app/views/courses/_course_form.html.erb @@ -292,14 +292,12 @@ -

    <%= l(:text_command) %> <% end %> -

    diff --git a/app/views/users/_course_form.html.erb b/app/views/users/_course_form.html.erb index 13ab819d..6de99f7d 100644 --- a/app/views/users/_course_form.html.erb +++ b/app/views/users/_course_form.html.erb @@ -1,44 +1,44 @@
    -
    +
    - -
    - + +
    +
    - - - - - - - <% unless @bid.parent_id.nil?%> - - - - <% end %> -
    <%= l(:label_limit_time) %>: <%= @bid.deadline %>
    作业类型: <%=@bid.homework_type==Bid::HomeworkFile ? "提交文件" : "提交项目"%>
    -
    - <% author=Bid.find(@bid.parent_id).author%> - 作业来源于<%= link_to(author.lastname+author.firstname, user_path(Bid.find(@bid.parent_id).author))%>的需求:<%= link_to(Bid.find(@bid.parent_id).name, respond_path(Bid.find(@bid.parent_id))) %> -
    -
    + + <%= l(:label_limit_time) %>: <%= @bid.deadline %> + + + 作业类型: <%= @bid.homework_type==Bid::HomeworkFile ? "提交文件" : "提交项目" %> + + <% unless @bid.parent_id.nil? %> + + +
    + <% author=Bid.find(@bid.parent_id).author %> + 作业来源于<%= link_to(author.lastname+author.firstname, user_path(Bid.find(@bid.parent_id).author)) %> + 的需求:<%= link_to(Bid.find(@bid.parent_id).name, respond_path(Bid.find(@bid.parent_id))) %> +
    + + + <% end %> + +
    - -
    -
    - - - - -
    <%= render :partial => 'tags/tag', :locals => {:obj => @bid, :object_flag => "4"}%>
    + +
    +
    + + + + +
    <%= render :partial => 'tags/tag', :locals => {:obj => @bid, :object_flag => "4"} %>
    -
    +
    - -
    + +
    -
    -
    - <%= l(:label_commit_homework) %> -
    -
    - - - - -
    <% if @bid.homework_type == 1%> - <% if @bid.homeworks.size>0 %> - <% for homework in @bid.homeworks.eager_load(:user) %> - <%= link_to image_tag(url_to_avatar(homework.user), :class => "avatar", :title => homework.user.name), user_path(homework.user), :class => "avatar" %> <% end %> - <% else %> -

    - <%= l(:label_no_course_project) %> -

    <% end %> - <% else %> - <% if @bid.projects.size>0 %> - <% for project in @bid.projects%> - <%= link_to image_tag(url_to_avatar(project), :class => "avatar", :title => project.name), project_path(project), :class => "avatar" %> <% end %> - <% else %> -

    - <%= l(:label_no_course_project) %> -

    <% end %> - <% end %>
    -
    -
    -
    -
    - - - -
    - -
    -
      -
    • - <%= link_to l(:label_question_student), {:controller => 'bids', :action => 'show' },:class => link_class(:respond)%> -
    • - <% if User.current.member_of? @bid.courses.first%> -
    • - <% if User.current.logged? && @bid.courses.first && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0) %> - <%= link_to l(:label_homework_commit), {:controller => 'bids', :action => 'show_project' },:class => link_class(:project)%> - <% else %> - <%= link_to l(:label_homework_info), {:controller => 'bids', :action => 'show_project' },:class => link_class(:project)%> - - <% end %> -
    • +
      +
      + <%= l(:label_commit_homework) %> +
      +
      + + + diff --git a/app/views/bids/show_courseEx.html.erb b/app/views/bids/show_courseEx.html.erb new file mode 100644 index 00000000..039de6b7 --- /dev/null +++ b/app/views/bids/show_courseEx.html.erb @@ -0,0 +1,72 @@ +<% if @bid.homework_type == Bid::HomeworkFile %> + + <%= render :partial => 'homework' %> + +<% else %> + + + <% if User.current.logged? %> + + +
      + <% if @bid.homework_type == 1 %> + <% if @bid.homeworks.size>0 %> + <% for homework in @bid.homeworks.eager_load(:user) %> + <%= link_to image_tag(url_to_avatar(homework.user), :class => "avatar", :title => homework.user.name), user_path(homework.user), :class => "avatar" %> + <% end %> + <% else %> +

      + <%= l(:label_no_course_project) %> +

      <% end %> - - + +
      + +
      +
        +
      • + <%= link_to l(:label_question_student), {:controller => 'bids', :action => 'show'}, :class => link_class(:respond) %> +
      • + <% if User.current.member_of? @bid.courses.first %> +
      • + <% if User.current.logged? && @bid.courses.first && (!Member.where('user_id = ? and course_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and course_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?', 5, 10, 7)).size >0) %> + <%= link_to l(:label_homework_commit), {:controller => 'bids', :action => 'show_course'}, :class => link_class(:course) %> + <% else %> + <%= link_to l(:label_homework_info), {:controller => 'bids', :action => 'show_course'}, :class => link_class(:course) %> + + <% end %> +
      • + <% end %> + +
      -
      +
      - <%= yield %> - <%= call_hook :view_layouts_base_content %> -
      - - <%= render :partial => 'layouts/base_footer'%> - - - + <%= yield %> + <%= call_hook :view_layouts_base_content %> +
      + + <%= render :partial => 'layouts/base_footer' %> + + + - - + + - - <%= call_hook :view_layouts_base_body_bottom %> + + <%= call_hook :view_layouts_base_body_bottom %> + <% end %> diff --git a/config/routes.rb b/config/routes.rb index 59c3eb35..3ee5d777 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -591,6 +591,7 @@ RedmineApp::Application.routes.draw do end resources :news, :except => [:show, :edit, :update, :destroy] resources :boards + match '/homework', :controller => 'courses', :action => 'homework', :as => 'homework', :via => :get end # end of resources :courses match 'courses/:id/feedback', :to => 'courses#feedback', :via => :get, :as => 'course_feedback' match '/courses/search', :controller => 'courses', :action => 'search', :via => [:get, :post] @@ -632,6 +633,7 @@ RedmineApp::Application.routes.draw do match 'calls/new_bid', :controller => 'bids', :action => 'new_bid' match 'contest/new_contest', :controller => 'bids', :action => 'new_contest' #huang match 'calls/:id/show_project', :controller => 'bids', :action => 'show_project', :as => 'project_for_bid' + match 'calls/:id/show_course', :controller => 'bids', :action => 'show_course', :as => 'course_for_bid' # nwb added match 'calls/:id/new_exercise_book', :controller => 'homework_attach', :action => 'new', :as => 'new_homework_attach' match 'calls/:id/add', :controller => 'bids', :action => 'add' match 'calls/:id/delete', :controller => 'bids', :action => 'delete' diff --git a/db/schema.rb b/db/schema.rb index 51a2f805..2af470d0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -207,6 +207,17 @@ ActiveRecord::Schema.define(:version => 20140611161801) do t.string "reward" end + create_table "contestnotifications", :force => true do |t| + t.integer "contest_id" + t.string "title" + t.string "summary" + t.string "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 => "" @@ -595,6 +606,15 @@ ActiveRecord::Schema.define(:version => 20140611161801) do 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 "open_id_authentication_associations", :force => true do |t| t.integer "issued" t.integer "lifetime" From 2f724aa23e58baf1b53e95093c942393f4dcaf99 Mon Sep 17 00:00:00 2001 From: yanxd Date: Tue, 17 Jun 2014 11:41:00 +0800 Subject: [PATCH 078/183] =?UTF-8?q?xss=20=E8=BF=87=E6=BB=A4memo=20content?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/memos/show.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index 5ffcedac..1252483d 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -48,13 +48,14 @@
      <%= label_tag l(:field_subject) %>: <%=h @memo.subject %>
      - <%= raw @memo.content %> + <%=h sanitize(@memo.content.html_safe) %>

      <% if @memo.attachments.any?%> <% options = {:author => true, :deletable => @memo.deleted_attach_able_by?(User.current) } %> <%= render :partial => 'attachments/links', :locals => {:attachments => @memo.attachments, :options => options} %> <% end %>

      +
      <%= authoring @memo.created_at, @memo.author.name %>
      From 2000f1ddf637c28ad2994ad752497561fb43074f Mon Sep 17 00:00:00 2001 From: yanxd Date: Tue, 17 Jun 2014 14:42:08 +0800 Subject: [PATCH 079/183] =?UTF-8?q?=E4=BA=BA=E7=89=A9=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E4=BF=A1=E6=81=AF=E4=BC=9A=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E4=B8=A4=E6=AC=A1=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 16 +++++++++------- app/controllers/my_controller.rb | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index af848786..b5f6d7d5 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -144,14 +144,16 @@ class AccountController < ApplicationController #added by bai unless @user.id.nil? - ue = UserExtensions.create(:identity => params[:identity].to_i,:technical_title => params[:technical_title], :gender => params[:gender].to_i, :user_id => @user.id, :student_id => params[:no]) - unless params[:province].nil? || params[:city].nil? - ue.location = params[:province] - ue.location_city = params[:city] - ue.save - end + ue = @user.extensions + + ue.identity = params[:identity] + ue.technical_title = params[:technical_title] + ue.gender = params[:gender] + ue.student_id = params[:no] + ue.location = params[:province] + ue.location_city = params[:city] + @user.save end - #end end end diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index a87df4fe..9b169cb8 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -61,7 +61,7 @@ class MyController < ApplicationController end end - @se = @user.user_extensions ||= UserExtensions.new + @se = @user.extensions @se.school_id = params[:occupation] if params[:occupation] @se.gender = params[:gender] @se.location = params[:province] if params[:province] From 936c40b49094a5fef053b5b4b9ba2a532302ec4d Mon Sep 17 00:00:00 2001 From: nwb Date: Tue, 17 Jun 2014 15:06:31 +0800 Subject: [PATCH 080/183] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=92=8C=E8=A7=86=E5=9B=BE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 5 +- app/controllers/contests_controller.rb | 21 +++++- app/controllers/homework_attach_controller.rb | 34 ++++----- app/models/bid.rb | 2 +- app/views/bids/show_course.html.erb | 11 ++- app/views/bids/show_courseEx.html.erb | 72 +++++++++++++++++++ app/views/homework_attach/new.html.erb | 6 +- config/routes.rb | 2 +- 8 files changed, 122 insertions(+), 31 deletions(-) create mode 100644 app/views/bids/show_courseEx.html.erb diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index d7c54db3..9c4d8cfa 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -8,7 +8,7 @@ class BidsController < ApplicationController menu_item :homework_statistics, :only => :homework_statistics #Ended by young before_filter :find_bid, :only => [:show, :show_project, :create,:destroy,:more,:back,:add,:delete,:new,:show_results,:set_reward, :add_homework, :fork, :create_fork, - :show_course, :show_bid_project, :show_bid_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings] + :show_course, :show_courseEx,:show_bid_project, :show_bid_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings] # added by fq before_filter :require_login, :only => [:join_in_contest, :unjoin_in_contest] # end @@ -448,7 +448,7 @@ class BidsController < ApplicationController # 显示作业课程 # add by nwb - def show_course + def show_courseEx # flash[:notice] = "" @membership = User.current.coursememberships.all(:conditions => Course.visible_condition(User.current)) @option = [] @@ -462,6 +462,7 @@ class BidsController < ApplicationController @user = @bid.author @bidding_project = @bid.biding_projects.all + if params[:student_id].present? @temp = [] @bidding_project.each do |pro| diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index f50fe191..adadfbf4 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -74,7 +74,26 @@ class ContestsController < ApplicationController end end - def show_contest + def homework + @offset, @limit = api_offset_and_limit({:limit => 10}) + @bids = @course.homeworks.order('deadline DESC') + @bids = @bids.like(params[:name]) if params[:name].present? + @bid_count = @bids.count + @bid_pages = Paginator.new @bid_count, @limit, params['page'] + + @offset ||= @bid_pages.reverse_offset + unless @offset == 0 + @bids = @bids.offset(@offset).limit(@limit).all.reverse + else + limit = @bid_count % @limit + @bids = @bids.offset(@offset).limit(limit).all.reverse + end + render :layout => 'base_courses' + + end + + + def show_contest @user = @contest.author @jours = @contest.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') @limit = 10 diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index d10f09ff..2922eea1 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -1,21 +1,21 @@ class HomeworkAttachController < ApplicationController ############################### #判断当前角色权限时需先找到当前操作的project - before_filter :find_project_by_bid_id, :only => [:new] - before_filter :find_project_by_hoemwork_id, :only => [:edit,:update,:destroy,:show,:add_homework_users,:destory_homework_users] + before_filter :find_course_by_bid_id, :only => [:new] + before_filter :find_course_by_hoemwork_id, :only => [:edit,:update,:destroy,:show,:add_homework_users,:destory_homework_users] #判断当前角色是否有操作权限 #勿删 before_filter :authorize, :only => [:new,:edit,:update,:destroy] - def find_project_by_bid_id + def find_course_by_bid_id @bid = Bid.find(params[:id]) - @project = @bid.courses[0] + @course = @bid.courses[0] rescue ActiveRecord::RecordNotFound render_404 end - def find_project_by_hoemwork_id + def find_course_by_hoemwork_id @homework = HomeworkAttach.find(params[:id]) - @project = @homework.bid.courses[0] + @course = @homework.bid.courses[0] end #获取作业的成员 @@ -35,7 +35,7 @@ class HomeworkAttachController < ApplicationController #作业添加成员(参与人员) def add_homework_users - if User.current.admin? || User.current.member_of?(@homework.bid.courses.first) + if User.current.admin? || User.current.member_of_course?(@homework.bid.courses.first) #@homework = HomeworkAttach.find(params[:id]) if params[:membership] if params[:membership][:user_ids] @@ -59,7 +59,7 @@ class HomeworkAttachController < ApplicationController #作业删除成员(参与人员) def destory_homework_users #@homework = HomeworkAttach.find(params[:id]) - if User.current.admin? || User.current.member_of?(@homework.bid.courses.first) + if User.current.admin? || User.current.member_of_course?(@homework.bid.courses.first) homework_user = @homework.homework_users.where("user_id = #{params[:user_id]}").first homework_user.destroy get_homework_member @homework @@ -73,7 +73,7 @@ class HomeworkAttachController < ApplicationController def create bid = Bid.find params[:bid_id] - if User.current.admin? || User.current.member_of?(bid.courses.first) + if User.current.admin? || User.current.member_of_course?(bid.courses.first) # modify by nwb if bid.homeworks.where("user_id = ?",User.current).count == 0 user_id = params[:user_id] bid_id = params[:bid_id] @@ -97,7 +97,7 @@ class HomeworkAttachController < ApplicationController if @homework.save respond_to do |format| - format.html { redirect_to project_for_bid_path @homework.bid } + format.html { redirect_to course_for_bid_path @homework.bid } format.json { head :no_content } end else @@ -113,7 +113,7 @@ class HomeworkAttachController < ApplicationController def new @bid = Bid.find(params[:id]) - if User.current.admin? || User.current.member_of?(@bid.courses.first) + if User.current.admin? || User.current.member_of_course?(@bid.courses.first) #nwb #该课程的学生的集合(新建不实现功能:添加成员) #@members = @bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and user_id <> #{User.current.id}", {:role_id => [5, 10]}) @@ -138,7 +138,7 @@ class HomeworkAttachController < ApplicationController def get_homework_member_list @homework = HomeworkAttach.find(params[:bid_id]) course = @homework.bid.courses.first - if User.current.admin? || User.current.member_of?(course) + if User.current.admin? || User.current.member_of_course?(course) get_homework_member @homework else raise "error" @@ -163,7 +163,7 @@ class HomeworkAttachController < ApplicationController def edit #@homework = HomeworkAttach.find(params[:id]) - if User.current.admin? || User.current.member_of?(@homework.bid.courses.first) + if User.current.admin? || User.current.member_of_course?(@homework.bid.courses.first) #@members = @homework.bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => [5, 10]}) get_homework_member @homework else @@ -174,7 +174,7 @@ class HomeworkAttachController < ApplicationController def update #@homework = HomeworkAttach.find(params[:id]) course = @homework.bid.courses.first - if User.current.admin? || User.current.member_of?(course) + if User.current.admin? || User.current.member_of_course?(course) name = params[:homework_name] description = params[:homework_description] @homework.name = name @@ -184,7 +184,7 @@ class HomeworkAttachController < ApplicationController end if @homework.save respond_to do |format| - format.html { redirect_to project_for_bid_path @homework.bid } + format.html { redirect_to course_for_bid_path @homework.bid } format.json { head :no_content } end else @@ -199,7 +199,7 @@ class HomeworkAttachController < ApplicationController if User.current.admin? || User.current == @homework if @homework.destroy respond_to do |format| - format.html { redirect_to project_for_bid_path @homework.bid } + format.html { redirect_to course_for_bid_path @homework.bid } format.json { head :no_content } end else @@ -212,7 +212,7 @@ class HomeworkAttachController < ApplicationController #显示作业信息 def show #@homework = HomeworkAttach.find(params[:id]) - if User.current.admin? || User.current.member_of?(@homework.bid.courses.first) + if User.current.admin? || User.current.member_of_course?(@homework.bid.courses.first) # 打分统计 stars_reates = @homework. rates(:quality) diff --git a/app/models/bid.rb b/app/models/bid.rb index b36efe6f..f65d71fa 100644 --- a/app/models/bid.rb +++ b/app/models/bid.rb @@ -21,7 +21,7 @@ class Bid < ActiveRecord::Base belongs_to :author, :class_name => 'User', :foreign_key => :author_id belongs_to :course has_many :biding_projects, :dependent => :destroy - has_many :courses, :through => :biding_courses + has_many :projects, :through => :biding_projects has_many :courses_member, :class_name => 'User', :through => :courses has_many :journals_for_messages, :as => :jour, :dependent => :destroy has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy diff --git a/app/views/bids/show_course.html.erb b/app/views/bids/show_course.html.erb index 574bd117..aacc011e 100644 --- a/app/views/bids/show_course.html.erb +++ b/app/views/bids/show_course.html.erb @@ -8,10 +8,10 @@
      - @@ -22,10 +22,9 @@

      - +
      <%= link_to_project(course) %> - <%= l(:label_homework) %> (<%= link_to (course.homeworks.count), {:controller => 'projects', :action => 'homework', :id => course.identifier} %>) + <%= link_to_course(course) %> + <%= l(:label_homework) %> (<%= link_to (course.homeworks.count), {:controller => 'courses', :action => 'homework', :id => course.id} %>)     - <%= l(:label_course_news)%> (<%= link_to (course.news.count), {:controller => 'news', :action => 'index', :project_id => course.identifier} %>) + <%= l(:label_course_news)%> (<%= link_to (course.news.count), {:controller => 'news', :action => 'index', :course_id => course.id} %>)
      <%= format_time(course.created_on) %> <%= format_time(course.created_at) %> - <% t_course = Course.find_by_extra(course.identifier) %> - 教师:<%= link_to(t_course.teacher.lastname+t_course.teacher.firstname, user_path(t_course.teacher)) %> + 教师:<%= link_to(course.teacher.lastname+course.teacher.firstname, user_path(course.teacher)) %>
      + + +
      +
      + + + <% if @bid.reward_type == Bid::Homework %> + + + + <% else %> + + + + <% end %> + + + +
      <%= select_tag 'bid', options_for_select(select_option_helper(@option)), :name => 'bid', :class => 'grayline' %> + +
      + <%= link_to '创建项目', new_project_path(course: 0, project_type: 0), :target => '_blank' %> +
      +
      <%= f.text_area :bid_message, :id => "bid_message", :required => true, :rows => 4, :cols => 40, :placeholder => l(:label_bid_reason_homework), :style => "resize: none;", :class => 'noline' %>
      <%= f.text_area :bid_message, :id => "bid_message", :required => true, :rows => 4, :cols => 40, :placeholder => l(:label_bid_reason), :style => "resize: none;", :class => 'noline' %>
      + <%= submit_tag l(:button_add), :name => nil, :class => "enterprise", + :onmouseout => "this.style.backgroundPosition = 'left top'", + :onmouseover => "this.style.backgroundPosition = 'left -30px'" %> + <%= submit_tag l(:button_cancel), :name => nil, :onclick => "cancel();", + :type => 'button', :class => "enterprise", :onmouseout => "this.style.backgroundPosition = 'left top'", + :onmouseover => "this.style.backgroundPosition = 'left -30px'" %> +
      + <% end %> +
      + <% end %> +
      + <%= render :partial => 'project_list', :locals => {:bidding_project => @bidding_project, :bid => @bid} %> +
      +<% end %> + diff --git a/app/views/homework_attach/new.html.erb b/app/views/homework_attach/new.html.erb index 618fc15a..99fce0f4 100644 --- a/app/views/homework_attach/new.html.erb +++ b/app/views/homework_attach/new.html.erb @@ -6,9 +6,9 @@ - <%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%> -

      <%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> > - <%= link_to(@bid.courses.first.name.to_s, homework_project_path(@bid.courses.first)) if @bid.courses.first%> > + <%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index'%> +

      <%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'courses', :action => 'index' %> > + <%= link_to(@bid.courses.first.name.to_s, homework_course_path(@bid.courses.first)) if @bid.courses.first%> > <%=link_to(@bid.name, respond_path(@bid)) %> > <%= link_to "创建作业", new_homework_attach_path(@bid)%>

      diff --git a/config/routes.rb b/config/routes.rb index 3ee5d777..47a2a69f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -633,7 +633,7 @@ RedmineApp::Application.routes.draw do match 'calls/new_bid', :controller => 'bids', :action => 'new_bid' match 'contest/new_contest', :controller => 'bids', :action => 'new_contest' #huang match 'calls/:id/show_project', :controller => 'bids', :action => 'show_project', :as => 'project_for_bid' - match 'calls/:id/show_course', :controller => 'bids', :action => 'show_course', :as => 'course_for_bid' # nwb added + match 'calls/:id/show_course', :controller => 'bids', :action => 'show_courseEx', :as => 'course_for_bid' # nwb added match 'calls/:id/new_exercise_book', :controller => 'homework_attach', :action => 'new', :as => 'new_homework_attach' match 'calls/:id/add', :controller => 'bids', :action => 'add' match 'calls/:id/delete', :controller => 'bids', :action => 'delete' From b76f1c2b12ae33af963516faa07abcc7332d205b Mon Sep 17 00:00:00 2001 From: yanxd Date: Tue, 17 Jun 2014 15:16:17 +0800 Subject: [PATCH 081/183] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=B2=89=E4=B8=9D=E5=88=97=E8=A1=A8=E5=87=BA=E9=94=99?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/user_fanslist.html.erb | 103 +++++++++++++------------ 1 file changed, 55 insertions(+), 48 deletions(-) diff --git a/app/views/users/user_fanslist.html.erb b/app/views/users/user_fanslist.html.erb index 3247c67a..fb1a6d0d 100644 --- a/app/views/users/user_fanslist.html.erb +++ b/app/views/users/user_fanslist.html.erb @@ -1,51 +1,58 @@ -

      <%= l(:label_x_user_fans, :count => User.current.watcher_users(User.current.id).count)%>

      +

      <%= l(:label_x_user_fans, :count => User.current.watcher_users(User.current.id).count) %>

      - <% for user in @user.watcher_users %> -
      • - - - - - -
        <%= link_to image_tag(url_to_avatar(user), :class => "avatar"), - user_path(user), - :title => "#{user.name}" %> - - - - - - - - - - - - - -
        <%= content_tag "div", link_to(user.name,user_path(user)), :class => "project_avatar_name" %> -

        - <% unless user.memberships.empty? %> - <% cond = Project.visible_condition(User.current) + "AND projects.project_type <> 1" %> - <% memberships = user.memberships.all(:conditions => cond) %> - <%= l(:label_x_contribute_to, :count => memberships.count) %> - <% for member in memberships %> - <%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %> - <% end %> - <% end %> -

        -

        - <% unless user.memberships.empty? %> - <% cond = Project.visible_condition(User.current) + "AND projects.project_type = 1" %> - <% memberships = user.memberships.all(:conditions => cond) %> - <%= l(:label_x_course_contribute_to, :count => memberships.count) %> - <% for member in memberships %> - <%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %> - <% end %> - <% end %> -

        -
        <%= l(:label_user_joinin) %><%= format_date(user.created_on) %> -
      -<% end %> + <% for user in @user.watcher_users %> +
        +
      • + + + + + +
        <%= link_to image_tag(url_to_avatar(user), :class => "avatar"), + user_path(user), + :title => "#{user.name}" %> + + + + + + + + + + + + + + +
        + <%= content_tag "div", link_to(user.name, user_path(user)), :class => "project_avatar_name" %> +

        + <% unless user.memberships.empty? %> + <% cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" %> + <% memberships = user.memberships.all(:conditions => cond) %> + <%= l(:label_x_contribute_to, :count => memberships.count) %> + <% for member in memberships %> + <%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %> + <% end %> + <% end %> +

        + +

        + <% unless user.memberships.empty? %> + <% cond = Project.visible_condition(User.current) + " AND projects.project_type = 1" %> + <% memberships = user.memberships.all(:conditions => cond) %> + <%= l(:label_x_course_contribute_to, :count => memberships.count) %> + <% for member in memberships %> + <%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %> + <% end %> + <% end %> +

        +
        <%= l(:label_user_joinin) %><%= format_date(user.created_on) %> +
        +
        +
      • +
      + <% end %>
      \ No newline at end of file From ec72bb2904098cd41def4176e8001247d3db1251 Mon Sep 17 00:00:00 2001 From: nwb Date: Tue, 17 Jun 2014 15:17:04 +0800 Subject: [PATCH 082/183] =?UTF-8?q?=E7=BC=96=E8=BE=91=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 4 ++-- app/controllers/zipdown_controller.rb | 2 +- app/views/bids/_homework_list.html.erb | 2 +- app/views/homework_attach/edit.html.erb | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 9c4d8cfa..1862c782 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -972,9 +972,9 @@ class BidsController < ApplicationController def memberAccess # 是课程,则判断当前用户是否参加了课程 return true if current_user.admin? - return 0 if @bid.courses.first.project_type == Project::ProjectType_project + #return 0 if @bid.courses.first.project_type == Project::ProjectType_project currentUser = User.current - render_403 unless currentUser.member_of?(@bid.courses.first) + render_403 unless currentUser.member_of_cousrse?(@bid.courses.first) end end diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 808df65d..df57e4f4 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -37,7 +37,7 @@ class ZipdownController < ApplicationController #下载某一学生的作业的所有文件 def download_user_homework homework = HomeworkAttach.find params[:homework] - if homework != nil && (User.current.admin? || User.current.member_of?(homework.bid.courses.first)) + if homework != nil && (User.current.admin? || User.current.member_of_course?(homework.bid.courses.first)) zipfile = zip_homework_by_user homework send_file zipfile, :filename => homework.name, :type => detect_content_type(zipfile) if zipfile else diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 18778f5e..ec15b890 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -3,7 +3,7 @@ <% is_teacher = is_course_teacher User.current,@bid.courses.first %> <% is_evaluation = @bid.is_evaluation == 1 || @bid.is_evaluation == nil %> -<%= form_tag(:controller => 'bids', :action => "show_project", :method => :get) do %> +<%= form_tag(:controller => 'bids', :action => "show_courseEx", :method => :get) do %>
      diff --git a/app/views/homework_attach/edit.html.erb b/app/views/homework_attach/edit.html.erb index f7104840..b530e606 100644 --- a/app/views/homework_attach/edit.html.erb +++ b/app/views/homework_attach/edit.html.erb @@ -16,9 +16,9 @@ - - +
      <%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%>

      <%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> > - <%= link_to(@homework.bid.courses.first.name.to_s, homework_project_path(@homework.bid.courses.first)) if @homework.bid.courses.first%> > +

      <%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index'%>

      <%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'courses', :action => 'index' %> > + <%= link_to(@homework.bid.courses.first.name.to_s, homework_course_path(@homework.bid.courses.first)) if @homework.bid.courses.first%> > <%=link_to(@homework.bid.name, respond_path(@homework.bid)) %> > <%= link_to "修改作业",edit_homework_attach_path(@homework)%>

      From 0de6cc8a31c536aa13d4b73eee4f1279a002de39 Mon Sep 17 00:00:00 2001 From: nwb Date: Tue, 17 Jun 2014 15:20:39 +0800 Subject: [PATCH 083/183] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=9F=BA=E7=A1=80=E8=A7=86=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_base_homework_attach.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/layouts/_base_homework_attach.html.erb b/app/views/layouts/_base_homework_attach.html.erb index 6b020d80..7e609774 100644 --- a/app/views/layouts/_base_homework_attach.html.erb +++ b/app/views/layouts/_base_homework_attach.html.erb @@ -6,9 +6,9 @@ - <%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%> -

      <%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> > - <%= link_to(homework_attach.bid.courses.first.name.to_s, homework_project_path(homework_attach.bid.courses.first)) if homework_attach.bid.courses.first%> > + <%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index'%> +

      <%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'courses', :action => 'index' %> > + <%= link_to(homework_attach.bid.courses.first.name.to_s, homework_course_path(homework_attach.bid.courses.first)) if homework_attach.bid.courses.first%> > <%=link_to(homework_attach.bid.name, respond_path(homework_attach.bid)) %> > <%= link_to homework_attach.name.nil? ? homework_attach.attachments.first.filename : homework_attach.name,homework_attach_path(homework_attach)%>

      From 726697a69bfae661234851587a5c590836ffea9a Mon Sep 17 00:00:00 2001 From: nwb Date: Tue, 17 Jun 2014 15:31:33 +0800 Subject: [PATCH 084/183] =?UTF-8?q?BUG=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 2922eea1..311d9c1a 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -196,7 +196,7 @@ class HomeworkAttachController < ApplicationController def destroy #@homework = HomeworkAttach.find(params[:id]) - if User.current.admin? || User.current == @homework + if User.current.admin? || User.current == @homework.user if @homework.destroy respond_to do |format| format.html { redirect_to course_for_bid_path @homework.bid } From 50dbe3d04a13e0bd47c251b731771317153ed757 Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 17 Jun 2014 15:57:31 +0800 Subject: [PATCH 085/183] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=BE=97=E5=88=86=E5=8F=98=E5=8C=96=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 2 +- app/models/changeset.rb | 8 ++- app/models/document.rb | 6 +-- app/models/issue.rb | 18 ++++--- app/models/journal.rb | 8 +-- app/models/journals_for_message.rb | 8 +-- app/models/memo.rb | 13 ++--- app/models/message.rb | 12 ++--- app/models/praise_tread.rb | 10 ++-- app/models/user_score.rb | 80 ++++++++++++++++++++++-------- app/models/watcher.rb | 8 +-- db/schema.rb | 38 +++++++++++++- 12 files changed, 143 insertions(+), 68 deletions(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index b2a7cfb0..66d1553e 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -370,7 +370,7 @@ class Attachment < ActiveRecord::Base type = self.container_type types = %w|Document News Version Project Issue Message WikiPage| if types.include?(type) - UserScore.project(:push_file, User.current, { attachment_id: self.id }) + UserScore.project(:push_file, User.current,self, { attachment_id: self.id }) end end end diff --git a/app/models/changeset.rb b/app/models/changeset.rb index 36f78d32..6c22455a 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -19,7 +19,7 @@ class Changeset < ActiveRecord::Base belongs_to :repository belongs_to :user - after_save :be_user_score # user_score + #after_save :be_user_score # user_score has_many :filechanges, :class_name => 'Change', :dependent => :delete_all # fq @@ -63,7 +63,7 @@ class Changeset < ActiveRecord::Base includes(:repository => :project).where(Project.allowed_to_condition(args.shift || User.current, :view_changesets, *args)) } - after_create :scan_for_issues + after_create :scan_for_issues,:be_user_score # user_score before_create :before_create_cs # fq @@ -300,11 +300,9 @@ class Changeset < ActiveRecord::Base # update user score def be_user_score - if self.new_record? - UserScore.project(:push_code, self.user, { changeset_id: self.id }) + UserScore.project(:push_code, self.user,self, { changeset_id: self.id }) #更新用户等级 self.user.update_user_level - end end end diff --git a/app/models/document.rb b/app/models/document.rb index 3710e6eb..7c273068 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -21,7 +21,7 @@ class Document < ActiveRecord::Base belongs_to :user belongs_to :category, :class_name => "DocumentCategory", :foreign_key => "category_id" - before_save :be_user_score # user_score + after_create :be_user_score # user_score acts_as_attachable :delete_permission => :delete_documents @@ -62,8 +62,6 @@ class Document < ActiveRecord::Base # update user score def be_user_score - if self.new_record? - UserScore.project(:push_document, self.user, { document_id: self.id }) - end + UserScore.project(:push_document, self.user,self,{ document_id: self.id }) end end diff --git a/app/models/issue.rb b/app/models/issue.rb index 6cfa9b7e..a9b3e357 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -76,8 +76,8 @@ class Issue < ActiveRecord::Base attr_reader :current_journal # fq - after_create :act_as_activity - before_save :be_user_score + after_create :act_as_activity,:be_user_score_new_issue + after_update :be_user_score # after_create :be_user_score # end @@ -1489,14 +1489,18 @@ class Issue < ActiveRecord::Base # update user score def be_user_score - if self.new_record? - UserScore.project(:post_issue, User.current, { issue_id: self.id }) - elsif self.done_ratio_changed? - UserScore.project(:update_issue_ratio, User.current, { issue_id: self.id }) + #缺陷完成度更新 + if self.done_ratio_changed? + UserScore.project(:update_issue_ratio, User.current,self,{ issue_id: self.id }) #缺陷状态更改 elsif self.status_id_changed? #协同得分 - UserScore.joint(:change_issue_status, User.current,nil, {issue_id: self.id}) + UserScore.joint(:change_issue_status, User.current,nil,self, {issue_id: self.id}) end end + + #发布缺陷 + def be_user_score_new_issue + UserScore.project(:post_issue, User.current,self, { issue_id: self.id }) + end end diff --git a/app/models/journal.rb b/app/models/journal.rb index b0e1e9d0..8027f18a 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -45,10 +45,10 @@ class Journal < ActiveRecord::Base before_create :split_private_notes # fq - after_create :act_as_activity + after_create :act_as_activity,:be_user_score # end - before_save :be_user_score + #before_save :be_user_score #before_destroy :down_user_score scope :visible, lambda {|*args| @@ -158,9 +158,9 @@ class Journal < ActiveRecord::Base # 更新用户分数 -by zjc def be_user_score #新建了缺陷留言且留言不为空,不为空白 - if self.new_record? && !self.notes.nil? && self.notes.gsub(' ','') != '' + if !self.notes.nil? && self.notes.gsub(' ','') != '' #协同得分加分 - UserScore.joint(:post_issue_message, User.current,self.issue.author, { message_id: self.id }) + UserScore.joint(:post_issue_message, User.current,self.issue.author,self, { message_id: self.id }) end end # 减少用户分数 -by zjc diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index cba605af..967511be 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -40,9 +40,9 @@ class JournalsForMessage < ActiveRecord::Base validates :notes, presence: true after_create :act_as_activity #huang - after_create :reset_counters! + after_create :reset_counters!,:be_user_score after_destroy :reset_counters! - before_save :be_user_score + #before_save :be_user_score #before_destroy :down_user_score # default_scope { where('m_parent_id IS NULL') } @@ -105,9 +105,9 @@ class JournalsForMessage < ActiveRecord::Base # 更新用户分数 -by zjc def be_user_score #新建了留言回复 - if self.new_record? && self.reply_id != 0 + if self.reply_id != 0 #协同得分加分 - UserScore.joint(:reply_message, User.current,User.find(self.reply_id), { journals_for_messages_id: self.id }) + UserScore.joint(:reply_message, User.current,User.find(self.reply_id),self, { journals_for_messages_id: self.id }) end end # 更新用户分数 -by zjc diff --git a/app/models/memo.rb b/app/models/memo.rb index d706f814..1e857a22 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -12,6 +12,7 @@ class Memo < ActiveRecord::Base acts_as_tree :counter_cache => :replies_count, :order => "#{Memo.table_name}.created_at ASC" acts_as_attachable + has_many :user_score_details, :class_name => 'UserScoreDetails',:as => :score_changeable_obj belongs_to :last_reply, :class_name => 'Memo', :foreign_key => 'last_reply_id' # acts_as_searchable :column => ['subject', 'content'], # #:include => { :forum => :p} @@ -40,13 +41,13 @@ class Memo < ActiveRecord::Base "parent_id", "replies_count" - after_create :add_author_as_watcher, :reset_counters! + after_create :add_author_as_watcher, :reset_counters!,:be_user_score # after_update :update_memos_forum after_destroy :reset_counters! # after_create :send_notification # after_save :plusParentAndForum # after_destroy :minusParentAndForum - before_save :be_user_score + #before_save :be_user_score # scope :visible, lambda { |*args| # includes(:forum => ).where() # } @@ -145,11 +146,11 @@ class Memo < ActiveRecord::Base #更新用户分数 -by zjc def be_user_score #新建memo且无parent的为发帖 - if self.new_record? && self.parent_id.nil? - UserScore.joint(:post_message, User.current,nil, { memo_id: self.id }) + if self.parent_id.nil? + UserScore.joint(:post_message, User.current,nil,self ,{ memo_id: self.id }) #新建memo且有parent的为回帖 - elsif self.new_record? && !self.parent_id.nil? - UserScore.joint(:reply_posting, User.current,self.parent.author, { memo_id: self.id }) + elsif !self.parent_id.nil? + UserScore.joint(:reply_posting, User.current,self.parent.author,self, { memo_id: self.id }) end end diff --git a/app/models/message.rb b/app/models/message.rb index e778977f..4d35d003 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -53,8 +53,8 @@ class Message < ActiveRecord::Base after_destroy :reset_counters! # fq - after_create :act_as_activity - before_save :be_user_score + after_create :act_as_activity,:be_user_score + #before_save :be_user_score #before_destroy :down_user_score # end @@ -127,11 +127,11 @@ class Message < ActiveRecord::Base #更新用户分数 -by zjc def be_user_score #新建message且无parent的为发帖 - if self.new_record? && self.parent_id.nil? - UserScore.joint(:post_message, User.current,nil, { message_id: self.id }) + if self.parent_id.nil? + UserScore.joint(:post_message, User.current,nil,self, { message_id: self.id }) #新建message且有parent的为回帖 - elsif self.new_record? && !self.parent_id.nil? - UserScore.joint(:reply_posting, User.current,self.parent.author, { message_id: self.id }) + elsif !self.parent_id.nil? + UserScore.joint(:reply_posting, User.current,self.parent.author,self, { message_id: self.id }) end end #减少用户分数 diff --git a/app/models/praise_tread.rb b/app/models/praise_tread.rb index 11d68157..b18b569d 100644 --- a/app/models/praise_tread.rb +++ b/app/models/praise_tread.rb @@ -2,7 +2,7 @@ class PraiseTread < ActiveRecord::Base attr_accessible :user_id,:praise_tread_object_id,:praise_tread_object_type,:praise_or_tread belongs_to :user belongs_to :praise_tread_object, polymorphic: true - before_save :be_user_score + after_create :be_user_score def self.find_object_by_type_and_id(type,id) @obj = nil @@ -28,15 +28,15 @@ class PraiseTread < ActiveRecord::Base #更新用户分数 - by zjc def be_user_score #踩贴吧或讨论区帖子 - if self.new_record? && self.praise_or_tread == 0 && (self.praise_tread_object_type == 'Memo' || self.praise_tread_object_type == 'Message') + if self.praise_or_tread == 0 && (self.praise_tread_object_type == 'Memo' || self.praise_tread_object_type == 'Message') obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id) target_user = obj.author - UserScore.skill(:treaded_by_user, User.current,target_user, { praise_tread_id: self.id }) + UserScore.skill(:treaded_by_user, User.current,target_user,self, { praise_tread_id: self.id }) #顶贴吧或讨论区帖子 - elsif self.new_record? && self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Memo' || self.praise_tread_object_type == 'Message') + elsif self.praise_or_tread == 1 && (self.praise_tread_object_type == 'Memo' || self.praise_tread_object_type == 'Message') obj = PraiseTread.find_object_by_type_and_id(self.praise_tread_object_type,praise_tread_object_id) target_user = obj.author - UserScore.skill(:praised_by_user, User.current,target_user,{ praise_tread_id: self.id }) + UserScore.skill(:praised_by_user, User.current,target_user,self,{ praise_tread_id: self.id }) #更新用户等级 target_user.update_user_level end diff --git a/app/models/user_score.rb b/app/models/user_score.rb index 6d582919..0e355b79 100644 --- a/app/models/user_score.rb +++ b/app/models/user_score.rb @@ -48,46 +48,51 @@ class UserScore < ActiveRecord::Base # # => true #当前用户发帖计分操作成功 # # Returns boolean. 返回积分保存结果 - def self.joint(operate, current_user, target_user, options={}) + def self.joint(operate, current_user, target_user,obj, options={}) current_user, target_user = get_users(current_user, target_user) user_score = current_user.user_score_attr case operate when :post_message # current_user 发帖了 Add Message user_score.collaboration = user_score.collaboration.to_i + 2 user_score.save + create_score_changed_details({:current_user_id => current_user.id ,:score_type => "collaboration",:score_action => "post_message",:user_id => current_user.id,:old_score => user_score.collaboration - 2,:new_score => user_score.collaboration,:current_user_level => current_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a message. options => (#{options.to_s})" - when :delete_message # current_user 发帖了 Delete Message - user_score.collaboration = user_score.collaboration.to_i - 2 - user_score.save - Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a message. options => (#{options.to_s})" + #when :delete_message # current_user 删帖了 Delete Message + # user_score.collaboration = user_score.collaboration.to_i - 2 + # user_score.save + # Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a message. options => (#{options.to_s})" when :post_issue_message # current_user 对 target_user 的缺陷留言了 Add Journal user_score.collaboration = user_score.collaboration.to_i + 1 user_score.save + create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "collaboration",:score_action => "post_issue_message",:user_id => current_user.id,:old_score => user_score.collaboration - 1,:new_score => user_score.collaboration,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a issue. options => (#{options.to_s})" - when :delete_issue_message # current_user 删除了 对 target_user 的缺陷留言了 Delete Journal - user_score.collaboration = user_score.collaboration.to_i - 1 - user_score.save - Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a issue. options => (#{options.to_s})" + #when :delete_issue_message # current_user 删除了 对 target_user 的缺陷留言了 Delete Journal + # user_score.collaboration = user_score.collaboration.to_i - 1 + # user_score.save + # Rails.logger.info "[UserScore#joint] ===> User: #{current_user} deleting a issue. options => (#{options.to_s})" when :change_issue_status # current_user 更改了缺陷的状态 Changed Issue user_score.collaboration = user_score.collaboration.to_i + 1 user_score.save + create_score_changed_details({:current_user_id => current_user.id , :score_type => "collaboration",:score_action => "change_issue_status",:user_id => current_user.id,:old_score => user_score.collaboration - 1,:new_score => user_score.collaboration,:current_user_level => current_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) Rails.logger.info "[UserScore#joint] ===> User: #{current_user} change issue status. options => (#{options.to_s})" when :reply_message # current_user 对 target_user 留言的回复 Add Journals_for_messages user_score.collaboration = user_score.collaboration.to_i + 1 user_score.save + create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "collaboration",:score_action => "reply_message",:user_id => current_user.id,:old_score => user_score.collaboration - 1,:new_score => user_score.collaboration,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply message. options => (#{options.to_s})" - when :reply_message_delete # current_user 删除了对 target_user 留言的回复 delete Journals_for_messages - user_score.collaboration = user_score.collaboration.to_i - 1 - user_score.save - Rails.logger.info "[UserScore#joint] ===> User: #{current_user} delete reply message. options => (#{options.to_s})" + #when :reply_message_delete # current_user 删除了对 target_user 留言的回复 delete Journals_for_messages + # user_score.collaboration = user_score.collaboration.to_i - 1 + # user_score.save + # Rails.logger.info "[UserScore#joint] ===> User: #{current_user} delete reply message. options => (#{options.to_s})" when :reply_posting # current_user 对 target_user 帖子的回复 Add Message user_score.collaboration = user_score.collaboration.to_i + 1 user_score.save + create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "collaboration",:score_action => "reply_posting",:user_id => current_user.id,:old_score => user_score.collaboration - 1,:new_score => user_score.collaboration,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply posting. options => (#{options.to_s})" - when :reply_deleting # current_user 删除了 对 target_user 帖子的回复 Delete Message - user_score.collaboration = user_score.collaboration.to_i - 1 - user_score.save - Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply deleting. options => (#{options.to_s})" + #when :reply_deleting # current_user 删除了 对 target_user 帖子的回复 Delete Message + # user_score.collaboration = user_score.collaboration.to_i - 1 + # user_score.save + # Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply deleting. options => (#{options.to_s})" else Rails.logger.error "[UserScore#joint] ===> #{operate} is not define." return false @@ -106,17 +111,19 @@ class UserScore < ActiveRecord::Base # # => true #当前被关注用户记分成功 # # Returns boolean. 返回积分保存结果 - def self.influence(operate, current_user, target_user, options={}) + def self.influence(operate, current_user, target_user,obj, options={}) current_user, target_user = get_users(current_user, target_user) user_score = target_user.user_score_attr case operate when :followed_by # current_user 关注了target_user Add watcher user_score.influence = user_score.influence.to_i + 2 user_score.save + create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "influence",:score_action => "followed_by",:user_id => target_user.id,:old_score => user_score.influence - 2,:new_score => user_score.influence,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) Rails.logger.info "[UserScore#influence] ===> User: #{current_user} be followed. options => (#{options.to_s})" when :cancel_followed # current_uer 取消了对 target_user的关注 delete watcher user_score.influence = user_score.influence.to_i - 2 user_score.save + create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "influence",:score_action => "cancel_followed",:user_id => target_user.id,:old_score => user_score.influence + 2,:new_score => user_score.influence,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) Rails.logger.info "[UserScore#influence] ===> User: #{current_user} canceled followed. options => (#{options.to_s})" else Rails.logger.error "[UserScore#influence] ===> #{operate} is not define." @@ -136,7 +143,7 @@ class UserScore < ActiveRecord::Base # # => true #当前current_user对target_user用户帖子的记分成功 # # Returns boolean. 返回积分保存结果 - def self.skill(operate, current_user, target_user, options={}) + def self.skill(operate, current_user, target_user,obj, options={}) current_user, target_user = get_users(current_user, target_user) current_user_score = current_user.user_score_attr target_user_score = target_user.user_score_attr @@ -146,6 +153,7 @@ class UserScore < ActiveRecord::Base when :treaded_by_user # current_user 踩了 target_user 的帖子 current_user_score.skill = current_user_score.skill.to_i - 2 #踩别人的帖子减2分 add praise_tread current_user_score.save + create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "skill",:score_action => "treaded_by_user",:user_id => current_user.id,:old_score => current_user_score.skill + 2,:new_score => current_user_score.skill,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) if current_user.id == target_user.id target_user.reload target_user_score = target_user.user_score_attr @@ -154,12 +162,15 @@ class UserScore < ActiveRecord::Base if level == 1 target_user_score.skill = target_user_score.skill.to_i - 2 #帖子被一级会员踩-2分 add praise_tread target_user_score.save + create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "skill",:score_action => "treaded_by_user",:user_id => target_user.id,:old_score => target_user_score.skill + 2,:new_score => target_user_score.skill,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) elsif level == 2 target_user_score.skill = target_user_score.skill.to_i - 4 #帖子被二级会员踩-4分 add praise_tread target_user_score.save + create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "skill",:score_action => "treaded_by_user",:user_id => target_user.id,:old_score => target_user_score.skill + 4,:new_score => target_user_score.skill,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) elsif level == 3 target_user_score.skill = target_user_score.skill.to_i - 6 #帖子被三级会员踩-6分 add praise_tread target_user_score.save + create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "skill",:score_action => "treaded_by_user",:user_id => target_user.id,:old_score => target_user_score.skill + 6,:new_score => target_user_score.skill,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) end Rails.logger.info "[UserScore#skill] ===> User: #{current_user} treaded_by #{target_user}. options => (#{options.to_s})" @@ -168,14 +179,16 @@ class UserScore < ActiveRecord::Base if level == 1 target_user_score.skill = target_user_score.skill.to_i + 4 #帖子被一级会员顶+4分 add praise_tread target_user_score.save + create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "skill",:score_action => "praised_by_user",:user_id => target_user.id,:old_score => target_user_score.skill - 4,:new_score => target_user_score.skill,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) elsif level == 2 target_user_score.skill = target_user_score.skill.to_i + 6 #帖子被二级会员顶+6分 add praise_tread target_user_score.save + create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "skill",:score_action => "praised_by_user",:user_id => target_user.id,:old_score => target_user_score.skill - 6,:new_score => target_user_score.skill,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) elsif level == 3 target_user_score.skill = target_user_score.skill.to_i + 8 #帖子被三级会员顶+8分 add praise_tread target_user_score.save + create_score_changed_details({:current_user_id => current_user.id ,:target_user_id =>target_user.id, :score_type => "skill",:score_action => "praised_by_user",:user_id => target_user.id,:old_score => target_user_score.skill - 8,:new_score => target_user_score.skill,:current_user_level => current_user.get_level,:target_user_level => target_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) end - Rails.logger.info "[UserScore#skill] ===> User: #{current_user} praised_by #{target_user}. options => (#{options.to_s})" else Rails.logger.error "[UserScore#skill] ===> #{operate} is not define." @@ -195,7 +208,7 @@ class UserScore < ActiveRecord::Base # # => true #当前current_user对项目贡献积分成功 # # Returns boolean. 返回积分保存结果 - def self.project(operate, current_user, options={}) + def self.project(operate, current_user,obj, options={}) current_user, target_user = get_users(current_user, nil) user_score = current_user.try(:user_score_attr) return false if current_user.nil? @@ -203,22 +216,27 @@ class UserScore < ActiveRecord::Base when :push_code # current_user 提交了代码 changeset user_score = user_score.active.to_i + 4 user_score.save + create_score_changed_details({:current_user_id => current_user.id , :score_type => "active",:score_action => "push_code",:user_id => current_user.id,:old_score => user_score.active - 4,:new_score => user_score.active,:current_user_level => current_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] pushed code one time. options => (#{options.to_s})" when :push_document # current_user 提交了文档 document user_score.active = user_score.active.to_i + 4 user_score.save + create_score_changed_details({:current_user_id => current_user.id , :score_type => "active",:score_action => "push_document",:user_id => current_user.id,:old_score => user_score.active - 4,:new_score => user_score.active,:current_user_level => current_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] pushed a document. options => (#{options.to_s})" when :push_file # current_user 提交了附件 attachment user_score.active = user_score.active.to_i + 4 user_score.save + create_score_changed_details({:current_user_id => current_user.id , :score_type => "active",:score_action => "push_file",:user_id => current_user.id,:old_score => user_score.active - 4,:new_score => user_score.active,:current_user_level => current_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] pushed a file. options => (#{options.to_s})" when :update_issue_ratio # current_user 更新了缺陷完成度 issue user_score.active = user_score.active.to_i + 2 user_score.save + create_score_changed_details({:current_user_id => current_user.id , :score_type => "active",:score_action => "update_issue_ratio",:user_id => current_user.id,:old_score => user_score.active - 2,:new_score => user_score.active,:current_user_level => current_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] updated issue ratio. options => (#{options.to_s})" when :post_issue # current_user 发布了缺陷 issue user_score.active = user_score.active.to_i + 4 user_score.save + create_score_changed_details({:current_user_id => current_user.id , :score_type => "active",:score_action => "post_issue",:user_id => current_user.id,:old_score => user_score.active - 4,:new_score => user_score.active,:current_user_level => current_user.get_level,:score_changeable_obj_id=> obj.id,:score_changeable_obj_type => obj.class.to_s}) Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] posting issue. options => (#{options.to_s})" else Rails.logger.error "[UserScore#project] ===> #{operate} is not define." @@ -234,6 +252,26 @@ class UserScore < ActiveRecord::Base score end + #创建分数改变记录 -by zjc + def self.create_score_changed_details(attributes) + if attributes.is_a? Hash + usd = UserScoreDetails.new + usd.current_user_id =attributes[:current_user_id] + usd.target_user_id = attributes[:target_user_id] + usd.score_type = attributes[:score_type] + usd.score_action = attributes[:score_action] + usd.user_id = attributes[:user_id] + usd.old_score = attributes[:old_score] + usd.new_score = attributes[:new_score] + usd.current_user_level = attributes[:current_user_level] + usd.target_user_level = attributes[:target_user_level] + #usd.score_changeable_obj = attributes[:score_changeable_obj] + usd.score_changeable_obj_id = attributes[:score_changeable_obj_id] + usd.score_changeable_obj_type = attributes[:score_changeable_obj_type] + usd.save + end + end + private def self.get_users(current_user, target_user) diff --git a/app/models/watcher.rb b/app/models/watcher.rb index 88f23900..e2e255a1 100644 --- a/app/models/watcher.rb +++ b/app/models/watcher.rb @@ -22,7 +22,7 @@ class Watcher < ActiveRecord::Base has_one :project_status has_one :users_status #end - before_save :be_user_score + after_create :be_user_score before_destroy :down_user_score validates_presence_of :user @@ -76,9 +76,9 @@ class Watcher < ActiveRecord::Base # 更新用户分数 -by zjc def be_user_score #添加了关注 - if self.new_record? && self.watchable_type == 'Principal' + if self.watchable_type == 'Principal' #影响力得分 - UserScore.influence(:followed_by, self.user,self.watchable, { watcher_id: self.id }) + UserScore.influence(:followed_by, self.user,self.watchable,self, { watcher_id: self.id }) end end @@ -86,7 +86,7 @@ class Watcher < ActiveRecord::Base def down_user_score #取消关注 if self.watchable_type == 'Principal' - UserScore.influence(:cancel_followed, self.user,self.watchable, { watcher_id: self.id }) + UserScore.influence(:cancel_followed, self.user,self.watchable,self, { watcher_id: self.id }) end end diff --git a/db/schema.rb b/db/schema.rb index b37bc56e..c8cf7128 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 => 20140609061903) do +ActiveRecord::Schema.define(:version => 20140617013146) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -206,6 +206,17 @@ ActiveRecord::Schema.define(:version => 20140609061903) do t.string "reward" end + create_table "contestnotifications", :force => true do |t| + t.integer "contest_id" + t.string "title" + t.string "summary" + t.string "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 => "" @@ -567,6 +578,15 @@ ActiveRecord::Schema.define(:version => 20140609061903) do 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 "open_id_authentication_associations", :force => true do |t| t.integer "issued" t.integer "lifetime" @@ -923,6 +943,22 @@ ActiveRecord::Schema.define(:version => 20140609061903) do 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" From ab486aa8118604067bc74e5c0b914192587bddaf Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 17 Jun 2014 15:59:34 +0800 Subject: [PATCH 086/183] =?UTF-8?q?=E8=A1=A5=E5=85=85user=5Fscore=5Fdetail?= =?UTF-8?q?s=20Model=E5=8F=8A=E6=95=B0=E6=8D=AE=E8=BF=81=E7=A7=BB=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user_score_details.rb | 4 +++ ...0140617013146_create_user_score_details.rb | 19 +++++++++++++ test/fixtures/user_score_details.yml | 27 +++++++++++++++++++ test/unit/user_score_details_test.rb | 7 +++++ 4 files changed, 57 insertions(+) create mode 100644 app/models/user_score_details.rb create mode 100644 db/migrate/20140617013146_create_user_score_details.rb create mode 100644 test/fixtures/user_score_details.yml create mode 100644 test/unit/user_score_details_test.rb diff --git a/app/models/user_score_details.rb b/app/models/user_score_details.rb new file mode 100644 index 00000000..61d5d098 --- /dev/null +++ b/app/models/user_score_details.rb @@ -0,0 +1,4 @@ +class UserScoreDetails < ActiveRecord::Base + attr_accessible :current_user_id, :current_user_level, :new_score, :old_score, :score_action, :score_changeable_obj_id, :score_changeable_obj_type, :score_type, :target_user_id, :target_user_level, :user_id + belongs_to :score_changeable_obj,:polymorphic => true +end diff --git a/db/migrate/20140617013146_create_user_score_details.rb b/db/migrate/20140617013146_create_user_score_details.rb new file mode 100644 index 00000000..e830e3e0 --- /dev/null +++ b/db/migrate/20140617013146_create_user_score_details.rb @@ -0,0 +1,19 @@ +class CreateUserScoreDetails < ActiveRecord::Migration + def change + create_table :user_score_details 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.timestamps + end + end +end diff --git a/test/fixtures/user_score_details.yml b/test/fixtures/user_score_details.yml new file mode 100644 index 00000000..ac8da802 --- /dev/null +++ b/test/fixtures/user_score_details.yml @@ -0,0 +1,27 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + current_user_id: 1 + target_user_id: 1 + score_type: MyString + score_action: MyString + user_id: 1 + old_score: 1 + new_score: 1 + current_user_level: 1 + target_user_level: 1 + score_changeable_obj_id: 1 + score_changeable_obj_type: MyString + +two: + current_user_id: 1 + target_user_id: 1 + score_type: MyString + score_action: MyString + user_id: 1 + old_score: 1 + new_score: 1 + current_user_level: 1 + target_user_level: 1 + score_changeable_obj_id: 1 + score_changeable_obj_type: MyString diff --git a/test/unit/user_score_details_test.rb b/test/unit/user_score_details_test.rb new file mode 100644 index 00000000..657a9c2f --- /dev/null +++ b/test/unit/user_score_details_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class UserScoreDetailsTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From 1cb1eeeb1dd7822f28e098396c96a7f29863bc21 Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 17 Jun 2014 17:41:59 +0800 Subject: [PATCH 087/183] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=EF=BC=9A=E5=A7=93=E5=90=8D=E3=80=81=E5=B7=A5=E4=BD=9C=E5=8D=95?= =?UTF-8?q?=E4=BD=8D=20=E8=AF=BE=E7=A8=8B=E4=B8=BB=E9=A1=B5=EF=BC=9A?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=90=8D=E7=A7=B0=E3=80=81=E6=95=99=E5=B8=88?= =?UTF-8?q?=E5=8D=95=E4=BD=8D=20=E9=A1=B9=E7=9B=AE=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=EF=BC=9A=E9=A1=B9=E7=9B=AE=E5=90=8D=E7=A7=B0=20=E7=AB=9E?= =?UTF-8?q?=E8=B5=9B=E4=B8=BB=E9=A1=B5=EF=BC=9A=E7=AB=9E=E8=B5=9B=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=20=E4=B8=BB=E9=A1=B5=EF=BC=9A=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=88=97=3D>=E5=8D=95=E4=BD=8D=E5=90=8D=E7=A7=B0=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E9=83=A8=E5=88=86=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 5 +++++ app/views/layouts/base_courses.html.erb | 6 ++++-- app/views/layouts/base_newcontest.html.erb | 2 +- app/views/layouts/base_projects.html.erb | 2 +- app/views/layouts/base_users.html.erb | 11 ++++++++--- app/views/projects/_course.html.erb | 6 +++++- 6 files changed, 24 insertions(+), 8 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 494b8333..ae5b1829 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -801,6 +801,11 @@ class UsersController < ApplicationController else @user = User.find(params[:id]) end + if @user.user_score.nil? + us = UserScore.new + us.user_id = @user.id + us.save + end rescue ActiveRecord::RecordNotFound render_404 end diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index dfdf0a10..adedb66c 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -73,7 +73,8 @@ - + + - + + <% else %> diff --git a/app/views/layouts/base_newcontest.html.erb b/app/views/layouts/base_newcontest.html.erb index 91120feb..a14f25cd 100644 --- a/app/views/layouts/base_newcontest.html.erb +++ b/app/views/layouts/base_newcontest.html.erb @@ -62,7 +62,7 @@ diff --git a/app/views/files/_course_sort_by_attachtypel.html.erb b/app/views/files/_course_sort_by_attachtypel.html.erb index fe3311bd..f73cac07 100644 --- a/app/views/files/_course_sort_by_attachtypel.html.erb +++ b/app/views/files/_course_sort_by_attachtypel.html.erb @@ -36,7 +36,7 @@ <%= file.attachmentstype.typeName %>   - <%= render :partial => 'attachments/type_edit', :locals => {:attachmenttypes => attachmenttypes, + <%= render :partial => 'attachments/course_type_edit', :locals => {:attachmenttypes => attachmenttypes, :attachment => file,:contentype=>selContentType} %> diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index 68c5f5ca..b086b90d 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -176,6 +176,37 @@ <%end%> } + + function course_attachmenttypes_change(id, type) { + <% if @course%> + $.ajax({ + url: '<%=updateType_attachments_path%>', + type: "POST", + data: { + attachmentid: encodeURIComponent(id), + newtype: encodeURIComponent(type) + } + + }).complete(function (xhr, textStatus) { + + if (textStatus == 'success') { + $.ajax({ + url: '<%=getattachtype_course_files_path(course_id: @course)%>', + type: "POST", + data: { + type: $('#attachment_browse').val(), + contentType: $('#attach_sufix_browse').val() + } + }).error(function () { + alert('error'); + }); + } else if (textStatus == 'error') { + alert('An error has occurred'); + } + }); + <%end%> + + } From 2a9d6eb01230a508cba38859a871cc6a85fc47c8 Mon Sep 17 00:00:00 2001 From: nwb Date: Wed, 18 Jun 2014 16:11:38 +0800 Subject: [PATCH 100/183] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E5=8E=9F=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E8=B5=84=E6=BA=90=E6=96=87=E4=BB=B6=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20140618155324_migrate_course_file_type.rb | 12 ++++++++++++ db/schema.rb | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20140618155324_migrate_course_file_type.rb diff --git a/db/migrate/20140618155324_migrate_course_file_type.rb b/db/migrate/20140618155324_migrate_course_file_type.rb new file mode 100644 index 00000000..6cbf3b87 --- /dev/null +++ b/db/migrate/20140618155324_migrate_course_file_type.rb @@ -0,0 +1,12 @@ +class MigrateCourseFileType < ActiveRecord::Migration + def change + # 迁移原课程资源文件类型 + Attachment.all.each do |attach| + if attach.container_type == "Course" && attach.attachtype == 1 + attach.attachtype = 4 + attach.save + end + end + end + +end diff --git a/db/schema.rb b/db/schema.rb index 18a3fb84..8c6ed01f 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 => 20140618105214) do +ActiveRecord::Schema.define(:version => 20140618155324) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false From e17090d5061e0ccc57da710463612c9f66f224b8 Mon Sep 17 00:00:00 2001 From: nwb Date: Wed, 18 Jun 2014 16:29:29 +0800 Subject: [PATCH 101/183] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E9=80=9A=E7=9F=A5show=E6=96=B9=E6=B3=95=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=8B=AC=E7=AB=8B=E8=A7=86=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/news_controller.rb | 8 ++- app/views/news/_course_show.html.erb | 85 ++++++++++++++++++++++++++ app/views/news/_project_show.html.erb | 85 ++++++++++++++++++++++++++ app/views/news/show.html.erb | 88 ++------------------------- 4 files changed, 181 insertions(+), 85 deletions(-) create mode 100644 app/views/news/_course_show.html.erb create mode 100644 app/views/news/_project_show.html.erb diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 7fbbc83e..f91bc401 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -151,7 +151,13 @@ class NewsController < ApplicationController def destroy @news.destroy - redirect_to project_news_index_path(@project) + # modify by nwb + if @project + redirect_to project_news_index_path(@project) + elsif @course + redirect_to course_news_index_path(@course) + end + end private diff --git a/app/views/news/_course_show.html.erb b/app/views/news/_course_show.html.erb new file mode 100644 index 00000000..2ef952f6 --- /dev/null +++ b/app/views/news/_course_show.html.erb @@ -0,0 +1,85 @@ +
      + <%= watcher_link(@news, User.current) %> + <%= link_to(l(:button_edit), + edit_news_path(@news), + :class => 'icon icon-edit', + :accesskey => accesskey(:edit), + :onclick => '$("#edit-news").show(); return false;') if User.current.allowed_to?(:manage_news, @course) %> + <%= delete_link news_path(@news) if User.current.allowed_to?(:manage_news, @course) %> +
      + +

      <%=h @news.title %>

      + +<% if authorize_for('news', 'edit') %> + +<% end %> + +
      + +
      + <%= textilizable(@news, :description) %> +
      + <%= link_to_attachments @news %> +
      + + <% if @news.commentable? %> +

      + <%= toggle_link l(:label_comment_add), "add_comment_form", :focus => "comment_comments" %> +

      + <%= form_tag({:controller => 'comments', :action => 'create', :id => @news}, :id => "add_comment_form", :style => "display:none;") do %> +
      + <%= text_area 'comment', 'comments', :cols => 80, :rows => 15, :class => 'wiki-edit' %> + <%= wikitoolbar_for 'comment_comments' %> +
      +

      + <%= submit_tag l(:button_add) %> +

      + <% end %> + <% end %> + + <% html_title @news.title -%> + + <% content_for :header_tags do %> + <%= stylesheet_link_tag 'scm' %> + <% end %> + + +
      +
      +

      <%= l(:label_comment_plural) %>

      + <% comments = @comments.reverse %> + <% comments.each do |comment| %> + <% next if comment.new_record? %> +
      <%= @project.name %><%= link_to @project.name,project_path(@project) %>
      @@ -180,7 +181,8 @@ <% unless @course.teacher.user_extensions.nil? %>
      <%= l(:label_teacher_work_unit) %> :<%= @course.teacher.user_extensions.school %><%= link_to @course.teacher.user_extensions.school,options={:controller => 'welcome',:action => 'course',:school_id => @course.teacher.user_extensions.school.id}, html_options={:method => 'get'} %>
      - + <% if User.current.login? %> diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 433e8aae..bd15b128 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -57,7 +57,7 @@ - <% unless @course.teacher.user_extensions.nil? %> + <% unless @course.teacher.user_extensions.nil? || @course.teacher.user_extensions.school.nil? %> diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index 88190d53..ce9671ad 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -116,7 +116,9 @@ + <% unless @user.user_extensions.nil? || @user.user_extensions.school.nil? %> + <% end %>
      <%= h @contest.name %><%= link_to @contest.name, show_contest_contest_path(@contest) %>
      <%= image_tag(url_to_avatar(@project), :class => 'avatar2') %>
      - <%= @project.name %> + <%= link_to @project.name, project_path(@project)%>
      diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index 8c9531b5..193171e6 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -56,7 +56,9 @@
      - @@ -92,7 +94,8 @@ <% comments_score = comments_count * 0.1 %> <% finall_influence_score = news_score + wiki_contents_score + comments_score %> <% finall_user_score = finall_messages_score + finall_user_project_score + finall_activity_score + finall_influence_score %> - + + + diff --git a/app/views/projects/_course.html.erb b/app/views/projects/_course.html.erb index 6ea80203..6c4bfe9a 100644 --- a/app/views/projects/_course.html.erb +++ b/app/views/projects/_course.html.erb @@ -18,7 +18,11 @@ <%if @admin&&@admin.first&&@admin.first.user&&@admin.first.user.user_extensions%> <%# unless @project.course_extra.school.nil? %> - <%= @project.course_extra.teacher.user_extensions.school.try(:name) %> + + <% unless @project.course_extra.teacher.user_extensions.school.nil? %> + <%= link_to @project.course_extra.teacher.user_extensions.school.try(:name),options={:controller => 'welcome',:action => 'course',:school_id => @project.course_extra.teacher.user_extensions.school.id}, html_options={:method => 'get'}%> + <% end %> + <%# end %> <% end %>

      From 3afb70bf846a06915a0adb7e265a1149a692f008 Mon Sep 17 00:00:00 2001 From: nwb Date: Tue, 17 Jun 2014 17:48:02 +0800 Subject: [PATCH 088/183] =?UTF-8?q?=E4=B8=BB=E8=AE=B2=E6=95=99=E5=B8=88?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA=E4=B8=8D=E5=85=81=E8=AE=B8=E9=80=80?= =?UTF-8?q?=E5=87=BA=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/watchers_helper.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 9a77b436..a5672766 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -71,6 +71,9 @@ module WatchersHelper # Somebody may use option params def join_in_course(course, user, options=[]) return '' unless user && user.logged? + # modify by nwb + # 主讲教师不允许退出课程 + return '' if user.id == course.tea_id joined = user.member_of_course?(course) text = joined ? l(:label_exit_course) : l(:label_join_course) url_t = join_path(:object_id => course.id) @@ -85,6 +88,9 @@ module WatchersHelper def join_in_course_for_list(course, user, options=[]) return '' unless user && user.logged? + # modify by nwb + # 主讲教师不允许退出课程 + return '' if user.id == course.tea_id joined = user.member_of_course?(course) text = joined ? l(:label_exit_course) : l(:label_join_course) url_t = join_path(:object_id => course.id) From 9b707f2b5ac96d5f89043b9c957de17a0baf6ac4 Mon Sep 17 00:00:00 2001 From: yanxd Date: Tue, 17 Jun 2014 18:03:50 +0800 Subject: [PATCH 089/183] a --- app/controllers/zipdown_controller.rb | 6 +++--- app/views/bids/_homework.html.erb | 2 +- app/views/bids/_homework_list.html.erb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 808df65d..4fddec10 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -27,7 +27,7 @@ class ZipdownController < ApplicationController else logger.error "[ZipDown#assort] ===> #{obj.class.to_s.to_sym} unKown !!" end - send_file zipfile, :filename => obj.name, :type => detect_content_type(zipfile) if zipfile + send_file zipfile, :filename => obj.name+".zip", :type => detect_content_type(zipfile) if zipfile #rescue NameError, ActiveRecord::RecordNotFound => e #logger.error "[ZipDown] ===> #{e}" @@ -39,7 +39,7 @@ class ZipdownController < ApplicationController homework = HomeworkAttach.find params[:homework] if homework != nil && (User.current.admin? || User.current.member_of?(homework.bid.courses.first)) zipfile = zip_homework_by_user homework - send_file zipfile, :filename => homework.name, :type => detect_content_type(zipfile) if zipfile + send_file zipfile, :filename => homework.name+".zip", :type => detect_content_type(zipfile) if zipfile else render_403 :message => :notice_not_authorized end @@ -88,7 +88,7 @@ class ZipdownController < ApplicationController #length = attach.storage_path.length homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1) end - zipping "#{homeattach.user.name.to_s}.zip", homeworks_attach_path, OUTPUT_FOLDER, true + zipping "#{homeattach.user.name.to_s}_#{Time.now.to_i}.zip", homeworks_attach_path, OUTPUT_FOLDER, true #user_attaches_paths end diff --git a/app/views/bids/_homework.html.erb b/app/views/bids/_homework.html.erb index 4e2681ba..1a55dc24 100644 --- a/app/views/bids/_homework.html.erb +++ b/app/views/bids/_homework.html.erb @@ -27,7 +27,7 @@ (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0) && cur_user_homework_for_bid(@bid).count == 0 %>
      - + <%#= link_to l(:label_commit_homework), new_submit_homework_path, :onclick => "$('#put-bid-form').slideToggle(); this.blur(); return false;" %> <%= link_to l(:label_course_new_homework),new_homework_attach_path %>
      <% end %> diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 18778f5e..c49013cb 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -8,7 +8,7 @@
      <%= h (@user.name) %> + + + <%= link_to h (@user.name) %> <%= image_tag(gender_avatar_uri(@user), weight:"25px", height:"25px") if (@user.user_extensions && (@user.user_extensions.identity != 2) )%>
      <%= l(:label_user_grade)%>: <%= link_to(format("%.2f" , @user.user_score.total_score).to_f, {:controller => 'users', @@ -102,6 +105,7 @@ }, :style => 'color :#E8770D;') %>
      <%= l(:label_user_grade)%>: <%= link_to(format("%.2f" , finall_user_score).to_f, {:controller => 'users', @@ -174,12 +178,13 @@ --> + <% unless @user.user_extensions.nil? %> <% unless @user.user_extensions.identity == 2 %>
      <%= l(:field_occupation) %>: <% unless @user.user_extensions.school.nil? %> - <%= @user.user_extensions.school.name %> + <%= link_to @user.user_extensions.school.name, options={:controller => 'welcome',:action => 'course',:school_id => @user.user_extensions.school.id}, html_options={:method => 'get'} %> <% end %>
      - + +
      <%= l(:label_task_plural)%>(<%= @homework_list.count%>) - <%= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), remote: false, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if( + <%#= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), remote: false, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if( User.current.admin? || !(User.current.roles_for_project(@bid.courses.first).map(&:id) & ([7,9])).empty? ) || (Rails.env.development?) %> From 8840a11a9996225612ad55659a238fcd98780465 Mon Sep 17 00:00:00 2001 From: yanxd Date: Tue, 17 Jun 2014 18:38:13 +0800 Subject: [PATCH 090/183] attachments error --- app/controllers/attachments_controller.rb | 2 ++ public/file_not_found.html | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 public/file_not_found.html diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 99160b0c..65206350 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -59,6 +59,8 @@ class AttachmentsController < ApplicationController :type => detect_content_type(@attachment), :disposition => (@attachment.image? ? 'inline' : 'attachment') end + rescue => e + redirect_to "http://forge.trustie.net/file_not_found.html" end #更新资源文件类型 diff --git a/public/file_not_found.html b/public/file_not_found.html new file mode 100644 index 00000000..80b0e3dd --- /dev/null +++ b/public/file_not_found.html @@ -0,0 +1,23 @@ + + +文件未找到 + + +

      文件已经损坏

      +

      抱歉,因文件已经损坏,请重新上传此文件.

      +

      Back

      + + From 97a4aaf8aba3be3b49381bb3b2f36a670541aa69 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 17 Jun 2014 18:49:21 +0800 Subject: [PATCH 091/183] =?UTF-8?q?homework=5Fattach=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=88=97project=5Fid=E5=8F=8A=E7=9B=B8=E5=85=B3=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=BF=81=E7=A7=BB=20=E7=BC=96=E8=BE=91=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E9=A1=B5=E9=9D=A2=E5=A2=9E=E5=8A=A0=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=85=B3=E8=81=94=E9=A1=B9=E7=9B=AE=EF=BC=8C=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=9B=B4=E6=96=B0=E9=A1=B9=E7=9B=AE=E7=9A=84?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 4 +++- app/helpers/homework_attach_helper.rb | 12 ++++++++++++ app/views/homework_attach/edit.html.erb | 9 +++++++-- ...92219_add_project_id_to_homework_attach.rb | 5 +++++ db/schema.rb | 19 +++++++++---------- 5 files changed, 36 insertions(+), 13 deletions(-) create mode 100644 db/migrate/20140617092219_add_project_id_to_homework_attach.rb diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index d10f09ff..48187bdc 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -177,8 +177,10 @@ class HomeworkAttachController < ApplicationController if User.current.admin? || User.current.member_of?(course) name = params[:homework_name] description = params[:homework_description] + project_id = params[:homework_attach][:project_id] @homework.name = name @homework.description = description + @homework.project_id = project_id if params[:attachments] @homework.save_attachments(params[:attachments]) end @@ -196,7 +198,7 @@ class HomeworkAttachController < ApplicationController def destroy #@homework = HomeworkAttach.find(params[:id]) - if User.current.admin? || User.current == @homework + if User.current.admin? || User.current == @homework.user if @homework.destroy respond_to do |format| format.html { redirect_to project_for_bid_path @homework.bid } diff --git a/app/helpers/homework_attach_helper.rb b/app/helpers/homework_attach_helper.rb index 28bb48d3..4fbedb3a 100644 --- a/app/helpers/homework_attach_helper.rb +++ b/app/helpers/homework_attach_helper.rb @@ -54,4 +54,16 @@ module HomeworkAttachHelper raise RuntimeError, 'unknow type, Please input you type into this helper.' end end + + def user_projects_option + projects = Project.where("id < 8") + type = [] + projects.each do |project| + option = [] + option << project.name + option << project.id + type << option + end + type + end end \ No newline at end of file diff --git a/app/views/homework_attach/edit.html.erb b/app/views/homework_attach/edit.html.erb index f7104840..e5e3e005 100644 --- a/app/views/homework_attach/edit.html.erb +++ b/app/views/homework_attach/edit.html.erb @@ -42,11 +42,16 @@
      <%= form_for(@homework) do |f|%>

      - 标 题: + 标      题:  <%= f.text_field :name, :required => true, :name => "homework_name", :size => 60, :style => "width:490px;"%>

      - 描 述: + 关联项目: + <%= f.select :project_id, options_for_select(user_projects_option),:name => "project_id", :required => true%> + <%= link_to '创建项目', new_project_path(course: 0, project_type: 0), :target => '_blank' %> +

      +

      + 描      述:  <%= f.text_area :description, :rows => 8, :name => "homework_description", :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %> diff --git a/db/migrate/20140617092219_add_project_id_to_homework_attach.rb b/db/migrate/20140617092219_add_project_id_to_homework_attach.rb new file mode 100644 index 00000000..d18bf3c3 --- /dev/null +++ b/db/migrate/20140617092219_add_project_id_to_homework_attach.rb @@ -0,0 +1,5 @@ +class AddProjectIdToHomeworkAttach < ActiveRecord::Migration + def change + add_column :homework_attaches, :project_id, :integer, default: 0 + end +end diff --git a/db/schema.rb b/db/schema.rb index c8cf7128..b7de4e0b 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 => 20140617013146) do +ActiveRecord::Schema.define(:version => 20140617092219) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -348,12 +348,13 @@ ActiveRecord::Schema.define(:version => 20140617013146) do 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.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "reward" t.string "name" t.string "description" t.integer "state" + t.integer "project_id", :default => 0 end create_table "homework_for_courses", :force => true do |t| @@ -960,13 +961,11 @@ ActiveRecord::Schema.define(:version => 20140617013146) do 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 + t.integer "user_id" + t.integer "collaboration" + t.integer "influence" + t.integer "skill" + t.integer "activity" end create_table "user_statuses", :force => true do |t| From efb6c1fd19c15760f657ff0ea8f923e94ac32300 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 18 Jun 2014 10:07:19 +0800 Subject: [PATCH 092/183] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E3=80=81=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E4=BD=9C=E4=B8=9A=E5=A2=9E=E5=8A=A0=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=80=89=E9=A1=B9(=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA)=202.homework=5Fattach=E4=B8=8Eproject?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=85=B3=E8=81=94=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 4 +++- app/models/homework_attach.rb | 3 ++- app/models/project.rb | 1 + app/views/homework_attach/edit.html.erb | 5 +++-- app/views/homework_attach/new.html.erb | 6 ++++++ db/schema.rb | 12 +++++++----- 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 48187bdc..652025fc 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -77,6 +77,7 @@ class HomeworkAttachController < ApplicationController if bid.homeworks.where("user_id = ?",User.current).count == 0 user_id = params[:user_id] bid_id = params[:bid_id] + project_id = params[:new_form][:project_id] sta = 0 name = params[:new_form][:name] description = params[:new_form][:description] @@ -85,7 +86,8 @@ class HomeworkAttachController < ApplicationController :state => sta, :name => name, :description => description, - :bid_id => bid_id + :bid_id => bid_id, + :project_id => project_id } diff --git a/app/models/homework_attach.rb b/app/models/homework_attach.rb index e60d4230..99d540bd 100644 --- a/app/models/homework_attach.rb +++ b/app/models/homework_attach.rb @@ -9,6 +9,7 @@ class HomeworkAttach < ActiveRecord::Base has_many :homework_users, :dependent => :destroy has_many :users, :through => :homework_users seems_rateable :allow_update => true, :dimensions => :quality + belongs_to :project safe_attributes "bid_id", "user_id" @@ -30,7 +31,7 @@ class HomeworkAttach < ActiveRecord::Base result end - def project + def project_for_homework work = HomeworkForCourse.find_by_bid_id(self.bid_id) if work work.project diff --git a/app/models/project.rb b/app/models/project.rb index b8e11d99..ee9f7b2f 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -30,6 +30,7 @@ class Project < ActiveRecord::Base # Specific overidden Activities + belongs_to :homework_attach has_many :time_entry_activities has_many :members, :include => [:principal, :roles], :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}" has_many :memberships, :class_name => 'Member' diff --git a/app/views/homework_attach/edit.html.erb b/app/views/homework_attach/edit.html.erb index e5e3e005..bfcf1f64 100644 --- a/app/views/homework_attach/edit.html.erb +++ b/app/views/homework_attach/edit.html.erb @@ -46,9 +46,10 @@ <%= f.text_field :name, :required => true, :name => "homework_name", :size => 60, :style => "width:490px;"%>

      - 关联项目: - <%= f.select :project_id, options_for_select(user_projects_option),:name => "project_id", :required => true%> + 提交项目: + <%= f.select :project_id, options_for_select(user_projects_option,@homework.project.id),:name => "project_id", :required => true%> <%= link_to '创建项目', new_project_path(course: 0, project_type: 0), :target => '_blank' %> +

      提交项目可以为空

      描      述:  diff --git a/app/views/homework_attach/new.html.erb b/app/views/homework_attach/new.html.erb index 618fc15a..c74d17bd 100644 --- a/app/views/homework_attach/new.html.erb +++ b/app/views/homework_attach/new.html.erb @@ -26,6 +26,12 @@ 标 题: <%= f.text_field "name", :required => true, :size => 60, :style => "width:490px;" %>

      +

      + 提交项目: + <%= f.select :project_id, options_for_select(user_projects_option),:name => "project_id", :required => true%> + <%= link_to '创建项目', new_project_path(course: 0, project_type: 0), :target => '_blank' %> +

      提交项目可以为空

      +

      描 述: diff --git a/db/schema.rb b/db/schema.rb index b7de4e0b..fc215116 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -961,11 +961,13 @@ ActiveRecord::Schema.define(:version => 20140617092219) do end create_table "user_scores", :force => true do |t| - t.integer "user_id" - t.integer "collaboration" - t.integer "influence" - t.integer "skill" - t.integer "activity" + 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| From 0480405afb9497714c3932ae1d87b2030d3109c0 Mon Sep 17 00:00:00 2001 From: nwb Date: Wed, 18 Jun 2014 11:08:44 +0800 Subject: [PATCH 093/183] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E5=8E=9F=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=90=84=E6=95=B0=E6=8D=AE=E8=BF=81=E7=A7=BB=E6=96=87?= =?UTF-8?q?=E4=BB=B6BUG=202.=E8=BF=81=E7=A7=BB=E8=AF=BE=E7=A8=8B=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 1 + app/controllers/courses_controller.rb | 2 +- app/helpers/courses_helper.rb | 4 +-- app/helpers/watchers_helper.rb | 4 ++- ...0140603033359_add_boards_type_to_boards.rb | 21 ++++++------ ...3081801_add_courseid_to_enabled_modules.rb | 21 ++++++------ ...140604011630_add_courseid_to_to_members.rb | 21 ++++++------ ...name_project_id_to_homework_for_courses.rb | 10 ++++++ ...140605025302_migrate_course_attachments.rb | 1 + .../20140605025303_migrate_course_tags.rb | 1 + .../20140606027403_migrate_course_journals.rb | 1 + .../20140611161801_add_courseid_to_news.rb | 18 ++++++++-- .../20140618105213_migrate_course_students.rb | 13 +++++++ db/schema.rb | 34 ++++++++++--------- 14 files changed, 99 insertions(+), 53 deletions(-) create mode 100644 db/migrate/20140618105213_migrate_course_students.rb diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 1862c782..633160c1 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -287,6 +287,7 @@ class BidsController < ApplicationController end #end + # 显示课程 def show_course bids = Bid.where('parent_id = ?', @bid.id) @courses = [] diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 4e74449e..49341d58 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -105,7 +105,7 @@ class CoursesController < ApplicationController @course_count = @courses_all.count @course_pages = Paginator.new @course_count, per_page_option, params['page'] - + # 课程的动态数 @course_activity_count=Hash.new @courses_all.each do |course| @course_activity_count[course.id]=0 diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index f3eab89e..afb19454 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -91,8 +91,8 @@ module CoursesHelper end alias studentCountOrigin studentCount - def studentCount project - count = studentCountOrigin project + def studentCount course + count = studentCountOrigin course garble count end diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index a5672766..00867d9f 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -85,7 +85,9 @@ module WatchersHelper link_to text, url_f, :remote => true, :method => method, :id => "#{course.id}", :class => []+options end end - + + # 用户是否允许加入课程判断 + # add by nwb def join_in_course_for_list(course, user, options=[]) return '' unless user && user.logged? # modify by nwb diff --git a/db/migrate/20140603033359_add_boards_type_to_boards.rb b/db/migrate/20140603033359_add_boards_type_to_boards.rb index ea06cc20..fcef8b11 100644 --- a/db/migrate/20140603033359_add_boards_type_to_boards.rb +++ b/db/migrate/20140603033359_add_boards_type_to_boards.rb @@ -2,17 +2,18 @@ class AddBoardsTypeToBoards < ActiveRecord::Migration def change add_column :boards, :course_id, :int - Board.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all("course_id = project_id") - Board.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all(project_id: -1) + # course_id不能直接设置为 project_id + #Board.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all("course_id = project_id") + #Board.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all(project_id: -1) - #Board.all.each do |board| - # project = Project.find_by_id(board.project_id) - # if project && project.project_type == 1 - # board.course_id = board.project_id - # board.project_id = -1 - # board.save - # end - # end + Board.all.each do |board| + project = Project.find_by_id(board.project_id) + if project && project.project_type == 1 + board.course_id = project.course_extra.id + board.project_id = -1 + board.save + end + end end end diff --git a/db/migrate/20140603081801_add_courseid_to_enabled_modules.rb b/db/migrate/20140603081801_add_courseid_to_enabled_modules.rb index e31c3f95..be4fe7e6 100644 --- a/db/migrate/20140603081801_add_courseid_to_enabled_modules.rb +++ b/db/migrate/20140603081801_add_courseid_to_enabled_modules.rb @@ -2,16 +2,17 @@ class AddCourseidToEnabledModules < ActiveRecord::Migration def change add_column :enabled_modules, :course_id, :int - EnabledModule.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all("course_id = project_id") - EnabledModule.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all(project_id: -1) + #couese_id不能直接设置为project_id + #EnabledModule.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all("course_id = project_id") + #EnabledModule.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all(project_id: -1) - #EnabledModule.all.each do |enablemodule| - # project = Project.find_by_id(enablemodule.project_id) - # if project && project.project_type == 1 - # enablemodule.course_id = enablemodule.project_id - # enablemodule.project_id = -1 - # enablemodule.save - # end - #end + EnabledModule.all.each do |enablemodule| + project = Project.find_by_id(enablemodule.project_id) + if project && project.project_type == 1 + enablemodule.course_id = project.course_extra.id + enablemodule.project_id = -1 + enablemodule.save + end + end end end diff --git a/db/migrate/20140604011630_add_courseid_to_to_members.rb b/db/migrate/20140604011630_add_courseid_to_to_members.rb index 9dd66c7f..583e3a2d 100644 --- a/db/migrate/20140604011630_add_courseid_to_to_members.rb +++ b/db/migrate/20140604011630_add_courseid_to_to_members.rb @@ -5,17 +5,18 @@ class AddCourseidToToMembers < ActiveRecord::Migration remove_index :members, name: 'index_members_on_user_id_and_project_id' add_index "members", ["user_id", "project_id","course_id"], :name => "index_members_on_user_id_and_project_id", :unique => true - Member.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all("course_id = project_id") - Member.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all(project_id: -1) + #couese_id不能直接设置为project_id + #Member.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all("course_id = project_id") + #Member.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all(project_id: -1) # 课程成员数据迁移 - #Member.all.each do |member| - # project = Project.find_by_id(member.project_id) - # if project && project.project_type == 1 - # member.course_id = member.project_id - # member.project_id = -1 - # member.save - # end - #end + Member.all.each do |member| + project = Project.find_by_id(member.project_id) + if project && project.project_type == 1 + member.course_id = project.course_extra.id + member.project_id = -1 + member.save + end + end end end diff --git a/db/migrate/20140604071624_rename_project_id_to_homework_for_courses.rb b/db/migrate/20140604071624_rename_project_id_to_homework_for_courses.rb index e7cd811a..7336fe73 100644 --- a/db/migrate/20140604071624_rename_project_id_to_homework_for_courses.rb +++ b/db/migrate/20140604071624_rename_project_id_to_homework_for_courses.rb @@ -1,5 +1,15 @@ class RenameProjectIdToHomeworkForCourses < ActiveRecord::Migration def change rename_column(:homework_for_courses, :project_id, :course_id) + + # 作业数据迁移 + HomeworkForCourse.all.each do |work| + project = Project.find_by_id(work.project_id) + if project && project.project_type == 1 + work.course_id = project.course_extra.id + work.project_id = -1 + work.save + end + end end end diff --git a/db/migrate/20140605025302_migrate_course_attachments.rb b/db/migrate/20140605025302_migrate_course_attachments.rb index 447624fa..358710c9 100644 --- a/db/migrate/20140605025302_migrate_course_attachments.rb +++ b/db/migrate/20140605025302_migrate_course_attachments.rb @@ -6,6 +6,7 @@ class MigrateCourseAttachments < ActiveRecord::Migration project = Project.find_by_id(attach.container_id) if project && project.project_type == 1 attach.container_type= 'Course' + attach.container_id = project.course_extra.id attach.save end end diff --git a/db/migrate/20140605025303_migrate_course_tags.rb b/db/migrate/20140605025303_migrate_course_tags.rb index 17f93d40..6e95839e 100644 --- a/db/migrate/20140605025303_migrate_course_tags.rb +++ b/db/migrate/20140605025303_migrate_course_tags.rb @@ -6,6 +6,7 @@ class MigrateCourseTags < ActiveRecord::Migration project = Project.find_by_id(tagging.taggable_id) if project && project.project_type == 1 tagging.taggable_type= 'Course' + tagging.taggable_id = project.course_extra.id tagging.save end end diff --git a/db/migrate/20140606027403_migrate_course_journals.rb b/db/migrate/20140606027403_migrate_course_journals.rb index 44b3e562..40c57e81 100644 --- a/db/migrate/20140606027403_migrate_course_journals.rb +++ b/db/migrate/20140606027403_migrate_course_journals.rb @@ -5,6 +5,7 @@ class MigrateCourseJournals < ActiveRecord::Migration project = Project.find_by_id(journal.jour_id) if project && project.project_type == 1 journal.jour_type = 'Course' + journal.jour_id = project.course_extra.id journal.save end end diff --git a/db/migrate/20140611161801_add_courseid_to_news.rb b/db/migrate/20140611161801_add_courseid_to_news.rb index 9e08a446..5ca62a6a 100644 --- a/db/migrate/20140611161801_add_courseid_to_news.rb +++ b/db/migrate/20140611161801_add_courseid_to_news.rb @@ -1,10 +1,22 @@ class AddCourseidToNews < ActiveRecord::Migration - #迁移原课程新闻数据 + #迁移原课程通知数据 def change add_column :news, :course_id, :int - News.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all("course_id = project_id") - News.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all(project_id: -1) + # course_id不能直接设置为 project_id + #News.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all("course_id = project_id") + #News.where('project_id IN (SELECT id FROM projects WHERE project_type=1)').update_all(project_id: -1) + + News.all.each do |news| + project = Project.find_by_id(news.project_id) + if project && project.project_type == 1 + news.course_id = project.course_extra.id + news.project_id = -1 + news.save + end + end + + end end diff --git a/db/migrate/20140618105213_migrate_course_students.rb b/db/migrate/20140618105213_migrate_course_students.rb new file mode 100644 index 00000000..b9ac6671 --- /dev/null +++ b/db/migrate/20140618105213_migrate_course_students.rb @@ -0,0 +1,13 @@ +class MigrateCourseStudents < ActiveRecord::Migration + def change + # 原课程的学生数据迁移成新模式 + StudentsForCourse.all.each do |student| + project = Project.find_by_id(student.course_id) + if project + student.course_id = project.course_extra.id + student.save + end + end + end + +end diff --git a/db/schema.rb b/db/schema.rb index 2af470d0..6481ace3 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 => 20140611161801) do +ActiveRecord::Schema.define(:version => 20140618105213) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -742,18 +742,18 @@ ActiveRecord::Schema.define(:version => 20140611161801) do create_table "relative_memos", :force => true do |t| t.integer "osp_id" t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :null => false + t.string "subject", :null => false + t.text "content", :limit => 16777215, :null => false t.integer "author_id" - t.integer "replies_count", :default => 0 + 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.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" @@ -972,11 +972,13 @@ ActiveRecord::Schema.define(:version => 20140611161801) do add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id" create_table "user_scores", :force => true do |t| - t.integer "user_id" - t.integer "collaboration" - t.integer "influence" - t.integer "skill" - t.integer "activity" + 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| From 08ba10c32d34ac3fd67b3cf31dbcd6548980c06c Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 18 Jun 2014 11:42:59 +0800 Subject: [PATCH 094/183] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B6=85=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=20=E5=B7=B2=E6=B7=BB=E5=8A=A0=E7=9A=84=E8=B6=85?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=EF=BC=9A=20=E5=AD=A6=E6=A0=A1=E4=B8=BB?= =?UTF-8?q?=E9=A1=B5=EF=BC=8C=E8=AF=BE=E7=A8=8B=E4=BF=A1=E6=81=AF=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E5=AD=A6=E6=A0=A1=E5=90=8D=E7=A7=B0=20=E7=AB=9E?= =?UTF-8?q?=E8=B5=9B=E4=B8=AD=E9=A1=B9=E7=9B=AE=E5=88=97=E8=A1=A8=EF=BC=9A?= =?UTF-8?q?=20=E5=8F=82=E8=B5=9B=E4=BA=BA=20=E7=AB=9E=E8=B5=9B=E4=B8=AD?= =?UTF-8?q?=E5=8F=82=E5=85=A5=E7=AB=9E=E8=B5=9Btab=E9=A1=B5=EF=BC=9A?= =?UTF-8?q?=E5=8F=82=E8=B5=9B=E4=BB=A3=E8=A1=A8=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E7=95=8C=E9=9D=A2=E6=95=99=E5=B8=88=E5=8D=95?= =?UTF-8?q?=E4=BD=8D=E4=B8=8D=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E6=B7=BB=E5=8A=A0=E8=B6=85=E9=93=BE=E6=8E=A5=20?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E7=95=8C=E9=9D=A2=E4=BD=9C=E4=B8=9A=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E6=B7=BB=E5=8A=A0=E8=B6=85=E9=93=BE=E6=8E=A5=20?= =?UTF-8?q?=E8=BD=AF=E4=BB=B6=E4=BC=97=E5=8C=85=E9=A1=B5=E9=9D=A2=EF=BC=9A?= =?UTF-8?q?=E8=BD=AF=E4=BB=B6=E4=BC=97=E5=8C=85=E5=90=8D=E7=A7=B0=20?= =?UTF-8?q?=E8=BD=AF=E4=BB=B6=E4=BC=97=E5=8C=85=E9=A1=B5=E9=9D=A2=EF=BC=9A?= =?UTF-8?q?=E5=85=B3=E6=B3=A8=E6=A0=8F=E4=B8=8B=E5=A4=B4=E5=83=8F=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=93=BE=E6=8E=A5=EF=BC=8C=E5=8F=82=E4=B8=8E=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=A0=8F=EF=BC=9A=E5=9B=BE=E7=89=87=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=20=E8=B4=B4=E5=90=A7=E5=B8=96=E5=AD=90?= =?UTF-8?q?=EF=BC=9A=E4=BF=AE=E5=A4=8D=20=E5=8F=91=E5=B8=96=E5=9B=9E?= =?UTF-8?q?=E5=B8=96=E4=B8=8B=E6=96=B9=20=E2=80=9C=E7=94=B1xxx=E5=9C=A8XXX?= =?UTF-8?q?=E4=B9=8B=E5=89=8D=E6=B7=BB=E5=8A=A0=E2=80=9D=E4=B8=AD=E5=90=8D?= =?UTF-8?q?=E5=AD=90=E6=9C=AA=E9=93=BE=E6=8E=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/bids/show.html.erb | 2 +- app/views/contests/_list_projects.html.erb | 3 ++- app/views/contests/show_attendingcontest.html.erb | 6 ++++-- app/views/layouts/base_bids.html.erb | 8 ++++---- app/views/layouts/base_homework.html.erb | 6 ++++-- app/views/memos/show.html.erb | 6 ++++-- app/views/welcome/course.html.erb | 4 ++-- 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/app/views/bids/show.html.erb b/app/views/bids/show.html.erb index 8b7e0d8e..96ed4ea7 100644 --- a/app/views/bids/show.html.erb +++ b/app/views/bids/show.html.erb @@ -2,7 +2,7 @@

      <%= image_tag(url_to_avatar(@bid.author), :class => "avatar")%> -

      <%= link_to(@bid.author.lastname+@bid.author.firstname, user_path(@bid.author))%>:<%= @bid.name %>

      +

      <%= link_to(@bid.author.lastname+@bid.author.firstname, user_path(@bid.author))%>:<%= link_to(@bid.name,respond_path(@bid)) %>

      <% if @bid.reward_type.nil? or @bid.reward_type == 1%>

      <%= l(:label_bids_reward_method) %><%= l(:label_call_bonus) %>  <%= l(:label_RMB_sign) %><%= @bid.budget %> diff --git a/app/views/contests/_list_projects.html.erb b/app/views/contests/_list_projects.html.erb index 48a5ed32..10086e5a 100644 --- a/app/views/contests/_list_projects.html.erb +++ b/app/views/contests/_list_projects.html.erb @@ -76,7 +76,8 @@ <%= l(:label_contest_user) %> <% unless c_project.user.nil? %> - <%= c_project.user.lastname %><%= c_project.user.firstname %> + + <%= link_to c_project.user.lastname + c_project.user.firstname,user_path(c_project.user) %> <% end %> diff --git a/app/views/contests/show_attendingcontest.html.erb b/app/views/contests/show_attendingcontest.html.erb index 8a567bd5..d6f614db 100644 --- a/app/views/contests/show_attendingcontest.html.erb +++ b/app/views/contests/show_attendingcontest.html.erb @@ -259,7 +259,8 @@ <%= l(:label_attendingcontest_time) %> :<%= format_time c_project.created_at %> <%= l(:label_attendingcontest_spoksman) %> - :<%= c_project.user.name %> + + :<%= link_to c_project.user.name,user_path(c_project.user) %>

      @@ -293,7 +294,8 @@ <%= l(:label_attendingcontest_time) %> :<%= format_time c_softapplication.created_at %> <%= l(:label_attendingcontest_spoksman) %> - :<%= c_softapplication.softapplication.user.name %> + + :<%= link_to c_softapplication.softapplication.user.name,user_path(c_softapplication.softapplication.user) %>
      diff --git a/app/views/layouts/base_bids.html.erb b/app/views/layouts/base_bids.html.erb index f82a5bd2..075ee847 100644 --- a/app/views/layouts/base_bids.html.erb +++ b/app/views/layouts/base_bids.html.erb @@ -68,7 +68,7 @@
      - + <% if User.current.login? %> @@ -143,7 +143,7 @@ <% if @bid.watcher_users.size>0 %> <% for user in @bid.watcher_users%> - <%= image_tag(url_to_avatar(user), :class => "avatar", :title => user.name ) %> + <%= link_to image_tag(url_to_avatar(user), :class => "avatar", :title => user.name ),user_path(user) %> <% end %> <% else %>

      <%= l(:label_project_no_follow) %>

      @@ -164,8 +164,8 @@ @@ -114,7 +115,8 @@ - + +
      <%= h @bid.name %><%= link_to @bid.name,bid_path %>
      <% if @bid.projects.size>0 %> - <% for project in @bid.projects%> - <%= image_tag(url_to_avatar(project), :class => "avatar", :title => project.name) %> + <% for project in @bid.projects%> + <%= link_to image_tag(url_to_avatar(project), :class => "avatar", :title => project.name),project_path(project) %> <% end%> <% else %>

      <%= l(:label_no_bid_project) %>

      diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index 34d3b7b5..88190d53 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -70,7 +70,8 @@
      - <%= h @bid.name %> + + <%=link_to(@bid.name, respond_path(@bid)) %>
      <%= l(:label_teacher_work_unit) %> :<%= @user.user_extensions.occupation %><%= link_to @user.user_extensions.school,options={:controller => 'welcome',:action => 'course',:school_id => @user.user_extensions.school.id}, html_options={:method => 'get'} %>
      diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index 1252483d..830f18d8 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -57,7 +57,8 @@

      -
      <%= authoring @memo.created_at, @memo.author.name %>
      + +
      <%= authoring @memo.created_at, @memo.author %>

      @@ -122,7 +123,8 @@
      <%= authoring reply.created_at, reply.author.name %><%= authoring reply.created_at, reply.author %>
      diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index 88496262..0730e912 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -98,7 +98,7 @@ <% if(course.school == nil) %>               <% else %> - <%= course.school.name.try(:gsub, /(.+)$/, '\1:') %> + <%= link_to course.school.name.try(:gsub, /(.+)$/, '\1:'), options={:action => 'course',:school_id => course.school.id}, html_options={:method => 'get'}%> <% end %> @@ -151,7 +151,7 @@
      <% course = Course.find_by_extra(project.identifier) %> - <%= course.school.name.try(:gsub, /(.+)$/, '\1:') %> + <%=link_to course.school.name.try(:gsub, /(.+)$/, '\1:'),options={:action => 'course',:school_id => course.school.id}, html_options={:method => 'get'} %> <%= link_to(course.try(:teacher).try(:realname), user_path(course.teacher)) %> From 8f78177d47c198eec194a9ca6a68910089ad62e4 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 18 Jun 2014 11:51:20 +0800 Subject: [PATCH 095/183] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=BF=81=E7=A7=BB=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...18020535_remove_data_to_homework_attach.rb | 25 +++++++++++++++++++ db/schema.rb | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20140618020535_remove_data_to_homework_attach.rb diff --git a/db/migrate/20140618020535_remove_data_to_homework_attach.rb b/db/migrate/20140618020535_remove_data_to_homework_attach.rb new file mode 100644 index 00000000..16a1b491 --- /dev/null +++ b/db/migrate/20140618020535_remove_data_to_homework_attach.rb @@ -0,0 +1,25 @@ +class RemoveDataToHomeworkAttach < ActiveRecord::Migration + def up + bidding_projects = BidingProject.joins(:bid).where("bids.reward_type = 3") + bidding_projects.each do |biding| + homework = HomeworkAttach.new + homework.project_id = biding.project_id + homework.bid_id = biding.bid_id + homework.created_at = biding.created_at + homework.updated_at = biding.updated_at + homework.reward = biding.reward + homework.description = biding.description + homework.user_id = biding.user_id + homework.state = 0 + homework.save + end + end + + def down + bidding_projects = BidingProject.joins(:bid).where("bids.reward_type = 3") + bidding_projects.each do |biding| + homework = HomeworkAttach.where("bid_id = #{biding.bid_id} and user_id = #{biding.user_id}") + homework.first.destroy + end + end +end diff --git a/db/schema.rb b/db/schema.rb index fc215116..18cc2a71 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 => 20140617092219) do +ActiveRecord::Schema.define(:version => 20140618020535) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false From f80e1f811a4cda7e16c89c5b48ccb00383ebcf97 Mon Sep 17 00:00:00 2001 From: nwb Date: Wed, 18 Jun 2014 14:01:45 +0800 Subject: [PATCH 096/183] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...20140604071624_rename_project_id_to_homework_for_courses.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/db/migrate/20140604071624_rename_project_id_to_homework_for_courses.rb b/db/migrate/20140604071624_rename_project_id_to_homework_for_courses.rb index 7336fe73..613f141c 100644 --- a/db/migrate/20140604071624_rename_project_id_to_homework_for_courses.rb +++ b/db/migrate/20140604071624_rename_project_id_to_homework_for_courses.rb @@ -4,10 +4,9 @@ class RenameProjectIdToHomeworkForCourses < ActiveRecord::Migration # 作业数据迁移 HomeworkForCourse.all.each do |work| - project = Project.find_by_id(work.project_id) + project = Project.find_by_id(work.course_id) if project && project.project_type == 1 work.course_id = project.course_extra.id - work.project_id = -1 work.save end end From d2db58050d1a622e360649ff9effeb2fd5e39455 Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 18 Jun 2014 14:21:05 +0800 Subject: [PATCH 097/183] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=9C=AA=E5=A1=AB=E5=B7=A5=E4=BD=9C=E5=8D=95=E4=BD=8D=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/contests/show_attendingcontest.html.erb | 4 ++++ app/views/layouts/base_courses.html.erb | 2 +- app/views/layouts/base_homework.html.erb | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/views/contests/show_attendingcontest.html.erb b/app/views/contests/show_attendingcontest.html.erb index d6f614db..7818f5fb 100644 --- a/app/views/contests/show_attendingcontest.html.erb +++ b/app/views/contests/show_attendingcontest.html.erb @@ -260,7 +260,9 @@ :<%= format_time c_project.created_at %> <%= l(:label_attendingcontest_spoksman) %> + <% unless c_project.nil? || c_project.user.nil? %> :<%= link_to c_project.user.name,user_path(c_project.user) %> + <% end %>
      @@ -295,7 +297,9 @@ :<%= format_time c_softapplication.created_at %> <%= l(:label_attendingcontest_spoksman) %> + <% unless c_softapplication.nil? || c_softapplication.softapplication.nil? || c_softapplication.softapplication.user.nil? %> :<%= link_to c_softapplication.softapplication.user.name,user_path(c_softapplication.softapplication.user) %> + <% end %>
      diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index adedb66c..5ab0a98a 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -178,7 +178,7 @@
      <%= l(:label_teacher_work_unit) %> :
      <%= l(:label_teacher_work_unit) %> : <%= link_to @user.user_extensions.school,options={:controller => 'welcome',:action => 'course',:school_id => @user.user_extensions.school.id}, html_options={:method => 'get'} %>
      From 80145c5c3be91ce8bee00c0255d10d7fb3d66004 Mon Sep 17 00:00:00 2001 From: nwb Date: Wed, 18 Jun 2014 15:18:30 +0800 Subject: [PATCH 098/183] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=8A=A8=E6=80=81=E6=95=B0=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E7=A1=AE=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 5 +++++ db/migrate/20140606027403_migrate_course_journals.rb | 3 +++ db/schema.rb | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 49341d58..ca409c55 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -520,6 +520,11 @@ class CoursesController < ApplicationController activities[board.course_id]+=board.messages.where("updated_on>?", date_from).count end + #news + News.where(course_id: @course_ids).where("created_on>?",date_from).each do |news| + activities[news.course_id]+=1 + end + #feedbackc_count JournalsForMessage.where(jour_id: @course_ids, jour_type: Course).each do |jourformess| activities[jourformess.jour_id]+=1 diff --git a/db/migrate/20140606027403_migrate_course_journals.rb b/db/migrate/20140606027403_migrate_course_journals.rb index 40c57e81..4a13ef38 100644 --- a/db/migrate/20140606027403_migrate_course_journals.rb +++ b/db/migrate/20140606027403_migrate_course_journals.rb @@ -8,6 +8,9 @@ class MigrateCourseJournals < ActiveRecord::Migration journal.jour_id = project.course_extra.id journal.save end + # 将自动设置的更新日期还原 + sql = ActiveRecord::Base.connection() + sql.insert "update journals_for_messages set updated_on=created_on where jour_type='Course'" end end diff --git a/db/schema.rb b/db/schema.rb index 6481ace3..18a3fb84 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 => 20140618105213) do +ActiveRecord::Schema.define(:version => 20140618105214) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false From 462e5ab5891fd1dbc1853b09ac03093eaa62e483 Mon Sep 17 00:00:00 2001 From: nwb Date: Wed, 18 Jun 2014 15:48:06 +0800 Subject: [PATCH 099/183] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E6=96=87=E4=BB=B6=E7=B1=BB=E5=9E=8B=E7=BC=96?= =?UTF-8?q?=E8=BE=91BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../attachments/_course_type_edit.html.erb | 14 +++++++++ .../_course_show_all_attachment.html.erb | 2 +- .../_course_sort_by_attachtypel.html.erb | 2 +- app/views/files/index.html.erb | 31 +++++++++++++++++++ 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 app/views/attachments/_course_type_edit.html.erb diff --git a/app/views/attachments/_course_type_edit.html.erb b/app/views/attachments/_course_type_edit.html.erb new file mode 100644 index 00000000..f0bebaf8 --- /dev/null +++ b/app/views/attachments/_course_type_edit.html.erb @@ -0,0 +1,14 @@ +<% edit_allowed = User.current.allowed_to?(:manage_files, @course) %> +<% if attachmenttypes.any? %> + + <%= link_to(image_tag('edit/edit.png'), 'javascript:void(0);',:style=>"white-space:nowrap;", :id=>"edit_box"+attachment.id.to_s , + :onclick =>"$('#put-tag-form-" +attachment.id.to_s+ "').show(); + $('#attach_type_id_label" +attachment.id.to_s+ "').hide(); + $('#edit_box" +attachment.id.to_s+ "').hide();") if edit_allowed %> + +<% end %> + diff --git a/app/views/files/_course_show_all_attachment.html.erb b/app/views/files/_course_show_all_attachment.html.erb index 083fd2f7..1a8a8ca6 100644 --- a/app/views/files/_course_show_all_attachment.html.erb +++ b/app/views/files/_course_show_all_attachment.html.erb @@ -41,7 +41,7 @@
      <%= file.attachmentstype.typeName %> - <%= render :partial => 'attachments/type_edit', :locals => {:attachmenttypes => attachmenttypes, :attachment => file, :contentype => selContentType} %> + <%= render :partial => 'attachments/course_type_edit', :locals => {:attachmenttypes => attachmenttypes, :attachment => file, :contentype => selContentType} %> <%= file.show_suffix_type %>
      + + + + +
      <%= image_tag(url_to_avatar(comment.author), :class => "avatar")%> + + + + + + + + + + + +
      <%= link_to_user(comment.author) if comment.respond_to?(:author) %> <%= l(:label_project_newadd) %><%= l(:label_comment_plural) %>
      +

      + <%= textilizable(comment.comments) %> +

      <%= format_time(comment.created_on) %><%= link_to_if_authorized image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment}, + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %>
      + <% end if @comments.any? %> +
      diff --git a/app/views/news/_project_show.html.erb b/app/views/news/_project_show.html.erb new file mode 100644 index 00000000..c8a8c576 --- /dev/null +++ b/app/views/news/_project_show.html.erb @@ -0,0 +1,85 @@ +
      + <%= watcher_link(@news, User.current) %> + <%= link_to(l(:button_edit), + edit_news_path(@news), + :class => 'icon icon-edit', + :accesskey => accesskey(:edit), + :onclick => '$("#edit-news").show(); return false;') if User.current.allowed_to?(:manage_news, @project) %> + <%= delete_link news_path(@news) if User.current.allowed_to?(:manage_news, @project) %> +
      + +

      <%=h @news.title %>

      + +<% if authorize_for('news', 'edit') %> + +<% end %> + +
      + +
      + <%= textilizable(@news, :description) %> +
      + <%= link_to_attachments @news %> +
      + + <% if @news.commentable? %> +

      + <%= toggle_link l(:label_comment_add), "add_comment_form", :focus => "comment_comments" %> +

      + <%= form_tag({:controller => 'comments', :action => 'create', :id => @news}, :id => "add_comment_form", :style => "display:none;") do %> +
      + <%= text_area 'comment', 'comments', :cols => 80, :rows => 15, :class => 'wiki-edit' %> + <%= wikitoolbar_for 'comment_comments' %> +
      +

      + <%= submit_tag l(:button_add) %> +

      + <% end %> + <% end %> + + <% html_title @news.title -%> + + <% content_for :header_tags do %> + <%= stylesheet_link_tag 'scm' %> + <% end %> + + +
      +
      +

      <%= l(:label_comment_plural) %>

      + <% comments = @comments.reverse %> + <% comments.each do |comment| %> + <% next if comment.new_record? %> + + + + + +
      <%= image_tag(url_to_avatar(comment.author), :class => "avatar")%> + + + + + + + + + + + +
      <%= link_to_user(comment.author) if comment.respond_to?(:author) %> <%= l(:label_project_newadd) %><%= l(:label_comment_plural) %>
      +

      + <%= textilizable(comment.comments) %> +

      <%= format_time(comment.created_on) %><%= link_to_if_authorized image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment}, + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %>
      + <% end if @comments.any? %> +
      diff --git a/app/views/news/show.html.erb b/app/views/news/show.html.erb index ed1bcacb..6e588836 100644 --- a/app/views/news/show.html.erb +++ b/app/views/news/show.html.erb @@ -1,85 +1,5 @@ -
      - <%= watcher_link(@news, User.current) %> - <%= link_to(l(:button_edit), - edit_news_path(@news), - :class => 'icon icon-edit', - :accesskey => accesskey(:edit), - :onclick => '$("#edit-news").show(); return false;') if User.current.allowed_to?(:manage_news, @project) %> - <%= delete_link news_path(@news) if User.current.allowed_to?(:manage_news, @project) %> -
      - -

      <%=h @news.title %>

      - -<% if authorize_for('news', 'edit') %> - +<% if @project %> + <%= render :partial => 'project_show', locals: {project: @project} %> +<% elsif @course %> + <%= render :partial => 'course_show', locals: {course: @course} %> <% end %> - -
      - -
      - <%= textilizable(@news, :description) %> -
      - <%= link_to_attachments @news %> -
      - - <% if @news.commentable? %> -

      - <%= toggle_link l(:label_comment_add), "add_comment_form", :focus => "comment_comments" %> -

      - <%= form_tag({:controller => 'comments', :action => 'create', :id => @news}, :id => "add_comment_form", :style => "display:none;") do %> -
      - <%= text_area 'comment', 'comments', :cols => 80, :rows => 15, :class => 'wiki-edit' %> - <%= wikitoolbar_for 'comment_comments' %> -
      -

      - <%= submit_tag l(:button_add) %> -

      - <% end %> - <% end %> - - <% html_title @news.title -%> - - <% content_for :header_tags do %> - <%= stylesheet_link_tag 'scm' %> - <% end %> - - -
      -
      -

      <%= l(:label_comment_plural) %>

      - <% comments = @comments.reverse %> - <% comments.each do |comment| %> - <% next if comment.new_record? %> - - - - - -
      <%= image_tag(url_to_avatar(comment.author), :class => "avatar")%> - - - - - - - - - - - -
      <%= link_to_user(comment.author) if comment.respond_to?(:author) %> <%= l(:label_project_newadd) %><%= l(:label_comment_plural) %>
      -

      - <%= textilizable(comment.comments) %> -

      <%= format_time(comment.created_on) %><%= link_to_if_authorized image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment}, - :data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %>
      - <% end if @comments.any? %> -
      From f0b016bcbe4d43a4deb9bd9d6101fc09ad0e934a Mon Sep 17 00:00:00 2001 From: nwb Date: Wed, 18 Jun 2014 16:45:33 +0800 Subject: [PATCH 102/183] =?UTF-8?q?=E8=AE=A8=E8=AE=BA=E5=8C=BA=E7=95=99?= =?UTF-8?q?=E8=A8=80=E7=BC=96=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/messages/_form.html.erb | 7 ++++++- app/views/messages/edit.html.erb | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/views/messages/_form.html.erb b/app/views/messages/_form.html.erb index 04940dbd..931b472c 100644 --- a/app/views/messages/_form.html.erb +++ b/app/views/messages/_form.html.erb @@ -19,7 +19,12 @@ <% if !replying && !@message.new_record? && @message.safe_attribute?('board_id') %>


      - <%= f.select :board_id, boards_options_for_select(@message.project.boards) %>

      + <%# modify by nwb%> + <% if @message.project %> + <%= f.select :board_id, boards_options_for_select(@message.project.boards) %>

      + <% elsif @message.course %> + <%= f.select :board_id, boards_options_for_select(@message.course.boards) %>

      + <% end %> <% end %>

      diff --git a/app/views/messages/edit.html.erb b/app/views/messages/edit.html.erb index b7f59129..2577a463 100644 --- a/app/views/messages/edit.html.erb +++ b/app/views/messages/edit.html.erb @@ -1,4 +1,8 @@ -<%= board_breadcrumb(@message) %> +<% if @message.project %> + <%= board_breadcrumb(@message) %> +<% elsif @message.course %> + <%= course_board_breadcrumb(@message) %> +<% end %>

      <%= avatar(@topic.author, :size => "24") %><%=h @topic.subject %>

      From c0d97870d58d0f35b0c4e76489297255dc8a8d37 Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 18 Jun 2014 17:35:05 +0800 Subject: [PATCH 103/183] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=3D=E3=80=8B=E6=96=87?= =?UTF-8?q?=E6=A1=A3=20=E6=96=87=E6=A1=A3=E6=8F=90=E4=BA=A4=E8=80=85?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B6=85=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/attachments/_links.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb index c135ee21..52b090bd 100644 --- a/app/views/attachments/_links.html.erb +++ b/app/views/attachments/_links.html.erb @@ -24,7 +24,8 @@ <% end %> <% end %> <% if options[:author] %> - <%= h(attachment.author) %>, <%= format_time(attachment.created_on) %> + + <%= link_to h(attachment.author),user_path(attachment.author) %>, <%= format_time(attachment.created_on) %> <% end %>

      <% end %> From f5c912364773fb9483b552038c2a59242e2d7c80 Mon Sep 17 00:00:00 2001 From: nwb Date: Thu, 19 Jun 2014 09:37:58 +0800 Subject: [PATCH 104/183] =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E8=AF=BE=E7=A8=8B=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=EF=BC=8C=E7=AE=A1=E7=90=86=E5=91=98=E5=88=9B=E5=BB=BA=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=90=8E=E6=88=90=E4=B8=BA=E8=AF=A5=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E6=88=90=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 4 ++-- app/models/course.rb | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index ca409c55..8883aabb 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -235,7 +235,7 @@ class CoursesController < ApplicationController if User.current.user_extensions.identity == 0 if @course.save - unless User.current.admin? + #unless User.current.admin? 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]) m.project_id = -1 @@ -246,7 +246,7 @@ class CoursesController < ApplicationController end @course.members << m @course.course_infos << course - end + #end respond_to do |format| format.html { flash[:notice] = l(:notice_successful_create) diff --git a/app/models/course.rb b/app/models/course.rb index da5bb5be..7a9e411d 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -26,7 +26,6 @@ class Course < ActiveRecord::Base has_many :enabled_modules, :dependent => :delete_all has_many :boards, :dependent => :destroy, :order => "position ASC" #has_many :course_journals_for_messages, :class_name => 'CourseJournalsForMessage', :as => :jour, :dependent => :destroy - has_many :journals_for_messages, :as => :jour, :dependent => :destroy has_many :news, :dependent => :destroy, :include => :author acts_as_taggable From 9061a7722121eb5764ae5847e102f74fda7f32b8 Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 19 Jun 2014 10:45:30 +0800 Subject: [PATCH 105/183] =?UTF-8?q?=E4=BF=AE=E6=94=B9user.user=5Fscore?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E9=97=AE=E9=A2=98=E7=9A=84=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 5 ----- app/models/user_score.rb | 12 ++++++++++++ app/views/layouts/base_users.html.erb | 2 +- app/views/users/_score_new_index.html.erb | 6 +++--- app/views/users/_show_new_score.html.erb | 12 ++++++------ 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ae5b1829..494b8333 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -801,11 +801,6 @@ class UsersController < ApplicationController else @user = User.find(params[:id]) end - if @user.user_score.nil? - us = UserScore.new - us.user_id = @user.id - us.save - end rescue ActiveRecord::RecordNotFound render_404 end diff --git a/app/models/user_score.rb b/app/models/user_score.rb index 0e355b79..07c66985 100644 --- a/app/models/user_score.rb +++ b/app/models/user_score.rb @@ -246,6 +246,18 @@ class UserScore < ActiveRecord::Base Rails.logger.error "[UserScore#project] ===> Exception: #{e}." end + #获取用户的user_score + def self.score(user) + if user.user_score.nil? + us = UserScore.new + us.user_id = user.id + us.save + us + else + user.user_score + end + end + #计算总得分 def total_score score = self.influence.to_i + self.skill.to_i + self.collaboration.to_i + self.active.to_i diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index 193171e6..895f83bb 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -98,7 +98,7 @@ <%= l(:label_user_grade)%>: - <%= link_to(format("%.2f" , @user.user_score.total_score).to_f, {:controller => 'users', + <%= link_to(format("%.2f" , @user.user_score_attr.total_score).to_f, {:controller => 'users', :action => 'show_new_score', :remote => true, :id => @user.id diff --git a/app/views/users/_score_new_index.html.erb b/app/views/users/_score_new_index.html.erb index 10fa1e84..43687aa7 100644 --- a/app/views/users/_score_new_index.html.erb +++ b/app/views/users/_score_new_index.html.erb @@ -28,7 +28,7 @@
      = <%= l(:label_user_score_of_collaboration) %> + <%= l(:label_user_score_of_influence) %> + <%= l(:label_user_score_of_skill)%> + <%= l(:label_user_score_of_active) %>
      -
      = <%= format("%.2f" ,@user.user_score.collaboration.nil? ? 0:@user.user_score.collaboration).to_f %> + <%= format("%.2f" , @user.user_score.influence.nil? ? 0:@user.user_score.influence ).to_f %> - + <%= format("%.2f" , @user.user_score.skill.nil? ? 0:@user.user_score.skill).to_f %> + <%= format("%.2f" , @user.user_score.active.nil? ? 0:@user.user_score.active).to_f %>
      -
      = <%= format("%.2f" ,@user.user_score.total_score.nil? ? 0:@user.user_score.total_score).to_f %>
      +
      = <%= format("%.2f" ,@user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_f %> + <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence ).to_f %> + + <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_f %> + <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_f %>
      +
      = <%= format("%.2f" ,@user.user_score_attr.total_score.nil? ? 0:@user.user_score_attr.total_score).to_f %>
      diff --git a/app/views/users/_show_new_score.html.erb b/app/views/users/_show_new_score.html.erb index d22150a8..3fd5f105 100644 --- a/app/views/users/_show_new_score.html.erb +++ b/app/views/users/_show_new_score.html.erb @@ -38,7 +38,7 @@ - +
      <%= l(:label_user_score) %>
      <%= format("%.2f" , @user.user_score.total_score).to_f %>
      <%= format("%.2f" , @user.user_score_attr.total_score).to_f %>
      @@ -49,23 +49,23 @@ <%= l(:label_user_score) %> : - <%= format("%.2f" , @user.user_score.total_score).to_f %> + <%= format("%.2f" , @user.user_score_attr.total_score).to_f %>
      <%= l(:label_user_score_of_collaboration) %> : - <%= format("%.2f" , @user.user_score.collaboration.nil? ? 0:@user.user_score.collaboration).to_f %> + <%= format("%.2f" , @user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_f %>
      <%= l(:label_user_score_of_influence) %> : - <%= format("%.2f" , @user.user_score.influence.nil? ? 0:@user.user_score.influence).to_f %> + <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence).to_f %>
      <%= l(:label_user_score_of_skill) %> : - <%= format("%.2f" , @user.user_score.skill.nil? ? 0:@user.user_score.skill).to_f %> + <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_f %>
      <%= l(:label_user_score_of_active) %> : - <%= format("%.2f" , @user.user_score.active.nil? ? 0:@user.user_score.active).to_f %> + <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_f %>
      From 8a5e1f5d9faa1ed209afe459b040d4697b5626c9 Mon Sep 17 00:00:00 2001 From: nwb Date: Thu, 19 Jun 2014 11:45:02 +0800 Subject: [PATCH 106/183] =?UTF-8?q?=E7=95=8C=E9=9D=A2=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/_course_form.html.erb | 2 +- config/locales/en.yml | 1 + config/locales/zh.yml | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/courses/_course_form.html.erb b/app/views/courses/_course_form.html.erb index 4f2f5a79..d223bbad 100644 --- a/app/views/courses/_course_form.html.erb +++ b/app/views/courses/_course_form.html.erb @@ -301,7 +301,7 @@

      -

      <%= f.check_box :is_public, :style => "margin-left:10px;" %><%= l(:label_public_info) %>

      +

      <%= f.check_box :is_public, :style => "margin-left:10px;" %><%= l(:label_course_public_info) %>

      <%= f.text_field :course_type, :value => 1 %>

      diff --git a/config/locales/en.yml b/config/locales/en.yml index 9aec93af..4e2ba078 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1477,6 +1477,7 @@ en: label_course: Course label_course_new: New course label_public_info: "If you don't choose public, only the project's members can see the project." + label_course_public_info: "If you don't choose public, only the course's members can see the course." label_course_student: Student label_homework: Task label_course_new_homework: New homework diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 483d5e10..6b0f089e 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1722,6 +1722,7 @@ zh: label_course_new: 新建课程 label_course_join_student: 加入课程 label_public_info: (打钩为公开,不打钩则不公开,若不公开,仅项目成员可见该项目。) + label_course_public_info: (打钩为公开,不打钩则不公开,若不公开,仅课程成员可见该课程。) label_course_view_student: 查看其他课程 label_course_student: 学生 label_homework: 课程作业 From 71bb76ff916a29cf839e2c6277a32c83cd725c18 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 19 Jun 2014 13:51:39 +0800 Subject: [PATCH 107/183] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E9=A1=B5=E9=9D=A2=E6=94=B9=E9=80=A0=EF=BC=8C?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=96=B0=E7=9A=84=E9=A1=B5=E9=9D=A2=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/bids/_homework_list.html.erb | 138 +++++++++++++++---------- 1 file changed, 84 insertions(+), 54 deletions(-) diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index c49013cb..14d18216 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -28,75 +28,105 @@ <% @homework_list.each do |homework|%> - - -
      <%= image_tag(url_to_avatar(homework.user), :class => "avatar")%> - + + @@ -125,7 +128,7 @@ From f2cb1390da32e5981f4926ed4657c4b0ada75855 Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 19 Jun 2014 14:33:57 +0800 Subject: [PATCH 109/183] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B8=A6pre=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E7=BC=BA=E9=99=B7=E7=95=99=E8=A8=80=E7=9A=84=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/journals_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/journals_helper.rb b/app/helpers/journals_helper.rb index 26b4c13b..cfebb4d3 100644 --- a/app/helpers/journals_helper.rb +++ b/app/helpers/journals_helper.rb @@ -70,7 +70,7 @@ module JournalsHelper content << textilizable(journal, :notes) css_classes = "wiki" css_classes << " editable" if editable - content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes) + content_tag('div', content.html_safe, :id => "journal-#{journal.id}-notes", :class => css_classes ,:style => "width:580px") end def link_to_in_place_notes_editor(text, field_id, url, options={}) From 3e37a54a0f5bcb4806d2fe74fe1a26fa92a7de54 Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 19 Jun 2014 14:44:58 +0800 Subject: [PATCH 110/183] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AB=9E=E8=B5=9B?= =?UTF-8?q?=E5=A4=84=E4=B8=8D=E8=83=BD=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/models/mailer.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index e954f03c..81ef95c8 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -75,7 +75,12 @@ class Mailer < ActionMailer::Base return -1 end mail :to => journals_for_message.jour.author.mail, :subject => @title - else + elsif journals_for_message.jour.class.to_s.to_sym == :Contest + if !journals_for_message.jour.author.notify_about? journals_for_message + return -1 + end + mail :to => journals_for_message.jour.author.mail, :subject => @title + else mail :to => @mail.mail, :subject => @title end From 9e4dbcc08e8ffcd9b94df03014436ff5c8d0ad79 Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 19 Jun 2014 15:31:30 +0800 Subject: [PATCH 111/183] =?UTF-8?q?=E5=8A=A0=E5=9B=9E=E5=AD=A6=E6=A0=A1?= =?UTF-8?q?=E4=B8=BB=E9=A1=B5=E5=AD=A6=E6=A0=A1=E7=9A=84=E8=B6=85=E9=93=BE?= =?UTF-8?q?=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/welcome/course.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index 0730e912..ce53924e 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -193,7 +193,8 @@ <% if(course.school == nil) %>               <% else %> - <%= course.school.name.try(:gsub, /(.+)$/, '\1:') %> + + <%= link_to course.school.name.try(:gsub, /(.+)$/, '\1:'), options={:action => 'course',:school_id => course.school.id}, html_options={:method => 'get'}%> <% end %> From 0736dd12540e2202917d5832deb2fa316e6d23ef Mon Sep 17 00:00:00 2001 From: nwb Date: Thu, 19 Jun 2014 15:50:42 +0800 Subject: [PATCH 112/183] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E5=9B=9E=E5=A4=8D=E6=9D=83=E9=99=90=E5=92=8C=E7=95=8C?= =?UTF-8?q?=E9=9D=A2BUG=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 5 + app/views/messages/_course_show.html.erb | 200 +++++++++++++++++++++ app/views/messages/_project_show.html.erb | 200 +++++++++++++++++++++ app/views/messages/show.html.erb | 203 +--------------------- 4 files changed, 409 insertions(+), 199 deletions(-) create mode 100644 app/views/messages/_course_show.html.erb create mode 100644 app/views/messages/_project_show.html.erb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f7b94587..f14a637d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -46,6 +46,11 @@ module ApplicationHelper def authorize_for(controller, action) User.current.allowed_to?({:controller => controller, :action => action}, @project) end + + # add by nwb + def authorize_for_course(controller, action) + User.current.allowed_to?({:controller => controller, :action => action}, @course) + end def authorize_for_contest(controller, action) User.current.allowed_to?({:controller => controller, :action => action}, @contest) diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb new file mode 100644 index 00000000..243406a3 --- /dev/null +++ b/app/views/messages/_course_show.html.erb @@ -0,0 +1,200 @@ + + +
      + + <%= render :partial => "/praise_tread/praise_tread",:locals => {:obj => @topic,:show_flag => true,:user_id =>User.current.id,:horizontal => true}%> +
      + <%= watcher_link(@topic, User.current) %> + <%= link_to( + l(:button_quote), + {:action => 'quote', :id => @topic}, + :remote => true, + :method => 'get', + :class => 'icon icon-comment', + :remote => true) if !@topic.locked? && authorize_for('messages', 'reply') %> + <%= link_to( + l(:button_edit), + {:action => 'edit', :id => @topic}, + :class => 'icon icon-edit' + ) if @message.editable_by?(User.current) %> + <%= link_to( + l(:button_delete), + {:action => 'destroy', :id => @topic}, + :method => :post, + :data => {:confirm => l(:text_are_you_sure)}, + :class => 'icon icon-del' + ) if @message.destroyable_by?(User.current) %> +
      + +
      +
      + <%= link_to image_tag(url_to_avatar(@topic.author), :class => "avatar"), user_path(@topic.author) %> +
      +

      + <%= link_to @topic.author, user_path(@topic.author) %> +

      +
      +
      +
      + <% if @project %> + <%= label_tag l(:field_subject) %>: <%= link_to @topic.subject, project_boards_path(@topic.project) %> + <% elsif @course %> + <%= label_tag l(:field_subject) %>: <%= link_to @topic.subject, course_boards_path(@topic.course) %> + <% end %> +
      +
      + <%= textilizable(@topic, :content) %> + <%= link_to_attachments @topic, :author => false %> +
      +
      +
      <%= authoring @topic.created_on, @topic.author %>
      + + +
      <%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %>
      +
      + + + + +
      +
      +
      + +<% unless @replies.empty? %> +
      +
      +
      +
      +

      <%= l(:label_reply_plural) %> (<%= @reply_count %>)

      + <% reply_count = 0 %> + <% @replies.each do |message| %> +
      "> + +
      + + + + + + + + + + +
      <%= image_tag(url_to_avatar(homework.user), :class => "avatar")%>
      +

      + <%= link_to (is_teacher ? homework.user.realname : homework.user ), user_path(homework.user)%> +

      +
      + <% if (users_for_homework(homework).include?(User.current) || is_teacher) %> + <%= link_to l(:button_edit), edit_homework_attach_path(homework) %> + <% if homework.user == User.current || is_teacher %> + <%= link_to(l(:label_bid_respond_delete), homework, + method: :delete, :confirm => l(:text_are_you_sure)) %> + <% end %> + <% end %> +
      + +
      + - + - - - - - + + + + + + + + + + - +
      -   作业   :  + 作业名称:  <% if homework.name == nil || homework.name == "" %> - <% attachments = homework.attachments.map %> - <% for attachment in attachments %> - <% if attachments.count > 1 %> - <% homework_filename = attachment.filename + "等" + attachments.count.to_s + "个文件" %> - <% else %> - <% homework_filename = attachment.filename %> - <% end %> - <% end %> + <% homework_filename = homework.user.name + "提交的作业" %> <% else %> <% homework_filename = homework.name %> <% end %> - <% if is_evaluation || is_teacher%> - <%= link_to homework_filename, :controller => "zipdown", :action => "download_user_homework",:homework => homework%> - <% else %> - <%= homework_filename %> - <% end %> + <%= link_to homework_filename , homework_attach_path(homework)%> - <% if is_student %> - <% if is_evaluation %> - <%= link_to "互评>>" , homework_attach_path(homework)%> - <% else %> - <%= link_to "查看详细" , homework_attach_path(homework)%> - <% end %> - <% else %> - <% if is_teacher %> - <%= link_to "综评>>" , homework_attach_path(homework)%> - <% end %> + + 参与人员:  + <% homework_users = "" %> + <% homework.users.each do |user| %> + <% homework_users = user.name %> + <% end %> + <% if homework.users.count == 0 %> + 无 + <% else %> + <%= homework_users %> + <% end %> + + <% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %> + 迟交 <% end %>
        - 发布人:  <%= link_to ( is_teacher ? homework.user.realname : homework.user ), user_path(homework.user)%> - - 作业评分: - <%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %> - - <% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %> - 迟交 - <% end %> -
      + 开发项目:  + <% if homework.project != nil %> + <%= link_to homework.project.name,project_path(homework.project.id)%> + <% else %> + 该作业暂无项目 + <% end %> + + 项目得分:  + <% if homework.project != nil %> + 0分 + <% else %> + 0分 + <% end %> +
      + 提交文件:  + <%= link_to "打包下载", :controller => "zipdown", :action => "download_user_homework",:homework => homework%> + + + 互评得分:  + <%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %>   + <%= link_to "学生互评>>",homework_attach_path(homework) %> +
        - <% if User.current.member_of?(@bid.courses.first) %> - <%= l(:label_bidding_user_studentcode) %>  : <%= homework.user.student_id%> - <% end %> - + + - <% if (users_for_homework(homework).include?(User.current) || is_teacher) %> - <%= link_to l(:button_edit), edit_homework_attach_path(homework) %> - <% if homework.user == User.current || is_teacher %> - <%= link_to(l(:label_bid_respond_delete), homework, - method: :delete, :confirm => l(:text_are_you_sure)) %> - <% end %> - <% end %> + 综评得分:  + <%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %>   + <%= link_to "教师评分>>",homework_attach_path(homework) %>
      From d38e0094693dba1a01bc8c4e637d35fc7522d972 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 19 Jun 2014 14:01:18 +0800 Subject: [PATCH 108/183] =?UTF-8?q?=E5=8F=96=E6=B6=88=E5=AD=A6=E5=8F=B7?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=8F=82=E4=B8=8E?= =?UTF-8?q?=E4=BA=BA=E5=91=98=E5=9C=A8=E4=BD=9C=E4=B8=9A=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/bids/_homework_list.html.erb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 14d18216..42d6460a 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -72,12 +72,15 @@ 参与人员:  <% homework_users = "" %> <% homework.users.each do |user| %> - <% homework_users = user.name %> + <% homework_users = homework_users + user.name %> + <% if user != homework.users.last %> + <% homework_users = homework_users + "、" %> + <% end %> <% end %> <% if homework.users.count == 0 %> 无 <% else %> - <%= homework_users %> + <%= homework_users %> <% end %>
      @@ -114,7 +117,7 @@ 互评得分:  - <%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %>   + <%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %>分   <%= link_to "学生互评>>",homework_attach_path(homework) %>
      综评得分:  - <%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %>   + <%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %>分   <%= link_to "教师评分>>",homework_attach_path(homework) %>
      + + + + + + + + + + + + +
      <%= link_to image_tag(url_to_avatar(message.author), :class => "avatar"), user_path(message.author) %> +
      + <%= link_to( + "引用", + {:action => 'quote', :id => message}, + :remote => true, + :method => 'get', + :title => l(:button_quote)) if !@topic.locked? && authorize_for('messages', 'reply') %> + <%= link_to( + #image_tag('edit.png'), + "编辑", + {:action => 'edit', :id => message}, + :title => l(:button_edit) + ) if message.editable_by?(User.current) %> + <%= link_to( + #image_tag('delete.png'), + "删除", + {:action => 'destroy', :id => message}, + :method => :post, + :data => {:confirm => l(:text_are_you_sure)}, + :title => l(:button_delete) + ) if message.destroyable_by?(User.current) %> +
      +
      + <%= textilizable message, :content, :attachments => message.attachments %> +
      + <%= link_to_attachments message, :author => false %>
      <%= authoring message.created_on, message.author %>
      + + + <% end %> + +<% end %> + + + + +<% if !@topic.locked? && authorize_for_course('messages', 'reply') %> + +<% end %> + +<% html_title @topic.subject %> + + \ No newline at end of file diff --git a/app/views/messages/_project_show.html.erb b/app/views/messages/_project_show.html.erb new file mode 100644 index 00000000..4456f36e --- /dev/null +++ b/app/views/messages/_project_show.html.erb @@ -0,0 +1,200 @@ + + +
      + + <%= render :partial => "/praise_tread/praise_tread",:locals => {:obj => @topic,:show_flag => true,:user_id =>User.current.id,:horizontal => true}%> +
      + <%= watcher_link(@topic, User.current) %> + <%= link_to( + l(:button_quote), + {:action => 'quote', :id => @topic}, + :remote => true, + :method => 'get', + :class => 'icon icon-comment', + :remote => true) if !@topic.locked? && authorize_for('messages', 'reply') %> + <%= link_to( + l(:button_edit), + {:action => 'edit', :id => @topic}, + :class => 'icon icon-edit' + ) if @message.editable_by?(User.current) %> + <%= link_to( + l(:button_delete), + {:action => 'destroy', :id => @topic}, + :method => :post, + :data => {:confirm => l(:text_are_you_sure)}, + :class => 'icon icon-del' + ) if @message.destroyable_by?(User.current) %> +
      + +
      +
      + <%= link_to image_tag(url_to_avatar(@topic.author), :class => "avatar"), user_path(@topic.author) %> +
      +

      + <%= link_to @topic.author, user_path(@topic.author) %> +

      +
      +
      +
      + <% if @project %> + <%= label_tag l(:field_subject) %>: <%= link_to @topic.subject, project_boards_path(@topic.project) %> + <% elsif @course %> + <%= label_tag l(:field_subject) %>: <%= link_to @topic.subject, course_boards_path(@topic.course) %> + <% end %> +
      +
      + <%= textilizable(@topic, :content) %> + <%= link_to_attachments @topic, :author => false %> +
      +
      +
      <%= authoring @topic.created_on, @topic.author %>
      + + +
      <%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %>
      +
      + + + + +
      +
      +
      + +<% unless @replies.empty? %> +
      +
      +
      +
      +

      <%= l(:label_reply_plural) %> (<%= @reply_count %>)

      + <% reply_count = 0 %> + <% @replies.each do |message| %> +
      "> + + + + + + + + + + + + + + +
      <%= link_to image_tag(url_to_avatar(message.author), :class => "avatar"), user_path(message.author) %> +
      + <%= link_to( + "引用", + {:action => 'quote', :id => message}, + :remote => true, + :method => 'get', + :title => l(:button_quote)) if !@topic.locked? && authorize_for('messages', 'reply') %> + <%= link_to( + #image_tag('edit.png'), + "编辑", + {:action => 'edit', :id => message}, + :title => l(:button_edit) + ) if message.editable_by?(User.current) %> + <%= link_to( + #image_tag('delete.png'), + "删除", + {:action => 'destroy', :id => message}, + :method => :post, + :data => {:confirm => l(:text_are_you_sure)}, + :title => l(:button_delete) + ) if message.destroyable_by?(User.current) %> +
      +
      + <%= textilizable message, :content, :attachments => message.attachments %> +
      + <%= link_to_attachments message, :author => false %>
      <%= authoring message.created_on, message.author %>
      +
      + + <% end %> + +<% end %> + + + + +<% if !@topic.locked? && authorize_for('messages', 'reply') %> + +<% end %> + +<% html_title @topic.subject %> + + \ No newline at end of file diff --git a/app/views/messages/show.html.erb b/app/views/messages/show.html.erb index 24dffbc4..6e588836 100644 --- a/app/views/messages/show.html.erb +++ b/app/views/messages/show.html.erb @@ -1,200 +1,5 @@ - - -
      - - <%= render :partial => "/praise_tread/praise_tread",:locals => {:obj => @topic,:show_flag => true,:user_id =>User.current.id,:horizontal => true}%> -
      - <%= watcher_link(@topic, User.current) %> - <%= link_to( - l(:button_quote), - {:action => 'quote', :id => @topic}, - :remote => true, - :method => 'get', - :class => 'icon icon-comment', - :remote => true) if !@topic.locked? && authorize_for('messages', 'reply') %> - <%= link_to( - l(:button_edit), - {:action => 'edit', :id => @topic}, - :class => 'icon icon-edit' - ) if @message.editable_by?(User.current) %> - <%= link_to( - l(:button_delete), - {:action => 'destroy', :id => @topic}, - :method => :post, - :data => {:confirm => l(:text_are_you_sure)}, - :class => 'icon icon-del' - ) if @message.destroyable_by?(User.current) %> -
      - -
      -
      - <%= link_to image_tag(url_to_avatar(@topic.author), :class => "avatar"), user_path(@topic.author) %> -
      -

      - <%= link_to @topic.author, user_path(@topic.author) %> -

      -
      -
      -
      - <% if @project %> - <%= label_tag l(:field_subject) %>: <%= link_to @topic.subject, project_boards_path(@topic.project) %> - <% elsif @course %> - <%= label_tag l(:field_subject) %>: <%= link_to @topic.subject, course_boards_path(@topic.course) %> - <% end %> -
      -
      - <%= textilizable(@topic, :content) %> - <%= link_to_attachments @topic, :author => false %> -
      -
      -
      <%= authoring @topic.created_on, @topic.author %>
      - - -
      <%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %>
      -
      - - - - -
      -
      -
      - -<% unless @replies.empty? %> -
      -
      -
      -
      -

      <%= l(:label_reply_plural) %> (<%= @reply_count %>)

      -<% reply_count = 0 %> -<% @replies.each do |message| %> -
      "> - - - - - - - - - - - - - - -
      <%= link_to image_tag(url_to_avatar(message.author), :class => "avatar"), user_path(message.author) %> -
      - <%= link_to( - "引用", - {:action => 'quote', :id => message}, - :remote => true, - :method => 'get', - :title => l(:button_quote)) if !@topic.locked? && authorize_for('messages', 'reply') %> - <%= link_to( - #image_tag('edit.png'), - "编辑", - {:action => 'edit', :id => message}, - :title => l(:button_edit) - ) if message.editable_by?(User.current) %> - <%= link_to( - #image_tag('delete.png'), - "删除", - {:action => 'destroy', :id => message}, - :method => :post, - :data => {:confirm => l(:text_are_you_sure)}, - :title => l(:button_delete) - ) if message.destroyable_by?(User.current) %> -
      -
      - <%= textilizable message, :content, :attachments => message.attachments %> -
      - <%= link_to_attachments message, :author => false %>
      <%= authoring message.created_on, message.author %>
      -
      - +<% if @project %> + <%= render :partial => 'project_show', locals: {project: @project} %> +<% elsif @course %> + <%= render :partial => 'course_show', locals: {course: @course} %> <% end %> - -<% end %> - - - - -<% if !@topic.locked? && authorize_for('messages', 'reply') %> - -<% end %> - -<% html_title @topic.subject %> - - \ No newline at end of file From ef234d8c50d3813971b7a291e5268c846853f425 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 19 Jun 2014 15:55:42 +0800 Subject: [PATCH 113/183] =?UTF-8?q?1.=E6=8C=89=E7=85=A7=E6=96=B0=E7=9A=84?= =?UTF-8?q?=E8=AF=84=E5=88=86=E8=A7=84=E5=88=99=E4=BF=AE=E6=94=B9=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E5=BE=97=E5=88=86=202.=E4=BF=AE=E6=94=B9=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E5=88=97=E8=A1=A8=E6=98=BE=E7=A4=BA=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=203.=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=9A=84=E4=BA=92=E8=AF=84=E5=BE=97=E5=88=86=E3=80=81=E6=95=99?= =?UTF-8?q?=E5=B8=88=E8=AF=84=E5=88=86=E3=80=81=E6=9C=80=E7=BB=88=E8=AF=84?= =?UTF-8?q?=E5=88=86=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 4 ++ app/helpers/courses_helper.rb | 24 +++++++++++ app/views/bids/_app_link.html.erb | 8 ++++ app/views/bids/_homework_list.html.erb | 40 +++++++++++++------ .../_comprehensive_evaluation.html.erb | 16 +------- .../homework_attach/_show_score.html.erb | 14 +++++++ app/views/homework_attach/show.html.erb | 13 ++---- 7 files changed, 82 insertions(+), 37 deletions(-) create mode 100644 app/views/bids/_app_link.html.erb create mode 100644 app/views/homework_attach/_show_score.html.erb diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 652025fc..20ae4c54 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -1,4 +1,5 @@ class HomeworkAttachController < ApplicationController + include CoursesHelper ############################### #判断当前角色权限时需先找到当前操作的project before_filter :find_project_by_bid_id, :only => [:new] @@ -241,6 +242,9 @@ class HomeworkAttachController < ApplicationController @offset ||= @feedback_pages.offset @jour = @jours[@offset, @limit] @comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation is not null").order("created_on DESC") + + @totle_score = score_for_homework @homework + @teaher_score = teacher_score_for_homework @homework else render_403 :message => :notice_not_authorized end diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 0602e52d..96ea4e28 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -182,4 +182,28 @@ module CoursesHelper def users_for_homework homework homework.nil? ? [] : (homework.users + [homework.user]) end + + #获取指定作业的最终评分 + #最终评分 = 学生评分的平均分 * 0.4 +教师评分 * 0.6 + def score_for_homework homework + return format("%.2f",(teacher_score_for_homework(homework).to_f * 0.6 + student_score_for_homework(homework).to_f * 0.4)) + end + + #获取作业的互评得分 + def student_score_for_homework homework + member = searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first + student_stars = homework.rates(:quality).where("rater_id <> #{member.user_id}").select("stars") + student_stars_count = 0 + student_stars.each do |star| + student_stars_count = student_stars_count + star.stars + end + return format("%.2f",student_stars_count / (student_stars.count == 0 ? 1 : student_stars.count)) + end + + #获取作业的教师评分 + def teacher_score_for_homework homework + member = searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first + teacher_stars = homework.rates(:quality).where("rater_id = #{member.user_id}").select("stars").first + return format("%.2f",teacher_stars == nil ? 0 : teacher_stars.stars) + end end diff --git a/app/views/bids/_app_link.html.erb b/app/views/bids/_app_link.html.erb new file mode 100644 index 00000000..645fe94f --- /dev/null +++ b/app/views/bids/_app_link.html.erb @@ -0,0 +1,8 @@ +<% for attachment in attachments %> + <%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%> + <% if attachment.is_text? %> + <%= link_to image_tag('magnifier.png'), + :controller => 'attachments', :action => 'show', + :id => attachment, :filename => attachment.filename %> + <% end %> +<% end -%> \ No newline at end of file diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 42d6460a..e1ca9e0f 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -72,7 +72,7 @@ 参与人员:  <% homework_users = "" %> <% homework.users.each do |user| %> - <% homework_users = homework_users + user.name %> + <% homework_users = homework_users + (is_teacher ? user.realname : user.name) %> <% if user != homework.users.last %> <% homework_users = homework_users + "、" %> <% end %> @@ -101,35 +101,49 @@
      项目得分:  - <% if homework.project != nil %> - 0分 - <% else %> - 0分 - <% end %> + + <% if homework.project != nil %> + 0分 + <% else %> + 0分 + <% end %> +
      提交文件:  - <%= link_to "打包下载", :controller => "zipdown", :action => "download_user_homework",:homework => homework%> + <% if is_evaluation %> + <%= link_to "打包下载", :controller => "zipdown", :action => "download_user_homework",:homework => homework%> + <% else %> + 未开启互评功能作业不允许下载 + <% end %> 互评得分:  - <%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %>分   - <%= link_to "学生互评>>",homework_attach_path(homework) %> + <%= student_score_for_homework(homework) %>分   + <% if is_evaluation && is_student && (!users_for_homework(homework).include? User.current)%> + <%= link_to "学生互评>>",homework_attach_path(homework) %> + <% end %> +
      - + + <% if is_evaluation %> + <%= render :partial => 'app_link', :locals => {:attachments => homework.attachments} %> + <% end %> 综评得分:  - <%= format("%.2f", homework.rate_averages.first.try(:avg).to_f ) %>分   - <%= link_to "教师评分>>",homework_attach_path(homework) %> + <%= score_for_homework homework %>分   + <% if is_teacher %> + <%= link_to "教师评分>>",homework_attach_path(homework) %> + <% end %> +
      diff --git a/app/views/homework_attach/_comprehensive_evaluation.html.erb b/app/views/homework_attach/_comprehensive_evaluation.html.erb index 08db3054..786659d9 100644 --- a/app/views/homework_attach/_comprehensive_evaluation.html.erb +++ b/app/views/homework_attach/_comprehensive_evaluation.html.erb @@ -1,23 +1,9 @@ <% is_teacher = is_course_teacher User.current,homework.bid.courses.first %> <% if comprehensive_evaluation != nil && comprehensive_evaluation.count > 0 %> - <% stars = homework.rates(:quality).where("rater_id = #{comprehensive_evaluation.first.user.id}").select("stars").first %>
      作业综评: - -
      - <% if stars != nil %> -
      - <% else %> -
      - <% end %> -
      -
      -
      -
      -
      + <%= render :partial => 'show_score', locals: {:stars => teaher_score} %>
      <%= comprehensive_evaluation.first.notes%>
      diff --git a/app/views/homework_attach/_show_score.html.erb b/app/views/homework_attach/_show_score.html.erb new file mode 100644 index 00000000..7c2403e1 --- /dev/null +++ b/app/views/homework_attach/_show_score.html.erb @@ -0,0 +1,14 @@ + +
      + <% if stars != nil %> +
      + <% else %> +
      + <% end %> +
      +
      +
      +
      +
      \ No newline at end of file diff --git a/app/views/homework_attach/show.html.erb b/app/views/homework_attach/show.html.erb index 4ab6141d..915485fe 100644 --- a/app/views/homework_attach/show.html.erb +++ b/app/views/homework_attach/show.html.erb @@ -49,7 +49,7 @@ 平均评分: - <%= rating_for @homework, :static => true, dimension: :quality, class: 'rateable div_inline' %> + <%= render :partial => 'show_score', :locals => {:stars => @totle_score} %> 发布时间:<%=format_time @homework.created_at %> @@ -110,17 +110,12 @@
      - <% score = @homework.average(:quality).try(:avg).try(:round, 2).to_s %>
      最终得分
      - <% if score == "" %> - 0分 - <% else %> - <%= score %>分 - <% end %> + <%= @totle_score %>分
      - <%= rating_for @homework, :static => true, dimension: :quality, class: 'rateable div_inline' %> + <%= render :partial => 'show_score', :locals => {:stars => @totle_score} %>
      @@ -137,7 +132,7 @@
      - <%= render :partial => 'comprehensive_evaluation', :locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework} %> + <%= render :partial => 'comprehensive_evaluation', :locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework, :teaher_score => @teaher_score} %>
      From 4d06d263035c0528e0eb23c85960f1f268a0ec69 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 19 Jun 2014 15:58:49 +0800 Subject: [PATCH 114/183] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E9=A1=B5=E9=9D=A2=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/homework_attach/new.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/homework_attach/new.html.erb b/app/views/homework_attach/new.html.erb index c74d17bd..46ab0ce8 100644 --- a/app/views/homework_attach/new.html.erb +++ b/app/views/homework_attach/new.html.erb @@ -23,7 +23,7 @@ :bid_id => @bid }) do |f|%>

      - 标 题: + 标      题: <%= f.text_field "name", :required => true, :size => 60, :style => "width:490px;" %>

      @@ -33,7 +33,7 @@

      提交项目可以为空

      - 描 述: + 描      述: <%= f.text_area "description", :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %> From 31049fcf4eeedbee8471a9fad9dcf17984a9fbc7 Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 19 Jun 2014 15:59:55 +0800 Subject: [PATCH 115/183] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8C=E6=97=B6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=BC=BA=E9=99=B7=E7=8A=B6=E6=80=81=E5=92=8C?= =?UTF-8?q?=E7=BC=BA=E9=99=B7=E5=AE=8C=E6=88=90=E5=BA=A6=E6=97=B6=E5=8F=AA?= =?UTF-8?q?=E6=9C=89=E7=BC=BA=E9=99=B7=E5=AE=8C=E6=88=90=E5=BA=A6=E5=8A=A0?= =?UTF-8?q?=E5=88=86=E5=8F=8A=E8=AE=B0=E5=BD=95=E5=88=86=E6=95=B0=E5=8F=98?= =?UTF-8?q?=E5=8C=96=E7=BB=86=E8=8A=82=EF=BC=8C=E7=BC=BA=E9=99=B7=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=9B=B4=E6=94=B9=E6=93=8D=E4=BD=9C=E6=9C=AA=E5=8A=A0?= =?UTF-8?q?=E5=88=86=E5=8F=8A=E8=AE=B0=E5=BD=95=E5=88=86=E6=95=B0=E5=8F=98?= =?UTF-8?q?=E5=8C=96=E7=BB=86=E8=8A=82bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/issue.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/issue.rb b/app/models/issue.rb index a9b3e357..3cd67d01 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1492,10 +1492,11 @@ class Issue < ActiveRecord::Base #缺陷完成度更新 if self.done_ratio_changed? UserScore.project(:update_issue_ratio, User.current,self,{ issue_id: self.id }) + end #缺陷状态更改 - elsif self.status_id_changed? - #协同得分 - UserScore.joint(:change_issue_status, User.current,nil,self, {issue_id: self.id}) + if self.status_id_changed? + #协同得分 + UserScore.joint(:change_issue_status, User.current,nil,self, {issue_id: self.id}) end end From 59e643393855d988f3f39918b69bdfc83f6eaa95 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 19 Jun 2014 16:52:53 +0800 Subject: [PATCH 116/183] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E7=94=A8=E6=88=B7=E5=BB=BA=E7=AB=8B=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E4=B8=8D=E6=AD=A3=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/homework_attach_helper.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/helpers/homework_attach_helper.rb b/app/helpers/homework_attach_helper.rb index 4fbedb3a..fe7f123b 100644 --- a/app/helpers/homework_attach_helper.rb +++ b/app/helpers/homework_attach_helper.rb @@ -56,13 +56,17 @@ module HomeworkAttachHelper end def user_projects_option - projects = Project.where("id < 8") + cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" + memberships = User.current.memberships.all(:conditions => cond) + projects = memberships.map(&:project) type = [] projects.each do |project| - option = [] - option << project.name - option << project.id - type << option + if project != nil + option = [] + option << project.name + option << project.id + type << option + end end type end From e43a84ab4b4af728cb0774589c75085f0eccd3ac Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 19 Jun 2014 17:00:40 +0800 Subject: [PATCH 117/183] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8D=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=97=A0=E5=85=B3=E8=81=94=E9=A1=B9=E7=9B=AE=E6=98=AF=E8=BF=9B?= =?UTF-8?q?=E5=85=A5=E7=BC=96=E8=BE=91=E7=95=8C=E9=9D=A2=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=202.=E4=BF=AE=E5=A4=8D=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E7=BB=BC=E8=AF=84=E9=A1=B5=E9=9D=A2=E4=B8=8D=E4=BC=9A?= =?UTF-8?q?=E5=8F=8A=E6=97=B6=E6=9B=B4=E6=96=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 3 +++ app/views/homework_attach/addjours.js.erb | 2 +- app/views/homework_attach/edit.html.erb | 7 ++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 20ae4c54..ef3d683b 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -276,6 +276,9 @@ class HomeworkAttachController < ApplicationController @offset ||= @feedback_pages.offset @jour = @jours[@offset, @limit] @comprehensive_evaluation = @homework.journals_for_messages.where("is_comprehensive_evaluation is not null").order("created_on DESC") + + @totle_score = score_for_homework @homework + @teaher_score = teacher_score_for_homework @homework respond_to do |format| format.js end diff --git a/app/views/homework_attach/addjours.js.erb b/app/views/homework_attach/addjours.js.erb index ed5887a7..e16609b6 100644 --- a/app/views/homework_attach/addjours.js.erb +++ b/app/views/homework_attach/addjours.js.erb @@ -1,6 +1,6 @@ <% if @add_jour.is_comprehensive_evaluation == 1 %> $('#comprehensive_evaluation').html('<%= escape_javascript(render(:partial => 'comprehensive_evaluation', - :locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework} )) %>'); + :locals => {:comprehensive_evaluation => @comprehensive_evaluation,:homework => @homework,:teaher_score => @teaher_score} )) %>'); <% else %> $('#message').html('<%= escape_javascript(render(:partial => 'showjour', :locals => {:jour =>@jour, :state => false,:homework => @homework} )) %>'); $('#pre_show').html('<%= escape_javascript(render(:partial => 'pre_show', :locals => {:content => nil})) %>'); diff --git a/app/views/homework_attach/edit.html.erb b/app/views/homework_attach/edit.html.erb index bfcf1f64..7467ca1a 100644 --- a/app/views/homework_attach/edit.html.erb +++ b/app/views/homework_attach/edit.html.erb @@ -47,7 +47,12 @@

      提交项目: - <%= f.select :project_id, options_for_select(user_projects_option,@homework.project.id),:name => "project_id", :required => true%> + <% if @homework.project.nil? %> + <%= f.select :project_id, options_for_select(user_projects_option),:name => "project_id", :required => true%> + <% else %> + <%= f.select :project_id, options_for_select(user_projects_option,@homework.project.id),:name => "project_id", :required => true%> + <% end %> + <%= link_to '创建项目', new_project_path(course: 0, project_type: 0), :target => '_blank' %>

      提交项目可以为空

      From 463edeee71094c6945155cc2a3a08c7d8c67b471 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 19 Jun 2014 17:49:18 +0800 Subject: [PATCH 118/183] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8D=E6=9C=AA=E5=BC=80?= =?UTF-8?q?=E5=90=AF=E4=BA=92=E8=AF=84=E5=8A=9F=E8=83=BD=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=80=BB=E8=AF=84=E5=BE=97=E5=88=86=E8=AE=A1=E7=AE=97=E4=B8=8D?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98=202.=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=9C=AA=E9=80=89=E6=8B=A9=E9=A1=B9=E7=9B=AE=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E3=80=81=E4=BF=AE=E6=94=B9=E6=9C=89=E8=AF=AF=E7=9A=84?= =?UTF-8?q?BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 20 +++++++++++++++++-- app/helpers/courses_helper.rb | 6 +++++- app/views/bids/_homework_list.html.erb | 2 +- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index ef3d683b..b11bf0dc 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -78,7 +78,15 @@ class HomeworkAttachController < ApplicationController if bid.homeworks.where("user_id = ?",User.current).count == 0 user_id = params[:user_id] bid_id = params[:bid_id] - project_id = params[:new_form][:project_id] + if params[:homework_attach] + if params[:homework_attach][:project_id] + project_id = params[:homework_attach][:project_id] + else + project_id = 0 + end + else + project_id = 0 + end sta = 0 name = params[:new_form][:name] description = params[:new_form][:description] @@ -180,7 +188,15 @@ class HomeworkAttachController < ApplicationController if User.current.admin? || User.current.member_of?(course) name = params[:homework_name] description = params[:homework_description] - project_id = params[:homework_attach][:project_id] + if params[:homework_attach] + if params[:homework_attach][:project_id] + project_id = params[:homework_attach][:project_id] + else + project_id = 0 + end + else + project_id = 0 + end @homework.name = name @homework.description = description @homework.project_id = project_id diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 96ea4e28..90bbe101 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -186,7 +186,11 @@ module CoursesHelper #获取指定作业的最终评分 #最终评分 = 学生评分的平均分 * 0.4 +教师评分 * 0.6 def score_for_homework homework - return format("%.2f",(teacher_score_for_homework(homework).to_f * 0.6 + student_score_for_homework(homework).to_f * 0.4)) + if homework.bid.is_evaluation == 1 || homework.bid.is_evaluation == nil + return format("%.2f",(teacher_score_for_homework(homework).to_f * 0.6 + student_score_for_homework(homework).to_f * 0.4)) + else + return teacher_score_for_homework homework + end end #获取作业的互评得分 diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index e1ca9e0f..b52ac693 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -114,7 +114,7 @@ 提交文件:  - <% if is_evaluation %> + <% if is_evaluation || is_teacher%> <%= link_to "打包下载", :controller => "zipdown", :action => "download_user_homework",:homework => homework%> <% else %> 未开启互评功能作业不允许下载 From 2ee5b422fb18e531283abebc96dcdc980fe2f04b Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 19 Jun 2014 18:16:55 +0800 Subject: [PATCH 119/183] =?UTF-8?q?RolesController.rb=E7=A7=BB=E5=9B=9Eapp?= =?UTF-8?q?/controls?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/{views/roles => controllers}/roles_controller.rb | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/{views/roles => controllers}/roles_controller.rb (100%) diff --git a/app/views/roles/roles_controller.rb b/app/controllers/roles_controller.rb similarity index 100% rename from app/views/roles/roles_controller.rb rename to app/controllers/roles_controller.rb From 19530df395e7d1b4a630862845d9d6f6ace4b73c Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 19 Jun 2014 19:14:51 +0800 Subject: [PATCH 120/183] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/bids/_app_link.html.erb | 32 +++++++++++++++++++------- app/views/bids/_attachment.html.erb | 6 +++++ app/views/bids/_homework_list.html.erb | 4 ++-- 3 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 app/views/bids/_attachment.html.erb diff --git a/app/views/bids/_app_link.html.erb b/app/views/bids/_app_link.html.erb index 645fe94f..d61f4ef8 100644 --- a/app/views/bids/_app_link.html.erb +++ b/app/views/bids/_app_link.html.erb @@ -1,8 +1,24 @@ -<% for attachment in attachments %> - <%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%> - <% if attachment.is_text? %> - <%= link_to image_tag('magnifier.png'), - :controller => 'attachments', :action => 'show', - :id => attachment, :filename => attachment.filename %> - <% end %> -<% end -%> \ No newline at end of file + + + <% count = 0 %> + <% for attachment in attachments %> + <% if attachments.count == 1 %> + + <% elsif attachments.count == 2 %> + + <% else %> + + <% end %> + <% end %> + +
      + <%= render :partial => 'attachment', :locals => {:attachment => attachment} %> + + <%= render :partial => 'attachment', :locals => {:attachment => attachment} %> + + <% if count == 3 %> + <% break %> + <% end %> + <%= render :partial => 'attachment', :locals => {:attachment => attachment} %> + <% count = count +1 %> +
      \ No newline at end of file diff --git a/app/views/bids/_attachment.html.erb b/app/views/bids/_attachment.html.erb new file mode 100644 index 00000000..6bccc08f --- /dev/null +++ b/app/views/bids/_attachment.html.erb @@ -0,0 +1,6 @@ +<%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%> +<% if attachment.is_text? %> + <%= link_to image_tag('magnifier.png'), + :controller => 'attachments', :action => 'show', + :id => attachment, :filename => attachment.filename,:style => "width:50px"%> +<% end %> \ No newline at end of file diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index b52ac693..0a92df47 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -132,8 +132,8 @@ - - <% if is_evaluation %> + + <% if is_evaluation || is_teacher%> <%= render :partial => 'app_link', :locals => {:attachments => homework.attachments} %> <% end %> From 36fecfc6355a196f50a4e200ca99992b4fd7cee0 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 19 Jun 2014 19:48:03 +0800 Subject: [PATCH 121/183] =?UTF-8?q?1.=E7=95=8C=E9=9D=A2=E9=A2=9C=E8=89=B2?= =?UTF-8?q?=E8=B0=83=E6=95=B4=202.=E5=BE=97=E5=88=86=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E2=80=9C=E5=88=86=E2=80=9D=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/bids/_homework_list.html.erb | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 0a92df47..30c6c602 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -12,7 +12,7 @@ User.current.admin? || !(User.current.roles_for_project(@bid.courses.first).map(&:id) & ([7,9])).empty? ) || (Rails.env.development?) %> - + @@ -92,22 +94,23 @@ - 开发项目:  - <% if homework.project != nil %> - <%= link_to homework.project.name,project_path(homework.project.id)%> - <% else %> - 暂无 - <% end %> + 开发项目:  + <% if homework.project != nil %> + <%= link_to homework.project.name,project_path(homework.project.id)%> + <% else %> + 暂无 + <% end %> - 项目得分:  + 项目得分:  <% if homework.project != nil %> - 0 + <%= project_score homework.project %> <% else %> - 0 + 0.00 <% end %> + From 989407dad2215fd1c1dcd5e73a36c92b6725fd07 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 19 Jun 2014 20:15:15 +0800 Subject: [PATCH 123/183] 12 --- app/helpers/courses_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 3d52e5fb..1bc11645 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -211,6 +211,7 @@ module CoursesHelper return format("%.2f",teacher_stars == nil ? 0 : teacher_stars.stars) end + #获取指定作业的得分 def project_score project issue_count = project.issues.count issue_journal_count = project.issue_changes.count From 6039cf63af132e28755aec5ed10ce6e2fe4cbeb4 Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 20 Jun 2014 09:08:18 +0800 Subject: [PATCH 124/183] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E6=9D=83=E9=99=90?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user.rb | 3 +++ public/stylesheets/application.css | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index d4e71009..a0861cd2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -818,6 +818,9 @@ class User < Principal # authorize if user has at least one role that has this permission roles = memberships.collect {|m| m.roles}.flatten.uniq + if roles.count == 0 + roles = coursememberships.collect {|m| m.roles}.flatten.uniq + end roles << (self.logged? ? Role.non_member : Role.anonymous) roles.any? {|role| role.allowed_to?(action) && diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 1952334e..97acb9a7 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -691,6 +691,12 @@ ul.tool li{list-style-type:none; word-break: break-all; } +ul.user_course_sort{margin:0px; padding-left:0em;} +ul.user_course_sort li{list-style-type:none; + height:auto;} + + + .info-break{ word-wrap: break-word; word-break: break-all; From 5277eddb959662cb67adb89c447f32329b39b44a Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 20 Jun 2014 09:40:12 +0800 Subject: [PATCH 125/183] =?UTF-8?q?=E5=B0=81=E8=A3=85=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E4=BD=9C=E4=B8=9A=E5=8F=82=E4=B8=8E=E4=BA=BA?= =?UTF-8?q?=E5=91=98=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 13 +++++++++++++ app/views/bids/_homework_list.html.erb | 8 +------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 1bc11645..0e0456bd 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -236,4 +236,17 @@ module CoursesHelper finall_project_score = finall_issue_score + finall_new_score + finall_file_score + finall_code_submit_score + topic_score format("%.2f",finall_project_score) end + + #获取指定作业的参与人员 + #返回结果:张三、李四、王五 + def homework_user_of_homework homework,is_teacher + homework_users = "" + homework.users.each do |user| + homework_users = homework_users + (is_teacher ? user.realname : user.name) + if user != homework.users.last + homework_users = homework_users + "、" + end + end + return homework_users + end end diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index a24c8b32..451324ce 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -72,13 +72,7 @@ 合作成员:  - <% homework_users = "" %> - <% homework.users.each do |user| %> - <% homework_users = homework_users + (is_teacher ? user.realname : user.name) %> - <% if user != homework.users.last %> - <% homework_users = homework_users + "、" %> - <% end %> - <% end %> + <% homework_users = homework_user_of_homework(homework,is_teacher) %> <% if homework.users.count == 0 %> 无 <% else %> From 8cdab80d314aea583a227b1e0649387f0700534d Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 20 Jun 2014 10:32:51 +0800 Subject: [PATCH 126/183] =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E9=93=BE=E6=8E=A5BUG=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_course_form.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/users/_course_form.html.erb b/app/views/users/_course_form.html.erb index ecdd0438..f5cada9a 100644 --- a/app/views/users/_course_form.html.erb +++ b/app/views/users/_course_form.html.erb @@ -23,10 +23,10 @@ <%= l(:label_x_base_courses_member, :count => membership.course.members.count) %> (<%= "#{membership.course.members.count}" %>)   <%= l(:label_homework) %> - (<%= link_to (membership.course.homeworks.count), {:controller => 'courses', :action => 'homework', :id => membership.course.extra} %>) + (<%= link_to (membership.course.homeworks.count), {:controller => 'courses', :action => 'homework', :id => membership.course.id} %>)    - <%#= l(:label_course_news) %> - (<%#= link_to (membership.course.news.count), {:controller => 'news', :action => 'index', :course_id => membership.course.extra} %>) + <%= l(:label_course_news) %> + (<%= link_to (membership.course.news.count), {:controller => 'news', :action => 'index', :course_id => membership.course.id} %>) From d0c9390e915be65182157af80a1c8acfea41763d Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 20 Jun 2014 10:52:34 +0800 Subject: [PATCH 127/183] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BB=80=E4=B9=88?= =?UTF-8?q?=E6=98=AF=E9=A1=B9=E7=9B=AE=E9=93=BE=E6=8E=A5=E3=80=82=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E4=BB=80=E4=B9=88=E6=98=AF=E9=A1=B9=E7=9B=AE=20?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0jQuary=E7=AA=97=E5=B8=98=E6=95=88=E6=9E=9C?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E8=A7=A3=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/bids/_homework.html.erb | 39 +++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/app/views/bids/_homework.html.erb b/app/views/bids/_homework.html.erb index 11b47819..d967d623 100644 --- a/app/views/bids/_homework.html.erb +++ b/app/views/bids/_homework.html.erb @@ -21,6 +21,12 @@ $.globalEval(submit_homework()); return false; } + + function show() + { + $("#what_is_project_div").slideToggle(); + + }
      <% if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && @@ -32,11 +38,34 @@
    <% end %> -<% if @homework_list.empty? %> -
    - 暂无学生提交作业! -
    -<% end %> + + + + + + + + + +
    + <% if @homework_list.empty? %> +
    + 暂无学生提交作业! +
    + <% end %> +
    + +
    + + + +
    <%= render :partial => 'homework_list', :locals => {:homework => @homework_list} %> From d2376eb0b13d8e75c69be9dd4d248d82b53894b8 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 20 Jun 2014 11:16:08 +0800 Subject: [PATCH 128/183] =?UTF-8?q?=E5=B0=86=E9=A1=B5=E9=9D=A2=E9=83=A8?= =?UTF-8?q?=E5=88=86jS=E4=BB=A3=E7=A0=81=E8=BD=AC=E4=B8=BAJQuary=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/bids/_homework.html.erb | 1 - app/views/homework_attach/edit.html.erb | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/views/bids/_homework.html.erb b/app/views/bids/_homework.html.erb index d967d623..b53e0658 100644 --- a/app/views/bids/_homework.html.erb +++ b/app/views/bids/_homework.html.erb @@ -25,7 +25,6 @@ function show() { $("#what_is_project_div").slideToggle(); - }
    diff --git a/app/views/homework_attach/edit.html.erb b/app/views/homework_attach/edit.html.erb index 7467ca1a..189b32d9 100644 --- a/app/views/homework_attach/edit.html.erb +++ b/app/views/homework_attach/edit.html.erb @@ -1,10 +1,10 @@ From 18762e2da76b43519b52247fb6379d33d90c1fb8 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 20 Jun 2014 13:52:17 +0800 Subject: [PATCH 129/183] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E3=80=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BD=9C=E4=B8=9A=E6=97=B6=E6=8F=90=E4=BA=A4=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=A2=9E=E5=8A=A0=E7=A9=BA=E5=80=BC=E9=80=89=E6=8B=A9?= =?UTF-8?q?=EF=BC=8C=E5=8D=B3=E4=B8=8D=E9=80=89=E5=AE=9A=E4=BB=BB=E4=BD=95?= =?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/helpers/homework_attach_helper.rb | 4 ++++ app/views/homework_attach/new.html.erb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/helpers/homework_attach_helper.rb b/app/helpers/homework_attach_helper.rb index fe7f123b..3510dc78 100644 --- a/app/helpers/homework_attach_helper.rb +++ b/app/helpers/homework_attach_helper.rb @@ -59,7 +59,11 @@ module HomeworkAttachHelper cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" memberships = User.current.memberships.all(:conditions => cond) projects = memberships.map(&:project) + not_have_project = [] + not_have_project << "<>" + not_have_project << 0 type = [] + type << not_have_project projects.each do |project| if project != nil option = [] diff --git a/app/views/homework_attach/new.html.erb b/app/views/homework_attach/new.html.erb index 46ab0ce8..8ec0eb0b 100644 --- a/app/views/homework_attach/new.html.erb +++ b/app/views/homework_attach/new.html.erb @@ -28,7 +28,7 @@

    提交项目: - <%= f.select :project_id, options_for_select(user_projects_option),:name => "project_id", :required => true%> + <%= f.select :project_id, options_for_select(user_projects_option),:name => "project_id", :required => true, :style => "width:490px;"%> <%= link_to '创建项目', new_project_path(course: 0, project_type: 0), :target => '_blank' %>

    提交项目可以为空

    From 54d4b957ee0eadf6746dd9839bf62a0521636f13 Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 20 Jun 2014 14:04:11 +0800 Subject: [PATCH 130/183] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AB=96=E6=8E=92?= =?UTF-8?q?=E7=9A=84=E8=B8=A9=E9=A1=B6=E5=9B=BE=E6=A0=87=E5=9C=A8=E8=B8=A9?= =?UTF-8?q?=E6=88=96=E9=A1=B6=E5=AE=8C=E5=90=8E=E5=8F=98=E6=88=90=E6=A8=AA?= =?UTF-8?q?=E6=8E=92=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/praise_tread_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/praise_tread_controller.rb b/app/controllers/praise_tread_controller.rb index 97cf3cda..368b901f 100644 --- a/app/controllers/praise_tread_controller.rb +++ b/app/controllers/praise_tread_controller.rb @@ -9,7 +9,7 @@ class PraiseTreadController < ApplicationController if request.get? @obj_id = params[:obj_id] @obj_type = params[:obj_type] - @horizontal = params[:horizontal] + @horizontal = params[:horizontal].downcase == "false" ? false:true @obj = find_object_by_type_and_id(@obj_type,@obj_id) praise_tread_plus(@obj_type,@obj_id,1) end @@ -45,7 +45,7 @@ class PraiseTreadController < ApplicationController if request.get? @obj_id = params[:obj_id] @obj_type = params[:obj_type] - @horizontal = params[:horizontal] + @horizontal = params[:horizontal].downcase == "false" ? false:true @obj = find_object_by_type_and_id(@obj_type,@obj_id) praise_tread_plus(@obj_type,@obj_id,0) end From 05659fa2dbd85e64cffc59363627829aed7f6230 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 20 Jun 2014 14:45:41 +0800 Subject: [PATCH 131/183] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E5=90=8E=E5=9C=A8=E2=80=9D=E4=BF=AE=E6=94=B9=E8=B5=84=E6=96=99?= =?UTF-8?q?=E2=80=9C=E4=B8=AD=E5=8F=91=E7=8E=B0=E6=88=91=E5=9C=A8=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E6=97=B6=E9=80=89=E6=8B=A9=E7=9A=84=E2=80=9D=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E2=80=9C=E8=BA=AB=E4=BB=BD=E5=92=8C=E5=9C=B0=E5=8C=BA?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E4=BB=A5=E5=8F=8A=E5=AD=A6=E5=8F=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E9=83=BD=E6=B2=A1=E6=9C=89=E4=BA=86=EF=BC=8C=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E9=87=8D=E6=96=B0=E5=A1=AB=E5=86=99=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index af848786..085ee0c6 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -143,13 +143,17 @@ class AccountController < ApplicationController end #added by bai - unless @user.id.nil? - ue = UserExtensions.create(:identity => params[:identity].to_i,:technical_title => params[:technical_title], :gender => params[:gender].to_i, :user_id => @user.id, :student_id => params[:no]) - unless params[:province].nil? || params[:city].nil? - ue.location = params[:province] - ue.location_city = params[:city] - ue.save - end + if @user.id != nil + ue = @user.user_extensions ||= UserExtensions.new + #ue = UserExtensions.create(:identity => params[:identity].to_i,:technical_title => params[:technical_title], :gender => params[:gender].to_i, :user_id => @user.id, :student_id => ) + ue.identity = params[:identity].to_i + ue.technical_title = params[:technical_title] + ue.gender = params[:gender].to_i + ue.user_id = @user.id + ue.student_id = params[:no] + ue.location = params[:province] if params[:province] != nil + ue.location_city = params[:city] if params[:city] != nil + ue.save end #end From 339b5b0296a1b69c5e8eb1c6737abf622c3b48cf Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 20 Jun 2014 17:14:43 +0800 Subject: [PATCH 132/183] =?UTF-8?q?=E7=BC=BA=E9=99=B7=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9B=B4=E6=8E=A5=E6=98=BE=E7=A4=BA=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E9=9C=80=E8=A6=81=E7=82=B9=E5=87=BB=E7=95=99=E8=A8=80?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E6=89=8D=E6=98=BE=E7=A4=BA=E7=BC=BA=E9=99=B7?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/issues/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb index 8e6ad803..89fc862d 100644 --- a/app/views/issues/show.html.erb +++ b/app/views/issues/show.html.erb @@ -147,7 +147,7 @@ end %>
    <% if @issue.editable? %> -