From 0f2f4717b6f6aa40792ab5e1bce3fdbadfa76e75 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 19 May 2016 13:50:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=88=97=E8=A1=A8=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=BA=8F=E5=8F=B7=E5=92=8C=E7=BF=BB=E9=A1=B5=E3=80=81?= =?UTF-8?q?=E6=8C=89=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4=E5=80=92=E6=8E=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 5 +++-- app/helpers/application_helper.rb | 11 +++++++++++ app/views/homework_common/index.html.erb | 6 ++++++ app/views/users/_user_homework_detail.html.erb | 7 ++++++- app/views/users/_user_homework_list.html.erb | 2 +- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 0566d3d98..9da4b90b9 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -20,15 +20,16 @@ class HomeworkCommonController < ApplicationController @page = params[:page] ? params[:page].to_i + 1 : 0 @is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) if @is_teacher - @homeworks = @course.homework_commons.order("updated_at desc").limit(10).offset(@page * 10) + #@homeworks = @course.homework_commons.order("created_at desc").limit(10).offset(@page * 10) @homework_commons = @course.homework_commons.order("created_at desc") else - @homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("updated_at desc").limit(10).offset(@page * 10) + #@homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at desc").limit(10).offset(@page * 10) @homework_commons = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at desc") end @is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher)) @is_new = params[:is_new] + @homeworks = paginateHelper @homework_commons,10 #设置at已读 @homeworks.each do |homework| homework.journals_for_messages.each do |j| diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 229aceb1c..7d970c762 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3248,3 +3248,14 @@ def strip_html(text,len=0,endss="...") end return ss end + +def get_hw_index(hw,is_teacher) + if is_teacher + homeworks = hw.course.homework_commons.order("created_at asc") + else + homeworks = hw.course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at asc") + end + hw_ids = homeworks.map{|hw| hw.id} if !homeworks.empty? + index = hw_ids.index(hw.id) + return index +end diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb index e34cf0736..29cff8933 100644 --- a/app/views/homework_common/index.html.erb +++ b/app/views/homework_common/index.html.erb @@ -73,6 +73,12 @@ <% end%> <%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => @homeworks,:page => 0,:is_in_course => 1,:course_id => @course.id} %> +
+ +
+
diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index decaba88c..c0578c042 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -11,7 +11,12 @@ <%= link_to homework_common.course.name, course_path(homework_common.course_id), :class => "newsBlue ml15"%> <% if homework_common.homework_detail_manual%> diff --git a/app/views/users/_user_homework_list.html.erb b/app/views/users/_user_homework_list.html.erb index e42c5d8b2..f7669047c 100644 --- a/app/views/users/_user_homework_list.html.erb +++ b/app/views/users/_user_homework_list.html.erb @@ -31,7 +31,7 @@ <% if homework_commons.count == 10%> <% if is_in_course == 1%> - <%= link_to "点击展开更多",homework_common_index_path(:course => course_id,:page => page,:is_in_course => is_in_course),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%> + <%#= link_to "点击展开更多",homework_common_index_path(:course => course_id,:page => page,:is_in_course => is_in_course),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%> <% else%> <%= link_to "点击展开更多",student_homeworks_user_path(User.current.id,:page => page,:is_in_course => is_in_course),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%>