diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 00b11323b..ba6c136bb 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -17,9 +17,9 @@ 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("created_at desc").limit(10).offset(@page * 10) + @homeworks = @course.homework_commons.order("updated_at desc").limit(10).offset(@page * 10) else - @homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at desc").limit(10).offset(@page * 10) + @homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("updated_at desc").limit(10).offset(@page * 10) end @is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher)) @is_new = params[:is_new] diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index a38d83851..0c8bb6c01 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -303,6 +303,7 @@ class StudentWorkController < ApplicationController stu_project.save end end + @homework.update_attributes(:updated_at => Time.now) update_course_activity(@homework.class,@homework.id) update_user_activity(@homework.class,@homework.id) update_org_activity(@homework.class,@homework.id) @@ -500,6 +501,10 @@ class StudentWorkController < ApplicationController when 3 #学生评分 学生评分显示平均分 @work.student_score = @work.student_works_scores.where(:reviewer_role => 3).average(:score).try(:round, 2).to_f end + @homework.update_attributes(:updated_at => Time.now) + update_course_activity(@homework.class,@homework.id) + update_user_activity(@homework.class,@homework.id) + update_org_activity(@homework.class,@homework.id) if @work.save respond_to do |format| format.js diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 921262106..ea984aa80 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -58,6 +58,7 @@ class UsersController < ApplicationController helper :sort helper :attachments include SortHelper + include ApplicationHelper helper :custom_fields include CustomFieldsHelper include AvatarHelper @@ -690,6 +691,11 @@ class UsersController < ApplicationController end student_work.save + homework.update_attributes(:updated_at => Time.now) + update_course_activity(homework.class,homework.id) + update_user_activity(homework.class,homework.id) + update_org_activity(homework.class,homework.id) + flash[:notice] = l(:notice_successful_create) redirect_to student_work_index_url(:homework => params[:homework]) else diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index d1aa67483..e6d1d9117 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -276,7 +276,7 @@ class WordsController < ApplicationController ids = params[:asset_id].split(',') update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE end - + @homework_common.update_attributes(:updated_at => Time.now) update_course_activity(@homework_common.class,@homework_common.id) update_user_activity(@homework_common.class,@homework_common.id) update_org_activity(@homework_common.class,@homework_common.id) diff --git a/db/migrate/20160309024051_update_homework_common_updated_at.rb b/db/migrate/20160309024051_update_homework_common_updated_at.rb new file mode 100644 index 000000000..89a0e992d --- /dev/null +++ b/db/migrate/20160309024051_update_homework_common_updated_at.rb @@ -0,0 +1,18 @@ +class UpdateHomeworkCommonUpdatedAt < ActiveRecord::Migration + def up + count = HomeworkCommon.all.count / 30 + 2 + transaction do + for i in 1 ... count do i + HomeworkCommon.page(i).per(30).each do |hw| + ca = CourseActivity.where("course_act_type = 'HomeworkCommon' and course_act_id = #{hw.id}").first + unless ca.nil? + hw.update_attributes(:updated_at => ca.updated_at) + end + end + end + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index a7ffc23b1..5bc8b1ea0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160304234903) do +ActiveRecord::Schema.define(:version => 20160309024051) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1387,6 +1387,7 @@ ActiveRecord::Schema.define(:version => 20160304234903) do t.integer "changeset_num", :default => 0 t.integer "board_message_num", :default => 0 t.integer "board_num", :default => 0 + t.integer "act_num", :default => 0 t.integer "attach_num", :default => 0 t.datetime "commit_time" end