commit
0536af6625
@ -1,3 +1,14 @@
|
|||||||
class HomeworkUsersController < ApplicationController
|
class HomeworkUsersController < ApplicationController
|
||||||
|
#新增数据
|
||||||
|
def create option
|
||||||
|
user = HomeworkUser.new option
|
||||||
|
user.save
|
||||||
|
user
|
||||||
|
end
|
||||||
|
#删除数据
|
||||||
|
def destory homework_user
|
||||||
|
user = HomeworkUser.find homework_user
|
||||||
|
user.destroy
|
||||||
|
user
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,10 +1,57 @@
|
|||||||
module HomeworkAttachHelper
|
module HomeworkAttachHelper
|
||||||
|
#判断是否具有删除的权限
|
||||||
def attach_delete(project)
|
def attach_delete(project)
|
||||||
if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0) || project.user_id == User.current.id)
|
if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0) || project.user_id == User.current.id)
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
#作业添加、编辑界面的tab页
|
||||||
|
def homework_settings_tabs f
|
||||||
|
@f = f
|
||||||
|
tabs = [{:name => 'info', :partial => 'homework_attach/edit_homework', :label => :label_information_plural},
|
||||||
|
{:name => 'members', :partial => 'homework_attach/homework_member', :label => :label_member_plural}
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
#作业可选成员列表分页
|
||||||
|
def render_new_members_for_homework members
|
||||||
|
#scope = Principal.active.sorted.not_member_of(project).like(params[:q])
|
||||||
|
#scope = project.members
|
||||||
|
#principals = paginateHelper members,10
|
||||||
|
#principals = members
|
||||||
|
#principal_count = members.count
|
||||||
|
#limit = 10
|
||||||
|
#principal_pages = Redmine::Pagination::Paginator.new principal_count, limit, params['page'] #by young
|
||||||
|
#offset ||= principal_pages.offset
|
||||||
|
#principals = members[offset, limit]
|
||||||
|
users = members.map(&:user)
|
||||||
|
s = content_tag('div', member_check_box_tags_ex('membership[user_ids][]', users), :id => 'principals')
|
||||||
|
links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false) {|text, parameters, options|
|
||||||
|
link_to text, get_homework_member_list_homework_attach_index_path( parameters.merge(:q => params[:q], bid_id: params[:id]||@homework)), :remote => true }
|
||||||
|
return s + content_tag('div', content_tag('ul', links), :class => 'pagination_new')
|
||||||
|
end
|
||||||
|
|
||||||
|
#扩展的checkbox生成
|
||||||
|
def member_check_box_tags_ex(name, principals)
|
||||||
|
s = ''
|
||||||
|
principals.each do |member|
|
||||||
|
s << "<label>#{ check_box_tag name, member.id, false, :id => nil } #{h member.name }</label><br/>"
|
||||||
|
end
|
||||||
|
s.html_safe
|
||||||
|
end
|
||||||
|
|
||||||
|
def paginateHelper obj, pre_size=20
|
||||||
|
@obj_count = obj.count
|
||||||
|
@obj_pages = Redmine::Pagination::Paginator.new @obj_count, pre_size, params['page']
|
||||||
|
if obj.kind_of? ActiveRecord::Base or obj.kind_of? ActiveRecord::Relation
|
||||||
|
obj.limit(@obj_pages.per_page).offset(@obj_pages.offset)
|
||||||
|
elsif obj.kind_of? Array
|
||||||
|
obj[@obj_pages.offset, @obj_pages.per_page]
|
||||||
|
else
|
||||||
|
logger.error "[ApplicationController] Error : application_controller#paginateHelper ===> unknow category: #{obj.class}"
|
||||||
|
raise RuntimeError, 'unknow type, Please input you type into this helper.'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -1,6 +1,6 @@
|
|||||||
class HomeworkUser < ActiveRecord::Base
|
class HomeworkUser < ActiveRecord::Base
|
||||||
attr_accessible :homework_attach_id, :user_id
|
attr_accessible :homework_attach_id, :user_id
|
||||||
|
|
||||||
belongs_to :homework_attach
|
belongs_to :homework_attach, :foreign_key => :homework_attach_id
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
end
|
end
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
#用户等级类 - by zjc
|
||||||
|
class UserLevels < ActiveRecord::Base
|
||||||
|
attr_accessible :user_id, :level
|
||||||
|
belongs_to :user
|
||||||
|
end
|
@ -0,0 +1,44 @@
|
|||||||
|
<%= error_messages_for 'member' %>
|
||||||
|
<div style="float:left; width:60%;padding-left: 10px;padding-right: 10px"
|
||||||
|
xmlns="http://www.w3.org/1999/html" id = "homework_of_users">
|
||||||
|
<table class="list members" style="width: 100%">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><%= l(:label_user) %></th>
|
||||||
|
<th><%= l(:label_role_plural) %></th>
|
||||||
|
<th style="width:10%"></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<!-- 发布人员不能被删除,将发布人员放在第一位 -->
|
||||||
|
<tr id="member-<%= homework.user.id %>" class="<%= cycle 'odd', 'even' %> member" style="text-align: center">
|
||||||
|
<td style="width: 40%"><%= link_to_user homework.user %></td>
|
||||||
|
<td style="text-align: center;width: 50%"> 发布人员 </td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<% hoemwork_users.each do |user| %>
|
||||||
|
<tr id="member-<%= user.id %>" class="<%= cycle 'odd', 'even' %> member" style="text-align: center">
|
||||||
|
<% if homework.user != user %>
|
||||||
|
<td style="width: 40%"><%= link_to_user user %></td>
|
||||||
|
<td style="text-align: center;width: 50%"> 参与人员 </td>
|
||||||
|
<td><%= link_to l(:button_delete),destory_homework_users_homework_attach_path(:user_id=>user),:remote => true, :method => :post %></td>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="splitcontentright" style="width: 37%">
|
||||||
|
<%= form_for(hoemwork_users, {:url => add_homework_users_homework_attach_path(homework), :remote => true, :method => :post}) do |f| %>
|
||||||
|
<fieldset>
|
||||||
|
<legend><%= l(:label_member_new) %></legend>
|
||||||
|
<p><%= label_tag "principal_search", l(:label_principal_search) %><%= text_field_tag 'principal_search', nil %></p>
|
||||||
|
<%= javascript_tag "observeSearchfield('principal_search', null, '#{ escape_javascript get_homework_member_list_homework_attach_index_path(:q => params[:q], :bid_id => params[:id]||homework, :format => 'js') }')" %>
|
||||||
|
<div id="principals_for_new_member">
|
||||||
|
<%= render_new_members_for_homework(members) %>
|
||||||
|
</div>
|
||||||
|
<p><%= submit_tag l(:button_add), :id => 'member-add-submit' %></p>
|
||||||
|
</fieldset>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
@ -0,0 +1,3 @@
|
|||||||
|
<div id="principals_for_new_member">
|
||||||
|
<%= render_new_members_for_homework(members) %>
|
||||||
|
</div>
|
@ -0,0 +1,22 @@
|
|||||||
|
<div class="box">
|
||||||
|
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||||
|
<strong>标 题:</strong>
|
||||||
|
<%= f.text_field "name", :required => true, :size => 60, :style => "width:490px;" %>
|
||||||
|
</p>
|
||||||
|
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||||
|
<strong style="vertical-align: top">描 述:</strong>
|
||||||
|
<span style="margin-left:-10px;padding-right: 20px;">
|
||||||
|
<%= f.text_area "description", :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<p style="padding-left: 60px">
|
||||||
|
<fieldset style="text-align: left;">
|
||||||
|
<legend>
|
||||||
|
<%= l(:label_attachment_plural) %>
|
||||||
|
</legend>
|
||||||
|
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||||
|
<%= render :partial => 'attachments/form' %>
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
</p>
|
||||||
|
</div>
|
@ -0,0 +1 @@
|
|||||||
|
$('#content2').html('<%= escape_javascript(render(:partial => 'homework_member', :locals => {:members => @members,:hoemwork_users =>@hoemwork_users,:homework => @homework} )) %>');
|
@ -0,0 +1 @@
|
|||||||
|
$('#content2').html('<%= escape_javascript(render(:partial => 'homework_member', :locals => {:members => @members,:hoemwork_users =>@hoemwork_users,:homework => @homework} )) %>');
|
@ -1,35 +1,79 @@
|
|||||||
<p style="font-weight: bold; color: rgb(237,137,36)" xmlns="http://www.w3.org/1999/html"> <%=raw l(:label_new_homework)%> </p>
|
<script type="text/javascript">
|
||||||
<div class="box">
|
function switchTab(ProTag) {
|
||||||
|
var display_index = 3 - ProTag;
|
||||||
|
document.getElementById("tab" + ProTag).className = "selected";
|
||||||
|
document.getElementById("tab" + display_index).className = "";
|
||||||
|
document.getElementById("content" + ProTag).style.display = "";
|
||||||
|
document.getElementById("content" + display_index).style.display = "none";
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="top-content">
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td class="info_font" style="width: 240px; color: #15bccf">高校课程实践社区</td>
|
||||||
|
<td style="width: auto; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%></a></td>
|
||||||
|
<td><p class="top-content-list-homework"><%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> >
|
||||||
|
<span><%= link_to(@homework.bid.courses.first.name.to_s, homework_project_path(@homework.bid.courses.first)) if @homework.bid.courses.first%></span> >
|
||||||
|
<%=link_to(@homework.bid.name, respond_path(@homework.bid)) %> > <span><%= link_to "修改作业",edit_homework_attach_path(@homework)%></span></p></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p style="font-weight: bold; color: rgb(237,137,36)" xmlns="http://www.w3.org/1999/html"> <%=raw l(:label_edit_homework)%> </p>
|
||||||
|
<div class="tabs">
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a id = "tab1" href="#" class = "selected" onclick="switchTab(1);this.blur();return false;">
|
||||||
|
<%= l(:label_information_plural) %>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a id="tab2" href="#" onclick="switchTab(2); this.blur(); return false;">
|
||||||
|
<%= l(:label_member_plural) %>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="box" id="content1">
|
||||||
<%= form_for(@homework) do |f|%>
|
<%= form_for(@homework) do |f|%>
|
||||||
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||||
<strong>标 题:</strong>
|
<strong>标 题:</strong>
|
||||||
<%= f.text_field :name, :required => true, :name => "homework_name", :size => 60, :style => "width:490px;"%>
|
<%= f.text_field :name, :required => true, :name => "homework_name", :size => 60, :style => "width:490px;"%>
|
||||||
</p>
|
</p>
|
||||||
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||||
<strong style="vertical-align: top">描 述:</strong>
|
<strong style="vertical-align: top">描 述:</strong>
|
||||||
<span style="margin-left:-10px;padding-right: 20px;">
|
<span style="margin-left:-10px;padding-right: 20px;">
|
||||||
<%= f.text_area :description, :rows => 8, :name => "homework_description", :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
|
<%= f.text_area :description, :rows => 8, :name => "homework_description", :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<p style="padding-left: 60px">
|
<p style="padding-left: 60px">
|
||||||
<fieldset style="text-align: left;">
|
<fieldset style="text-align: left;">
|
||||||
<p style="padding-left: 60px">
|
<p style="padding-left: 60px">
|
||||||
<% options = {:author => true, :deletable => attach_delete(@homework)} %>
|
<% options = {:author => true, :deletable => attach_delete(@homework)} %>
|
||||||
<%= render :partial => 'attachments/links',
|
<%= render :partial => 'attachments/links',
|
||||||
:locals => {:attachments => @homework.attachments, :options => options} %>
|
:locals => {:attachments => @homework.attachments, :options => options} %>
|
||||||
</p>
|
</p>
|
||||||
<legend>
|
<legend>
|
||||||
<%= l(:label_attachment_plural) %>
|
<%= l(:label_attachment_plural) %>
|
||||||
</legend>
|
</legend>
|
||||||
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
|
||||||
<%= render :partial => 'attachments/form' %>
|
<%= render :partial => 'attachments/form' %>
|
||||||
</p>
|
</p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</p>
|
</p>
|
||||||
<p style="padding-left: 60px;padding-top: 10px;">
|
<p style="padding-left: 60px;padding-top: 10px;">
|
||||||
<span >
|
<span >
|
||||||
<%= submit_tag t(:label_button_ok), :sta => 0, :class => "enterprise"%>
|
<%= submit_tag t(:label_button_ok), :sta => 0, :class => "enterprise"%>
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="content2" style="display: none" >
|
||||||
|
<%= render :partial => "homework_member",:locals => {:members => @members,:hoemwork_users =>@hoemwork_users,:homework => @homework} %>
|
||||||
|
</div>
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
$('#principals_for_new_member').replaceWith('<%= j(render :partial => "member_list_partial", locals:{members: @members})%>');
|
||||||
|
|
@ -0,0 +1,15 @@
|
|||||||
|
<div class="top-content">
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td class="info_font" style="width: 240px; color: #15bccf">高校课程实践社区</td>
|
||||||
|
<td style="width: auto; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%></a></td>
|
||||||
|
<td><p class="top-content-list-homework"><%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> >
|
||||||
|
<span><%= link_to(homework_attach.bid.courses.first.name.to_s, homework_project_path(homework_attach.bid.courses.first)) if homework_attach.bid.courses.first%></span> >
|
||||||
|
<%=link_to(homework_attach.bid.name, respond_path(homework_attach.bid)) %> > <span><%= link_to homework_attach.name.nil? ? homework_attach.attachments.first.filename : homework_attach.name,homework_attach_path(homework_attach)%></span></p></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
@ -1,5 +1,3 @@
|
|||||||
<!-- added by bai -->
|
|
||||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'users/show_score') %>');
|
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'users/show_score') %>');
|
||||||
showModal('ajax-modal', '400px');
|
showModal('ajax-modal', '400px');
|
||||||
$('#ajax-modal').addClass('new-watcher');
|
$('#ajax-modal').addClass('new-watcher');
|
||||||
<!-- end -->
|
|
@ -0,0 +1,5 @@
|
|||||||
|
class AddUserIdToDocuments < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :documents, :user_id, :integer, default: 0
|
||||||
|
end
|
||||||
|
end
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,72 @@
|
|||||||
|
desc "User Score description"
|
||||||
|
task :user_score do
|
||||||
|
puts "user_score sync."
|
||||||
|
end
|
||||||
|
|
||||||
|
namespace :user_score do
|
||||||
|
desc "calculating user score"
|
||||||
|
# Rails.env = 'production'
|
||||||
|
task :calculate => :environment do
|
||||||
|
puts "loading..."
|
||||||
|
# collaboration 协同得分
|
||||||
|
users = {}
|
||||||
|
# 发帖
|
||||||
|
Message.includes(:author).where("parent_id IS NULL").all.each do |m|
|
||||||
|
users[m.author.id] = users[m.author.id].to_i + 2
|
||||||
|
end
|
||||||
|
puts ":post_message calculate Completed. users count: #{users.count}"
|
||||||
|
|
||||||
|
# 对缺陷的留言
|
||||||
|
Journal.includes(:user).all.each do |j|
|
||||||
|
users[j.user.id] = users[j.user.id].to_i + 1
|
||||||
|
end
|
||||||
|
puts ":post_issue calculate Completed. users count: #{users.count}"
|
||||||
|
|
||||||
|
# 更改一次缺陷状态
|
||||||
|
Journal.joins(:details, :user).where("#{JournalDetail.table_name}.prop_key = 'status_id'").each do |j|
|
||||||
|
users[j.user.id] = users[j.user.id].to_i + 1
|
||||||
|
end
|
||||||
|
puts ":change_issue_status calculate Completed. users count: #{users.count}"
|
||||||
|
|
||||||
|
# 对留言的回复
|
||||||
|
JournalsForMessage.includes(:user).where("m_parent_id IS NOT NULL").each do |jfm|
|
||||||
|
users[jfm.user.id] = users[jfm.user.id].to_i + 1
|
||||||
|
end
|
||||||
|
puts ":reply_message calculate Completed. users count: #{users.count}"
|
||||||
|
|
||||||
|
# 对帖子的回复
|
||||||
|
Message.includes(:author).where("parent_id IS NOT NULL").each do |m|
|
||||||
|
users[m.author.id] = users[m.author.id].to_i + 1
|
||||||
|
end
|
||||||
|
puts ":reply_posting calculate Completed. users count: #{users.count}"
|
||||||
|
|
||||||
|
users.each do |user_id, score|
|
||||||
|
UserScore.find_or_create_by_user_id(user_id).update_attribute(:collaboration, score)
|
||||||
|
end
|
||||||
|
puts "=== UserScore#collaboration calculate Completed. users count: #{users.count}"
|
||||||
|
|
||||||
|
users.clear
|
||||||
|
|
||||||
|
# influence 影响力得分
|
||||||
|
# ...
|
||||||
|
|
||||||
|
# skill 技术得分
|
||||||
|
# ...
|
||||||
|
|
||||||
|
# active 项目贡献得分
|
||||||
|
# ...
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "create tmp file, to test"
|
||||||
|
file 'tmp/test.yml' do
|
||||||
|
require 'yaml'
|
||||||
|
var = {
|
||||||
|
:name => "name",
|
||||||
|
:age => "age",
|
||||||
|
:agent => "agent"
|
||||||
|
}
|
||||||
|
File.open('tmp/test.yml', 'w') do |f|
|
||||||
|
f.write YAML.dump({'conf' => var })
|
||||||
|
end
|
||||||
|
end
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue