From db1874fa0752034bcbd39d01c2454d29cb6a5367 Mon Sep 17 00:00:00 2001 From: baiyu Date: Thu, 9 Jan 2014 10:58:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=AF=84=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 8 ++++++-- app/models/user_extensions.rb | 20 ++++++++++++++++++++ app/views/layouts/base_users.html.erb | 13 +++++++++++-- config/routes.rb | 1 + 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4b7f04547..60a0b6e4d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -30,11 +30,11 @@ class UsersController < ApplicationController before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info, - :user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects] + :user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score] #edit has been deleted by huang, 2013-9-23 before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, :user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info, - :watch_projects] + :watch_projects, :show_score] accept_api_auth :index, :show, :create, :update, :destroy,:tag_save #william @@ -86,6 +86,10 @@ class UsersController < ApplicationController end end + def show_score + + end + ##added by fq def watch_bids cond = 'bids.reward_type <> 1' diff --git a/app/models/user_extensions.rb b/app/models/user_extensions.rb index 64229f517..e2c42a745 100644 --- a/app/models/user_extensions.rb +++ b/app/models/user_extensions.rb @@ -25,6 +25,23 @@ class UserExtensions < ActiveRecord::Base return self.brief_introduction end + # added by bai + def show_identity + if self.identity == 0 + user_identity = '教师' + elsif self.identity == 1 + user_identity = '学生' + elsif self.identity == 2 + user_identity = '企业' + elsif self.identity == 3 + user_identity = '开发者' + else + user_identity = '' + end + return user_identity + end +# end + def self.introduction(user, message) unless user.user_extensions.nil? info = user.user_extensions @@ -37,4 +54,7 @@ class UserExtensions < ActiveRecord::Base info.save end end + + + end diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index ad4876de5..ae29544cc 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -62,14 +62,23 @@ <% unless User.current == @user %> <%= watcher_link(@user, User.current) %> <% else %> - <%= link_to(l(:label_user_edit), my_account_path(@user)) if User.current %><% end %> + <%= link_to(l(:label_user_edit), my_account_path(@user)) if User.current %> + <% end %> + + + <%= link_to(l(:label_user_grade), {:controller => 'users', :action => 'show_score', :remote => true, :id => @user.id})%>: <%= @user.user_status.grade %> + + +
<%= link_to l(:label_user_watcher)+"("+User.watched_by(@user.id).count.to_s+")" ,:controller=>"users", :action=>"user_watchlist"%>   - <%= link_to l(:label_x_user_fans, :count => User.current.watcher_users(User.current.id).count)+"("+@user.watcher_users(@user.id).count.to_s+")", :controller=>"users", :action=>"user_fanslist" %>  + + <%= link_to l(:label_x_user_fans, :count => User.current.watcher_users(User.current.id).count)+"("+@user.watcher_users.count.to_s+")", :controller=>"users", :action=>"user_fanslist" %>  + <%= link_to l(:label_requirement_focus)+"("+Bid.watched_by(@user).where('reward_type = ?', 1).count.to_s+")" ,:controller=>"users", :action=>"watch_bids"%>   <% if @user.id == User.current.id %> diff --git a/config/routes.rb b/config/routes.rb index 6b5edb16d..91a3eeb9d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -113,6 +113,7 @@ RedmineApp::Application.routes.draw do match 'user_courses', :to => 'users#user_courses', :via => :get match 'user_homeworks', :to => 'users#user_homeworks', :via => :get match 'watch_projects', :to => 'users#watch_projects', :via => :get + match 'show_score', :to => 'users#show_score', :via => :get end end match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback" From 13fdbde1cfd779086eb1571208e5791f6f25fee3 Mon Sep 17 00:00:00 2001 From: baiyu Date: Thu, 16 Jan 2014 10:34:39 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E5=88=86=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 28 ++++++- app/controllers/users_controller.rb | 33 +++++++- app/models/project.rb | 7 +- app/models/user.rb | 9 ++- app/models/user_extensions.rb | 3 +- app/views/layouts/base_courses.html.erb | 2 +- app/views/layouts/base_projects.html.erb | 35 ++++++++ app/views/layouts/base_users.html.erb | 31 ++++++- .../_code_submit_score_index.html.erb | 5 ++ app/views/projects/_file_score_index.html.erb | 5 ++ .../projects/_issue_score_index.html.erb | 11 +++ app/views/projects/_news_score_index.html.erb | 5 ++ .../projects/_project_score_index.html.erb | 34 ++++++++ .../_projects_topic_score_index.html.erb | 8 ++ .../projects/_show_projects_score.html.erb | 81 +++++++++++++++++++ .../projects/code_submit_score_index.js.erb | 3 + app/views/projects/file_score_index.js.erb | 3 + app/views/projects/issue_score_index.js.erb | 3 + app/views/projects/news_score_index.js.erb | 3 + app/views/projects/project_score_index.js.erb | 3 + .../projects_topic_score_index.js.erb | 3 + app/views/projects/show_projects_score.js.erb | 3 + .../users/_activity_score_index.html.erb | 11 +++ .../users/_influence_score_index.html.erb | 15 ++++ app/views/users/_project_score_index.html.erb | 12 +++ app/views/users/_score_index.html.erb | 34 ++++++++ app/views/users/_show_score.html.erb | 75 +++++++++++++++++ app/views/users/_topic_score_index.html.erb | 23 ++++++ app/views/users/activity_score_index.js.erb | 1 + app/views/users/influence_score_index.js.erb | 1 + app/views/users/project_score_index.js.erb | 1 + app/views/users/score_index.js.erb | 1 + app/views/users/show_score.js.erb | 3 + app/views/users/topic_score_index.js.erb | 1 + config/locales/zh.yml | 31 ++++++- config/routes.rb | 14 ++++ public/stylesheets/application.css | 11 +++ .../stylesheets/application.css | 17 ++++ 38 files changed, 555 insertions(+), 14 deletions(-) create mode 100644 app/views/projects/_code_submit_score_index.html.erb create mode 100644 app/views/projects/_file_score_index.html.erb create mode 100644 app/views/projects/_issue_score_index.html.erb create mode 100644 app/views/projects/_news_score_index.html.erb create mode 100644 app/views/projects/_project_score_index.html.erb create mode 100644 app/views/projects/_projects_topic_score_index.html.erb create mode 100644 app/views/projects/_show_projects_score.html.erb create mode 100644 app/views/projects/code_submit_score_index.js.erb create mode 100644 app/views/projects/file_score_index.js.erb create mode 100644 app/views/projects/issue_score_index.js.erb create mode 100644 app/views/projects/news_score_index.js.erb create mode 100644 app/views/projects/project_score_index.js.erb create mode 100644 app/views/projects/projects_topic_score_index.js.erb create mode 100644 app/views/projects/show_projects_score.js.erb create mode 100644 app/views/users/_activity_score_index.html.erb create mode 100644 app/views/users/_influence_score_index.html.erb create mode 100644 app/views/users/_project_score_index.html.erb create mode 100644 app/views/users/_score_index.html.erb create mode 100644 app/views/users/_show_score.html.erb create mode 100644 app/views/users/_topic_score_index.html.erb create mode 100644 app/views/users/activity_score_index.js.erb create mode 100644 app/views/users/influence_score_index.js.erb create mode 100644 app/views/users/project_score_index.js.erb create mode 100644 app/views/users/score_index.js.erb create mode 100644 app/views/users/show_score.js.erb create mode 100644 app/views/users/topic_score_index.js.erb diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index de18c6454..2d925cf6b 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -46,7 +46,8 @@ class ProjectsController < ApplicationController before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise] 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] + :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] before_filter :authorize_global, :only => [:new, :create] before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar] #by young @@ -760,6 +761,31 @@ class ProjectsController < ApplicationController @project = nil end +# added by bai + def show_projects_score + + end + + def issue_score_index + + end + + def news_score_index + + end + + def file_score_index + + end + + def code_submit_score_index + + end + + def projects_topic_score_index + + end +# end private # Validates parent_id param according to user's permissions diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 60a0b6e4d..071ea6467 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -30,11 +30,13 @@ class UsersController < ApplicationController before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info, - :user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score] + :user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index, + :activity_score_index, :influence_score_index, :score_index] #edit has been deleted by huang, 2013-9-23 - before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, :user_homeworks, - :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_bids, :info, - :watch_projects, :show_score] + before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, + :user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, + :watch_bids, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, + :activity_score_index, :influence_score_index, :score_index] accept_api_auth :index, :show, :create, :update, :destroy,:tag_save #william @@ -86,9 +88,11 @@ class UsersController < ApplicationController end end +# added by bai def show_score end +# end ##added by fq def watch_bids @@ -682,6 +686,27 @@ class UsersController < ApplicationController end end +# added by bai + def topic_score_index + + end + + def project_score_index + + end + + def activity_score_index + + end + + def influence_score_index + + end + + def score_index + + end +# end private diff --git a/app/models/project.rb b/app/models/project.rb index e106ac0c0..1de3dbadc 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -81,13 +81,12 @@ class Project < ActiveRecord::Base :order => "#{CustomField.table_name}.position", :join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}", :association_foreign_key => 'custom_field_id' - - - - + has_many :tags, :through => :project_tags, :class_name => 'Tag' has_many :project_tags, :class_name => 'ProjectTags' + has_many :journals + acts_as_nested_set :order => 'name', :dependent => :destroy acts_as_attachable :view_permission => :view_files, :delete_permission => :manage_files diff --git a/app/models/user.rb b/app/models/user.rb index 3ee601b6a..723e7cbfc 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -90,8 +90,15 @@ class User < Principal has_many :students_for_courses has_many :courses, :through => :students_for_courses, :source => :project has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy +#### +# added by bai has_many :join_in_contests, :dependent => :destroy - ##### + has_many :news, :foreign_key => 'author_id' + has_many :comments, :foreign_key => 'author_id' + has_many :wiki_contents, :foreign_key => 'author_id' + has_many :journals + has_many :messages, :foreign_key => 'author_id' +# end ######added by nie has_many :project_infos, :dependent => :destroy diff --git a/app/models/user_extensions.rb b/app/models/user_extensions.rb index e2c42a745..4db36c83f 100644 --- a/app/models/user_extensions.rb +++ b/app/models/user_extensions.rb @@ -1,3 +1,4 @@ +# encoding: utf-8 =begin identity字段含义 0 教师教授 @@ -25,7 +26,7 @@ class UserExtensions < ActiveRecord::Base return self.brief_introduction end - # added by bai +# added by bai def show_identity if self.identity == 0 user_identity = '教师' diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 418480e64..81d676e92 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -77,7 +77,7 @@ <% else %> <%= join_in_course(@project, User.current) %>
- <% end %> + <% end %> 1111 <% unless User.current.member_of?(@project) %>
diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 794623dd2..ecf5373c2 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -57,6 +57,41 @@
<%= @project.name %>
+
+ + <% issue_count = @project.issues.count %> + <% issue_journal_count = @project.issue_changes.count %> + <% issue_score = issue_count * 0.2 %> + <% issue_journal_score = issue_journal_count * 0.1 %> + <% finall_issue_score = issue_score + issue_journal_score %> + + <% new_count = @project.news.count %> + <% new_score = new_count * 0.1 %> + <% finall_new_score = new_score %> + + <% document_count = @project.documents.count %> + <% file_score = document_count * 0.1 %> + <% finall_file_score = file_score %> + + <% changeset_count = @project.changesets.count %> + <% code_submit_score = changeset_count * 0.3 %> + <% finall_code_submit_score = code_submit_score %> + + <% board_message_count = 0 %> + <% @project.boards.each do |board| %> + <% board_message_count += board.messages_count %> + <% end %> + <% topic_score = board_message_count * 0.1 %> + <% finall_topic_score = topic_score %> + + <% finall_project_score = finall_issue_score + finall_new_score + finall_file_score + finall_code_submit_score + topic_score %> + + <% if @project.project_type == 0 %> + <%= link_to(l(:label_project_grade), {:controller => 'projects', :action => 'show_projects_score', :remote => true, :id => @project.id})%> : + <%= format("%.2f" , finall_project_score ).to_f %> + <% end %> + +
<% if ( !(User.current.member_of? @project) && User.current.login?) %> diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index ae29544cc..c829bcda1 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -67,7 +67,36 @@ - <%= link_to(l(:label_user_grade), {:controller => 'users', :action => 'show_score', :remote => true, :id => @user.id})%>: <%= @user.user_status.grade %> + <% messages_count = @user.messages.count %> + <% messages_score = messages_count * 0.05%> + <% finall_messages_score = messages_score %> + + <% journals_count = @user.journals.count %> + <% journals_score = journals_count * 0.1 %> + <% user_changesets_count = @user.changesets.count %> + <% user_changesets_score = user_changesets_count * 0.3 %> + <% finall_user_project_score = journals_score + user_changesets_score %> + + <% journals_for_messages_count = @user.journals_for_messages.count %> + <% activities_count = @user.activities.count %> + <% journals_for_messages_score = journals_for_messages_count * 0.05 %> + <% activities_score = activities_count * 0.2 %> + <% finall_activity_score = journals_for_messages_score + activities_score %> + + <% news_count = @user.news.count %> + <% news_score = news_count * 0.1 %> + <% wiki_contents_count = @user.wiki_contents.count %> + <% wiki_contents_score = wiki_contents_count * 0.1 %> + <% comments_count = @user.comments.count %> + <% 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 %> + + + <%= link_to(l(:label_user_grade), {:controller => 'users', :action => 'show_score', :remote => true, :id => @user.id})%>: + <%= format("%.2f" , finall_user_score).to_f %> + + diff --git a/app/views/projects/_code_submit_score_index.html.erb b/app/views/projects/_code_submit_score_index.html.erb new file mode 100644 index 000000000..0e14f4a85 --- /dev/null +++ b/app/views/projects/_code_submit_score_index.html.erb @@ -0,0 +1,5 @@ +<% changeset_count = @project.changesets.count %> +<% code_submit_score = changeset_count * 0.3 %> +<% finall_code_submit_score = code_submit_score %> +
<%= l(:label_code_submit_number) %> * 0.3 = <%= changeset_count %> * 0.3 = <%= format("%.2f" , code_submit_score).to_f %>
+
<%= l(:label_code_submit_score) %> = <%= format("%.2f" , finall_code_submit_score).to_f %>
diff --git a/app/views/projects/_file_score_index.html.erb b/app/views/projects/_file_score_index.html.erb new file mode 100644 index 000000000..d6a4e1f73 --- /dev/null +++ b/app/views/projects/_file_score_index.html.erb @@ -0,0 +1,5 @@ +<% document_count = @project.documents.count %> +<% file_score = document_count * 0.1 %> +<% finall_file_score = file_score %> +
<%= l(:label_file_number) %> * 0.1 = <%= document_count %> * 0.1 = <%= format("%.2f" , file_score).to_f %>
+
<%= l(:label_file_score) %> = <%= format("%.2f" , finall_file_score).to_f %>
\ No newline at end of file diff --git a/app/views/projects/_issue_score_index.html.erb b/app/views/projects/_issue_score_index.html.erb new file mode 100644 index 000000000..8ca3d240c --- /dev/null +++ b/app/views/projects/_issue_score_index.html.erb @@ -0,0 +1,11 @@ + +<% issue_count = @project.issues.count %> +<% issue_journal_count = @project.issue_changes.count %> +<% issue_score = issue_count * 0.2 %> +<% issue_journal_score = issue_journal_count * 0.1 %> +<% finall_issue_score = issue_score + issue_journal_score %> +
<%= l(:label_issue_number) %> * 0.2 = <%= issue_count %> * 0.2 = <%= format("%.2f" , issue_score).to_f %>
+
<%= l(:label_issue_journal_number) %> * 0.1 = <%= issue_journal_count %> * 0.1 = <%= format("%.2f" , issue_journal_score).to_f %>
+
<%= l(:label_issue_score) %> = <%= format("%.2f" , issue_score).to_f %> + <%= format("%.2f" , issue_journal_score).to_f %> + = <%= format("%.2f" , finall_issue_score).to_f %>
+ \ No newline at end of file diff --git a/app/views/projects/_news_score_index.html.erb b/app/views/projects/_news_score_index.html.erb new file mode 100644 index 000000000..db0b98138 --- /dev/null +++ b/app/views/projects/_news_score_index.html.erb @@ -0,0 +1,5 @@ +<% new_count = @project.news.count %> +<% new_score = new_count * 0.1 %> +<% finall_new_score = new_score %> +
<%= l(:label_new_number) %> * 0.1 = <%= new_count %> * 0.1 = <%= format("%.2f" , new_score).to_f %>
+
<%= l(:label_news_score) %> = <%= format("%.2f" , finall_new_score).to_f %>
\ No newline at end of file diff --git a/app/views/projects/_project_score_index.html.erb b/app/views/projects/_project_score_index.html.erb new file mode 100644 index 000000000..6f98d549f --- /dev/null +++ b/app/views/projects/_project_score_index.html.erb @@ -0,0 +1,34 @@ +<% issue_count = @project.issues.count %> +<% issue_journal_count = @project.issue_changes.count %> +<% issue_score = issue_count * 0.2 %> +<% issue_journal_score = issue_journal_count * 0.1 %> +<% finall_issue_score = issue_score + issue_journal_score %> + +<% new_count = @project.news.count %> +<% new_score = new_count * 0.1 %> +<% finall_new_score = new_score %> + +<% document_count = @project.documents.count %> +<% file_score = document_count * 0.1 %> +<% finall_file_score = file_score %> + +<% changeset_count = @project.changesets.count %> +<% code_submit_score = changeset_count * 0.3 %> +<% finall_code_submit_score = code_submit_score %> + +<% board_message_count = 0 %> +<% @project.boards.each do |board| %> +<% board_message_count += board.messages_count %> +<% end %> +<% topic_score = board_message_count * 0.1 %> +<% finall_topic_score = topic_score %> + +<% finall_project_score = finall_issue_score + finall_new_score + finall_file_score + finall_code_submit_score + topic_score %> + +<%= l(:label_projects_score) %> +
= <%= l(:label_issue_score) %> + <%= l(:label_news_score) %> + <%= l(:label_file_score) %> + + <%= l(:label_code_submit_score) %> + <%= l(:label_topic_score) %>
+
= <%= format("%.2f" , finall_issue_score).to_f %> + <%= format("%.2f" , finall_new_score).to_f %> + + <%= format("%.2f" , finall_file_score).to_f %> + <%= format("%.2f" , finall_code_submit_score).to_f %> + + <%= format("%.2f" , topic_score).to_f %>
+
= <%= format("%.2f" , finall_project_score).to_f %>
diff --git a/app/views/projects/_projects_topic_score_index.html.erb b/app/views/projects/_projects_topic_score_index.html.erb new file mode 100644 index 000000000..1c4e7b14d --- /dev/null +++ b/app/views/projects/_projects_topic_score_index.html.erb @@ -0,0 +1,8 @@ +<% board_message_count = 0 %> +<% @project.boards.each do |board| %> +<% board_message_count += board.messages_count %> +<% end %> +<% topic_score = board_message_count * 0.1 %> +<% finall_topic_score = topic_score %> +
<%= l(:label_topic_number) %> * 0.1 = <%= board_message_count %> * 0.1 = <%= topic_score %>
+
<%= l(:label_topic_score) %> = <%= format("%.2f" , finall_topic_score).to_f %>
diff --git a/app/views/projects/_show_projects_score.html.erb b/app/views/projects/_show_projects_score.html.erb new file mode 100644 index 000000000..e9b21e571 --- /dev/null +++ b/app/views/projects/_show_projects_score.html.erb @@ -0,0 +1,81 @@ + +<% issue_count = @project.issues.count %> +<% issue_journal_count = @project.issue_changes.count %> +<% issue_score = issue_count * 0.2 %> +<% issue_journal_score = issue_journal_count * 0.1 %> +<% finall_issue_score = issue_score + issue_journal_score %> + +<% new_count = @project.news.count %> +<% new_score = new_count * 0.1 %> +<% finall_new_score = new_score %> + +<% document_count = @project.documents.count %> +<% file_score = document_count * 0.1 %> +<% finall_file_score = file_score %> + +<% changeset_count = @project.changesets.count %> +<% code_submit_score = changeset_count * 0.3 %> +<% finall_code_submit_score = code_submit_score %> + +<% board_message_count = 0 %> +<% @project.boards.each do |board| %> +<% board_message_count += board.messages_count %> +<% end %> +<% topic_score = board_message_count * 0.1 %> +<% finall_topic_score = topic_score %> + +<% finall_project_score = finall_issue_score + finall_new_score + finall_file_score + finall_code_submit_score + topic_score %> + +

