diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb
index c4c1f8922..e20a5a868 100644
--- a/app/controllers/homework_attach_controller.rb
+++ b/app/controllers/homework_attach_controller.rb
@@ -78,8 +78,8 @@ class HomeworkAttachController < ApplicationController
def new
@bid = Bid.find(params[:id])
if User.current.admin? || User.current.member_of?(@bid.courses.first)
+ #该课程的学生的集合
@members = @bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and user_id <> #{User.current.id}", {:role_id => [5, 10]})
-
#@all_user = []
#@bid.courses.first.members.each do |member|
# @all_user << member.user
diff --git a/app/helpers/homework_attach_helper.rb b/app/helpers/homework_attach_helper.rb
index 85f9a64ad..95327edd1 100644
--- a/app/helpers/homework_attach_helper.rb
+++ b/app/helpers/homework_attach_helper.rb
@@ -19,23 +19,37 @@ module HomeworkAttachHelper
def render_new_members_for_homework members
#scope = Principal.active.sorted.not_member_of(project).like(params[:q])
#scope = project.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]
+ principals = paginateHelper members,10
+ #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]
s = content_tag('div', member_check_box_tags_ex('membership[user_ids][]', principals), :id => 'principals')
- links = pagination_links_full(principal_pages, principal_count, :per_page_links => false,:remote => true)
-
- s + content_tag('div', content_tag('ul', links), :class => 'pagination_new')
+ links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false) {|text, parameters, options|
+ link_to text, new_homework_attach_path( parameters.merge(:q => params[:q], :format => 'js')), :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 << "\n"
+ s << "
"
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
\ No newline at end of file
diff --git a/app/views/homework_attach/_homework_member.html.erb b/app/views/homework_attach/_homework_member.html.erb
index f69f9edff..ed268f652 100644
--- a/app/views/homework_attach/_homework_member.html.erb
+++ b/app/views/homework_attach/_homework_member.html.erb
@@ -1,131 +1,30 @@
<%= error_messages_for 'member' %>
-<%
- roles = Role.givable.all
- if @project.project_type == Project::ProjectType_course
- roles = roles[3..5]
- else
- roles = roles[0..2]
- end
- members = @project.member_principals.includes(:roles, :principal).all.sort
-%>
-
-
<%= l(:label_user) %> | -<%= l(:label_role_plural) %> | -- <%= call_hook(:view_projects_settings_members_table_header, :project => @project) %> + |
---|
<%= l(:label_user) %> | +<%= l(:label_role_plural) %> | ++ | ||
---|---|---|---|---|
<%= link_to_user User.current %> | +发布人员 | |||
<%= link_to_user member.principal %> | -
-
- <%= h member.roles.sort.collect(&:to_s).join(', ') %>
-
- <%= form_for(member, {:as => :membership, :remote => true, :url => membership_path(member),
- :method => :put,
- :html => {:id => "member-#{member.id}-roles-form", :class => 'hol'}}
- ) do |f| %>
-
-
- <% roles.each do |role| %>
- <%= submit_tag l(:button_change), :class => "small" %> - <%= link_to_function l(:button_cancel), - "$('#member-#{member.id}-roles').show(); $('#member-#{member.id}-roles-form').hide(); return false;" - %> - <% end %> - |
-
- <% if @project.project_type == 1 %>
- <% if member.roles.first.to_s == "Manager" %>
- - <% else %> - | - <%= link_to_function l(:button_edit), - "$('#member-#{member.id}-roles').hide(); $('#member-#{member.id}-roles-form').show(); return false;", - :class => 'icon icon-edit' %> - <%= delete_link membership_path(member), - :remote => true, - :data => (!User.current.admin? && member.include?(User.current) ? {:confirm => l(:text_own_membership_delete_confirmation)} : {}) if member.deletable? %> - | - <% end %> - <% else %> -- <%= link_to_function l(:button_edit), - "$('#member-#{member.id}-roles').hide(); $('#member-#{member.id}-roles-form').show(); return false;", - :class => 'icon icon-edit' %> - <%= delete_link membership_path(member), - :remote => true, - :data => (!User.current.admin? && member.include?(User.current) ? {:confirm => l(:text_own_membership_delete_confirmation)} : {}) if member.deletable? %> - | - <% end %> - - <%= call_hook(:view_projects_settings_members_table_row, {:project => @project, :member => member}) %> -
<%= l(:label_no_data) %>
- <% end %> + +标 题: <%= f.text_field "name", :required => true, :size => 60, :style => "width:490px;" %> diff --git a/app/views/homework_attach/new.html.erb b/app/views/homework_attach/new.html.erb index 0ead4babd..07475f58d 100644 --- a/app/views/homework_attach/new.html.erb +++ b/app/views/homework_attach/new.html.erb @@ -36,8 +36,8 @@ <%= render :partial => "new_homework",:locals => {:f => f} %>