From e39e801c617f58db31fea59379d8b361cc20e5d1 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Mon, 29 Dec 2014 20:46:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=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=E5=8A=9F=E8=83=BD=E3=80=8B=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 | 44 ++++++++++++++-------- app/views/courses/_member_list.html.erb | 10 +++-- app/views/courses/member_score_sort.js.erb | 2 +- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 21199f6f9..49cc40f10 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -210,14 +210,15 @@ class CoursesController < ApplicationController @render_file = 'member_list' @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' @is_remote = true + @score_sort_by = "desc" q = "#{params[:name].strip}" #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? if params[:incourse] - @results = searchmember_by_name(student_homework_score(0,0,0), q) + @results = searchmember_by_name(student_homework_score(0,0,0,"desc"), q) elsif params[:ingroup] @group = CourseGroup.find(params[:search_group_id]) - @results = searchmember_by_name(student_homework_score(@group.id,0,0), q) + @results = searchmember_by_name(student_homework_score(@group.id,0,0,"desc"), q) end @is_remote = true @result_count = @results.count @@ -307,16 +308,17 @@ class CoursesController < ApplicationController @render_file = 'member_list' @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' @is_remote = true + @score_sort_by = "desc" if params[:group_id] && params[:group_id] != "0" @group = CourseGroup.find(params[:group_id]) - @results = student_homework_score(@group.id,0, 0) + @results = student_homework_score(@group.id,0, 0,"desc") @results = paginateHelper @results, 10 else page_from = params[:page].nil? ? 0 : (params[:page].to_i - 1) - @results = student_homework_score(0,page_from, 10) + @results = student_homework_score(0,page_from, 10,"") @results = paginateHelper_for_members @results, 10 end @@ -329,7 +331,7 @@ class CoursesController < ApplicationController ## 有角色参数的才是课程,没有的就是项目 if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course))) @render_file = 'member_list' - + @score_sort_by = "desc" @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' @role = params[:role].nil? ? '2':params[:role] @is_remote = true @@ -343,7 +345,7 @@ class CoursesController < ApplicationController when '2' @subPage_title = l :label_student_list page = params[:page].nil? ? 0 : (params['page'].to_i - 1) - @members = student_homework_score(0,page, 10) + @members = student_homework_score(0,page, 10,"desc") @members = paginateHelper_for_members @members, 10 @@ -367,18 +369,31 @@ class CoursesController < ApplicationController def member_score_sort # @teachers= searchTeacherAndAssistant(@course) - # @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' + @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' + @subPage_title = l :label_student_list + @render_file = 'member_list' # @results = params[:result] if params[:result] # unless @result.nil? # @results = @result.reverse # # end - # @results = paginateHelper @results + # @results = paginateHelper @results@score_sort_by = "desc" + @is_remote = true + @score_sort_by = params[:sort_by] if params[:sort_by] + group_id = params[:group_id] + if group_id == '0' + page = params[:page].nil? ? 0 : (params['page'].to_i - 1) + @results = student_homework_score(0,page, 10,@score_sort_by) + + @results = paginateHelper_for_members @results, 10 + else + @group = Group.find(group_id) + @results = student_homework_score(group_id, 0, 0,@score_sort_by) + @results = paginateHelper @results, 10 + end end # 显示每个学生的作业评分详情 def show_member_score @@ -882,12 +897,12 @@ class CoursesController < ApplicationController end end - def student_homework_score(groupid,start_from, nums) + def student_homework_score(groupid,start_from, nums, score_sort_by) #teachers = find_course_teachers(@course) start_from = start_from * nums sql = ActiveRecord::Base.connection() - homework_scores = Member.find_by_sql("call member_score(#{@course.id},#{groupid},#{start_from},#{nums})") + homework_scores = Member.find_by_sql("call member_score(#{@course.id},#{groupid},#{start_from},#{nums}, '#{score_sort_by}')") sql.close() homework_scores @@ -903,10 +918,9 @@ class CoursesController < ApplicationController @render_file = 'member_list' @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' @is_remote = true - - + @score_sort_by = "desc" page_from = params[:page].nil? ? 0 : (params[:page].to_i - 1) - @results = student_homework_score(group.id,0,0) + @results = student_homework_score(group.id,0,0, "desc") @results = paginateHelper @results, 10 end diff --git a/app/views/courses/_member_list.html.erb b/app/views/courses/_member_list.html.erb index 7e6407aa5..295db933a 100644 --- a/app/views/courses/_member_list.html.erb +++ b/app/views/courses/_member_list.html.erb @@ -1,13 +1,15 @@ +