<%= l(:label_projects_score) %>

+
+ + + + + + +
<%= image_tag(url_to_avatar(@project), :class => 'avatar2') %> + + + +
<%= @project.name %>
+
+ + + +
<%= l(:label_projects_score) %>
<%= format("%.2f" , finall_project_score ).to_f %>
+
+
+ +
+
    +
  • + <%= link_to l(:label_projects_score), {:controller => 'projects', :action => 'show_projects_score', :remote => true}%> : + <%= format("%.2f" , finall_project_score ).to_f %> +
  • +
  • + <%= link_to l(:label_issue_score), {:controller => 'projects', :action => 'issue_score_index', :remote => true}%> : + <%= format("%.2f" , finall_issue_score).to_f %> +
  • +
  • + <%= link_to l(:label_news_score), {:controller => 'projects', :action => 'news_score_index', :remote => true}%> : + <%= format("%.2f" , finall_new_score).to_f %> +
  • +
  • + <%= link_to l(:label_file_score), {:controller => 'projects', :action => 'file_score_index', :remote => true}%> : + <%= format("%.2f" , finall_file_score).to_f %> +
  • +
  • + <%= link_to l(:label_code_submit_score), {:controller => 'projects', :action => 'code_submit_score_index', :remote => true}%> : + <%= format("%.2f" , finall_code_submit_score).to_f %> +
  • +
  • + <%= link_to l(:label_topic_score), {:controller => 'projects', :action => 'projects_topic_score_index', :remote => true}%> : + <%= format("%.2f" , finall_topic_score).to_f %> +
  • +
