From aa2590d4519d3924dea381da112b266f166e7403 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Tue, 3 Feb 2015 10:16:46 +0800 Subject: [PATCH 1/4] Signed-off-by: alan <547533434@qq.com> --- app/models/forum.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/forum.rb b/app/models/forum.rb index e47d18b02..f5581b232 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -5,7 +5,7 @@ class Forum < ActiveRecord::Base has_many :memos, :dependent => :destroy, conditions: "parent_id IS NULL" belongs_to :creator, :class_name => "User", :foreign_key => 'creator_id' - after_create :expire_forum_cache + after_create :expire_forum_cache, :send_email after_update :expire_forum_cache before_destroy :expire_forum_cache safe_attributes 'name', @@ -23,7 +23,7 @@ class Forum < ActiveRecord::Base acts_as_taggable scope :by_join_date, order("created_at DESC") - after_create :send_email + #after_create :send_email def reset_counters! self.class.reset_counters!(id) end From 1166a1463bd10802a6af7b9c65027d3241e0b557 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Sat, 7 Feb 2015 09:33:54 +0800 Subject: [PATCH 2/4] Signed-off-by: alan <547533434@qq.com> --- app/models/forum.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/forum.rb b/app/models/forum.rb index f5581b232..baa8e6260 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -5,7 +5,7 @@ class Forum < ActiveRecord::Base has_many :memos, :dependent => :destroy, conditions: "parent_id IS NULL" belongs_to :creator, :class_name => "User", :foreign_key => 'creator_id' - after_create :expire_forum_cache, :send_email + after_create :expire_forum_cache after_update :expire_forum_cache before_destroy :expire_forum_cache safe_attributes 'name', From 0ba6c6d3bab62069b56882d288214a045282e577 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Tue, 3 Mar 2015 16:03:59 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=BF=98=E5=8E=9Fmemcached=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E7=9A=84=E6=96=87=E4=BB=B6[memcache=E5=AE=9E=E9=AA=8C?= =?UTF-8?q?=E8=BF=98=E6=B2=A1=E5=BC=84=E5=A5=BD]=20Signed-off-by:=20alan?= =?UTF-8?q?=20<547533434@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/environments/development.rb | 6 ++---- config/environments/production.rb | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/config/environments/development.rb b/config/environments/development.rb index 80d1c9db8..3b894d207 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -8,12 +8,10 @@ RedmineApp::Application.configure do # Log error messages when you accidentally call methods on nil. config.whiny_nils = true config.logger = Logger.new('log/development.log', 'daily') # daily, weekly or monthly - - # Show full error reports and disable caching config.consider_all_requests_local = true - config.action_controller.perform_caching = true - config.cache_store = :dalli_store + config.action_controller.perform_caching = false + config.cache_store = :file_store, "#{Rails.root }/public/tmp/" # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = true diff --git a/config/environments/production.rb b/config/environments/production.rb index 0b61ed132..48b2514cf 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -3,7 +3,7 @@ RedmineApp::Application.configure do # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true - config.cache_store = :dalli_store + ##### # Customize the default logger (http://ruby-doc.org/core/classes/Logger.html) # From 451a022d5fe2855a5aa6f974128e9ab379e5f8b4 Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 3 Mar 2015 17:36:05 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E3=80=81=E4=BD=9C=E4=B8=9A=E5=88=97=E8=A1=A8=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/course.rb | 2 +- app/api/mobile/entities/homework.rb | 12 +++++++++++- app/services/courses_service.rb | 5 +++-- app/services/homework_service.rb | 26 +++++++++++++++++++++----- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/app/api/mobile/entities/course.rb b/app/api/mobile/entities/course.rb index 512aab69a..4c91738c1 100644 --- a/app/api/mobile/entities/course.rb +++ b/app/api/mobile/entities/course.rb @@ -53,7 +53,7 @@ module Mobile c[:course].teacher end end - expose :my_homework,using: Mobile::Entities::HomeworkAttach do |f, opt| + expose :my_homework,using: Mobile::Entities::Homework do |f, opt| f[:my_homework] if f.is_a?(Hash) && f.key?(:my_homework) end course_expose :current_user_is_member diff --git a/app/api/mobile/entities/homework.rb b/app/api/mobile/entities/homework.rb index 5b996c1af..55883e14e 100644 --- a/app/api/mobile/entities/homework.rb +++ b/app/api/mobile/entities/homework.rb @@ -1,10 +1,15 @@ module Mobile module Entities class Homework < Grape::Entity + include Redmine::I18n def self.homework_expose(field) expose field do |f,opt| if f.is_a?(Hash) && f.key?(field) - f[field] + if field == :created_on + format_time(f[field]) + else + f[field] + end elsif f.is_a?(::Bid) if f.respond_to?(field) f.send(field) @@ -18,6 +23,8 @@ module Mobile homework_expose :id #课程名称 homework_expose :course_name + + homework_expose :course_id #作业发布者 expose :author,using: Mobile::Entities::User do |f, opt| f[:author] @@ -42,6 +49,9 @@ module Mobile #只有作业启用了匿评功能且当前用户是课程老师且已提交的作品数量大于或等于2才能开启匿评 homework_expose :homework_state + homework_expose :created_on + homework_expose :deadline + expose :homework_for_anonymous_comments,using: Mobile::Entities::HomeworkAttach do |f, opt| f[:homework_for_anonymous_comments] if f.is_a?(Hash) && f.key?(:homework_for_anonymous_comments) end diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 7e80f415c..22b7f8cd3 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -383,8 +383,9 @@ class CoursesService end #end open_anonymous_evaluation = bid.open_anonymous_evaluation - {:course_name => course.name,:id => bid.id, :author => bid.author,:author_real_name => author_real_name, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => student_questions_count, - :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation,:homework_for_anonymous_comments => homework_for_anonymous_comments} + {:course_name => course.name,:course_id => course.id,:id => bid.id, :author => bid.author,:author_real_name => author_real_name, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => student_questions_count, + :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation,:homework_for_anonymous_comments => homework_for_anonymous_comments,:created_on => bid.created_on,:deadline => bid.deadline} + end #显示作业列表的同时显示分配给当前学生匿评的作业 diff --git a/app/services/homework_service.rb b/app/services/homework_service.rb index c5a333125..6287eeef5 100644 --- a/app/services/homework_service.rb +++ b/app/services/homework_service.rb @@ -26,8 +26,8 @@ class HomeworkService state = @bid.comment_status #end open_anonymous_evaluation = @bid.open_anonymous_evaluation - {:course_name => course.name,:id => @bid.id, :author => @bid.author,:author_real_name =>author, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => student_questions_count, - :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation} + {:course_name => course.name,:course_id => course.id,:id => @bid.id, :author => @bid.author,:author_real_name =>author, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => student_questions_count, + :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation,:created_on => @bid.created_on,:deadline => @bid.deadline} end # 启动作业匿评前提示信息 @@ -274,10 +274,26 @@ class HomeworkService membership.each do |mp| my_homeworks = [] mp.course.homeworks.each do |bid| - hw = bid.homeworks.where("user_id = #{current_user.id}") - my_homeworks << hw[0] unless (hw.nil? || hw[0].nil?) + #hw = bid.homeworks.where("user_id = #{current_user.id}") + @bid = bid + course = @bid.courses.first + author = @bid.author.lastname + @bid.author.firstname + many_times = course.homeworks.index(@bid) + 1 + name = @bid.name + homework_count = @bid.homeworks.count #已提交的作业数量 + student_questions_count = @bid.commit.nil? ? 0 : @bid.commit + description = @bid.description + #if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2 + state = @bid.comment_status + #end + open_anonymous_evaluation = @bid.open_anonymous_evaluation + + my_homeworks << {:course_name => course.name,:id => @bid.id, :author => @bid.author,:author_real_name =>author, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => student_questions_count, + :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation} + end + if mp.course.homeworks.count != 0 + course_list << {:course => mp.course,:img_url => url_to_avatar(mp.course),:my_homework => my_homeworks,:current_user_is_member => current_user.member_of_course?(mp.course),:current_user_is_teacher => is_course_teacher(current_user,mp.course)} end - course_list << {:course => mp.course,:img_url => url_to_avatar(mp.course),:my_homework => my_homeworks,:current_user_is_member => current_user.member_of_course?(mp.course),:current_user_is_teacher => is_course_teacher(current_user,mp.course)} end course_list end