This commit is contained in:
commit
26b933dddb
2
Gemfile
2
Gemfile
|
@ -14,7 +14,7 @@ gem "i18n", "~> 0.6.0"
|
|||
gem "coderay", "~> 1.0.6"
|
||||
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
|
||||
gem "builder", "3.0.0"
|
||||
gem 'acts-as-taggable-on'
|
||||
gem 'acts-as-taggable-on', '2.4.1'
|
||||
|
||||
group :development do
|
||||
gem 'better_errors', path: 'lib/better_errors'
|
||||
|
|
|
@ -134,7 +134,7 @@ PLATFORMS
|
|||
DEPENDENCIES
|
||||
activerecord-jdbc-adapter (= 1.2.5)
|
||||
activerecord-jdbcmysql-adapter
|
||||
acts-as-taggable-on
|
||||
acts-as-taggable-on (= 2.4.1)
|
||||
better_errors!
|
||||
builder (= 3.0.0)
|
||||
coderay (~> 1.0.6)
|
||||
|
|
|
@ -45,3 +45,9 @@ app\controller\welcome_controller.rb
|
|||
end
|
||||
end
|
||||
================================================================================
|
||||
|
||||
================================================================================
|
||||
0606:新坑
|
||||
user_scores表结构有问题,需要运行
|
||||
bundle exec rake db:migrate:down VERSION=20140410021724
|
||||
bundle exec rake db:migrate:up VERSION=20140410021724
|
|
@ -264,6 +264,14 @@ class ApplicationController < ActionController::Base
|
|||
render_404
|
||||
end
|
||||
|
||||
#根据course_id找project
|
||||
def find_project_by_course_id
|
||||
@bid = Bid.find params[:course_id]
|
||||
@project = @bid.courses[0]
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
# Find a project based on params[:project_id]
|
||||
# TODO: some subclasses override this, see about merging their logic
|
||||
def find_optional_project
|
||||
|
|
|
@ -26,6 +26,13 @@ class BidsController < ApplicationController
|
|||
helper :words
|
||||
helper :welcome
|
||||
|
||||
def find_project_by_bid_id
|
||||
@bid = Bid.find(params[:id])
|
||||
@project = @bid.courses[0]
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def homework_ajax_modal
|
||||
@bid = Bid.find_by_id(params[:id])
|
||||
# find_bid
|
||||
|
@ -410,9 +417,7 @@ class BidsController < ApplicationController
|
|||
@homework = HomeworkAttach.new
|
||||
#@homework_list = @bid.homeworks
|
||||
#增加作业按评分排序,
|
||||
@homework_list = HomeworkAttach.find_by_sql("SELECT homework_attaches.*,
|
||||
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id) AS score
|
||||
FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY score DESC,created_at ASC",:include => [:attachments])
|
||||
@homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC')
|
||||
if params[:student_id].present?
|
||||
@temp = []
|
||||
@homework_list.each do |pro|
|
||||
|
@ -528,6 +533,7 @@ class BidsController < ApplicationController
|
|||
message = params[:bid_message][:message] + "\n" + params[:reference_content]
|
||||
else
|
||||
message = params[:bid_message][:message]
|
||||
@m = message
|
||||
end
|
||||
refer_user_id = params[:bid_message][:reference_user_id].to_i
|
||||
@bid.add_jour(User.current, message, refer_user_id)
|
||||
|
|
|
@ -210,11 +210,14 @@ class ContestsController < ApplicationController
|
|||
# @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
|
||||
@membership.each do |membership|
|
||||
unless(membership.project.project_type==1)
|
||||
membership.member_roles.each{|role|
|
||||
if(role.role_id == 3)
|
||||
#membership.member_roles.each{|role|
|
||||
# if(role.role_id == 3)
|
||||
# @option << membership.project
|
||||
# end
|
||||
#}
|
||||
if User.current.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
|
||||
@option << membership.project
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
@user = @contest.author
|
||||
|
@ -301,11 +304,15 @@ class ContestsController < ApplicationController
|
|||
# @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
|
||||
@membership.each do |membership|
|
||||
unless(membership.project.project_type==1)
|
||||
membership.member_roles.each{|role|
|
||||
if(role.role_id == 3)
|
||||
#membership.member_roles.each{|role|
|
||||
#if(role.role_id == 3)
|
||||
#@option << membership.project
|
||||
#end
|
||||
#}
|
||||
#拥有编辑项目权限的可将该项目参赛
|
||||
if User.current.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
|
||||
@option << membership.project
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
@user = @contest.author
|
||||
|
|
|
@ -1,5 +1,23 @@
|
|||
class HomeworkAttachController < ApplicationController
|
||||
###############################
|
||||
#判断当前角色权限时需先找到当前操作的project
|
||||
before_filter :find_project_by_bid_id, :only => [:new]
|
||||
before_filter :find_project_by_hoemwork_id, :only => [:edit,:update,:destroy]
|
||||
#判断当前角色是否有操作权限
|
||||
#勿删 before_filter :authorize, :only => [:new,:edit,:update,:destroy]
|
||||
|
||||
def find_project_by_bid_id
|
||||
@bid = Bid.find(params[:id])
|
||||
@project = @bid.courses[0]
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
|
||||
def find_project_by_hoemwork_id
|
||||
@homework = HomeworkAttach.find(params[:id])
|
||||
@project = @homework.bid.courses[0]
|
||||
end
|
||||
|
||||
def index
|
||||
@homeworks = HomeworkAttach.all
|
||||
respond_to do |format|
|
||||
|
|
|
@ -37,6 +37,7 @@ class ProjectsController < ApplicationController
|
|||
# before_filter :authorize, :except => [:new_join, :new_homework, :homework, :statistics, :search, :watcherlist, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file,
|
||||
# :statistics, :feedback, :course, :enterprise_course, :course_enterprise, :project_respond, :share,
|
||||
# :show_projects_score, :issue_score_index, :news_score_index, :file_score_index, :code_submit_score_index, :projects_topic_score_index]
|
||||
#此条勿删 课程相关权限 ,:new_homework,:homework,:feedback,,:member
|
||||
before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :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]
|
||||
|
@ -721,6 +722,9 @@ class ProjectsController < ApplicationController
|
|||
@teachers= searchTeacherAndAssistant(@project)
|
||||
@canShowRealName = isCourseTeacher(User.current.id)
|
||||
end
|
||||
|
||||
#勿删 real_name action为虚拟的该方法并不存在,用来辅助判断真名权限
|
||||
#勿删 @canShowRealName = User.current.allowed_to?({:controller => "projects", :action => "real_name"}, @project || @projects, :global => false)
|
||||
respond_to do |format|
|
||||
format.html{render :layout => 'base_courses' if @base_courses_tag==1}
|
||||
format.api
|
||||
|
|
|
@ -108,11 +108,16 @@ class SoftapplicationsController < ApplicationController
|
|||
# @contesting_project_pages = Paginator.new @contesting_project_count, per_page_option, params['page']
|
||||
@membership.each do |membership|
|
||||
unless(membership.project.project_type==1)
|
||||
membership.member_roles.each{|role|
|
||||
if(role.role_id == 3)
|
||||
#membership.member_roles.each{|role|
|
||||
# if(role.role_id == 3)
|
||||
# @option << membership.project
|
||||
# end
|
||||
#}
|
||||
|
||||
#拥有编辑项目权限的可操作该项目
|
||||
if User.current.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
|
||||
@option << membership.project
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,21 @@
|
|||
class ZipdownController < ApplicationController
|
||||
#查找项目(课程)
|
||||
before_filter :find_project_by_bid_id, :only => [:assort,:download_user_homework]
|
||||
#检查权限
|
||||
#勿删 before_filter :authorize, :only => [:assort,:download_user_homework]
|
||||
SAVE_FOLDER = "#{Rails.root}/files"
|
||||
OUTPUT_FOLDER = "#{Rails.root}/tmp/archiveZip"
|
||||
|
||||
#通过作业Id找到项目(课程)
|
||||
def find_project_by_bid_id
|
||||
obj_class = params[:obj_class]
|
||||
obj_id = params[:obj_id]
|
||||
obj = obj_class.constantize.find(obj_id)
|
||||
case obj.class.to_s.to_sym
|
||||
when :Bid
|
||||
@project = obj.courses[0]
|
||||
end
|
||||
end
|
||||
def assort
|
||||
obj_class = params[:obj_class]
|
||||
obj_id = params[:obj_id]
|
||||
|
|
|
@ -157,13 +157,24 @@ module BidsHelper
|
|||
end
|
||||
#当前用户是不是指定课程的学生
|
||||
def is_cur_course_student? course
|
||||
people = []
|
||||
course.members.each do |member|
|
||||
if [5,10].include? member.roles.first.id
|
||||
people << member.user
|
||||
#people = []
|
||||
#course.members.includes(:user, :roles).each do |member|
|
||||
# if [5,10].include? member.roles.first.id
|
||||
# people << member.user
|
||||
# end
|
||||
#end
|
||||
#people.include?(User.current)
|
||||
#修改:能新建占位且不能新建任务的角色判定为学生
|
||||
is_student = false
|
||||
@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||
@membership.each do |membership|
|
||||
unless(membership.project.project_type==0)
|
||||
if !User.current.allowed_to?({:controller => "projects", :action => "new_homework"}, membership.project, :global => false) && User.current.allowed_to?({:controller => "homework_attach", :action => "new"}, membership.project, :global => false)
|
||||
is_student = true
|
||||
end
|
||||
end
|
||||
people.include?(User.current)
|
||||
end
|
||||
is_student
|
||||
end
|
||||
|
||||
# def select_option_helper option
|
||||
|
|
|
@ -137,12 +137,47 @@ module CoursesHelper
|
|||
Course.find_by_extra(try(extra))
|
||||
end
|
||||
#判断制定用户是不是当前课程的老师
|
||||
def is_course_teacher user,course
|
||||
searchPeopleByRoles(course, TeacherRoles).include?(user)
|
||||
def is_course_teacher (user,course)
|
||||
#people = []
|
||||
#course.members.includes(:roles, :user).each do |member|
|
||||
# role_id = member.roles.first.id
|
||||
# if TeacherRoles.include? role_id
|
||||
# people << member.user
|
||||
# end
|
||||
#end
|
||||
#people.include?(user)
|
||||
#修改为根据用户是否有发布任务的权限来判断用户是否是课程的老师
|
||||
is_teacher = false
|
||||
@membership = user.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||
@membership.each do |membership|
|
||||
unless(membership.project.project_type==0)
|
||||
if user.allowed_to?({:controller => "projects", :action => "new_homework"}, membership.project, :global => false)
|
||||
is_teacher = true
|
||||
end
|
||||
end
|
||||
end
|
||||
is_teacher
|
||||
end
|
||||
#当前用户是不是指定课程的学生
|
||||
def is_cur_course_student? course
|
||||
searchPeopleByRoles(course, StudentRoles).include?(User.current)
|
||||
#people = []
|
||||
#course.members.includes(:roles, :user).each do |member|
|
||||
# if StudentRoles.include? member.roles.first.id
|
||||
# people << member.user
|
||||
# end
|
||||
#end
|
||||
#people.include?(User.current)
|
||||
#修改:能新建占位且不能新建任务的角色判定为学生
|
||||
is_student = false
|
||||
@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||
@membership.each do |membership|
|
||||
unless(membership.project.project_type==0)
|
||||
if !User.current.allowed_to?({:controller => "projects", :action => "new_homework"}, membership.project, :global => false) && User.current.allowed_to?({:controller => "homework_attach", :action => "new"}, membership.project, :global => false)
|
||||
is_student = true
|
||||
end
|
||||
end
|
||||
end
|
||||
is_student
|
||||
end
|
||||
#获取当前用户在指定作业下提交的作业的集合
|
||||
def cur_user_homework_for_bid bid
|
||||
|
|
|
@ -4,11 +4,15 @@ def options_from_select_project(user)
|
|||
@option = []
|
||||
@membership.each do |membership|
|
||||
unless(membership.project.project_type==1)
|
||||
membership.member_roles.each{|role|
|
||||
if(role.role_id == 3)
|
||||
#membership.member_roles.each{|role|
|
||||
# if(role.role_id == 3)
|
||||
# @option << membership.project
|
||||
# end
|
||||
#}
|
||||
#拥有编辑项目权限的可操作该项目
|
||||
if user.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
|
||||
@option << membership.project
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
options_for_select(@option)
|
||||
|
|
|
@ -228,12 +228,21 @@ module UserScoreHelper
|
|||
isManager = 0
|
||||
members = Member.where('user_id = ?', user.id)
|
||||
members.each do |m|
|
||||
roles = m.member_roles
|
||||
roles.each do |r|
|
||||
if r.role_id == 3
|
||||
#roles = m.member_roles
|
||||
#roles.each do |r|
|
||||
# if r.role_id == 3
|
||||
# isManager = 1
|
||||
# end
|
||||
#end
|
||||
@membership = m.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||
@membership.each do |membership|
|
||||
#拥有编辑项目权限的可操作该项目
|
||||
if m.allowed_to?({:controller => "projects", :action => "edit"}, membership.project, :global => false)
|
||||
isManager = 1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
level = 0
|
||||
|
|
|
@ -56,6 +56,7 @@ class Attachment < ActiveRecord::Base
|
|||
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
|
||||
|
||||
before_save :files_to_final_location
|
||||
before_save :be_user_score # user_score
|
||||
after_destroy :delete_from_disk
|
||||
|
||||
# Returns an unsaved copy of the attachment
|
||||
|
@ -361,4 +362,17 @@ class Attachment < ActiveRecord::Base
|
|||
end
|
||||
"#{timestamp}_#{ascii}"
|
||||
end
|
||||
|
||||
|
||||
# update user score
|
||||
def be_user_score
|
||||
if self.container_id_changed?
|
||||
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 })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
class Changeset < ActiveRecord::Base
|
||||
belongs_to :repository
|
||||
belongs_to :user
|
||||
|
||||
after_save :be_user_score # user_score
|
||||
|
||||
has_many :filechanges, :class_name => 'Change', :dependent => :delete_all
|
||||
# fq
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
|
@ -292,4 +295,14 @@ class Changeset < ActiveRecord::Base
|
|||
def self.to_utf8(str, encoding)
|
||||
Redmine::CodesetUtil.to_utf8(str, encoding)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# update user score
|
||||
def be_user_score
|
||||
if self.new_record?
|
||||
UserScore.project(:push_code, self.user, { changeset_id: self.id })
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -19,6 +19,10 @@ class Document < ActiveRecord::Base
|
|||
include Redmine::SafeAttributes
|
||||
belongs_to :project
|
||||
belongs_to :category, :class_name => "DocumentCategory", :foreign_key => "category_id"
|
||||
|
||||
before_save :be_user_score # user_score
|
||||
|
||||
|
||||
acts_as_attachable :delete_permission => :delete_documents
|
||||
|
||||
acts_as_searchable :columns => ['title', "#{table_name}.description"], :include => :project
|
||||
|
@ -54,4 +58,11 @@ class Document < ActiveRecord::Base
|
|||
end
|
||||
@updated_on
|
||||
end
|
||||
|
||||
# update user score
|
||||
def be_user_score
|
||||
if self.new_record?
|
||||
UserScore.project(:push_document, User.current, { document_id: self.id })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -77,6 +77,8 @@ class Issue < ActiveRecord::Base
|
|||
|
||||
# fq
|
||||
after_create :act_as_activity
|
||||
before_save :be_user_score
|
||||
# after_create :be_user_score
|
||||
# end
|
||||
|
||||
delegate :notes, :notes=, :private_notes, :private_notes=, :to => :current_journal, :allow_nil => true
|
||||
|
@ -1484,4 +1486,14 @@ class Issue < ActiveRecord::Base
|
|||
and #{visible_condition(User.current, :project => project)}
|
||||
group by s.id, s.is_closed, j.id")
|
||||
end
|
||||
|
||||
# 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 })
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -51,7 +51,7 @@ class Mailer < ActionMailer::Base
|
|||
when :User
|
||||
user_newfeedback_user_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
|
||||
else
|
||||
logger.error "[Builds a Mail::Message ERROR] journalsForMessage's jour is unkown type, journalsForMessage.id = #{journals_for_message.id}"
|
||||
Rails.logger.error "[Builds a Mail::Message ERROR] journalsForMessage's jour is unkown type, journalsForMessage.id = #{journals_for_message.id}"
|
||||
return -1
|
||||
end
|
||||
#如果是直接留言并且留言对象是Project并且Project类型是课程
|
||||
|
@ -70,6 +70,11 @@ class Mailer < ActionMailer::Base
|
|||
end
|
||||
mail :to => @recipients,
|
||||
:subject => "#{l(:label_your_course)}#{journals_for_message.jour.name}#{l(:label_have_message)} "
|
||||
elsif journals_for_message.jour.class.to_s.to_sym == :Bid
|
||||
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
|
||||
|
|
|
@ -54,6 +54,7 @@ class Message < ActiveRecord::Base
|
|||
|
||||
# fq
|
||||
after_create :act_as_activity
|
||||
before_save :be_user_score
|
||||
# end
|
||||
|
||||
scope :visible, lambda {|*args|
|
||||
|
@ -121,4 +122,11 @@ class Message < ActiveRecord::Base
|
|||
self.acts << Activity.new(:user_id => self.author_id)
|
||||
end
|
||||
# end
|
||||
|
||||
# update user score
|
||||
def be_user_score
|
||||
if self.new_record?
|
||||
UserScore.joint(:post_message, User.current,nil, { message_id: self.id })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -137,7 +137,7 @@ class User < Principal
|
|||
has_one :user_extensions,:dependent => :destroy
|
||||
## end
|
||||
|
||||
#default_scope -> { includes(:user_extensions, :user_score) }
|
||||
# default_scope -> { includes(:user_extensions, :user_score) }
|
||||
scope :teacher, -> {
|
||||
joins(:user_extensions).where('user_extensions.identity = ?', UserExtensions::TEACHER)
|
||||
}
|
||||
|
@ -201,6 +201,7 @@ class User < Principal
|
|||
|
||||
# ======================================================================
|
||||
# 集中处理 User 扩展表为空的问题
|
||||
# 合并 user_score 属性
|
||||
validate :valid_user_extensions
|
||||
after_save :save_user_extensions
|
||||
|
||||
|
@ -208,21 +209,32 @@ class User < Principal
|
|||
self.user_extensions ||= UserExtensions.new
|
||||
end
|
||||
|
||||
def respond_to?(m, include_private = false)
|
||||
flag = UserExtensions.instance_methods.include? m.to_sym
|
||||
if flag
|
||||
flag
|
||||
else
|
||||
super
|
||||
def user_score_attr
|
||||
self.user_score ||= UserScore.new
|
||||
end
|
||||
|
||||
alias_method :ori_respond_to?, :respond_to?
|
||||
def respond_to?(m, include_private = false)
|
||||
flag = false
|
||||
flag = ori_respond_to? m.to_sym unless flag
|
||||
flag = UserExtensions.new.respond_to? m.to_sym unless flag
|
||||
flag = UserScore.new.respond_to? m.to_sym unless flag
|
||||
|
||||
flag
|
||||
end
|
||||
|
||||
def method_missing m, *args, &block
|
||||
if extensions.respond_to? m.to_sym
|
||||
self.class.send :define_method, m.to_sym, *args do
|
||||
self.class.send(:define_method, "_meta_#{m}".to_sym) do |*args, &block|
|
||||
self.extensions.__send__ m.to_sym, *args
|
||||
end
|
||||
__send__ m.to_sym, *args, &block
|
||||
__send__ "_meta_#{m}".to_sym, *args, &block
|
||||
|
||||
elsif user_score_attr.respond_to? m.to_sym
|
||||
self.class.send(:define_method, "_meta_#{m}".to_sym) do |*args, &block|
|
||||
self.user_score_attr.__send__ m.to_sym, *args
|
||||
end
|
||||
__send__ "_meta_#{m}".to_sym, *args, &block
|
||||
|
||||
else
|
||||
super
|
||||
|
@ -241,6 +253,7 @@ class User < Principal
|
|||
|
||||
def save_user_extensions
|
||||
self.extensions.save
|
||||
self.user_score_attr.save
|
||||
end
|
||||
# 集中处理 User 扩展表为空的问题 < end
|
||||
# ======================================================================
|
||||
|
|
|
@ -33,4 +33,154 @@ class UserScore < ActiveRecord::Base
|
|||
def self.find_min_issue
|
||||
self.minimum(:file)
|
||||
end
|
||||
# 以上类方法目测没用,反正也报错
|
||||
# ===============================================================================
|
||||
|
||||
# 前略·协同得分
|
||||
# operate - 更新操作 类型 symbol
|
||||
# user - 计分用户
|
||||
#
|
||||
# Examples
|
||||
#
|
||||
# UserScore.joint(:post_message, User.current, nil)
|
||||
# # => true #当前用户发帖计分操作成功
|
||||
#
|
||||
# Returns boolean. 返回积分保存结果
|
||||
def self.joint(operate, current_user, target_user, 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 发帖了
|
||||
user_score.collaboration = user_score.collaboration.to_i + 2
|
||||
user_score.save
|
||||
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a message. options => (#{options.to_s})"
|
||||
when :post_issue # current_user 对 target_user 的缺陷留言了
|
||||
user_score.collaboration = user_score.collaboration.to_i + 1
|
||||
user_score.save
|
||||
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} posting a issue. options => (#{options.to_s})"
|
||||
when :change_issue_status # current_user 更改了缺陷的状态
|
||||
user_score.collaboration = user_score.collaboration.to_i + 1
|
||||
user_score.save
|
||||
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} change issue status. options => (#{options.to_s})"
|
||||
when :reply_message # current_user 对 target_user 留言的回复
|
||||
user_score.collaboration = user_score.collaboration.to_i + 1
|
||||
user_score.save
|
||||
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply message. options => (#{options.to_s})"
|
||||
when :reply_posting # current_user 对 target_user 帖子的回复
|
||||
user_score.collaboration = user_score.collaboration.to_i + 1
|
||||
user_score.save
|
||||
Rails.logger.info "[UserScore#joint] ===> User: #{current_user} reply posting. options => (#{options.to_s})"
|
||||
else
|
||||
Rails.logger.error "[UserScore#joint] ===> #{operate} is not define."
|
||||
return false
|
||||
end
|
||||
rescue => e
|
||||
Rails.logger.error "[UserScore#joint] ===> Exception: #{e}."
|
||||
end
|
||||
|
||||
# 前略·影响力得分
|
||||
# operate - 更新操作 类型 symbol
|
||||
# user - 计分用户
|
||||
#
|
||||
# Examples
|
||||
#
|
||||
# UserScore.influence(:followed_by, user)
|
||||
# # => true #当前被关注用户记分成功
|
||||
#
|
||||
# Returns boolean. 返回积分保存结果
|
||||
def self.influence(operate, current_user, target_user, options={})
|
||||
current_user, target_user = get_users(current_user, target_user)
|
||||
user_score = current_user.user_score_attr
|
||||
case operate
|
||||
when :followed_by # current_user 关注了target_user
|
||||
user_score.active = user_score.influence.to_i + 2
|
||||
user_score.save
|
||||
Rails.logger.info "[UserScore#influence] ===> User: #{current_user} be followed. options => (#{options.to_s})"
|
||||
else
|
||||
Rails.logger.error "[UserScore#influence] ===> #{operate} is not define."
|
||||
return false
|
||||
end
|
||||
rescue => e
|
||||
Rails.logger.error "[UserScore#influence] ===> Exception: #{e}."
|
||||
end
|
||||
|
||||
# 前略·技术得分
|
||||
# operate - 更新操作 类型 symbol
|
||||
# user - 计分用户
|
||||
#
|
||||
# Examples
|
||||
#
|
||||
# UserScore.skill(:followed_by, current_user, target_user)
|
||||
# # => true #当前current_user对target_user用户帖子的记分成功
|
||||
#
|
||||
# Returns boolean. 返回积分保存结果
|
||||
def self.skill(operate, current_user, target_user, options={})
|
||||
current_user, target_user = get_users(current_user, target_user)
|
||||
user_score = current_user.user_score_attr
|
||||
case operate
|
||||
# when :treading # current_user 踩了 target_user 的帖子
|
||||
# Rails.logger.info "[UserScore#skill] ===> User: #{current_user} treading #{target_user}'s posting. options => (#{options.to_s})"
|
||||
when :treaded_by_user # current_user 踩了 target_user 的帖子
|
||||
Rails.logger.info "[UserScore#skill] ===> User: #{current_user} treaded_by #{target_user}. options => (#{options.to_s})"
|
||||
when :praised_by_user # current_user 顶了 target_user 的帖子
|
||||
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."
|
||||
return false
|
||||
end
|
||||
rescue => e
|
||||
Rails.logger.error "[UserScore#skill] ===> Exception: #{e}."
|
||||
end
|
||||
|
||||
# 前略·项目得分
|
||||
# operate - 更新操作 类型 symbol
|
||||
# user - 计分用户
|
||||
#
|
||||
# Examples
|
||||
#
|
||||
# UserScore.project(:pull_code, current_user)
|
||||
# # => true #当前current_user对项目贡献积分成功
|
||||
#
|
||||
# Returns boolean. 返回积分保存结果
|
||||
def self.project(operate, current_user, options={})
|
||||
current_user, target_user = get_users(current_user, nil)
|
||||
user_score = current_user.try(:user_score_attr)
|
||||
return false if current_user.nil?
|
||||
case operate
|
||||
when :push_code # current_user 提交了代码
|
||||
user_score = user_score.active.to_i + 4
|
||||
user_score.save
|
||||
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
|
||||
user_score.active = user_score.active.to_i + 4
|
||||
user_score.save
|
||||
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] pushed a document. options => (#{options.to_s})"
|
||||
when :push_file # current_user
|
||||
user_score.active = user_score.active.to_i + 4
|
||||
user_score.save
|
||||
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
|
||||
user_score.active = user_score.active.to_i + 2
|
||||
user_score.save
|
||||
Rails.logger.debug "[UserScore#project] ===> User: [#{current_user.id},#{current_user.name}] updated issue ratio. options => (#{options.to_s})"
|
||||
when :post_issue # current_user
|
||||
user_score.active = user_score.active.to_i + 4
|
||||
user_score.save
|
||||
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."
|
||||
return false
|
||||
end
|
||||
rescue => e
|
||||
Rails.logger.error "[UserScore#project] ===> Exception: #{e}."
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.get_users(current_user, target_user)
|
||||
cUser = (current_user.kind_of?User) ? current_user : User.find_by_id(current_user)
|
||||
tUser = (target_user.kind_of?User) ? target_user : User.find_by_id(target_user)
|
||||
|
||||
[cUser, tUser]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -75,7 +75,8 @@
|
|||
</td>
|
||||
<td>
|
||||
<strong>作业评分:</strong>
|
||||
<%= homework_score homework %>
|
||||
|
||||
<%= format("%.2f", homework.rate_averages.first.try(:avg).to_i ) %>
|
||||
</td>
|
||||
<td valign="top" align="right">
|
||||
<% if Time.parse(@bid.deadline.to_s) < Time.parse(homework.created_at.to_s) %>
|
||||
|
@ -86,7 +87,7 @@
|
|||
<tr>
|
||||
<td valign="top">
|
||||
<% if User.current.member_of?(@bid.courses.first) %>
|
||||
<strong><%= l(:label_bidding_user_studentcode) %> : <%= homework.user.user_extensions.student_id%></strong>
|
||||
<strong><%= l(:label_bidding_user_studentcode) %> : <%= homework.user.student_id%></strong>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
<% if @bid.homework_type == Bid::HomeworkFile %>
|
||||
<!-- 提交文件类型 -->
|
||||
<%= render :partial => 'homework' %>
|
||||
|
||||
<% else %>
|
||||
|
||||
<!-- 提交引用项目 -->
|
||||
<script type="text/javascript" language="javascript">
|
||||
function clearInfo(id, content) {
|
||||
var text = $('#' + id);
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
<%= yield :header_tags -%>
|
||||
</head>
|
||||
<body class="<%= h body_css_classes %>">
|
||||
<% project = @bid.courses.first %>
|
||||
<% course = Course.find_by_extra(project.identifier) %>
|
||||
<% project = @bid.courses.includes(:course_extra).first %>
|
||||
<% course = project.course_extra %>
|
||||
<div id="wrapper">
|
||||
<div id="wrapper2">
|
||||
<div id="wrapper3">
|
||||
|
@ -179,7 +179,7 @@
|
|||
<tr>
|
||||
<td style="padding-top: 5px"> <% if @bid.homework_type == 1%>
|
||||
<% if @bid.homeworks.size>0 %>
|
||||
<% for homework in @bid.homeworks %>
|
||||
<% 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 %>
|
||||
<p class="font_lighter">
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<% else %>
|
||||
<p class="font_description">
|
||||
|
||||
<%= l(:label_project_cousre_studentun) %><%= link_to"#{l(:label_course_join_student)}",{:controller=>'projects',:action=>'course', :course => 1}, :class => 'icon icon-add' %>
|
||||
<%= l(:label_project_cousre_studentun) %><%= link_to"#{l(:label_course_join_student)}",{:controller=>'projects',:action=>'course', :project_type => 1}, :class => 'icon icon-add' %>
|
||||
</p>
|
||||
<% end %>
|
||||
<% else %>
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
<!-- added by bai -->
|
||||
<% unless @user.id == 1%>
|
||||
<% messages_count = @user.messages.count %>
|
||||
<% messages_score = messages_count * 0.05%>
|
||||
<% finall_messages_score = messages_score %>
|
||||
<% end %>
|
||||
|
||||
<% journals_count = @user.journals.count %>
|
||||
<% journals_score = journals_count * 0.1 %>
|
||||
|
@ -28,7 +26,7 @@
|
|||
|
||||
<h3 class="title"><%= l(:label_user_score) %></h3>
|
||||
<div class="inf_user_image">
|
||||
<table style="border-bottom: solid 1px #80a6d2;", width="100%">
|
||||
<table style="border-bottom: solid 1px #80a6d2;" width="100%">
|
||||
<tr>
|
||||
<td align="left" valign="middle" ><%= image_tag(url_to_avatar(@user), :class => 'avatar2') %></td>
|
||||
<td width="35%">
|
||||
|
@ -48,7 +46,7 @@
|
|||
|
||||
</table>
|
||||
|
||||
<table style="border-bottom: solid 0px #80a6d2;", width="100%">
|
||||
<table style="border-bottom: solid 0px #80a6d2;" width="100%">
|
||||
<tr>
|
||||
<%= link_to l(:label_user_score), {:controller => 'users', :action => 'score_index', :remote => true} %> :
|
||||
<%= format("%.2f" , finall_user_score).to_f %>
|
||||
|
@ -73,31 +71,6 @@
|
|||
|
||||
</div>
|
||||
|
||||
<!-- <div class="inf_user_image">
|
||||
<ul>
|
||||
<li>
|
||||
<%= link_to l(:label_user_score), {:controller => 'users', :action => 'score_index', :remote => true} %> :
|
||||
<%= format("%.2f" , finall_user_score).to_f %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to l(:label_user_score_of_topic), {:controller => 'users', :action => 'topic_score_index', :remote => true} %> :
|
||||
<%= format("%.2f" , finall_messages_score).to_f %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to l(:label_user_score_of_project), {:controller => 'users', :action => 'project_score_index', :remote => true} %> :
|
||||
<%= format("%.2f" , finall_user_project_score).to_f %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to l(:label_user_score_of_activity), {:controller => 'users', :action => 'activity_score_index', :remote => true} %> :
|
||||
<%= format("%.2f" , finall_activity_score).to_f %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to l(:label_user_score_of_influence), {:controller => 'users', :action => 'influence_score_index', :remote => true} %> :
|
||||
<%= format("%.2f" , finall_influence_score).to_f %>
|
||||
</li>
|
||||
</ul>
|
||||
</div> -->
|
||||
<div id="show_score_detail", style="padding-left: 6px">
|
||||
<div id="show_score_detail" style="padding-left: 6px">
|
||||
<%= render :partial => 'users/score_index', :locals => {:index => 0 } %>
|
||||
</div>
|
||||
<!-- end -->
|
|
@ -1,5 +1,3 @@
|
|||
<!-- added by bai -->
|
||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'users/show_score') %>');
|
||||
showModal('ajax-modal', '400px');
|
||||
$('#ajax-modal').addClass('new-watcher');
|
||||
<!-- end -->
|
|
@ -13,7 +13,7 @@
|
|||
<tr> <!-- modified by bai 区别了“关注”里个人参与的项目与课程-->
|
||||
<td colspan="2" width="580px" ><p class="font_description">
|
||||
<% unless user.memberships.empty? %>
|
||||
<% cond = Project.visible_condition(User.current) + "AND projects.project_type <> 1" %>
|
||||
<% 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 %>
|
||||
|
@ -23,7 +23,7 @@
|
|||
</p>
|
||||
<p class="font_description">
|
||||
<% unless user.memberships.empty? %>
|
||||
<% cond = Project.visible_condition(User.current) + "AND projects.project_type = 1" %>
|
||||
<% 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 %>
|
||||
|
|
|
@ -473,6 +473,27 @@ en:
|
|||
permission_export_wiki_pages: Export wiki pages
|
||||
permission_manage_subtasks: Manage subtasks
|
||||
permission_manage_related_issues: Manage related issues
|
||||
permission_view_journals_for_messages: View journals messages
|
||||
permission_view_courses: View courses
|
||||
permission_new_course: Create course
|
||||
permission_configure_course: Configure course
|
||||
permission_close_course: Close/open course
|
||||
permission_new_assignment: Create assignment
|
||||
permission_edit_assignment: Edit assignment
|
||||
permission_delete_assignment: Delete assignment
|
||||
permission_new_placeholder: Create placeholder
|
||||
permission_edit_placeholder: Edit placeholder
|
||||
permission_delete_placeholder: Delete placeholder
|
||||
permission_commit_content: Commit content
|
||||
permission_new_course_notify: Create course notify
|
||||
permission_edit_course_notify: Eidt course notify
|
||||
permission_delete_course_notify: Delete course notify
|
||||
permission_view_assignment: View assignment
|
||||
permission_view_placeholder: View placeholder
|
||||
permission_view_course_messages: View course messages
|
||||
permission_view_real_name: View real name
|
||||
permission_view_students: View students
|
||||
permission_export_homeworks: Export homeworks
|
||||
|
||||
project_module_issue_tracking: Issue tracking
|
||||
project_module_time_tracking: Time tracking
|
||||
|
|
|
@ -454,7 +454,27 @@ zh:
|
|||
permission_export_wiki_pages: 导出 wiki 页面
|
||||
permission_manage_subtasks: 管理子任务
|
||||
permission_view_journals_for_messages: 查看留言
|
||||
permission_view_courses: 查看课程列表
|
||||
permission_view_courses: 查看课程
|
||||
permission_new_course: 新建课程
|
||||
permission_configure_course: 配置课程
|
||||
permission_close_course: 关闭/重开课程
|
||||
permission_new_assignment: 新建任务
|
||||
permission_edit_assignment: 编辑任务
|
||||
permission_delete_assignment: 删除任务
|
||||
permission_new_placeholder: 新建占位
|
||||
permission_edit_placeholder: 编辑占位
|
||||
permission_delete_placeholder: 删除占位
|
||||
permission_commit_content: 提交内容
|
||||
permission_new_course_notify: 发布课程通知
|
||||
permission_edit_course_notify: 编辑课程通知
|
||||
permission_delete_course_notify: 删除课程通知
|
||||
permission_view_assignment: 查看任务
|
||||
permission_view_placeholder: 查看占位
|
||||
permission_view_course_messages: 查看留言
|
||||
permission_view_real_name: 查看真名
|
||||
permission_view_students: 查看成员
|
||||
permission_export_homeworks: 导出作业
|
||||
|
||||
|
||||
project_module_issue_tracking: 问题跟踪
|
||||
project_module_time_tracking: 时间跟踪
|
||||
|
|
|
@ -172,6 +172,7 @@ default_projects_modules:
|
|||
- boards
|
||||
- calendar
|
||||
- gantt
|
||||
- course
|
||||
default_projects_tracker_ids:
|
||||
serialized: true
|
||||
default:
|
||||
|
|
|
@ -923,11 +923,13 @@ ActiveRecord::Schema.define(:version => 20140605025247) 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 "user_id", :null => false
|
||||
t.integer "collaboration"
|
||||
t.integer "influence"
|
||||
t.integer "skill"
|
||||
t.integer "activity"
|
||||
t.integer "active"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "user_statuses", :force => true do |t|
|
||||
|
|
|
@ -179,13 +179,27 @@ Redmine::AccessControl.map do |map|
|
|||
end
|
||||
|
||||
#课程权限模块
|
||||
map.project_module :course do
|
||||
map.project_module :course do |map|
|
||||
map.permission :view_courses,{:projects => [:course]},:read => true
|
||||
end
|
||||
|
||||
#作业模块权限
|
||||
map.project_module :bids do |map|
|
||||
map.permission :view_homework_attaches, {:bids => [:show, :show_project, :revision]}, :read => true
|
||||
#map.permission :new_course, {}, :read => true
|
||||
#map.permission :configure_course,{},:read => true
|
||||
#map.permission :close_course,{},:read => true
|
||||
map.permission :new_assignment,{:projects => [:new_homework]},:read => true
|
||||
map.permission :edit_assignment,{:bids => [:edit]},:read => true
|
||||
map.permission :delete_assignment,{:bids => [:homework_destroy]},:read => true
|
||||
map.permission :new_placeholder,{:homework_attach => [:new]},:read => true
|
||||
map.permission :edit_placeholder,{:homework_attach => [:edit,:update]},:read => true
|
||||
map.permission :delete_placeholder,{:homework_attach => [:destroy]},:read => true
|
||||
#map.permission :commit_content,{},:read => true
|
||||
#map.permission :new_course_notify,{},:read => true
|
||||
#map.permission :edit_course_notify,{},:read => true
|
||||
#map.permission :delete_course_notify,{},:read => true
|
||||
map.permission :view_assignment,{:projects => [:homework]},:read => true
|
||||
map.permission :view_placeholder,{:bids => [:show_project]},:read => true
|
||||
map.permission :view_course_messages,{:projects => [:feedback]},:read => true
|
||||
map.permission :view_real_name,{:projects => [:real_name]},:read => true
|
||||
map.permission :view_students,{:projects => [:member]}, :read=>true
|
||||
map.permission :export_homeworks,{:zipdown => [:assort,:download_user_homework]},:read => true
|
||||
end
|
||||
|
||||
map.project_module :boards do |map|
|
||||
|
|
Loading…
Reference in New Issue