+
+
+ <%= render :partial => 'projects/project_score_index', :locals => {:index => 0 } %> +
+ \ No newline at end of file diff --git a/app/views/projects/code_submit_score_index.js.erb b/app/views/projects/code_submit_score_index.js.erb new file mode 100644 index 000000000..ce1bc26fe --- /dev/null +++ b/app/views/projects/code_submit_score_index.js.erb @@ -0,0 +1,3 @@ +$('#show_score_detail').html('<%= escape_javascript(render :partial => 'projects/code_submit_score_index') %>'); +showModal('ajax-modal', '400px'); +$('#ajax-modal').addClass('new-watcher'); \ No newline at end of file diff --git a/app/views/projects/file_score_index.js.erb b/app/views/projects/file_score_index.js.erb new file mode 100644 index 000000000..67ccf5231 --- /dev/null +++ b/app/views/projects/file_score_index.js.erb @@ -0,0 +1,3 @@ +$('#show_score_detail').html('<%= escape_javascript(render :partial => 'projects/file_score_index') %>'); +showModal('ajax-modal', '400px'); +$('#ajax-modal').addClass('new-watcher'); \ No newline at end of file diff --git a/app/views/projects/issue_score_index.js.erb b/app/views/projects/issue_score_index.js.erb new file mode 100644 index 000000000..9d715a72d --- /dev/null +++ b/app/views/projects/issue_score_index.js.erb @@ -0,0 +1,3 @@ +$('#show_score_detail').html('<%= escape_javascript(render :partial => 'projects/issue_score_index') %>'); +showModal('ajax-modal', '400px'); +$('#ajax-modal').addClass('new-watcher'); diff --git a/app/views/projects/news_score_index.js.erb b/app/views/projects/news_score_index.js.erb new file mode 100644 index 000000000..266704b83 --- /dev/null +++ b/app/views/projects/news_score_index.js.erb @@ -0,0 +1,3 @@ +$('#show_score_detail').html('<%= escape_javascript(render :partial => 'projects/news_score_index') %>'); +showModal('ajax-modal', '400px'); +$('#ajax-modal').addClass('new-watcher'); diff --git a/app/views/projects/project_score_index.js.erb b/app/views/projects/project_score_index.js.erb new file mode 100644 index 000000000..a99c8ae6c --- /dev/null +++ b/app/views/projects/project_score_index.js.erb @@ -0,0 +1,3 @@ +$('#show_score_detail').html('<%= escape_javascript(render :partial => 'projects/project_score_index') %>'); +showModal('ajax-modal', '400px'); +$('#ajax-modal').addClass('new-watcher'); diff --git a/app/views/projects/projects_topic_score_index.js.erb b/app/views/projects/projects_topic_score_index.js.erb new file mode 100644 index 000000000..d2e1552b1 --- /dev/null +++ b/app/views/projects/projects_topic_score_index.js.erb @@ -0,0 +1,3 @@ +$('#show_score_detail').html('<%= escape_javascript(render :partial => 'projects/projects_topic_score_index') %>'); +showModal('ajax-modal', '400px'); +$('#ajax-modal').addClass('new-watcher'); \ No newline at end of file diff --git a/app/views/projects/show_projects_score.js.erb b/app/views/projects/show_projects_score.js.erb new file mode 100644 index 000000000..476cffae1 --- /dev/null +++ b/app/views/projects/show_projects_score.js.erb @@ -0,0 +1,3 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'projects/show_projects_score') %>'); +showModal('ajax-modal', '400px'); +$('#ajax-modal').addClass('new-watcher'); \ No newline at end of file diff --git a/app/views/users/_activity_score_index.html.erb b/app/views/users/_activity_score_index.html.erb new file mode 100644 index 000000000..fd1947812 --- /dev/null +++ b/app/views/users/_activity_score_index.html.erb @@ -0,0 +1,11 @@ + +<% journals_for_messages_count = @user.journals_for_messages.count %> +<% journals_for_messages_score = journals_for_messages_count * 0.05 %> +<% activities_count = @user.activities.count %> +<% activities_score = activities_count * 0.2 %> +<% finall_activity_score = journals_for_messages_score + activities_score %> +
<%= l(:label_message_number) %> * 0.05 = <%= @user.journals_for_messages.count %> * 0.05 = <%= format("%.2f" , journals_for_messages_score).to_f %>
+
<%= l(:label_activity_number) %> * 0.2 = <%= @user.activities.count %> * 0.2 = <%= format("%.2f" , activities_score).to_f %>
+
<%= l(:label_user_score_of_activity) %> = <%= format("%.2f" , journals_for_messages_score).to_f %> + <%= format("%.2f" , activities_score).to_f %> + = <%= format("%.2f" , finall_activity_score).to_f %>
+ \ No newline at end of file diff --git a/app/views/users/_influence_score_index.html.erb b/app/views/users/_influence_score_index.html.erb new file mode 100644 index 000000000..efc56deaf --- /dev/null +++ b/app/views/users/_influence_score_index.html.erb @@ -0,0 +1,15 @@ + +<% news_count = @user.news.count %> +<% news_score = news_count * 0.1 %> +<% wiki_contents_count = @user.wiki_contents.count %> +<% wiki_contents_score = wiki_contents_count * 0.1 %> +<% comments_count = @user.comments.count %> +<% comments_score = comments_count * 0.1 %> +<% finall_influence_score = news_score + wiki_contents_score + comments_score %> +
<%= l(:label_comments_number) %> * 0.1 = <%= @user.comments.count %> * 0.1 = <%= format("%.2f" , comments_score).to_f %>
+
<%= l(:label_news_number) %> * 0.1 = <%= @user.news.count %> * 0.1 = <%= format("%.2f" , news_score).to_f %>
+
<%= l(:label_wiki_number) %> * 0.1 = <%= @user.wiki_contents.count %> * 0.1 = <%= format("%.2f" , wiki_contents_score).to_f %>
+
<%= l(:label_user_score_of_influence) %> = <%= format("%.2f" , comments_score).to_f %> + <%= format("%.2f" , news_score).to_f %> + + <%= format("%.2f" , wiki_contents_score).to_f %> + = <%= format("%.2f" , finall_influence_score).to_f %> + \ No newline at end of file diff --git a/app/views/users/_project_score_index.html.erb b/app/views/users/_project_score_index.html.erb new file mode 100644 index 000000000..47fcb40f0 --- /dev/null +++ b/app/views/users/_project_score_index.html.erb @@ -0,0 +1,12 @@ + +<% journals_count = @user.journals.count %> +<% journals_score = journals_count * 0.1 %> +<% user_changesets_count = @user.changesets.count %> +<% user_changesets_score = user_changesets_count * 0.3 %> +<% finall_user_project_score = journals_score + user_changesets_score %> +
<%= l(:label_issue_message_number) %> * 0.1 = <%= @user.journals.count %> * 0.1 = <%= format("%.2f" , journals_score).to_f %>
+
<%= l(:label_code_submit_number) %> * 0.3 = <%= @user.changesets.count %> * 0.3 = <%= format("%.2f" , user_changesets_score).to_f %>
+
<%= l(:label_user_score_of_project) %> = <%= format("%.2f" , journals_score).to_f %> + <%= format("%.2f" , user_changesets_score).to_f %> + = <%= format("%.2f" , finall_user_project_score).to_f %> +
+ \ No newline at end of file diff --git a/app/views/users/_score_index.html.erb b/app/views/users/_score_index.html.erb new file mode 100644 index 000000000..210f45bf8 --- /dev/null +++ b/app/views/users/_score_index.html.erb @@ -0,0 +1,34 @@ + +<% messages_count = @user.messages.count %> +<% messages_score = messages_count * 0.05%> +<% finall_messages_score = messages_score %> + +<% journals_count = @user.journals.count %> +<% journals_score = journals_count * 0.1 %> +<% user_changesets_count = @user.changesets.count %> +<% user_changesets_score = user_changesets_count * 0.3 %> +<% finall_user_project_score = journals_score + user_changesets_score %> + +<% journals_for_messages_count = @user.journals_for_messages.count %> +<% activities_count = @user.activities.count %> +<% journals_for_messages_score = journals_for_messages_count * 0.05 %> +<% activities_score = activities_count * 0.2 %> +<% finall_activity_score = journals_for_messages_score + activities_score %> + +<% news_count = @user.news.count %> +<% news_score = news_count * 0.1 %> +<% wiki_contents_count = @user.wiki_contents.count %> +<% wiki_contents_score = wiki_contents_count * 0.1 %> +<% comments_count = @user.comments.count %> +<% 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 %> + +
<%= l(:label_user_score) %>
+
= <%= l(:label_user_score_of_topic) %> + <%= l(:label_user_score_of_project) %> + + <%= l(:label_user_score_of_activity) %>
+
   + <%= l(:label_user_score_of_influence) %>
