From 0e2db5fc73bf4e20d10d2d6e97c83a061d081f9d Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 8 Jun 2015 09:07:32 +0800 Subject: [PATCH 1/3] schema --- db/schema.rb | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index f8d638a5f..b3f5eab2f 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 => 20150514133640) do +ActiveRecord::Schema.define(:version => 20150528024616) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -438,6 +438,13 @@ ActiveRecord::Schema.define(:version => 20150514133640) do add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" + create_table "discuss_demos", :force => true do |t| + t.string "title" + t.text "body" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "documents", :force => true do |t| t.integer "project_id", :default => 0, :null => false t.integer "category_id", :default => 0, :null => false @@ -558,6 +565,13 @@ ActiveRecord::Schema.define(:version => 20150514133640) do t.datetime "updated_at", :null => false end + create_table "invite_lists", :force => true do |t| + t.integer "project_id" + t.integer "user_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "issue_categories", :force => true do |t| t.integer "project_id", :default => 0, :null => false t.string "name", :limit => 30, :default => "", :null => false @@ -652,6 +666,16 @@ ActiveRecord::Schema.define(:version => 20150514133640) do add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" + create_table "journal_details_copy", :force => true do |t| + t.integer "journal_id", :default => 0, :null => false + t.string "property", :limit => 30, :default => "", :null => false + t.string "prop_key", :limit => 30, :default => "", :null => false + t.text "old_value" + t.text "value" + end + + add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id" + create_table "journal_replies", :id => false, :force => true do |t| t.integer "journal_id" t.integer "user_id" From 7d76b20574505e300df1328e61ba3ac8483bf804 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 8 Jun 2015 17:16:34 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E9=82=A3=E5=9D=97?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=AF=B9=E4=BA=8E?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E7=9A=84=E5=AD=A6=E7=94=9F=E6=8F=90=E9=97=AE?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E5=9B=9E=E5=A4=8D=E5=8A=9F=E8=83=BD=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E5=8F=96=E6=B6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/homework.rb | 2 +- app/services/courses_service.rb | 54 ++++++++++++++--------------- app/services/homework_service.rb | 22 ++++++------ 3 files changed, 39 insertions(+), 39 deletions(-) diff --git a/app/api/mobile/entities/homework.rb b/app/api/mobile/entities/homework.rb index d4c34ffec..ee623d9ff 100644 --- a/app/api/mobile/entities/homework.rb +++ b/app/api/mobile/entities/homework.rb @@ -10,7 +10,7 @@ module Mobile else f[field] end - elsif f.is_a?(::Bid) + elsif f.is_a?(::HomeworkCommon) if f.respond_to?(field) f.send(field) else diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 49170bf30..d4a197aff 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -330,7 +330,7 @@ class CoursesService def homework_list params,current_user course = Course.find(params[:id]) if course.is_public != 0 || current_user.member_of_course?(course) - bids = course.homeworks.order('deadline DESC') + bids = course.homework_commons.order('end_time DESC') bids = bids.like(params[:name]) if params[:name].present? homeworks = [] bids.each do |bid| @@ -375,9 +375,9 @@ class CoursesService unless latest_attachment.nil? latest_course_dynamics << {:type => 3,:time => latest_attachment.created_on,:message =>latest_attachment.author.realname<< l(:label_recently_updated_courseware,:locale => get_user_language(current_user))<<":"< 4,:time => latest_bid.updated_on,:message => latest_bid.author.realname< get_user_language(current_user))<<":"< 4,:time => latest_bid.updated_at,:message => latest_bid.user.realname< get_user_language(current_user))<<":"< order.created_on} - end - latest_bid_message = messages.first - unless latest_bid_message.nil? - latest_course_dynamics << {:type => 4,:time => latest_bid_message.created_on,:message => l(:label_recently_updated_message,:locale => get_user_language(current_user))} - end + # messages = [] + # course.homework_commons.each do |hc| + # jour = hc.journals_for_messages.order("created_on desc").first + # unless jour.nil? + # messages << jour + # end + # end + # unless messages.count == 0 + # messages.sort!{|order,newer| newer.created_on <=> order.created_on} + # end + # latest_bid_message = messages.first + # unless latest_bid_message.nil? + # latest_course_dynamics << {:type => 4,:time => latest_bid_message.created_on,:message => l(:label_recently_updated_message,:locale => get_user_language(current_user))} + # end #每个作业中学生最后提交的作业 homeworks = [] - course.homeworks.each do |bid| - homework_attach = bid.homeworks.order('updated_at DESC').first + course.homework_commons.each do |bid| + homework_attach = bid.student_works.order('updated_at DESC').first unless homework_attach.nil? homeworks << homework_attach end @@ -533,21 +533,21 @@ class CoursesService mems end def show_homework_info course,bid,current_user,is_course_teacher - author_real_name = bid.author.lastname + bid.author.firstname - many_times = course.homeworks.index(bid) + 1 + author_real_name = bid.user.lastname + bid.user.firstname + many_times = course.homework_commons.index(bid) + 1 name = bid.name - homework_count = bid.homeworks.count #已提交的作业数量 - student_questions_count = bid.journals_for_messages.where('m_parent_id IS NULL').count + homework_count = bid.student_works.count #已提交的作业数量 + #student_questions_count = bid.journals_for_messages.where('m_parent_id IS NULL').count description = bid.description #if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2 - state = bid.comment_status + state = bid.homework_detail_manual.comment_status unless is_course_teacher homework_for_anonymous_comments = get_student_batch_homework_list bid,current_user end #end - open_anonymous_evaluation = bid.open_anonymous_evaluation - {: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} + open_anonymous_evaluation = bid.homework_detail_manual.comment_status + {:course_name => course.name,:course_id => course.id,:id => bid.id, :author => bid.user,:author_real_name => author_real_name, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => 0, + :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation,:homework_for_anonymous_comments => homework_for_anonymous_comments,:created_on => bid.created_at,:deadline => bid.end_time} end diff --git a/app/services/homework_service.rb b/app/services/homework_service.rb index 2e7f59888..2a2c6613c 100644 --- a/app/services/homework_service.rb +++ b/app/services/homework_service.rb @@ -14,21 +14,21 @@ class HomeworkService # state=1 关闭匿评 # state=2 匿评结束 def show_homework params - @bid = Bid.find(params[:id]) - course = @bid.courses.first - author = @bid.author.lastname + @bid.author.firstname - many_times = course.homeworks.index(@bid) + 1 + @bid = HomeworkCommon.find(params[:id]) + course = @bid.course + author = @bid.user.lastname + @bid.user.firstname + many_times = course.homework_commons.index(@bid) + 1 name = @bid.name - homework_count = @bid.homeworks.count #已提交的作业数量 - student_questions_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count + homework_count = @bid.student_works.count #已提交的作业数量 + #student_questions_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count description = @bid.description #if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2 - state = @bid.comment_status + state = @bid.homework_detail_manual.comment_status #end - open_anonymous_evaluation = @bid.open_anonymous_evaluation - jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') - {: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,:jours => jours} + open_anonymous_evaluation = @bid.homework_type + #jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') + {:course_name => course.name,:course_id => course.id,:id => @bid.id, :author => @bid.user,:author_real_name =>author, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => 0, + :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation,:created_on => @bid.created_at,:deadline => @bid.end_time,:jours => nil} end # 启动作业匿评前提示信息 From 05a77caeda767d694281eea19e41f95c38a55b27 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 9 Jun 2015 12:58:54 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E9=87=8D=E5=A4=8D=E5=8F=8A=E7=BB=9F=E8=AE=A1=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 4 ++-- app/views/mailer/send_for_user_activities.html.erb | 2 +- app/views/mailer/send_for_user_activities.text.erb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 204aa109a..7411dd30f 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -127,12 +127,12 @@ class Mailer < ActionMailer::Base # @homeworks = HomeworkAttach.where("user_id=#{user.id} and (created_at between '#{date_from}' and '#{date_to}')").order("created_at desc") # 查询user在课程中发布的讨论帖子 - course_mesages = Message.find_by_sql("select me.* from messages me, boards b, members m where + course_mesages = Message.find_by_sql("select distinct me.* from messages me, boards b, members m where b.id = me.board_id and b.course_id = m.course_id and b.course_id is not Null and m.user_id = '#{user.id}' and (me.created_on between '#{date_from}' and '#{date_to}') order by created_on desc") # 查询user在项目中发布的讨论帖子 - project_messages = Message.find_by_sql("select me.* from messages me, boards b, members m where + project_messages = Message.find_by_sql("select distinct me.* from messages me, boards b, members m where b.id = me.board_id and b.project_id = m.project_id and b.project_id != '-1' and m.user_id = '#{user.id}' and (me.created_on between '#{date_from}' and '#{date_to}') order by created_on desc") # messages = Message.find_by_sql("select DISTINCT * from messages where author_id = #{user.id} and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") diff --git a/app/views/mailer/send_for_user_activities.html.erb b/app/views/mailer/send_for_user_activities.html.erb index 9723783fe..54d2db43c 100644 --- a/app/views/mailer/send_for_user_activities.html.erb +++ b/app/views/mailer/send_for_user_activities.html.erb @@ -108,7 +108,7 @@

    <%= l(:view_borad_course) %> - (<%= @course_journal_messages.count %>) + (<%= @course_messages.count %>)

    <% @course_messages.each do |course_message|%>
  • diff --git a/app/views/mailer/send_for_user_activities.text.erb b/app/views/mailer/send_for_user_activities.text.erb index 669aca3d1..1bfbca4a1 100644 --- a/app/views/mailer/send_for_user_activities.text.erb +++ b/app/views/mailer/send_for_user_activities.text.erb @@ -88,7 +88,7 @@ <% unless @course_messages.first.nil? %> <%= l(:view_borad_course) %> - (<%= @course_journal_messages.count %>) + (<%= @course_messages.count %>) <% @course_messages.each do |course_message|%>