competition
linhk 11 years ago
commit aa4b8c2da9

@ -488,6 +488,11 @@ class BidsController < ApplicationController
if @bid.homework_type
@homework = HomeworkAttach.new
if @bid.proportion
teacher_proportion = @bid.proportion * 1.0 / 100
else
teacher_proportion = 1.0
end
#@homework_list = @bid.homeworks
#增加作业按评分排序,
#@homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC').order("#{HomeworkAttach.table_name}.created_at ASC")
@ -495,7 +500,7 @@ class BidsController < ApplicationController
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{@bid.author_id}) AS t_score,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id <> #{@bid.author_id}) AS s_score
FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY
(CASE WHEN t_score IS NULL THEN 0 ELSE t_score * #{@bid.proportion * 1.0 / 100} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - @bid.proportion * 1.0 / 100} END) DESC,created_at ASC")
(CASE WHEN t_score IS NULL THEN 0 ELSE t_score * #{teacher_proportion} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - teacher_proportion} END) DESC,created_at ASC")
if params[:student_id].present?
@temp = []
@homework_list.each do |pro|

@ -38,6 +38,17 @@ class FilesController < ApplicationController
@isproject = true
@containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)]
@containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
all_attachments = []
@containers.each do |container|
all_attachments += container.attachments
end
@limit = 10
@feedback_count = all_attachments.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
@offset ||= @feedback_pages.offset
@curse_attachments = all_attachments[@offset, @limit]
render :layout => !request.xhr?
elsif params[:course_id]
@isproject = false
@ -67,6 +78,18 @@ class FilesController < ApplicationController
else
@containers = [ Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on desc").find(@course.id)]
end
all_attachments = []
@containers.each do |container|
all_attachments += container.attachments
end
@limit = 10
@feedback_count = all_attachments.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
@offset ||= @feedback_pages.offset
@curse_attachments = all_attachments[@offset, @limit]
render :layout => 'base_courses'
end
end

@ -148,7 +148,8 @@ class NewsController < ApplicationController
flash[:notice] = l(:notice_successful_update)
redirect_to news_path(@news)
else
render :action => 'edit'
#flash[:error] = l(:notice_successful_update)
redirect_to news_path(@news)
end
end

@ -697,8 +697,8 @@ class ProjectsController < ApplicationController
else # @project.project_type == Project::ProjectType_project
roles = Role.find_all_givable
@subPage_title = l :label_member_list
@members = @project.member_principals.includes(:roles, :principal).all
@members = sort_project_members(@project, @members)
@members = @project.member_principals.includes(:roles, :principal).joins("LEFT JOIN #{OptionNumber.table_name} ON #{OptionNumber.table_name}.user_id = #{Member.table_name}.user_id and #{OptionNumber.table_name}.score_type = 2 AND #{Member.table_name}.project_id = #{OptionNumber.table_name}.project_id").order("#{OptionNumber.table_name}.total_score DESC").all
#@members = sort_project_members(@project, @members)
@applied_members = appied_project_members(@project, @members)
end
@members = paginateHelper @members

@ -441,7 +441,7 @@ module CoursesHelper
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)
homework_users = homework_users + (is_teacher ? (user.firstname + user.lastname) : user.login)
if user != homework.users.last
homework_users = homework_users + ""
end

