From 1965b75d920df0a9b69818719ba2538843fc73dd Mon Sep 17 00:00:00 2001
From: alan <547533434@qq.com>
Date: Thu, 18 Dec 2014 18:24:37 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E3=80=8A=E5=AD=A6=E7=94=9F?=
=?UTF-8?q?=E5=88=97=E8=A1=A8=E6=8C=89=E4=BD=9C=E4=B8=9A=E8=AF=84=E5=88=86?=
=?UTF-8?q?=E6=8E=92=E5=BA=8F=E3=80=8B=E5=8A=9F=E8=83=BD=20Signed-off-by:?=
=?UTF-8?q?=20alan=20<547533434@qq.com>?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/courses_controller.rb | 24 ++++-
app/helpers/courses_helper.rb | 28 +++---
app/views/courses/_member_list.html.erb | 99 +++++++++++--------
.../courses/_member_list_detail.html.erb | 48 +++++++++
app/views/courses/member_score_sort.js.erb | 4 +
config/routes.rb | 1 +
6 files changed, 147 insertions(+), 57 deletions(-)
create mode 100644 app/views/courses/_member_list_detail.html.erb
create mode 100644 app/views/courses/member_score_sort.js.erb
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 63b8294e7..12852c63d 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -23,7 +23,7 @@ class CoursesController < ApplicationController
before_filter :require_login, :only => [:join, :unjoin]
#before_filter :allow_join, :only => [:join]
-
+ @@result = nil
def join
if User.current.logged?
course = Course.find_by_id params[:object_id]
@@ -296,6 +296,7 @@ class CoursesController < ApplicationController
else
@results = searchStudent(@course)
end
+ @@result = @results
@members = searchStudent(@course)
@membercount = @members.count
@results = paginateHelper @results
@@ -308,6 +309,7 @@ class CoursesController < ApplicationController
@members = searchStudent(@course)
@membercount = @members.count
@results = searchStudent_by_group(group, @course)
+ @@result = @results
@results = paginateHelper @results
end
def member
@@ -326,13 +328,14 @@ class CoursesController < ApplicationController
when '2'
@subPage_title = l :label_student_list
- @members = searchStudent(@course)
- @membercount = @members.count
+ @members = searchStudent_sort(@course, 'desc')
+ @membercount = @members.count
else
@subPage_title = ''
@members = @course.member_principals.includes(:roles, :principal).all.sort
end
+ @@result = @members
@members = paginateHelper @members
render :layout => 'base_courses'
else
@@ -340,6 +343,21 @@ class CoursesController < ApplicationController
end
end
+
+ def member_score_sort
+ @teachers= searchTeacherAndAssistant(@course)
+ @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
+ @role = params[:role]
+ @course_groups = @course.course_groups if @course.course_groups
+ @show_serch = params[:role] == '2'
+ @subPage_title = l :label_student_list
+ @render_file = 'member_list'
+ unless @@result.nil?
+ @results = @@result.reverse
+ @@result = @results
+ end
+ @results = paginateHelper @results
+ end
# 显示每个学生的作业评分详情
def show_member_score
@member_score = Member.find(params[:member_id]) if params[:member_id]
diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb
index 6f0265132..ec3b9aad6 100644
--- a/app/helpers/courses_helper.rb
+++ b/app/helpers/courses_helper.rb
@@ -164,6 +164,18 @@ module CoursesHelper
members
end
def searchStudent project
+ #searchPeopleByRoles(project, StudentRoles)
+ members = []
+
+ project.members.each do |m|
+ if m && m.user && m.user.allowed_to?(:as_student,project)
+ members << m
+
+ end
+ end
+ members
+ end
+ def searchStudent_sort project, sort_by
#searchPeopleByRoles(project, StudentRoles)
members = []
@@ -173,20 +185,14 @@ module CoursesHelper
end
end
- members
- end
- def search_student_and_score project
- #searchPeopleByRoles(project, StudentRoles)
- members = []
- scores = []
- project.members.each do |m|
- if m && m.user && m.user.allowed_to?(:as_student,project)
- members << m
-
- end
+ members.sort!{ |mem1, mem2| mem1.student_homework_score[1].to_f <=> mem2.student_homework_score[1].to_f}
+ if sort_by == "desc"
+ members.reverse!
end
members
end
+
+
def searchStudent_by_name project, name
#searchPeopleByRoles(project, StudentRoles)
members = []
diff --git a/app/views/courses/_member_list.html.erb b/app/views/courses/_member_list.html.erb
index 2800c78ea..2ee9e3aad 100644
--- a/app/views/courses/_member_list.html.erb
+++ b/app/views/courses/_member_list.html.erb
@@ -1,3 +1,13 @@
+
<% if User.current.logged? && User.current.member_of_course?(@course) && @group %>
<% if !@canShowCode %>
@@ -30,61 +40,64 @@
<% if @subPage_title == l(:label_student_list) %>
- - 作业积分
+ - <%= link_to '作业积分', member_score_sort_course_path ,method: 'get', remote: true, :onclick => "change_pic('pic')"%>
+
- 加入时间
<% else %>
- - 加入时间
+ - 加入时间
<% end %>
- <% members.each do |member| %>
+
+ <% members.each do |member| %>
-
-
- <% next if member.new_record? %>
+
+
+ <% next if member.new_record? %>
-
<%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :width => 40, :height => 40)) %>
-
- <% if @canShowCode %>
- -
- <%= l(:label_bidding_user_studentname) %> :
- <%= link_to member.user.show_name, user_path(member.user) %>
+ <%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :width => 40, :height => 40)) %>
+
+ <% if @canShowCode %>
+ -
+ <%= l(:label_bidding_user_studentname) %> :
+ <%= link_to member.user.show_name, user_path(member.user) %>
-
- <%#= content_tag "li", "#{l(:label_bidding_user_studentname)}#{' : '}"link_to(member.user.show_name, user_path(member.user)) %>
- <% else %>
- <%= content_tag "li", link_to(member.user.name, user_path(member.user)) %>
- <% end %>
-
+
+ <%#= content_tag "li", "#{l(:label_bidding_user_studentname)}#{' : '}"link_to(member.user.show_name, user_path(member.user)) %>
+ <% else %>
+ <%= content_tag "li", link_to(member.user.name, user_path(member.user)) %>
+ <% end %>
+
- <% if @canShowCode %>
- -
- <%= l(:label_bidding_user_studentcode) %> :
- <%= link_to member.user.user_extensions.student_id, user_path(member.user) %>
-
- <%#= content_tag "li", "#{l(:label_bidding_user_studentcode)}#{' : '}#{member.user.user_extensions.student_id}", :style=> "color:#1c9ec7;" %>
- <% end %>
-
- <% if @subPage_title == l(:label_student_list) %>
- <%= link_to member.student_homework_score[1].to_s, {
- :action => 'show_member_score',
- :member_id => member.id,
- :remote => true},
- :class => 'ml258 c_red', :style => "color:red;" %>
+ <% if @canShowCode %>
+
+ <%= l(:label_bidding_user_studentcode) %> :
+ <%= link_to member.user.user_extensions.student_id, user_path(member.user) %>
+
+ <%#= content_tag "li", "#{l(:label_bidding_user_studentcode)}#{' : '}#{member.user.user_extensions.student_id}", :style=> "color:#1c9ec7;" %>
+ <% end %>
+
+ <% if @subPage_title == l(:label_student_list) %>
+ <%= link_to member.student_homework_score[1].to_s, {
+ :action => 'show_member_score',
+ :member_id => member.id,
+ :remote => true},
+ :class => 'ml258 c_red', :style => "color:red;" %>
- <% unless member.created_on.nil? %>
- <%= content_tag "span", "#{format_date(member.created_on)}#{l(:label_member_since)}", :class => "ml65 c_grey" %>
- <% end %>
- <% else %>
- <% unless member.created_on.nil? %>
- <%= content_tag "span", "#{format_date(member.created_on)}#{l(:label_member_since)}", :class => "ml65 c_grey", :style=>"margin-left:195px" %>
+ <% unless member.created_on.nil? %>
+ <%= content_tag "span", "#{format_date(member.created_on)}#{l(:label_member_since)}", :class => "ml65 c_grey" %>
+ <% end %>
+ <% else %>
+ <% unless member.created_on.nil? %>
+ <%= content_tag "span", "#{format_date(member.created_on)}#{l(:label_member_since)}", :class => "ml65 c_grey", :style=>"margin-left:195px" %>
+ <% end %>
<% end %>
- <% end %>
-
- <%= call_hook(:view_projects_settings_members_table_row, { :course => @course, :member => member}) %>
-
- <% end; reset_cycle %>
+
+ <%= call_hook(:view_projects_settings_members_table_row, { :course => @course, :member => member}) %>
+
+ <% end; reset_cycle %>
+
<% else %>
diff --git a/app/views/courses/_member_list_detail.html.erb b/app/views/courses/_member_list_detail.html.erb
new file mode 100644
index 000000000..47407c01b
--- /dev/null
+++ b/app/views/courses/_member_list_detail.html.erb
@@ -0,0 +1,48 @@
+<% members.each do |member| %>
+
+
+
+ <% next if member.new_record? %>
+
+
<%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :width => 40, :height => 40)) %>
+
+ <% if @canShowCode %>
+ -
+ <%= l(:label_bidding_user_studentname) %> :
+ <%= link_to member.user.show_name, user_path(member.user) %>
+
+
+ <%#= content_tag "li", "#{l(:label_bidding_user_studentname)}#{' : '}"link_to(member.user.show_name, user_path(member.user)) %>
+ <% else %>
+ <%= content_tag "li", link_to(member.user.name, user_path(member.user)) %>
+ <% end %>
+
+
+ <% if @canShowCode %>
+ -
+ <%= l(:label_bidding_user_studentcode) %> :
+ <%= link_to member.user.user_extensions.student_id, user_path(member.user) %>
+
+ <%#= content_tag "li", "#{l(:label_bidding_user_studentcode)}#{' : '}#{member.user.user_extensions.student_id}", :style=> "color:#1c9ec7;" %>
+ <% end %>
+
+ <% if @subPage_title == l(:label_student_list) %>
+ <%= link_to member.student_homework_score[1].to_s, {
+ :action => 'show_member_score',
+ :member_id => member.id,
+ :remote => true},
+ :class => 'ml258 c_red', :style => "color:red;" %>
+
+ <% unless member.created_on.nil? %>
+ <%= content_tag "span", "#{format_date(member.created_on)}#{l(:label_member_since)}", :class => "ml65 c_grey" %>
+ <% end %>
+ <% else %>
+ <% unless member.created_on.nil? %>
+ <%= content_tag "span", "#{format_date(member.created_on)}#{l(:label_member_since)}", :class => "ml65 c_grey", :style=>"margin-left:195px" %>
+ <% end %>
+ <% end %>
+
+
+ <%= call_hook(:view_projects_settings_members_table_row, { :course => @course, :member => member}) %>
+
+<% end; reset_cycle %>
\ No newline at end of file
diff --git a/app/views/courses/member_score_sort.js.erb b/app/views/courses/member_score_sort.js.erb
new file mode 100644
index 000000000..30965f835
--- /dev/null
+++ b/app/views/courses/member_score_sort.js.erb
@@ -0,0 +1,4 @@
+/**
+ * Created by Administrator on 2014/12/3.
+ */
+$("#list_detail").html("<%= escape_javascript( render :partial => 'member_list_detail', :locals => {:members => @results})%>");
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index f4fff69d4..226f2259e 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -646,6 +646,7 @@ RedmineApp::Application.routes.draw do
post 'restartcourse'
match "searchmembers", :controller => 'courses', :action => 'searchmembers', :via => [:post,:get]
match "searchgroupmembers", :via => [:post, :get]
+ match 'member_score_sort', :via => [:get]
match "updategroupname", :via => [:post, :get]
match "addgroups", :via => [:post, :get]
match 'deletegroup', :via => [:delete]