+
= <%= format("%.2f" , finall_messages_score).to_f %> + <%= format("%.2f" , finall_user_project_score).to_f %> + + <%= format("%.2f" , finall_activity_score).to_f %> + <%= format("%.2f" , finall_influence_score).to_f %>
+
= <%= format("%.2f" , finall_user_score).to_f %>
+ diff --git a/app/views/users/_show_score.html.erb b/app/views/users/_show_score.html.erb new file mode 100644 index 000000000..45a5d8b99 --- /dev/null +++ b/app/views/users/_show_score.html.erb @@ -0,0 +1,75 @@ + +<% messages_count = @user.messages.count %> +<% messages_score = messages_count * 0.05%> +<% finall_messages_score = messages_score %> + +<% journals_count = @user.journals.count %> +<% journals_score = journals_count * 0.1 %> +<% user_changesets_count = @user.changesets.count %> +<% user_changesets_score = user_changesets_count * 0.3 %> +<% finall_user_project_score = journals_score + user_changesets_score %> + +<% journals_for_messages_count = @user.journals_for_messages.count %> +<% activities_count = @user.activities.count %> +<% journals_for_messages_score = journals_for_messages_count * 0.05 %> +<% activities_score = activities_count * 0.2 %> +<% finall_activity_score = journals_for_messages_score + activities_score %> + +<% news_count = @user.news.count %> +<% news_score = news_count * 0.1 %> +<% wiki_contents_count = @user.wiki_contents.count %> +<% wiki_contents_score = wiki_contents_count * 0.1 %> +<% comments_count = @user.comments.count %> +<% 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 %> + +

<%= l(:label_user_score) %>

+
+ + + + + + +
<%= image_tag(url_to_avatar(@user), :class => 'avatar2') %> + + + +
<%= h @user.show_name %>
<%= @user.user_extensions.show_identity %>
+
+ + + +
<%= l(:label_user_score) %>
<%= format("%.2f" , finall_user_score).to_f %>
+
+
+ +
+
    +
  • + <%= link_to l(:label_user_score), {:controller => 'users', :action => 'score_index', :remote => true} %> : + <%= format("%.2f" , finall_user_score).to_f %> +
  • +
  • + <%= link_to l(:label_user_score_of_topic), {:controller => 'users', :action => 'topic_score_index', :remote => true} %> : + <%= format("%.2f" , finall_messages_score).to_f %> +
  • +
  • + <%= link_to l(:label_user_score_of_project), {:controller => 'users', :action => 'project_score_index', :remote => true} %> : + <%= format("%.2f" , finall_user_project_score).to_f %> +
  • +
  • + <%= link_to l(:label_user_score_of_activity), {:controller => 'users', :action => 'activity_score_index', :remote => true} %> : + <%= format("%.2f" , finall_activity_score).to_f %> +
  • +
  • + <%= link_to l(:label_user_score_of_influence), {:controller => 'users', :action => 'influence_score_index', :remote => true} %> : + <%= format("%.2f" , finall_influence_score).to_f %> +
  • +