@ -381,6 +381,46 @@ module UserScoreHelper
result
end
def get_option_num_by_id(user_id,type,project_id=nil)
if project_id.nil?
option_number = OptionNumber.where("user_id = '#{user_id}' and score_type = '#{type}'");
else
option_number = OptionNumber.where("user_id = '#{user_id}' and score_type = '#{type}' and project_id = '#{project_id}'");
end
result = nil
if option_number.nil? || option_number.count == 0
result = OptionNumber.new
result.user_id = user_id
result.memo = 0
result.messages_for_issues = 0
result.issues_status = 0
result.replay_for_message = 0
result.replay_for_memo = 0
result.follow = 0
result.tread = 0
result.praise_by_one = 0
result.praise_by_two = 0
result.praise_by_three = 0
result.tread_by_one = 0
result.tread_by_two = 0
result.tread_by_three = 0
result.changeset = 0
result.document = 0
result.attachment = 0
result.issue_done_ratio = 0
result.post_issue = 0
result.total_score = 0
result.score_type =type
unless project_id.nil?
result.project_id = project_id
end
else
result = option_number.first
end
result
end
#更新分数
def update_score(option_number)
option_number.total_score = collaboration(option_number) + influence(option_number) + skill(option_number) + active(option_number)
@ -418,11 +458,24 @@ module UserScoreHelper
#发帖数
def memo_num(user,project=nil)
if project.nil?
Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id != -1").all.count #+ Memo.includes(:author).where("parent_id IS NULL and author_id = '#{user.id}'").all.count
#Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id != -1").all.count #+ Memo.includes(:author).where("parent_id IS NULL and author_id = '#{user.id}'").all.count
users = Message.find_by_sql("SELECT COUNT(*) as m_count FROM `messages` JOIN `boards` ON boards.project_id != -1 AND messages.board_id = boards.id
WHERE messages.parent_id IS NULL AND messages.author_id = #{user.id}")
result = 0
users.each do |user|
result = user.m_count
end
result
#user.messages.where("parent_id IS NULL").count
else
Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id = #{project.id}").all.count
#Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id = #{project.id}").all.count
users = Message.find_by_sql("SELECT COUNT(*) as m_count FROM `messages` JOIN `boards` ON boards.project_id = '#{project.id}' AND messages.board_id = boards.id
WHERE messages.parent_id IS NULL AND messages.author_id = #{user.id}")
result = 0
users.each do |user|
result = user.m_count
end
result
end
end
@ -448,9 +501,21 @@ FROM `users` where id = #{user.id}")
def messges_for_issue_num(user,project=nil)
if project.nil?
Journal.includes(:user).where("user_id = '#{user.id}' and notes is not null and notes != ''").all.count
#Journal.includes(:user).where("user_id = '#{user.id}' and notes is not null and notes != ''").all.count
users = Journal.find_by_sql("SELECT COUNT(*) as m_count FROM journals WHERE journals.user_id = #{user.id} AND journals.notes IS NOT NULL AND journals.notes != ''")
result = 0
if users.count > 0
result = users.first.m_count
end
result
else
Journal.includes(:user).joins(:issue).where("#{Journal.table_name}.user_id = '#{user.id}' and #{Issue.table_name}.project_id = '#{project.id}' and #{Journal.table_name}.notes != '' and #{Journal.table_name}.notes is not null").all.count
#Journal.includes(:user).joins(:issue).where("#{Journal.table_name}.user_id = '#{user.id}' and #{Issue.table_name}.project_id = '#{project.id}' and #{Journal.table_name}.notes != '' and #{Journal.table_name}.notes is not null").all.count
users = Journal.find_by_sql("SELECT COUNT(*) as m_count FROM journals join issues on #{Journal.table_name}.journalized_type = 'Issue' and #{Journal.table_name}.journalized_id = #{Issue.table_name}.id WHERE journals.user_id = #{user.id} AND journals.notes IS NOT NULL AND journals.notes != ''and #{Issue.table_name}.project_id = '#{project.id}'")
result = 0
if users.count > 0
result = users.first.m_count
end
result
end
end
@ -471,9 +536,21 @@ FROM `users` where id = #{user.id}")
def issues_status_num(user,project=nil)
if project.nil?
Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
#Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
users = Journal.find_by_sql("SELECT COUNT(*) as m_count FROM journals JOIN journal_details on journals.id = journal_details.journal_id WHERE journal_details.prop_key = 'status_id' and journals.user_id = #{user.id}")
result = 0
if users.count > 0
result = users.first.m_count
end
result
else
Journal.joins(:issue,:details,:user).where("#{Issue.table_name}.project_id = '#{project.id}' and #{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
#Journal.joins(:issue,:details,:user).where("#{Issue.table_name}.project_id = '#{project.id}' and #{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
users = Journal.find_by_sql("SELECT COUNT(*) as m_count FROM journals JOIN journal_details on journals.id = journal_details.journal_id JOIN issues ON issues.id = journals.journalized_id and journalized_type = 'Issue' WHERE journal_details.prop_key = 'status_id' and journals.user_id = #{user.id} and issues.project_id = '#{project.id}'")
result = 0
if users.count > 0
result = users.first.m_count
end
result
end
end
@ -481,10 +558,10 @@ FROM `users` where id = #{user.id}")
def issues_status_score(user,project=nil)
if project.nil?
#Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM journals JOIN journal_details on journals.id = journal_details.journal_id WHERE journal_details.prop_key = 'status_id' and journals.user_id = users.id) AS m_score FROM users WHERE users.id = '#{user.id}'")
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM journals JOIN journal_details on journals.id = journal_details.journal_id WHERE journal_details.prop_key = 'status_id' and journals.user_id = users.id) AS m_count FROM users WHERE users.id = '#{user.id}'")
else
#Journal.joins(:issue,:details,:user).where("#{Issue.table_name}.project_id = '#{project.id}' and #{JournalDetail.table_name}.prop_key = 'status_id' and #{User.table_name}.id = '#{user.id}'").count
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM journals JOIN journal_details on journals.id = journal_details.journal_id JOIN issues ON issues.id = journals.journalized_id and journalized_type = 'Issue' WHERE journal_details.prop_key = 'status_id' and journals.user_id = users.id and issues.project_id = '#{project.id}') AS m_score FROM users WHERE users.id = '#{user.id}'")
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) FROM journals JOIN journal_details on journals.id = journal_details.journal_id JOIN issues ON issues.id = journals.journalized_id and journalized_type = 'Issue' WHERE journal_details.prop_key = 'status_id' and journals.user_id = users.id and issues.project_id = '#{project.id}') AS m_count FROM users WHERE users.id = '#{user.id}'")
end
end
@ -497,9 +574,21 @@ FROM `users` where id = #{user.id}")
def replay_for_message_num(user,project=nil)
if project.nil?
JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id} and jour_type = 'Project'").count
#JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id} and jour_type = 'Project'").count
users = JournalsForMessage.find_by_sql("SELECT COUNT(*) as m_count From #{JournalsForMessage.table_name} WHERE m_parent_id IS NOT NULL and user_id = #{user.id} and jour_type = 'Project'")
result = 0
if users.count > 0
result = users.first.m_count
end
result
else
JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id} and jour_type = 'Project' and jour_id = '#{project.id}'").count
#JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL and user_id = #{user.id} and jour_type = 'Project' and jour_id = '#{project.id}'").count
users = JournalsForMessage.find_by_sql("SELECT COUNT(*) as m_count From #{JournalsForMessage.table_name} WHERE m_parent_id IS NOT NULL and user_id = #{user.id} and jour_type = 'Project' and jour_id = '#{project.id}'")
result = 0
if users.count > 0
result = users.first.m_count
end
result
end
end
@ -508,7 +597,7 @@ FROM `users` where id = #{user.id}")
if project.nil?
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) From journals_for_messages WHERE m_parent_id IS NOT NULL and user_id = users.id and jour_type = 'Project') as m_score FROM users WHERE users.id = '#{user.id}'")
else
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) From journals_for_messages WHERE m_parent_id IS NOT NULL and user_id = users.id and jour_type = 'Project' and jour_id = '#{project.id}') as m_score FROM users WHERE users.id = '#{user.id}'")
User.find_by_sql("SELECT users.id,(SELECT COUNT(*) From journals_for_messages WHERE m_parent_id IS NOT NULL and user_id = users.id and jour_type = 'Project' and jour_id = '#{project.id}') as m_score FROM users WHERE users.id = '#{user.id}'")
end
end
@ -521,9 +610,21 @@ FROM `users` where id = #{user.id}")
def replay_for_memo_num(user,project=nil)
if project.nil?
Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NOT NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id != -1").all.count
#Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NOT NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id != -1").all.count
users = Message.find_by_sql("SELECT COUNT(*) as m_count FROM messages JOIN boards on messages.board_id = boards.id WHERE messages.parent_id IS NOT NULL AND messages.author_id = #{user.id} AND boards.project_id != -1")
result = 0
if users.count > 0
result = users.first.m_count
end
result
else
Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NOT NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id = #{project.id}").all.count
#Message.includes(:author).joins(:board).where("#{Message.table_name}.parent_id IS NOT NULL and #{Message.table_name}.author_id = '#{user.id}' and #{Board.table_name}.project_id = #{project.id}").all.count
users = Message.find_by_sql("SELECT COUNT(*) as m_count FROM messages JOIN boards on messages.board_id = boards.id WHERE messages.parent_id IS NOT NULL AND messages.author_id = #{user.id} AND boards.project_id = #{project.id}")
result = 0
if users.count > 0
result = users.first.m_count
end
result
end
end
@ -538,16 +639,22 @@ FROM `users` where id = #{user.id}")
#更新被关注的人数
def update_follow(user,type)
option_number = get_option_number(user,type)
option_number.follow = Watcher.includes(:watchable).where("watchable_type = 'Principal' and watchable_id = '#{user.id}'").count
option_number.follow = follow_num(user)#Watcher.includes(:watchable).where("watchable_type = 'Principal' and watchable_id = '#{user.id}'").count
update_score(option_number)
end
def follow_num(user)
Watcher.includes(:watchable).where("watchable_type = 'Principal' and watchable_id = '#{user.id}'").count
#Watcher.includes(:watchable).where("watchable_type = 'Principal' and watchable_id = '#{user.id}'").count
users = Watcher.find_by_sql("SELECT COUNT(*) as m_count FROM #{Watcher.table_name} WHERE watchable_type = 'Principal' and watchable_id = #{user.id}")
result = 0
if users.count > 0
result = users.first.m_count
end
result
end
def follow_score(user)
User.find_by_sql("SELECT users.id, (SELECT COUNT(*) * 2 FROM #{Watcher.table_name} WHERE watchable_type = 'Principal' and watchable_id = '#{user.id}') FROM users WHERE users.id = '#{user.id}'")
User.find_by_sql("SELECT users.id, (SELECT COUNT(*) * 2 FROM #{Watcher.table_name} WHERE watchable_type = 'Principal' and watchable_id = users.id) FROM users WHERE users.id = '#{user.id}'")
end
#更新帖子踩各项数量
@ -689,9 +796,21 @@ FROM `users` where id = #{user.id}")
def changeset_num(user,project=nil)
if project.nil?
Changeset.includes(:user).where("user_id = '#{user.id}'").all.count
#Changeset.includes(:user).where("user_id = '#{user.id}'").all.count
users = Changeset.find_by_sql("SELECT COUNT(*) as m_count FROM #{Changeset.table_name} WHERE user_id = #{user.id}")
result = 0
if users.count > 0
result = users.first.m_count
end
result
else
Changeset.includes(:user).joins(:repository).where("#{Changeset.table_name}.user_id = '#{user.id}' and #{Repository.table_name}.project_id = #{project.id}").all.count
#Changeset.includes(:user).joins(:repository).where("#{Changeset.table_name}.user_id = '#{user.id}' and #{Repository.table_name}.project_id = #{project.id}").all.count
users = Changeset.find_by_sql("SELECT COUNT(*) as m_count FROM #{Changeset.table_name} JOIN #{Repository.table_name} ON #{Changeset.table_name}.repository_id = #{Repository.table_name}.id WHERE #{Changeset.table_name}.user_id = #{user.id} and #{Repository.table_name}.project_id = #{project.id}")
result = 0
if users.count > 0
result = users.first.m_count
end
result
end
end
@ -705,9 +824,21 @@ FROM `users` where id = #{user.id}")
def document_num(user,project=nil)
if project.nil?
Document.includes(:user).where("user_id = '#{user.id}'").all.count
#Document.includes(:user).where("user_id = '#{user.id}'").all.count
users = Document.find_by_sql("SELECT COUNT(*) as m_count FROM #{Document.table_name} WHERE #{Document.table_name}.user_id = #{user.id}")
result = 0
if users.count > 0
result = users.first.m_count
end
result
else
Document.includes(:user,:project).where("user_id = '#{user.id}' and project_id = '#{project.id}'").all.count
#Document.includes(:user,:project).where("user_id = '#{user.id}' and project_id = '#{project.id}'").all.count
users = Document.find_by_sql("SELECT COUNT(*) as m_count FROM #{Document.table_name} WHERE #{Document.table_name}.user_id = #{user.id} and #{Document.table_name}.project_id = '#{project.id}'")
result = 0
if users.count > 0
result = users.first.m_count
end
result
end
end
@ -721,9 +852,21 @@ FROM `users` where id = #{user.id}")
def attachment_num(user,project=nil)
if project.nil?
Attachment.includes(:author,:container).where("author_id = '#{user.id}' and container_type = 'Project'").all.count
#Attachment.includes(:author,:container).where("author_id = '#{user.id}' and container_type = 'Project'").all.count
users = Attachment.find_by_sql("SELECT COUNT(*) as m_count FROM #{Attachment.table_name} WHERE author_id = '#{user.id}' and container_type = 'Project'")
result = 0
if users.count > 0
result = users.first.m_count
end
result
else
Attachment.includes(:author,:container).where("author_id = '#{user.id}' and container_type = 'Project' and container_id = #{project.id}").all.count
#Attachment.includes(:author,:container).where("author_id = '#{user.id}' and container_type = 'Project' and container_id = #{project.id}").all.count
users = Attachment.find_by_sql("SELECT COUNT(*) as m_count FROM #{Attachment.table_name} WHERE author_id = '#{user.id}' and container_type = 'Project' and container_id = #{project.id}")
result = 0
if users.count > 0
result = users.first.m_coumt
end
result
end
end
@ -736,9 +879,21 @@ FROM `users` where id = #{user.id}")
def issue_done_ratio_num(user,project=nil)
if project.nil?
Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'done_ratio' and #{User.table_name}.id = '#{user.id}'").count
#Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'done_ratio' and #{User.table_name}.id = '#{user.id}'").count
users = Journal.find_by_sql("SELECT COUNT(*) as m_count FROM #{Journal.table_name} JOIN #{JournalDetail.table_name} ON #{JournalDetail.table_name}.journal_id = #{Journal.table_name}.id WHERE #{JournalDetail.table_name}.prop_key = 'done_ratio' and #{Journal.table_name}.user_id = #{user.id}")
result = 0
if users.count > 0
result = users.first.m_count
end
result
else
Journal.joins(:issue,:details,:user).where("#{Issue.table_name}.project_id = '#{project.id}' and #{JournalDetail.table_name}.prop_key = 'done_ratio' and #{User.table_name}.id = '#{user.id}'").count
#Journal.joins(:issue,:details,:user).where("#{Issue.table_name}.project_id = '#{project.id}' and #{JournalDetail.table_name}.prop_key = 'done_ratio' and #{User.table_name}.id = '#{user.id}'").count
users = Journal.find_by_sql("SELECT COUNT(*) as m_count FROM #{Journal.table_name} JOIN #{JournalDetail.table_name} ON #{JournalDetail.table_name}.journal_id = #{Journal.table_name}.id JOIN issues ON issues.id = journals.journalized_id and journalized_type = 'Issue' WHERE #{JournalDetail.table_name}.prop_key = 'done_ratio' and #{Journal.table_name}.user_id = #{user.id} and #{Issue.table_name}.project_id = '#{project.id}'")
result = 0
if users.count > 0
result = users.first.m_count
end
result
end
end
@ -752,9 +907,21 @@ FROM `users` where id = #{user.id}")
def post_issue_num(user,project=nil)
if project.nil?
Issue.includes(:author).where("author_id = '#{user.id}'").all.count
#Issue.includes(:author).where("author_id = '#{user.id}'").all.count
users = Issue.find_by_sql("SELECT COUNT(*) as m_count FROM #{Issue.table_name} WHERE author_id = #{user.id}")
result = 0
if users.count > 0
result = users.first.m_count
end
result
else
Issue.includes(:author).where("author_id = '#{user.id}' and project_id = '#{project.id}'").all.count
#Issue.includes(:author).where("author_id = '#{user.id}' and project_id = '#{project.id}'").all.count
users = Issue.find_by_sql("SELECT COUNT(*) as m_count FROM #{Issue.table_name} WHERE author_id = #{user.id} and project_id = '#{project.id}'")
result = 0
if users.count > 0
result = users.first.m_count
end
result
end
end
@ -778,6 +945,9 @@ FROM `users` where id = #{user.id}")
update_attachment(user,type,project)
update_issue_done_ratio(user,type,project)
update_post_issue(user,type,project)
if project.nil?
update_follow(user,type)
end
update_score(ooption_num)
ooption_num
end

