From fd1dc80bf0760fa35cc9a8f372ee1f3c74dda8e7 Mon Sep 17 00:00:00 2001 From: z9hang Date: Wed, 7 Jan 2015 16:02:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BD=9C=E4=B8=9A=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/homeworks.rb | 3 ++- app/services/homework_service.rb | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/api/mobile/apis/homeworks.rb b/app/api/mobile/apis/homeworks.rb index 99acfd87f..0b86fef7b 100644 --- a/app/api/mobile/apis/homeworks.rb +++ b/app/api/mobile/apis/homeworks.rb @@ -16,7 +16,8 @@ module Mobile end route_param :id do get do - get_service.show_homework params + hs = HomeworkService.new + hs.show_homework params end end diff --git a/app/services/homework_service.rb b/app/services/homework_service.rb index 914889c68..c0a669bca 100644 --- a/app/services/homework_service.rb +++ b/app/services/homework_service.rb @@ -13,16 +13,17 @@ class HomeworkService def show_homework params @bid = Bid.find(params[:id]) course = @bid.courses.first - author = @bid.author.firstname + @bid.author.lastname + author = @bid.author.lastname + @bid.author.firstname many_times = course.homeworks.index(@bid) + 1 name = @bid.name - homework_count = @bid.homeworks.count + 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 - {:course => 'course', :atuthor => 'author', :many_times => 'many_times', :name => 'name', :homework_count => 'homework_count', - :descriptiong => 'description', :state => 'state'} + {:course => course, :atuthor => author, :many_times => many_times, :name => name, :homework_count => homework_count,:student_questions_count => student_questions_count, + :descriptiong => description, :state => state} end # 启动作业匿评