+
+
+ <%= render :partial => 'users/score_index', :locals => {:index => 0 } %> +
+ \ No newline at end of file diff --git a/app/views/users/_topic_score_index.html.erb b/app/views/users/_topic_score_index.html.erb new file mode 100644 index 000000000..ea3d202a5 --- /dev/null +++ b/app/views/users/_topic_score_index.html.erb @@ -0,0 +1,23 @@ + + + +<% messages_count = @user.messages.count %> +<% messages_score = messages_count * 0.05%> +
<%= l(:label_topic_number) %> * 0.05 = <%= @user.messages.count %> * 0.05 = <%= format("%.2f" , messages_score).to_f %>
+
<%= l(:label_user_score_of_topic) %> = <%= format("%.2f" , messages_score).to_f %>
+ \ No newline at end of file diff --git a/app/views/users/activity_score_index.js.erb b/app/views/users/activity_score_index.js.erb new file mode 100644 index 000000000..916627ecb --- /dev/null +++ b/app/views/users/activity_score_index.js.erb @@ -0,0 +1 @@ +$('#show_score_detail').html('<%= escape_javascript(render :partial => 'users/activity_score_index', :locals => {:index =>0 }) %>'); \ No newline at end of file diff --git a/app/views/users/influence_score_index.js.erb b/app/views/users/influence_score_index.js.erb new file mode 100644 index 000000000..cf0926b46 --- /dev/null +++ b/app/views/users/influence_score_index.js.erb @@ -0,0 +1 @@ +$('#show_score_detail').html('<%= escape_javascript(render :partial => 'users/influence_score_index', :locals => {:index =>0 }) %>'); \ No newline at end of file diff --git a/app/views/users/project_score_index.js.erb b/app/views/users/project_score_index.js.erb new file mode 100644 index 000000000..19ded64ee --- /dev/null +++ b/app/views/users/project_score_index.js.erb @@ -0,0 +1 @@ +$('#show_score_detail').html('<%= escape_javascript(render :partial => 'users/project_score_index', :locals => {:index =>1 }) %>'); \ No newline at end of file diff --git a/app/views/users/score_index.js.erb b/app/views/users/score_index.js.erb new file mode 100644 index 000000000..7911b988a --- /dev/null +++ b/app/views/users/score_index.js.erb @@ -0,0 +1 @@ +$('#show_score_detail').html('<%= escape_javascript(render :partial => 'users/score_index', :locals => {:index =>0 }) %>'); \ No newline at end of file diff --git a/app/views/users/show_score.js.erb b/app/views/users/show_score.js.erb new file mode 100644 index 000000000..3cd9a5e47 --- /dev/null +++ b/app/views/users/show_score.js.erb @@ -0,0 +1,3 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'users/show_score') %>'); +showModal('ajax-modal', '400px'); +$('#ajax-modal').addClass('new-watcher'); diff --git a/app/views/users/topic_score_index.js.erb b/app/views/users/topic_score_index.js.erb new file mode 100644 index 000000000..28505b627 --- /dev/null +++ b/app/views/users/topic_score_index.js.erb @@ -0,0 +1 @@ +$('#show_score_detail').html('<%= escape_javascript(render :partial => 'users/topic_score_index', :locals => {:index =>0 }) %>'); \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 67ffce6ad..e82bad2b0 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1594,7 +1594,36 @@ zh: label_endup_time: 结课时间 label_class_period: 整体课时 label_class_hour: 学时 - + label_user_score: 个人综合得分 + label_user_score_of_topic: 帖子得分 + label_user_score_of_project: 项目得分 + label_user_score_of_activity: 活跃度得分 + label_user_score_of_influence: 影响力得分 + label_question_top: 问题被顶次数 + label_question_down: 问题被踩次数 + label_answer_top: 回答被顶次数 + label_answer_down: 回答被踩次数 + label_comments_number: 评论的数量 + label_news_number: 新闻的数量 + label_wiki_number: wiki的数量 + label_message_number: 留言的数量 + label_activity_number: 个人动态数量 + label_issue_message_number: 对issue的留言数量 + label_code_submit_number: 代码提交次数 + label_topic_number: 讨论区发言数量 + label_projects_score: 项目综合得分 + label_issue_score: issue得分 + label_news_score: 新闻得分 + label_file_score: 文档得分 + label_code_submit_score: 代码提交得分 + label_topic_score: 讨论区得分 + label_issue_number: issue的数量 + label_issue_journal_number: issue的留言数量 + label_new_number: 新闻的数量 + label_file_number: 文档的数量 + label_code_submit_number: 代码提交数量 + label_topic_number: 讨论区帖子数量 + label_course_contribute_to: 参与了 %{project_count} 个项目: label_x_course_contribute_to: zero: "参与了 %{count} 个课程:" diff --git a/config/routes.rb b/config/routes.rb index 91a3eeb9d..a235f4ed3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -113,7 +113,21 @@ RedmineApp::Application.routes.draw do match 'user_courses', :to => 'users#user_courses', :via => :get match 'user_homeworks', :to => 'users#user_homeworks', :via => :get match 'watch_projects', :to => 'users#watch_projects', :via => :get + # added by bai match 'show_score', :to => 'users#show_score', :via => :get + match 'topic_score_index', :controller => 'users', :action => 'topic_score_index', :via => [:get, :post] + match 'project_score_index', :to => 'users#project_score_index', :via => :get + match 'activity_score_index', :to => 'users#activity_score_index', :via => :get + match 'influence_score_index', :to => 'users#influence_score_index', :via => :get + match 'score_index', :to => 'users#score_index', :via => :get + + match 'show_projects_score', :to => 'projects#show_projects_score', :via => [:get, :post] + match 'issue_score_index', :to => 'projects#issue_score_index', :via => [:get, :post] + match 'news_score_index', :to => 'projects#news_score_index', :via => [:get, :post] + match 'file_score_index', :to => 'projects#file_score_index', :via => [:get, :post] + match 'code_submit_score_index', :to => 'projects#code_submit_score_index', :via => [:get, :post] + match 'projects_topic_score_index', :to => 'projects#projects_topic_score_index', :via => [:get, :post] + # end end end match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback" diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 1d4eaf795..49a0d7493 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -379,6 +379,15 @@ span.forums-avatar-right{ } /*added by bai*/ +.user_underlinescore{ + margin:1; + padding:1; + width:700px; + height:1px; + background-color:#15bccf; + overflow:hidden +} + .top-course-content{ background-color: rgb(181,227, 251); height: 45px; @@ -828,6 +837,8 @@ ul.tool li{list-style-type:none; overflow:hidden } + + .user_enterprise_underline{ margin:1; padding:1; diff --git a/public/themes/redpenny-master/stylesheets/application.css b/public/themes/redpenny-master/stylesheets/application.css index 2e48b8141..b6ec9c3c4 100644 --- a/public/themes/redpenny-master/stylesheets/application.css +++ b/public/themes/redpenny-master/stylesheets/application.css @@ -1993,7 +1993,24 @@ div.avatar_user{ padding:5px 10px 6px 7px; /* Links */ } +.buttons_for_score a { + display:block; + float:left; + margin:0 7px 0 0; + background-color: #ec6300; + border:1px solid #dedede; + border-top:1px solid #eee; + border-left:1px solid #eee; + font-family:"微软雅黑", sans-serif; + font-size:12px; + line-height:130%; + text-decoration:none; + font-weight:bold; + color:#565656; + cursor:pointer; + padding:5px 10px 6px 7px; /* Links */ +} /* STANDARD */ .buttons_for_course a:hover{