@ -29,9 +29,9 @@ class Attachment < ActiveRecord::Base
include UserScoreHelper
validates_presence_of :filename, :author
validates_length_of :filename, :maximum => 255
validates_length_of :disk_filename, :maximum => 255
validates_length_of :description, :maximum => 255
validates_length_of :filename, :maximum => 254
validates_length_of :disk_filename, :maximum => 254
validates_length_of :description, :maximum => 254
validate :validate_max_file_size

@ -28,13 +28,15 @@
<tr>
<td style="vertical-align: top;width: 70px" >
<table style="text-align: center;width: 100%;table-layout: fixed">
<% user_name = is_teacher ? (homework.user.firstname + homework.user.lastname) : homework.user.login %>
<tr>
<td title="<%= homework.user.name %>"><%= image_tag(url_to_avatar(homework.user), :class => "avatar")%></td>
<td title="<%= user_name %>"><%= image_tag(url_to_avatar(homework.user), :class => "avatar")%></td>
</tr>
<tr>
<td title="<%= homework.user.name %>">
<td title="<%= user_name %>">
<p style="width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"><strong>
<%= link_to (is_teacher ? homework.user.realname : homework.user ), user_path(homework.user),{:style => "color:#727272"} %>
<%= link_to user_name, user_path(homework.user),{:style => "color:#727272"} %>
</strong></p>
</td>
</tr>

@ -1,9 +1,9 @@
<!--<p><%= link_to_project(news.project) + ': ' unless @project %>
<table><tr><td><img src="/images/new/news.png" width="40" height="40"/></td><td><%= link_to h(news.title), news_path(news) %>
<%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %>
<!--<p><%#= link_to_project(news.project) + ': ' unless @project %>
<table><tr><td><img src="/images/new/news.png" width="40" height="40"/></td><td><%#= link_to h(news.title), news_path(news) %>
<%#= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %>
<% unless news.summary.blank? %></td><td><span class="fontligher"><%=h news.summary %></span><% end %></td>
<td><span class="author"><%= authoring news.created_on, news.author %></span></td></tr></table></p>-->
<%# unless news.summary.blank? %></td><td><span class="fontligher"><%#=h news.summary %></span><% end %></td>
<td><span class="author"><%#= authoring news.created_on, news.author %></span></td></tr></table></p>-->
<table width="660px" border="0" align="center">
<tr>

@ -1,6 +1,6 @@
<% if @events_by_day != nil && @events_by_day.size >0 %>
<div class="content-title-top-avtive">
<!-- <h3><%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)).html_safe %></h3> -->
<!-- <h3><%#= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)).html_safe %></h3> -->
<p class="subtitle">
<%#= l(:label_date_from_to, :start => format_date(@date_from), :end => format_date(@date_to - 1)) %>
</p>
@ -29,7 +29,7 @@
<%= l(:label_new_activity) %> </span>
<%= link_to "#{eventToLanguageCourse(e.event_type, @course)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : e.event_url %>
<%= link_to "#{eventToLanguageCourse(e.event_type, @course)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : e.event_url,:style => "word-break:break-all;" %>
</td>
</tr>
<tr>

@ -25,60 +25,70 @@
</tr>
</thead>
<tbody>
<% @containers.each do |container| %>
<% next if container.attachments.empty? -%>
<% if container.is_a?(Version) -%>
<tr>
<%# @containers.each do |container| %>
<%# next if container.attachments.empty? -%>
<%# if container.is_a?(Version) -%>
<!--<tr>
<th colspan="5" align="left" style="line-height: 30px; font-size: 14px; ">
<%= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package", :style => "color: #666666;") %>
<%#= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package", :style => "color: #666666;") %>
</th>
</tr>
<% end -%>
<% container.attachments.each do |file| %>
<%if file.is_public == 0 && !User.current.member_of_course?(@course)%>
<%next%>
<%end%>
<tr class="file <%= cycle("odd", "odd") %>">
<td class="filename" style="font-size: 13px; "><%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %></td>
<!-- <td class="created_on"><%#= format_time(file.created_on) %></td> -->
<td class="filesize"><%= number_to_human_size(file.filesize) %></td>
<td class="attach_type">
<span id="attach_type_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.attachmentstype.typeName unless file.attachmentstype.nil? %></span>
</tr>-->
<%# end -%>
<% if @curse_attachments != nil %>
<% @curse_attachments.each do |file| %>
<%if file.is_public == 0 && !User.current.member_of_course?(@course)%>
<%next%>
<%end%>
<tr class="file <%= cycle("odd", "odd") %>">
<td class="filename" style="font-size: 13px; "><%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %></td>
<!-- <td class="created_on"><%#= format_time(file.created_on) %></td> -->
<td class="filesize"><%= number_to_human_size(file.filesize) %></td>
<td class="attach_type">
<span id="attach_type_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.attachmentstype.typeName unless file.attachmentstype.nil? %></span>
<span id="attach_type_id_edit<%= file.id %>" style="white-space:nowrap;">
<%= render :partial => 'attachments/course_type_edit', :locals => {:attachmenttypes => attachmenttypes, :attachment => file, :contentype => selContentType} %>
</span>
</td>
<td class="content_type"><%= file.show_suffix_type %></td>
<td class="field_file_dense">
<span id="field_file_dense_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.file_dense_str %></span>
&nbsp;
</td>
<td class="content_type"><%= file.show_suffix_type %></td>
<td class="field_file_dense">
<span id="field_file_dense_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.file_dense_str %></span>
&nbsp;
<span id="field_file_dense_id_edit<%= file.id %>" style="white-space:nowrap;">
<%= render :partial => 'course_file_dense_edit', :locals => {:file_dense_list => file.file_dense_list,
:attachment => file} %>
</span>
</td>
<td class="downloads"><%= file.downloads %></td>
<!-- <td class="digest" width="300px"><%= file.description %></td> -->
<td align="center">
<%= link_to(image_tag('delete.png'), attachment_path(file),
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
</td>
</tr>
<tr>
<td class='description' colspan="6">
<div class="tags_area">
<%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %>
<%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %>
<div class="tags_gradint"></div>
</div>
<div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a></div>
</td>
</tr>
<% end -%>
<% reset_cycle %>
</td>
<td class="downloads"><%= file.downloads %></td>
<!-- <td class="digest" width="300px"><%= file.description %></td> -->
<td align="center">
<%= link_to(image_tag('delete.png'), attachment_path(file),
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
</td>
</tr>
<tr>
<td class='description' colspan="6">
<div class="tags_area">
<%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %>
<%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %>
<div class="tags_gradint"></div>
</div>
<div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a></div>
</td>
</tr>
<% end -%>
<% end %>
<%# reset_cycle %>
<%# end -%>
<!-- %= h downloadAll(@containers) % -->
<!-- %= link_to "download all file", (downloadAll(@containers)) % -->
</tbody>
</table>
<!--分页-->
<div class="pagination" style="float:left;">
<ul>
<%= pagination_links_full @feedback_pages %>
</ul>
</div>

@ -25,16 +25,17 @@
</tr>
</thead>
<tbody>
<% @containers.each do |container| %>
<% next if container.attachments.empty? -%>
<% if container.is_a?(Version) -%>
<tr>
<%# @containers.each do |container| %>
<%# next if container.attachments.empty? -%>
<%# if container.is_a?(Version) -%>
<!--tr>
<th colspan="5" align="left" style="line-height: 30px; font-size: 14px; ">
<%= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package", :style => "color: #666666;") %>
<%#= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package", :style => "color: #666666;") %>
</th>
</tr>
<% end -%>
<% container.attachments.each do |file| %>
</tr-->
<%# end -%>
<% if @curse_attachments != nil %>
<% @curse_attachments.each do |file| %>
<%if file.is_public == 0 && !User.current.member_of?(@project)%>
<%next%>
<%end%>
@ -75,10 +76,17 @@
</td>
</tr>
<% end -%>
<% reset_cycle %>
<%# reset_cycle %>
<% end -%>
<!-- %= h downloadAll(@containers) % -->
<!-- %= link_to "download all file", (downloadAll(@containers)) % -->
</tbody>
</table>
<!--分页-->
<div class="pagination" style="float:left;">
<ul>
<%= pagination_links_full @feedback_pages %>
</ul>
</div>

@ -1,12 +1,13 @@
<%= error_messages_for @news %>
<div class="add_frame_header" >
<% str = l(:bale_news_notice)%>
<%= str %>
<%= is_new ? l(:bale_news_notice):l(:bale_edit_notice)%>
</div>
<div class="box tabular">
<p><%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %></p>
<!-- <p style="margin-left:-10px;"><%= f.text_area :summary, :cols => 60, :rows => 2, :style => "width:490px;margin-left:10px;" %></p> -->
<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;" %></p>
<p><%= f.text_field :title, :required => true, :size => 60, :style => "width:468px;", :onblur => "regexTitle();" %></p>
<P><span id="title_notice_span">(60个字符以内)</span></P>
<!-- <p style="margin-left:-10px;"><%#= f.text_area :summary, :cols => 60, :rows => 2, :style => "width:490px;margin-left:10px;" %></p> -->
<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:470px;", :onblur => "regexDescription();" %></p>
<P><span id="description_notice_span"></span></P>
<p id="attachments_form" style="margin-left:-10px;"><label style="padding-right: 15px;"><%= l(:label_attachment_plural) %></label><%= render :partial => 'attachments/form', :locals => {:container => @news} %></p>
</div>

@ -3,6 +3,59 @@
label_tips = l(:label_course_news)
%>
<script type="text/javascript">
function regexTitle()
{
var name = $("#news_title").val();
if(name.length ==0)
{
$("#title_notice_span").text("标题不能为空");
$("#title_notice_span").css('color','#ff0000');
$("#title_notice_span").focus();
return false;
}
else if(name.length <= 60)
{
$("#title_notice_span").text("填写正确");
$("#title_notice_span").css('color','#008000');
return true;
}
else
{
$("#title_notice_span").text("标题超过60个字符");
$("#title_notice_span").css('color','#ff0000');
$("#title_notice_span").focus();
return false;
}
}
function regexDescription()
{
var name = $("#news_description").val();
if(name.length ==0)
{
$("#description_notice_span").text("描述不能为空");
$("#description_notice_span").css('color','#ff0000');
$("#description_notice_span").focus();
return false;
}
else
{
$("#description_notice_span").text("填写正确");
$("#description_notice_span").css('color','#008000');
return true;
}
}
function submitNews()
{
if(regexTitle() && regexDescription())
{
$("#news-form").submit();
}
}
</script>
<span style="font-size: 16px; border-bottom:1px solid #f0f0f0; margin-right: 15px;">
<%= label_tips %>
</span>
@ -15,8 +68,9 @@
<div id="add-news" class="add_frame" style="display:none;">
<%= labelled_form_for @news, :url => course_news_index_path(@course),
:html => {:id => 'news-form', :multipart => true} do |f| %>
<%= render :partial => 'news/course_form', :locals => {:f => f} %>
<%= submit_tag l(:button_create), :class => 'whiteButton m3p10 h30', :name => nil %><!-- button-submit --> |
<%= render :partial => 'news/course_form', :locals => {:f => f, :is_new => true} %>
<%#= submit_tag l(:button_create), :class => 'whiteButton m3p10 h30', :name => nil %><!-- button-submit -->
<%= link_to l(:button_create), "#", :onclick => 'submitNews();', :class => 'whiteButton m3p10' %>|
<%= preview_link preview_news_path(:course_id => @course), 'news-form', target='preview', {:class => 'whiteButton m3p10'} %>
|
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-news").hide()', :class => 'whiteButton m3p10' %>

@ -1,3 +1,56 @@
<script type="text/javascript">
function regexTitle()
{
var name = $("#news_title").val();
if(name.length ==0)
{
$("#title_notice_span").text("标题不能为空");
$("#title_notice_span").css('color','#ff0000');
$("#title_notice_span").focus();
return false;
}
else if(name.length <= 60)
{
$("#title_notice_span").text("填写正确");
$("#title_notice_span").css('color','#008000');
return true;
}
else
{
$("#title_notice_span").text("标题超过60个字符");
$("#title_notice_span").css('color','#ff0000');
$("#title_notice_span").focus();
return false;
}
}
function regexDescription()
{
var name = $("#news_description").val();
if(name.length ==0)
{
$("#description_notice_span").text("描述不能为空");
$("#description_notice_span").css('color','#ff0000');
$("#description_notice_span").focus();
return false;
}
else
{
$("#description_notice_span").text("填写正确");
$("#description_notice_span").css('color','#008000');
return true;
}
}
function submitNews()
{
if(regexTitle() && regexDescription())
{
$("#news-form").submit();
}
}
</script>
<div class="contextual">
<%= watcher_link(@news, User.current) %>
<%= link_to(l(:button_edit),
@ -14,8 +67,9 @@
<div id="edit-news" style="display:none;">
<%= labelled_form_for :news, @news, :url => news_path(@news),
:html => { :id => 'news-form', :multipart => true, :method => :put } do |f| %>
<%= render :partial => 'course_form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<%= render :partial => 'course_form', :locals => { :f => f, :is_new => false } %>
<%#= submit_tag l(:button_save) %>
<%= link_to l(:button_save), "#", :onclick => 'submitNews();' %>
<%= preview_link preview_news_path(:course_id => @course, :id => @news), 'news-form',target='preview',{:class => ''} %> |
<%= link_to l(:button_cancel), "#", :onclick => '$("#edit-news").hide(); return false;' %>
<% end %>

@ -1,11 +1,10 @@
<%= error_messages_for @news %>
<div class="add_frame_header" >
<% str = @project ? l(:bale_news_notice) : l(:label_news_new) %>
<%= str %>
<%= @project ? l(:label_news_new) : l(:bale_news_notice) %>
</div>
<div class="box tabular">
<p><%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %></p>
<!-- <p style="margin-left:-10px;"><%= f.text_area :summary, :cols => 60, :rows => 2, :style => "width:490px;margin-left:10px;" %></p> -->
<!-- <p style="margin-left:-10px;"><%#= f.text_area :summary, :cols => 60, :rows => 2, :style => "width:490px;margin-left:10px;" %></p> -->
<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;" %></p>
<p id="attachments_form" style="margin-left:-10px;"><label style="padding-right: 15px;"><%= l(:label_attachment_plural) %></label><%= render :partial => 'attachments/form', :locals => {:container => @news} %></p>
</div>

@ -1,9 +1,9 @@
<!--<p><%= link_to_project(news.project) + ': ' unless @project %>
<table><tr><td><img src="/images/new/news.png" width="40" height="40"/></td><td><%= link_to h(news.title), news_path(news) %>
<%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %>
<!--<p><%#= link_to_project(news.project) + ': ' unless @project %>
<table><tr><td><img src="/images/new/news.png" width="40" height="40"/></td><td><%#= link_to h(news.title), news_path(news) %>
<%#= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count > 0 %>
<% unless news.summary.blank? %></td><td><span class="fontligher"><%=h news.summary %></span><% end %></td>
<td><span class="author"><%= authoring news.created_on, news.author %></span></td></tr></table></p>-->
<%# unless news.summary.blank? %></td><td><span class="fontligher"><%#=h news.summary %></span><%# end %></td>
<td><span class="author"><%#= authoring news.created_on, news.author %></span></td></tr></table></p>-->
<table width="660px" border="0" align="center">
<tr>

@ -1,4 +1,4 @@
<!-- <h3><%=l(:label_news_new)%></h3> -->
<!-- <h3><%#=l(:label_news_new)%></h3> -->
<% if @project %>
<%= labelled_form_for @news, :url => project_news_index_path(@project),
:html => {:id => 'news-form', :multipart => true} do |f| %>

@ -9,9 +9,30 @@
<div style="float: left; width: 600px; padding-top: 6px; margin-left: 8px"><%= softapplication.description.truncate(95, omission: '...') %></div>
<div style="float: left; width: 200px; margin-left: 70px; margin-top: -3px; line-height: 0.5em ">
<%contest = softapplication.contests.first%>
<!--<table width="100%" border="0">-->
<!--<tr>-->
<!--<td style="width: 70px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_belongs_contest)%></td>-->
<!--<td style="width: 100px; word-wrap: break-word; word-break: break-all">-->
<!--<%= contest ? link_to(contest.name.truncate(14, omission: '...'), show_attendingcontest_contest_path(contest), title: contest.name.to_s ) : '尚未加入竞赛'%>-->
<!--</td>-->
<!--</tr>-->
<!--<tr>-->
<!--<td style="width: 70px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_belongs_type)%></td>-->
<!--<td style="width: 100px; word-wrap: break-word; word-break: break-all">-->
<!--<%= softapplication.app_type_name %>-->
<!--</td>-->
<!--</tr>-->
<!--<tr>-->
<!--<td style="width: 70px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_adaptive_system)%></td>-->
<!--<td style="width: 100px; word-wrap: break-word; word-break: break-all">-->
<!--<%= softapplication.android_min_version_available %>-->
<!--</td>-->
<!--</tr>-->
<!--</table>-->
<p><%=l(:label_attendingcontestwork_belongs_contest)%><%= contest ? link_to(contest.name.truncate(14, omission: '...'), show_attendingcontest_contest_path(contest), title: contest.name.to_s ) : '尚未加入竞赛'%></p>
<p><%=l(:label_attendingcontestwork_belongs_type)%><%= softapplication.app_type_name.truncate(10, omission: '...') %></p>
<p><%=l(:label_attendingcontestwork_adaptive_system)%><%= softapplication.android_min_version_available %></p>
<p><%=l(:label_attendingcontestwork_belongs_type)%><%= softapplication.app_type_name.truncate(14, omission: '...') %></p>
<%strTitle = softapplication.android_min_version_available%>
<p><%=l(:label_attendingcontestwork_adaptive_system)%><lable title="<%= strTitle %>"><%= strTitle.truncate(10,omisiion:'...') %></lable></p>
</div>
<div style="padding-left: 53px">
<span><%=l(:label_attendingcontestwork_developers)%><%= softapplication.application_developers %></span>

@ -3,51 +3,54 @@
<div style="height: auto; padding-bottom: 10px">
<tr>
<td colspan="2" valign="top" width="320">
</td>
<td>
<table width="100%" border="0">
<tr style="font-size: 18px">
<td valign="top"><strong><%= @softapplication.name %></strong></td>
<td style="font-size: 15px; padding-right: 0px" align="right">
<%= link_to '删除', softapplication_path(@softapplication), method: :delete, data: {confirm: '您确定要删除吗?'} if @softapplication.destroyable_by? User.current %>&nbsp;
<%= link_to '编辑', edit_softapplication_path(@softapplication), method: :get if @softapplication.destroyable_by? User.current %>
</td>
</tr>
<tr>
<td style="width: 570px; padding-left:40px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_belongs_type)%><%= @softapplication.app_type_name %></td>
<% contest = @softapplication.contests.first %>
<td style="width: 240px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_belongs_contest)%><%= contest ? link_to(contest.name, show_attendingcontest_contest_path(contest)) : '尚未加入竞赛' %></td>
</tr>
<tr>
<td style="padding-left: 40px"><%=l(:label_attendingcontestwork_release_person)%><%= @softapplication.user.name %></td>
<td><%=l(:label_attendingcontestwork_adaptive_system)%><%= @softapplication.android_min_version_available %></td>
</tr>
<tr>
<td style="padding-left: 40px">
<span><%=l(:label_attendingcontestwork_download)%></span>
<span>
<% options = {:author => true, :deletable => @softapplication.user.eql?(User.current)} %><%= render :partial => 'attachments/app_link', :locals => {:attachments => @app_items, :options => options} %>
</span>
</td>
<td><%=l(:label_attendingcontestwork_developers)%><%= @softapplication.application_developers %></td>
</tr>
<tr>
<td style="padding-left: 40px"><%=l(:label_attendingcontestwork_average_scores)%>: <%= rating_for @softapplication, :static => true, dimension: :quality, class: 'rateable div_inline' %></td>
<td><%=l(:label_attendingcontestwork_release_time)%><%=format_time @softapplication.created_at %></td>
</tr>
<tr>
<td style="padding-left: 40px">
<% if @project %>
<%=l(:label_attendingcontestwork_deposit_project)%><%= link_to "#@project", project_path(@project) %>
<% end %>
</td>
</tr>
</table>
</td>
</tr>
<table width="100%" border="0">
<tr style="font-size: 18px">
<td valign="top"><strong><%= @softapplication.name %></strong></td>
<td style="font-size: 15px; padding-right: 0px" align="right">
<%= link_to '删除', softapplication_path(@softapplication), method: :delete, data: {confirm: '您确定要删除吗?'} if @softapplication.destroyable_by? User.current %>&nbsp;
<%= link_to '编辑', edit_softapplication_path(@softapplication), method: :get if @softapplication.destroyable_by? User.current %>
</td>
</tr>
</table>
</div>
<div style="height: auto; padding-bottom: 10px">
<table width="100%" border="0">
<tr>
<td style="width: 70px; padding-left:40px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_belongs_type)%></td>
<td style="width: 400px; word-wrap: break-word; word-break: break-all"><%= @softapplication.app_type_name %></td>
<% contest = @softapplication.contests.first %>
<td style="width: 70px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_belongs_contest)%></td>
<td style="width: 400px; word-wrap: break-word; word-break: break-all"><%= contest ? link_to(contest.name, show_attendingcontest_contest_path(contest)) : '尚未加入竞赛' %></td>
</tr>
<tr>
<td style="width: 70px; padding-left:40px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_release_person)%></td>
<td style="width: 400px; word-wrap: break-word; word-break: break-all"><%= @softapplication.user.name %></td>
<td style="width: 70px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_adaptive_system)%></td>
<td style="width: 400px; word-wrap: break-word; word-break: break-all"><%= @softapplication.android_min_version_available %></td>
</tr>
<tr>
<td style="width: 70px; padding-left:40px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_download)%></td>
<td style="width: 400px; word-wrap: break-word; word-break: break-all">
<% options = {:author => true, :deletable => @softapplication.user.eql?(User.current)} %><%= render :partial => 'attachments/app_link', :locals => {:attachments => @app_items, :options => options} %>
</td>
<td style="width: 70px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_developers)%></td>
<td style="width: 400px; word-wrap: break-word; word-break: break-all"><%= @softapplication.application_developers %></td>
</tr>
<tr>
<td style="width: 70px; padding-left:40px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_average_scores)%></td>
<td style="width: 400px; word-wrap: break-word; word-break: break-all"><%= rating_for @softapplication, :static => true, dimension: :quality, class: 'rateable div_inline' %></td>
<td style="width: 70px; word-wrap: break-word; word-break: break-all"><%=l(:label_attendingcontestwork_release_time)%></td>
<td style="width: 400px; word-wrap: break-word; word-break: break-all"><%=format_time @softapplication.created_at %></td>
</tr>
<tr>
<td style="padding-left: 40px">
<% if @project %>
<%=l(:label_attendingcontestwork_deposit_project)%><%= link_to "#@project", project_path(@project) %>
<% end %>
</td>
</tr>
</table>
</div>
<div class="underline-contests_one"></div>
@ -56,7 +59,7 @@
<div style="font-size: 15px;"><%=l(:label_work_description)%></div>
</strong>
<div style="padding-top: 5px"><%= @softapplication.description %></div>
<div style="padding-top: 5px; padding-left:10px"><%= @softapplication.description %></div>
</div>
<div class="underline-contests_one"></div>

@ -1782,6 +1782,7 @@ en:
label_no_file_uploaded: No file uploaded
label_forum_new: New forum
label_memo_new_from_forum: Release memo
bale_edit_notice: Edit
label_user_grade: Individual score
label_active_homework: homework
@ -1797,6 +1798,8 @@ en:
label_record: 湘ICP备09019772
label_check_comment: Check comment
label_notification: Notification
#end
# ajax异步验证

@ -707,6 +707,7 @@ zh:
label_news: 新闻
label_news_new: 添加新闻
bale_news_notice: 添加通知 #huang
bale_edit_notice: 修改通知
label_news_notice: 发布课程通知
label_news_plural: 新闻
label_news_latest: 最近的新闻

@ -0,0 +1,23 @@
desc "User New Score description"
task :user_new_score do
puts "user_score sync."
end
namespace :user_new_score do
desc "calculating user score"
task :calculating => :environment do
include UserScoreHelper
User.all.each do |user|
result = user_scores(user,1).total_score
puts "score of #{user.login} is #{result}"
end
Project.where("project_type != 1").all.each do |project|
project.member_principals.includes(:roles, :principal).all.each do |member|
result = user_scores(member.user,2,project).total_score
puts "#{user.login}/'s score in #{project.name} is #{result}"
end
end
puts "calculate completed"
end
end

@ -0,0 +1,453 @@
desc "User Score description"
task :user_score_new do
puts "user_score sync."
end
namespace :user_score_new do
desc "calculating user score"
task :calculated => :environment do
include UserScoreHelper
puts "truncating table...#{Rails.env}"
puts "loading..."
# collaboration 协同得分
users = {}
grades = {}
# 发帖
Message.find_by_sql("SELECT `messages`.author_id AS u_id,`boards`.project_id AS p_id, COUNT(*) AS memo_number FROM `messages` JOIN `boards` ON `messages`.board_id = `boards`.id WHERE `messages`.parent_id IS NULL AND `boards`.project_id != -1 GROUP BY `messages`.author_id,`boards`.project_id ").each do|message|
option_num = get_option_num_by_id(message.u_id,2,message.p_id)
option_num.memo = message.memo_number
option_num.save
update_score(option_num)
puts "#{message.u_id}'s memo number in project #{message.p_id}: #{message.memo_number}"
end
Message.find_by_sql("SELECT `messages`.author_id AS u_id, COUNT(*) AS memo_number FROM `messages` JOIN `boards` ON `messages`.board_id = `boards`.id WHERE `messages`.parent_id IS NULL AND `boards`.project_id != -1 GROUP BY `messages`.author_id").each do|message|
option_num = get_option_num_by_id(message.u_id,1)
option_num.memo = message.memo_number
option_num.save
update_score(option_num)
puts "#{message.u_id}'s memo number: #{message.memo_number}"
end
puts "post_message calculate Completed."
#
## 对缺陷的留言
Journal.find_by_sql("SELECT user_id AS u_id,COUNT(*) AS m_count FROM journals WHERE journals.notes IS NOT NULL AND journals.notes != '' GROUP BY u_id").each do |journal|
option_num = get_option_num_by_id(journal.u_id,1)
option_num.messages_for_issues = journal.m_count
option_num.save
update_score(option_num)
puts "#{journal.u_id}'s messages_for_issues number: #{journal.m_count}"
end
Journal.find_by_sql("SELECT #{Journal.table_name}.user_id AS u_id, #{Issue.table_name}.project_id AS p_id ,COUNT(*) as m_count FROM journals join #{Issue.table_name} on #{Journal.table_name}.journalized_type = 'Issue' and #{Journal.table_name}.journalized_id = #{Issue.table_name}.id WHERE journals.notes IS NOT NULL AND journals.notes != '' GROUP BY u_id,p_id").each do |journal|
option_num = get_option_num_by_id(journal.u_id,2,journal.p_id)
option_num.messages_for_issues = journal.m_count
option_num.save
update_score(option_num)
puts "#{journal.u_id}'s messages_for_issues number in project #{journal.p_id}: #{journal.m_count}"
end
puts ":post_issue_message calculate Completed"
#
## 更改一次缺陷状态
Journal.find_by_sql("SELECT journals.user_id AS u_id, COUNT(*) as m_count FROM journals JOIN journal_details on journals.id = journal_details.journal_id WHERE journal_details.prop_key = 'status_id' GROUP BY u_id").each do |journal|
option_num = get_option_num_by_id(journal.u_id,1)
option_num.issues_status = journal.m_count
option_num.save
update_score(option_num)
puts "#{journal.u_id}'s issues_status number: #{journal.m_count}"
end
Journal.find_by_sql("SELECT journals.user_id AS u_id,issues.project_id AS p_id,COUNT(*) as m_count FROM journals JOIN journal_details on journals.id = journal_details.journal_id JOIN issues ON issues.id = journals.journalized_id and journalized_type = 'Issue' WHERE journal_details.prop_key = 'status_id' GROUP BY u_id,p_id").each do |journal|
option_num = get_option_num_by_id(journal.u_id,2,journal.p_id)
option_num.issues_status = journal.m_count
option_num.save
update_score(option_num)
puts "#{journal.u_id}'s issues_status number in project #{journal.p_id}: #{journal.m_count}"
end
puts ":change_issue_status calculate Completed"
#
## 对留言的回复
JournalsForMessage.find_by_sql("SELECT user_id AS u_id,COUNT(*) as m_count From #{JournalsForMessage.table_name} WHERE m_parent_id IS NOT NULL and jour_type = 'Project' GROUP BY u_id").each do |jfm|
option_num = get_option_num_by_id(jfm.u_id,1)
option_num.replay_for_message = jfm.m_count
option_num.save
update_score(option_num)
puts "#{jfm.u_id}'s replay_for_message number: #{jfm.m_count}"
end
JournalsForMessage.find_by_sql("SELECT user_id AS u_id,jour_id AS p_id,COUNT(*) as m_count From #{JournalsForMessage.table_name} WHERE m_parent_id IS NOT NULL and jour_type = 'Project' GROUP BY u_id,p_id").each do |jfm|
option_num = get_option_num_by_id(jfm.u_id,2,jfm.p_id)
option_num.replay_for_message = jfm.m_count
option_num.save
update_score(option_num)
puts "#{jfm.u_id}'s replay_for_message number in project #{jfm.p_id}: #{jfm.m_count}"
end
puts ":reply_message calculate Completed"
#
## 对帖子的回复
Message.find_by_sql("SELECT messages.author_id AS u_id, COUNT(*) as m_count FROM messages JOIN boards on messages.board_id = boards.id WHERE messages.parent_id IS NOT NULL AND boards.project_id != -1 GROUP BY u_id").each do |message|
option_num = get_option_num_by_id(message.u_id,1)
option_num.replay_for_memo = message.m_count
option_num.save
update_score(option_num)
puts "#{message.u_id}'s replay_for_memo number: #{message.m_count}"
end
Message.find_by_sql("SELECT messages.author_id AS u_id,boards.project_id AS p_id,COUNT(*) as m_count FROM messages JOIN boards on messages.board_id = boards.id WHERE messages.parent_id IS NOT NULL AND boards.project_id != -1 GROUP BY u_id,p_id").each do |message|
option_num = get_option_num_by_id(message.u_id,2,message.p_id)
option_num.replay_for_memo = message.m_count
option_num.save
update_score(option_num)
puts "#{message.u_id}'s replay_for_memo number in project #{message.p_id}: #{message.m_count}"
end
puts ":reply_posting calculate Completed."
#
#UserScore.transaction do
# users.each do |user_id, score|
# UserScore.find_or_create_by_user_id(user_id).update_attribute(:collaboration, score)
# end
#end
#puts "=== UserScore#collaboration calculate Completed. collaboration users count: #{users.count}"
#puts ""
#
#users.clear
#
## influence 影响力得分
##关注
Watcher.find_by_sql("SELECT watchable_id AS u_id ,COUNT(*) as m_count FROM #{Watcher.table_name} WHERE watchable_type = 'Principal' GROUP BY u_id").each do |watcher|
option_num = get_option_num_by_id(watcher.u_id,1)
option_num.follow = watcher.m_count
option_num.save
update_score(option_num)
puts "#{watcher.u_id}'s follow number: #{watcher.m_count}"
end
puts ":followed_by calculate Completed."
#
#UserScore.transaction do
# users_influence.each do |user_id, score|
# UserScore.find_or_create_by_user_id(user_id).update_attribute(:influence, score)
# end
#end
#puts "=== UserScore#influence calculate Completed. influence users count: #{users_influence.count}"
#puts ""
## skill 技术得分
#计算相关user的等级
PraiseTread.find_by_sql("SELECT user_id AS u_id,COUNT(*) AS m_count FROM `praise_treads` WHERE praise_tread_object_type IN ( 'Issue','Message') GROUP BY u_id").each do |pt|
user = User.find(pt.u_id)
level = UserLevels.get_level(user)
puts "user #{user.login}'s level is #{level}"
end
## 踩帖
PraiseTread.find_by_sql("SELECT user_id AS u_id,COUNT(*) AS m_count FROM `praise_treads` WHERE praise_tread_object_type IN ( 'Issue','Message') AND praise_or_tread = 0 GROUP BY u_id").each do |pt|
#踩别人扣分
option_num = get_option_num_by_id(pt.u_id,1)
option_num.tread = pt.m_count
option_num.save
update_score(option_num)
puts "#{pt.u_id}'s tread number: #{pt.m_count}"
end
#SELECT AS u_id,COUNT(*) AS m_count FROM `praise_treads` JOIN issues ON `issues`.id = `praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Issue' WHERE praise_or_tread = 0 GROUP BY u_id
PraiseTread.find_by_sql("SELECT `issues`.author_id AS target_u_id,`user_levels`.level AS u_level,COUNT(*) AS m_count FROM `praise_treads` JOIN issues ON `issues`.id =`praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Issue' JOIN `user_levels` ON `praise_treads`.user_id = `user_levels`.user_id WHERE praise_or_tread = 0 GROUP BY target_u_id,u_level").each do |pt|
#缺陷被人踩的次数
option_num = get_option_num_by_id(pt.target_u_id,1)
if pt.u_level == 1
option_num.tread_by_one = pt.m_count
puts "user #{pt.target_u_id} tread by one-level member #{pt.m_count} times "
elsif pt.u_level == 2
option_num.tread_by_two = pt.m_count
puts "user #{pt.target_u_id} tread by two-level member #{pt.m_count} times "
elsif pt.u_level == 3
option_num.tread_by_three = pt.m_count
puts "user #{pt.target_u_id} tread by three-level member #{pt.m_count} times "
else
puts "level error!:#{pt.u_level}"
next
end
option_num.save
update_score(option_num)
end
PraiseTread.find_by_sql("SELECT `praise_treads`.user_id AS u_id,`issues`.project_id AS p_id, COUNT(*) AS m_count FROM `praise_treads` JOIN issues ON `issues`.id =`praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Issue' WHERE praise_or_tread = 0 GROUP BY u_id,p_id").each do |pt|
#项目中踩别人缺陷的次数
option_num = get_option_num_by_id(pt.u_id,2,pt.p_id)
option_num.tread = pt.m_count
option_num.save
update_score(option_num)
puts "#{pt.u_id}'s tread number: #{pt.m_count}"
end
#项目中被人踩缺陷的次数
PraiseTread.find_by_sql("SELECT `issues`.author_id AS target_u_id,`issues`.project_id AS p_id,`user_levels`.level AS u_level,COUNT(*) AS m_count FROM `praise_treads` JOIN issues ON `issues`.id =`praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Issue' JOIN `user_levels` ON `praise_treads`.user_id = `user_levels`.user_id WHERE praise_or_tread = 0 GROUP BY target_u_id,p_id,u_level").each do |pt|
option_num = get_option_num_by_id(pt.target_u_id,2,pt.p_id)
if pt.u_level == 1
option_num.tread_by_one = pt.m_count
puts "user #{pt.target_u_id} tread by one-level member in project #{pt.p_id} #{pt.m_count} times "
elsif pt.u_level == 2
option_num.tread_by_two = pt.m_count
puts "user #{pt.target_u_id} tread by two-level member in project #{pt.p_id} #{pt.m_count} times "
elsif pt.u_level == 3
option_num.tread_by_three = pt.m_count
puts "user #{pt.target_u_id} tread by three-level member in project #{pt.p_id} #{pt.m_count} times "
else
puts "level error!:#{pt.u_level}"
next
end
option_num.save
update_score(option_num)
end
PraiseTread.find_by_sql("SELECT `messages`.author_id AS target_u_id,`user_levels`.level AS u_level,COUNT(*) AS m_count FROM `praise_treads` JOIN messages ON `messages`.id =`praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Message' JOIN `user_levels` ON `praise_treads`.user_id = `user_levels`.user_id WHERE praise_or_tread = 0 GROUP BY target_u_id,u_level").each do |pt|
#讨论区被人踩的次数
option_num = get_option_num_by_id(pt.target_u_id,1)
if pt.u_level == 1
option_num.tread_by_one += pt.m_count
puts "user #{pt.target_u_id} tread by one-level member #{pt.m_count} times "
elsif pt.u_level == 2
option_num.tread_by_two += pt.m_count
puts "user #{pt.target_u_id} tread by two-level member #{pt.m_count} times "
elsif pt.u_level == 3
option_num.tread_by_three += pt.m_count
puts "user #{pt.target_u_id} tread by three-level member #{pt.m_count} times "
else
puts "level error!:#{pt.u_level}"
next
end
option_num.save
update_score(option_num)
end
PraiseTread.find_by_sql("SELECT `praise_treads`.user_id AS u_id,`boards`.project_id AS p_id, COUNT(*) AS m_count FROM `praise_treads` JOIN messages ON `messages`.id =`praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Message' JOIN `boards` ON `boards`.id = `messages`.board_id AND `boards`.project_id != '-1' WHERE praise_or_tread = 0 GROUP BY u_id , p_id").each do |pt|
#项目讨论区中踩别人的次数
option_num = get_option_num_by_id(pt.u_id,2,pt.p_id)
option_num.tread += pt.m_count
option_num.save
update_score(option_num)
puts "#{pt.u_id}'s tread number: #{pt.m_count}"
end
#项目中被人踩的次数
PraiseTread.find_by_sql("SELECT `messages`.author_id AS target_u_id,`boards`.project_id AS p_id,`user_levels`.level AS u_level,COUNT(*) AS m_count FROM `praise_treads` JOIN messages ON `messages`.id =`praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Message' JOIN `user_levels` ON `praise_treads`.user_id = `user_levels`.user_id JOIN `boards` ON `boards`.id = `messages`.board_id AND `boards`.project_id != '-1' WHERE praise_or_tread = 0 GROUP BY target_u_id,p_id,u_level").each do |pt|
option_num = get_option_num_by_id(pt.target_u_id,2,pt.p_id)
if pt.u_level == 1
option_num.tread_by_one += pt.m_count
puts "user #{pt.target_u_id} tread by one-level member in project #{pt.p_id} #{pt.m_count} times "
elsif pt.u_level == 2
option_num.tread_by_two += pt.m_count
puts "user #{pt.target_u_id} tread by two-level member in project #{pt.p_id} #{pt.m_count} times "
elsif pt.u_level == 3
option_num.tread_by_three += pt.m_count
puts "user #{pt.target_u_id} tread by three-level member in project #{pt.p_id} #{pt.m_count} times "
else
puts "level error!:#{pt.u_level}"
next
end
option_num.save
update_score(option_num)
end
#顶贴
#SELECT AS u_id,COUNT(*) AS m_count FROM `praise_treads` JOIN issues ON `issues`.id = `praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Issue' WHERE praise_or_tread = 0 GROUP BY u_id
PraiseTread.find_by_sql("SELECT `issues`.author_id AS target_u_id,`user_levels`.level AS u_level,COUNT(*) AS m_count FROM `praise_treads` JOIN issues ON `issues`.id =`praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Issue' JOIN `user_levels` ON `praise_treads`.user_id = `user_levels`.user_id WHERE praise_or_tread = 1 GROUP BY target_u_id,u_level").each do |pt|
#缺陷被人顶的次数
option_num = get_option_num_by_id(pt.target_u_id,1)
if pt.u_level == 1
option_num.praise_by_one = pt.m_count
puts "user #{pt.target_u_id} praise by one-level member #{pt.m_count} times "
elsif pt.u_level == 2
option_num.praise_by_two = pt.m_count
puts "user #{pt.target_u_id} praise by two-level member #{pt.m_count} times "
elsif pt.u_level == 3
option_num.praise_by_three = pt.m_count
puts "user #{pt.target_u_id} praise by three-level member #{pt.m_count} times "
else
puts "level error!:#{pt.u_level}"
next
end
option_num.save
update_score(option_num)
end
#项目中被人顶缺陷的次数
PraiseTread.find_by_sql("SELECT `issues`.author_id AS target_u_id,`issues`.project_id AS p_id,`user_levels`.level AS u_level,COUNT(*) AS m_count FROM `praise_treads` JOIN issues ON `issues`.id =`praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Issue' JOIN `user_levels` ON `praise_treads`.user_id = `user_levels`.user_id WHERE praise_or_tread = 1 GROUP BY target_u_id,p_id,u_level").each do |pt|
option_num = get_option_num_by_id(pt.target_u_id,2,pt.p_id)
if pt.u_level == 1
option_num.praise_by_one = pt.m_count
puts "user #{pt.target_u_id} praise by one-level member in project #{pt.p_id} #{pt.m_count} times "
elsif pt.u_level == 2
option_num.praise_by_two = pt.m_count
puts "user #{pt.target_u_id} praise by two-level member in project #{pt.p_id} #{pt.m_count} times "
elsif pt.u_level == 3
option_num.praise_by_three = pt.m_count
puts "user #{pt.target_u_id} praise by three-level member in project #{pt.p_id} #{pt.m_count} times "
else
puts "level error!:#{pt.u_level}"
next
end
option_num.save
update_score(option_num)
end
PraiseTread.find_by_sql("SELECT `messages`.author_id AS target_u_id,`user_levels`.level AS u_level,COUNT(*) AS m_count FROM `praise_treads` JOIN messages ON `messages`.id =`praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Message' JOIN `user_levels` ON `praise_treads`.user_id = `user_levels`.user_id WHERE praise_or_tread = 1 GROUP BY target_u_id,u_level").each do |pt|
#讨论区被人顶的次数
option_num = get_option_num_by_id(pt.target_u_id,1)
if pt.u_level == 1
option_num.praise_by_one += pt.m_count
puts "user #{pt.target_u_id} praise by one-level member #{pt.m_count} times "
elsif pt.u_level == 2
option_num.praise_by_two += pt.m_count
puts "user #{pt.target_u_id} praise by two-level member #{pt.m_count} times "
elsif pt.u_level == 3
option_num.praise_by_three += pt.m_count
puts "user #{pt.target_u_id} praise by three-level member #{pt.m_count} times "
else
puts "level error!:#{pt.u_level}"
next
end
option_num.save
update_score(option_num)
end
#项目中被人踩的次数
PraiseTread.find_by_sql("SELECT `messages`.author_id AS target_u_id,`boards`.project_id AS p_id,`user_levels`.level AS u_level,COUNT(*) AS m_count FROM `praise_treads` JOIN messages ON `messages`.id =`praise_treads`.praise_tread_object_id AND `praise_treads`.praise_tread_object_type = 'Message' JOIN `user_levels` ON `praise_treads`.user_id = `user_levels`.user_id JOIN `boards` ON `boards`.id = `messages`.board_id AND `boards`.project_id != '-1' WHERE praise_or_tread = 1 GROUP BY target_u_id,p_id,u_level").each do |pt|
option_num = get_option_num_by_id(pt.target_u_id,2,pt.p_id)
if pt.u_level == 1
option_num.praise_by_one += pt.m_count
puts "user #{pt.target_u_id} praise by one-level member in project #{pt.p_id} #{pt.m_count} times "
elsif pt.u_level == 2
option_num.praise_by_two += pt.m_count
puts "user #{pt.target_u_id} praise by two-level member in project #{pt.p_id} #{pt.m_count} times "
elsif pt.u_level == 3
option_num.praise_by_three += pt.m_count
puts "user #{pt.target_u_id} praise by three-level member in project #{pt.p_id} #{pt.m_count} times "
else
puts "level error!:#{pt.u_level}"
next
end
option_num.save
update_score(option_num)
end
puts "UserScore#skill calculate Completed."
#puts ""
#
## active 项目贡献得分
## 提交代码
Changeset.find_by_sql("SELECT user_id AS u_id, COUNT(*) AS m_count FROM `changesets` GROUP BY u_id").each do |changeset|
unless changeset.u_id.nil?
option_num = get_option_num_by_id(changeset.u_id,1)
option_num.changeset = changeset.m_count
option_num.save
update_score(option_num)
puts "#{changeset.u_id}'s changeset number: #{changeset.m_count}"
end
end
Changeset.find_by_sql("SELECT `changesets`.user_id AS u_id, `repositories`.project_id AS p_id,COUNT(*) AS m_count FROM `changesets` JOIN `repositories` ON `repositories`.id = `changesets`.repository_id GROUP BY u_id,p_id ").each do |changeset|
unless changeset.nil?
option_num = get_option_num_by_id(changeset.u_id,2,changeset.p_id)
option_num.changeset = changeset.m_count
option_num.save
update_score(option_num)
puts "#{changeset.u_id}'s changeset number in project #{changeset.p_id}: #{changeset.m_count}"
end
end
puts ":push_code calculate Completed."
##提交文档
Document.find_by_sql("SELECT user_id AS u_id ,COUNT(*) AS m_count FROM `documents` GROUP BY user_id").each do |document|
option_num = get_option_num_by_id(document.u_id,1)
option_num.document = document.m_count
option_num.save
update_score(option_num)
puts "#{document.u_id}'s document number: #{document.m_count}"
end
Document.find_by_sql("SELECT user_id AS u_id , project_id AS p_id, COUNT(*) AS m_count FROM `documents` GROUP BY u_id,p_id").each do |document|
option_num = get_option_num_by_id(document.u_id,2,document.p_id)
option_num.document = document.m_count
option_num.save
update_score(option_num)
puts "#{document.u_id}'s document number in project #{document.p_id}: #{document.m_count}"
end
puts ":push_document calculate Completed."
##提交附件
Attachment.find_by_sql("SELECT author_id AS u_id,COUNT(*) as m_count FROM #{Attachment.table_name} WHERE container_type = 'Project' GROUP By u_id").each do |attachment|
option_num = get_option_num_by_id(attachment.u_id,1)
option_num.attachment = attachment.m_count
option_num.save
update_score(option_num)
puts "#{attachment.u_id}'s attachment number: #{attachment.m_count}"
end
Attachment.find_by_sql("SELECT author_id AS u_id,container_id AS p_id,COUNT(*) as m_count FROM #{Attachment.table_name} WHERE container_type = 'Project' GROUP By u_id,p_id").each do |attachment|
option_num = get_option_num_by_id(attachment.u_id,2,attachment.p_id)
option_num.attachment = attachment.m_count
option_num.save
update_score(option_num)
puts "#{attachment.u_id}'s attachment number in project #{attachment.p_id}: #{attachment.m_count}"
end
puts ":push_file calculate Completed."
##更新完成度
Journal.find_by_sql("SELECT #{Journal.table_name}.user_id AS u_id, COUNT(*) as m_count FROM #{Journal.table_name} JOIN #{JournalDetail.table_name} ON #{JournalDetail.table_name}.journal_id = #{Journal.table_name}.id WHERE #{JournalDetail.table_name}.prop_key = 'done_ratio' GROUP BY u_id ").each do |j|
option_num = get_option_num_by_id(j.u_id,1)
option_num.issue_done_ratio = j.m_count
option_num.save
update_score(option_num)
puts "#{j.u_id}'s issue_done_ratio number: #{j.m_count}"
end
Journal.find_by_sql("SELECT #{Journal.table_name}.user_id AS u_id, #{Issue.table_name}.project_id AS p_id,COUNT(*) as m_count FROM #{Journal.table_name} JOIN #{JournalDetail.table_name} ON #{JournalDetail.table_name}.journal_id = #{Journal.table_name}.id JOIN issues ON issues.id = journals.journalized_id and journalized_type = 'Issue' WHERE #{JournalDetail.table_name}.prop_key = 'done_ratio' GROUP BY u_id,p_id ").each do |j|
option_num = get_option_num_by_id(j.u_id,2,j.p_id)
option_num.issue_done_ratio = j.m_count
option_num.save
update_score(option_num)
puts "#{j.u_id}'s issue_done_ratio number in project #{j.p_id}: #{j.m_count}"
end
puts ":update_issue_ratio calculate Completed."
##发布缺陷
Issue.find_by_sql("SELECT author_id AS u_id,COUNT(*) as m_count FROM #{Issue.table_name} GROUP BY u_id").each do |issues|
option_num = get_option_num_by_id(issues.u_id,1)
option_num.post_issue = issues.m_count
option_num.save
update_score(option_num)
puts "#{issues.u_id}'s issues number: #{issues.m_count}"
end
Issue.find_by_sql("SELECT author_id AS u_id,project_id AS p_id,COUNT(*) as m_count FROM #{Issue.table_name} GROUP BY u_id,p_id").each do |issues|
option_num = get_option_num_by_id(issues.u_id,2,issues.p_id)
option_num.post_issue = issues.m_count
option_num.save
update_score(option_num)
puts "#{issues.u_id}'s issues number in project #{issues.p_id}: #{issues.m_count}"
end
puts ":post_issue calculate Completed."
#
#
#UserScore.transaction do
# users_active.each do |user_id, score|
# UserScore.find_or_create_by_user_id(user_id).update_attribute(:active, score)
# end
#end
#puts "=== UserScore#active calculate Completed. active users count: #{users_active.count}"
#UserGrade.transaction do
# grades.each do |grade_id,score|
# grade = UserGrade.find(grade_id)
# grade.grade = score
# grade.save
# end
#end
#puts "=== UserGrid calculate Completed. UserGrids count: #{grades.count}"
end
end

@ -46,8 +46,8 @@ review = issue.code_review
%>
<%= l(:label_revision) + " "%>
<%= link_to_revision(assignment.revision, repo) %>
<% elsif assignment.attachment %>
<%= link_to(assignment.attachment.filename, :controller => 'attachments', :action => 'show', :id => attachment.id) %>
<% elsif assignment.respond_to?("attachment") && assignment.attachment %>
<%= link_to(assignment.attachment.filename.to_s, :controller => 'attachments', :action => 'show', :id => assignment.attachment.id) %>
<% end %>
</td>
</tr>

Loading…
Cancel
Save