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] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E9=82=A3=E5=9D=97=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=AF=B9=E4=BA=8E=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E7=9A=84=E5=AD=A6=E7=94=9F=E6=8F=90=E9=97=AE=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E5=9B=9E=E5=A4=8D=E5=8A=9F=E8=83=BD=E9=9C=80=E8=A6=81?= =?UTF-8?q?=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 # 启动作业匿评前提示信息