From e5082ff4898178012dfaa78bbe6fab5365a4b6b1 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 26 Jun 2015 09:18:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E7=89=88=E8=AF=BE=E7=A8=8B=E5=8A=A8?= =?UTF-8?q?=E6=80=81=20=E8=AF=BE=E7=A8=8B=E4=BD=9C=E4=B8=9A=E5=B1=95?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/entities/course_dynamic.rb | 8 ++--- app/api/mobile/entities/homework.rb | 4 +++ app/services/courses_service.rb | 38 ++++++++++++++++++----- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/app/api/mobile/entities/course_dynamic.rb b/app/api/mobile/entities/course_dynamic.rb index 56b83d513..f086f1dd1 100644 --- a/app/api/mobile/entities/course_dynamic.rb +++ b/app/api/mobile/entities/course_dynamic.rb @@ -22,7 +22,7 @@ module Mobile end end obj - elsif field == :jour_message_count + elsif field == :topic_count obj = nil c[:dynamics].each do |d| if d[:type] == 2 @@ -80,7 +80,7 @@ module Mobile course_dynamic_expose :count course_dynamic_expose :news_count course_dynamic_expose :document_count - course_dynamic_expose :jour_message_count + course_dynamic_expose :topic_count course_dynamic_expose :homework_count course_dynamic_expose :homework_submit_students course_dynamic_expose :homework_submit_num @@ -95,11 +95,11 @@ module Mobile end obj end - expose :jour_message,using:Mobile::Entities::Jours do |f,opt| + expose :topic,using:Mobile::Entities::Message do |f,opt| obj = nil f[:dynamics].each do |d| if d[:type] == 2 - obj = d[:jour_message] + obj = d[:topic] end end obj diff --git a/app/api/mobile/entities/homework.rb b/app/api/mobile/entities/homework.rb index 18dbe0d3b..e2c181048 100644 --- a/app/api/mobile/entities/homework.rb +++ b/app/api/mobile/entities/homework.rb @@ -68,6 +68,10 @@ module Mobile homework_expose :homework_notsubmit_num + expose :submit_student_list ,using:Mobile::Entities::User do |f,opt| + f[:studentlist] + end + end end end \ No newline at end of file diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 3856a7642..fd2cfe4a5 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.homework_commons.order('end_time DESC') + bids = course.homework_commons.page(1).per(3).order('end_time DESC') bids = bids.like(params[:name]) if params[:name].present? homeworks = [] bids.each do |bid| @@ -540,14 +540,35 @@ class CoursesService #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.homework_detail_manual.comment_status + #state = bid.homework_detail_manual.comment_status + if !bid.nil? + if bid.homework_type == 1 && bid.homework_detail_manual + case bid.homework_detail_manual.comment_status + when 1 + state = show_homework_deadline bid + when 2 + state = "正在匿评中" + when 3 + state = "匿评已结束" + end + elsif bid.homework_type == 0 + state = "未启用匿评" + elsif bid.homework_type == 2 + state = "编程作业" + else + end + end + studentlist = [] + bid.student_works.order("created_at desc").page(1).per(6).each do |work| + studentlist << work.user + end unless is_course_teacher homework_for_anonymous_comments = get_student_batch_homework_list bid,current_user end #end 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} + :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,:studentlist => studentlist} end @@ -628,9 +649,9 @@ class CoursesService return end if current_user == @user || current_user.admin? - membership = @user.coursememberships.all + membership = @user.coursememberships.page(1).per(10) else - membership = @user.coursememberships.all(:conditions => Course.visible_condition(current_user)) + membership = @user.coursememberships.page(1).per(10).all(:conditions => Course.visible_condition(current_user)) end if membership.nil? || membership.count == 0 raise l(:label_no_courses, :locale => get_user_language(current_user)) @@ -653,9 +674,10 @@ class CoursesService end # 课程讨论区 - latest_message = course.journals_for_messages.where("m_parent_id is null").order("created_on desc").first + latest_message = course.boards.first.topics[0] unless latest_message.nil? - latest_course_dynamics << {:type => 2, :time => latest_message.created_on, :count =>course.journals_for_messages.where('m_parent_id is null').count, :jour_message => latest_message} + latest_course_dynamics << {:type => 2, :time => latest_message.created_on, :count =>course.boards.nil? ? 0 : course.boards.first.topics.count, + :topic => latest_message} dynamics_count += 1 end @@ -710,7 +732,7 @@ class CoursesService #计算作业的截止日期,剩余日期 def show_homework_deadline homework - "截止日期:" << homework.end_time.to_s << ",剩余时间:" << (Date.parse(Time.now.to_s) - Date.parse(homework.end_time.to_s)).to_i.to_s << "天" + "距作业截止还有" << (Date.parse(Time.now.to_s) - Date.parse(homework.end_time.to_s)).to_i.to_s << "天" end end