From f3d8aebfe4edc0344fe6a5e6d0204ed6347e7f4f Mon Sep 17 00:00:00 2001
From: gonglexin <18008490802@163.com>
Date: Thu, 30 Oct 2014 20:32:35 +0800
Subject: [PATCH 1/5] =?UTF-8?q?=E7=BB=99=E6=8E=92=E5=BA=8F=E8=AE=BE?=
=?UTF-8?q?=E7=BD=AE=E6=AD=A3=E7=A1=AE=E7=9A=84=E8=B7=AF=E5=BE=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/helpers/application_helper.rb | 13 ++++++++++++-
app/views/homework_attach/_homeworks_list.html.erb | 10 +++-------
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 799316c47..be197a7da 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1892,5 +1892,16 @@ module ApplicationHelper
content_tag(:ul, logos.join("").html_safe, :class => ul_class.to_s).html_safe
end
-
+ def sort_homework_path(bid, sort)
+ case self.action_name
+ when 'get_not_batch_homework', 'show_courseEx'
+ get_not_batch_homework_homework_attach_path(bid, sort: sort)
+ when 'get_batch_homeworks'
+ get_batch_homeworks_homework_attach_path(bid, sort: sort)
+ when 'get_homeworks'
+ get_homeworks_homework_attach_path(bid, sort: sort)
+ else
+ '#'
+ end
+ end
end
diff --git a/app/views/homework_attach/_homeworks_list.html.erb b/app/views/homework_attach/_homeworks_list.html.erb
index f28caa08b..28fa1b6aa 100644
--- a/app/views/homework_attach/_homeworks_list.html.erb
+++ b/app/views/homework_attach/_homeworks_list.html.erb
@@ -7,14 +7,10 @@
)
按
-
- <%= l(:label_work_rating)%>
-
+ <%= link_to l(:label_work_rating), sort_homework_path(@bid, 'socre'), {:remote => true}%>
/
-
- <%= l(:label_time) %>
-
- <%= l(:label_sort) %>
+ <%= link_to l(:label_time), sort_homework_path(@bid, 'time'), {:remote => true}%>
+ <%= l(:label_sort) %>
From b2f75d5826d16768c972c00bf6b3220799ee3696 Mon Sep 17 00:00:00 2001
From: gonglexin <18008490802@163.com>
Date: Thu, 30 Oct 2014 21:08:37 +0800
Subject: [PATCH 2/5] =?UTF-8?q?=E7=BB=99=E6=97=B6=E9=97=B4=E5=92=8C?=
=?UTF-8?q?=E5=88=86=E6=95=B0=E6=8E=92=E5=BA=8F=E5=A2=9E=E5=8A=A0=E9=A1=BA?=
=?UTF-8?q?=E5=BA=8F=E5=92=8C=E5=80=92=E5=BA=8F=E6=8E=92=E5=BA=8F=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/homework_attach_controller.rb | 6 ++++++
app/helpers/application_helper.rb | 8 ++++----
app/views/homework_attach/_homeworks_list.html.erb | 4 ++--
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb
index 138030a3c..aa7bc506f 100644
--- a/app/controllers/homework_attach_controller.rb
+++ b/app/controllers/homework_attach_controller.rb
@@ -11,6 +11,7 @@ class HomeworkAttachController < ApplicationController
#获取未批作业列表
def get_not_batch_homework
+ sort, direction = params[:sort], params[:direction]
teachers = find_course_teachers @course
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM (SELECT homework_attaches.*,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN #{teachers}) AS t_score,
@@ -19,6 +20,7 @@ class HomeworkAttachController < ApplicationController
WHERE table1.t_score IS NULL")
@homework_list = paginateHelper all_homework_list,10
+ @direction = direction == 'asc'? 'desc' : 'asc'
respond_to do |format|
format.js
end
@@ -26,6 +28,7 @@ class HomeworkAttachController < ApplicationController
#获取已评作业列表
def get_batch_homeworks
+ sort, direction = params[:sort], params[:direction]
teachers = find_course_teachers @course
teacher_proportion = get_teacher_proportion @bid
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM (SELECT homework_attaches.*,
@@ -35,6 +38,7 @@ class HomeworkAttachController < ApplicationController
ORDER BY (CASE WHEN t_score IS NULL THEN 0 ELSE t_score * #{teacher_proportion} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - teacher_proportion} END) DESC,created_at ASC) AS table1
WHERE table1.t_score IS NOT NULL")
@homework_list = paginateHelper all_homework_list,10
+ @direction = direction == 'asc'? 'desc' : 'asc'
respond_to do |format|
format.js
end
@@ -42,6 +46,7 @@ class HomeworkAttachController < ApplicationController
#获取所有作业列表
def get_homeworks
+ sort, direction = params[:sort], params[:direction]
teachers = find_course_teachers @course
teacher_proportion = get_teacher_proportion @bid
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT homework_attaches.*,
@@ -50,6 +55,7 @@ class HomeworkAttachController < ApplicationController
FROM homework_attaches WHERE bid_id = #{@bid.id}
ORDER BY (CASE WHEN t_score IS NULL THEN 0 ELSE t_score * #{teacher_proportion} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - teacher_proportion} END) DESC,created_at ASC")
@homework_list = paginateHelper all_homework_list,10
+ @direction = direction == 'asc'? 'desc' : 'asc'
respond_to do |format|
format.js
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index be197a7da..e2fdf4739 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1892,14 +1892,14 @@ module ApplicationHelper
content_tag(:ul, logos.join("").html_safe, :class => ul_class.to_s).html_safe
end
- def sort_homework_path(bid, sort)
+ def sort_homework_path(bid, sort, direction)
case self.action_name
when 'get_not_batch_homework', 'show_courseEx'
- get_not_batch_homework_homework_attach_path(bid, sort: sort)
+ get_not_batch_homework_homework_attach_path(bid, sort: sort, direction: direction)
when 'get_batch_homeworks'
- get_batch_homeworks_homework_attach_path(bid, sort: sort)
+ get_batch_homeworks_homework_attach_path(bid, sort: sort, direction: direction)
when 'get_homeworks'
- get_homeworks_homework_attach_path(bid, sort: sort)
+ get_homeworks_homework_attach_path(bid, sort: sort, direction: direction)
else
'#'
end
diff --git a/app/views/homework_attach/_homeworks_list.html.erb b/app/views/homework_attach/_homeworks_list.html.erb
index c3abba458..578c1f9e5 100644
--- a/app/views/homework_attach/_homeworks_list.html.erb
+++ b/app/views/homework_attach/_homeworks_list.html.erb
@@ -7,9 +7,9 @@
)
按
- <%= link_to l(:label_work_rating), sort_homework_path(@bid, 'socre'), {:remote => true}%>
+ <%= link_to l(:label_work_rating), sort_homework_path(@bid, 'socre', @direction), {:remote => true}%>
/
- <%= link_to l(:label_time), sort_homework_path(@bid, 'time'), {:remote => true}%>
+ <%= link_to l(:label_time), sort_homework_path(@bid, 'time', @direction), {:remote => true}%>
<%= l(:label_sort) %>
From 811b6383f748b2998b2671d0b1f182809990136d Mon Sep 17 00:00:00 2001
From: gonglexin <18008490802@163.com>
Date: Thu, 30 Oct 2014 21:11:36 +0800
Subject: [PATCH 3/5] =?UTF-8?q?=E5=88=9D=E6=AC=A1=E5=8A=A0=E8=BD=BD?=
=?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=97=B6=E7=BB=99=E5=AE=9A=E4=B8=80=E4=B8=AA?=
=?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=8E=92=E5=BA=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/helpers/application_helper.rb | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index e2fdf4739..ccc9a884c 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1894,7 +1894,9 @@ module ApplicationHelper
def sort_homework_path(bid, sort, direction)
case self.action_name
- when 'get_not_batch_homework', 'show_courseEx'
+ when 'show_courseEx'
+ get_not_batch_homework_homework_attach_path(bid, sort: sort, direction: 'asc')
+ when 'get_not_batch_homework'
get_not_batch_homework_homework_attach_path(bid, sort: sort, direction: direction)
when 'get_batch_homeworks'
get_batch_homeworks_homework_attach_path(bid, sort: sort, direction: direction)
From 6cb2a5562f447f23c49bb6f82ee93fcdb62703b3 Mon Sep 17 00:00:00 2001
From: gonglexin <18008490802@163.com>
Date: Thu, 30 Oct 2014 22:03:00 +0800
Subject: [PATCH 4/5] =?UTF-8?q?=E6=9C=AA=E6=89=B9=E4=BD=9C=E4=B8=9A?=
=?UTF-8?q?=E6=8E=92=E5=BA=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/homework_attach_controller.rb | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb
index aa7bc506f..904cbeeea 100644
--- a/app/controllers/homework_attach_controller.rb
+++ b/app/controllers/homework_attach_controller.rb
@@ -12,11 +12,13 @@ class HomeworkAttachController < ApplicationController
#获取未批作业列表
def get_not_batch_homework
sort, direction = params[:sort], params[:direction]
+ order_by = sort == 'score'? "s_score #{direction}" : "created_at #{direction}"
+
teachers = find_course_teachers @course
all_homework_list = HomeworkAttach.eager_load(:attachments,:user,:rate_averages).find_by_sql("SELECT * FROM (SELECT homework_attaches.*,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id IN #{teachers}) AS t_score,
(SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id NOT IN #{teachers}) AS s_score
- FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY s_score DESC,created_at ASC) AS table1
+ FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY #{order_by}) AS table1
WHERE table1.t_score IS NULL")
@homework_list = paginateHelper all_homework_list,10
@@ -40,7 +42,7 @@ class HomeworkAttachController < ApplicationController
@homework_list = paginateHelper all_homework_list,10
@direction = direction == 'asc'? 'desc' : 'asc'
respond_to do |format|
- format.js
+ format.js.
end
end
From 4d9fb3e3c4c9d5ac060b7b0e1172559343bf608c Mon Sep 17 00:00:00 2001
From: gonglexin <18008490802@163.com>
Date: Thu, 30 Oct 2014 22:04:14 +0800
Subject: [PATCH 5/5] =?UTF-8?q?=E5=8E=BB=E6=8E=89.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/homework_attach_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb
index 904cbeeea..ff26d45b0 100644
--- a/app/controllers/homework_attach_controller.rb
+++ b/app/controllers/homework_attach_controller.rb
@@ -42,7 +42,7 @@ class HomeworkAttachController < ApplicationController
@homework_list = paginateHelper all_homework_list,10
@direction = direction == 'asc'? 'desc' : 'asc'
respond_to do |format|
- format.js.
+ format.js
end
end