diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 83862d22e..e898b855d 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -506,6 +506,7 @@ class BidsController < ApplicationController (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 WHERE table1.t_score IS NULL") + @cur_type = 1 else 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, @@ -516,8 +517,10 @@ class BidsController < ApplicationController WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id}) AS table1 WHERE table1.m_score IS NULL") @is_student_batch_homework = true + @cur_type = 4 end + @cur_page = params[:page] || 1 @homework_list = paginateHelper all_homework_list,10 @jours_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count if params[:student_id].present? diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index a143fe4aa..e54df3d22 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -12,6 +12,13 @@ class HomeworkAttachController < ApplicationController #判断当前角色是否有操作权限 #勿删 before_filter :authorize, :only => [:new,:edit,:update,:destroy] + #@cur_type: + #1.未批作业列表 + #2.已批作业列表 + #3.全部作业列表 + #4.匿评作业列表 + #根据此字段判断关闭homework_attach的show界面后是否要调用js刷新页面 + #获取未批作业列表 def get_not_batch_homework sort, direction = params[:sort], params[:direction] @@ -23,7 +30,8 @@ class HomeworkAttachController < ApplicationController FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY #{order_by}) AS table1 WHERE table1.t_score IS NULL") - + @cur_page = params[:page] || 1 + @cur_type = 1 @homework_list = paginateHelper all_homework_list,10 @direction = direction == 'asc'? 'desc' : 'asc' respond_to do |format| @@ -43,6 +51,8 @@ class HomeworkAttachController < ApplicationController FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY #{order_by}) AS table1 WHERE table1.t_score IS NOT NULL") + @cur_page = params[:page] || 1 + @cur_type = 2 @homework_list = paginateHelper all_homework_list,10 @direction = direction == 'asc'? 'desc' : 'asc' respond_to do |format| @@ -61,6 +71,8 @@ class HomeworkAttachController < ApplicationController (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 #{order_by}") + @cur_page = params[:page] || 1 + @cur_type = 3 @homework_list = paginateHelper all_homework_list,10 @direction = direction == 'asc'? 'desc' : 'asc' respond_to do |format| @@ -80,6 +92,8 @@ class HomeworkAttachController < ApplicationController INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id}) AS table1 WHERE table1.m_score IS NULL") + @cur_page = params[:page] || 1 + @cur_type = 4 @homework_list = paginateHelper all_homework_list,10 respond_to do |format| format.js @@ -104,6 +118,7 @@ class HomeworkAttachController < ApplicationController INNER JOIN homework_users ON homework_users.homework_attach_id = homework_attaches.id WHERE homework_attaches.bid_id = #{@bid.id} AND homework_users.user_id = #{User.current.id}") end + @cur_page = params[:page] || 1 @homework_list = paginateHelper all_homework_list,10 respond_to do |format| format.js @@ -368,6 +383,8 @@ class HomeworkAttachController < ApplicationController #@limit = 10 #@jours留言 is null条件用以兼容历史数据 @jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC") + @cur_page = params[:cur_page] || 1 + @cur_type = params[:cur_type] || 5 @jour = paginateHelper @jours,5 #@feedback_count = @jours.count #@feedback_pages = Paginator.new @feedback_count, @limit, params['page'] diff --git a/app/views/bids/_homework.html.erb b/app/views/bids/_homework.html.erb index d3aad1589..458ed68cc 100644 --- a/app/views/bids/_homework.html.erb +++ b/app/views/bids/_homework.html.erb @@ -42,13 +42,56 @@ function hiddent_alert_model(){hideModal($('#popbox02'));} - function hidden_homework_atert_form() + function hidden_homework_atert_form(cur_page,cur_type) { hideModal($("#popbox")); // 评了分的则刷新列表 - if($("#star_score > .rateable").attr('class').contains('jDisabled')) + switch (cur_type) { - $("#not_batch_homework").click(); + case 1: + $.ajax({ + type: "GET", + url: "<%= get_not_batch_homework_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, + data: 'text', + success: function (data) { + + } + }); + break; + case 2: + $.ajax({ + type: "GET", + url: "<%= get_batch_homeworks_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, + data: 'text', + success: function (data) { + + } + }); + break; + case 3: + $.ajax({ + type: "GET", + url: "<%= get_homeworks_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, + data: 'text', + success: function (data) { + + } + }); + break; + case 4: + $.ajax({ + type: "GET", + url: "<%= get_student_batch_homework_homework_attach_index_path(:bid_id => @bid.id)%>&page=" + cur_page, + data: 'text', + success: function (data) { + + } + }); + break; + case 5: + break; + default : + break; } } diff --git a/app/views/homework_attach/_homework.html.erb b/app/views/homework_attach/_homework.html.erb index c6b7895cc..63e398877 100644 --- a/app/views/homework_attach/_homework.html.erb +++ b/app/views/homework_attach/_homework.html.erb @@ -18,7 +18,7 @@ <% else %> <% homework_filename = homework.name %> <% end %> - <%= link_to homework_filename , homework_attach_path(homework), :title => homework_filename, :remote => true%> + <%= link_to homework_filename , homework_attach_path(homework,:cur_page => @cur_page,:cur_type => @cur_type), :title => homework_filename, :remote => true%>