From 1fdd3b0b92584f27c81874cca38bc3725ea9af7c Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 28 May 2015 09:19:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E5=93=81=E5=88=97=E8=A1=A8=E7=9A=84?= =?UTF-8?q?=E5=90=84=E7=A7=8D=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 4 ++- app/views/student_work/index.html.erb | 29 ++++++++++++++-------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index b69aec2e1..3bbadea64 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -7,8 +7,10 @@ class StudentWorkController < ApplicationController before_filter :author_of_work, :only => [:edit, :update, :destroy] def index - @stundet_works = @homework.student_works.order("final_score desc") + @order,sort = params[:order] || "final_score",params[:sort] || "desc" + @stundet_works = @homework.student_works.order("#{@order} #{sort}") @homework_commons = @course.homework_commons.order("created_at desc") + @score = sort == "desc" ? "asc" : "desc" respond_to do |format| format.html end diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb index be2cbbcb1..ff5da8889 100644 --- a/app/views/student_work/index.html.erb +++ b/app/views/student_work/index.html.erb @@ -46,8 +46,7 @@