diff --git a/app/api/mobile/entities/homework.rb b/app/api/mobile/entities/homework.rb index 9be9bc53e..5b996c1af 100644 --- a/app/api/mobile/entities/homework.rb +++ b/app/api/mobile/entities/homework.rb @@ -18,8 +18,14 @@ module Mobile homework_expose :id #课程名称 homework_expose :course_name - #课程老师 - homework_expose :course_teacher + #作业发布者 + expose :author,using: Mobile::Entities::User do |f, opt| + f[:author] + end + + #作业发布者真名 + homework_expose :author_real_name + #作业次数 homework_expose :homework_times #作业名称 diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 19f9c0fa2..b6fc21bf9 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -98,7 +98,8 @@ class CoursesController < ApplicationController #更新课程信息 def update cs = CoursesService.new - @course = cs.edit_course params,@course,User.current + c = cs.edit_course params,@course,User.current + @course = c[:course] if @course.errors.full_messages.count <= 0 respond_to do |format| format.html { diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index ab0a53744..1f5ca7894 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -3,7 +3,7 @@ class CoursesService include CoursesHelper include HomeworkAttachHelper include ApiHelper - #TODO:尚未整合权限系统 + #参数school_id为0或不传时返回所有课程,否则返回对应学校的课程 #参数per_page_count分页功能,每页显示的课程数 #参数page分页功能,当前页码 @@ -356,7 +356,7 @@ class CoursesService private def show_homework_info course,bid,current_user,is_course_teacher - author = bid.author.lastname + bid.author.firstname + author_real_name = bid.author.lastname + bid.author.firstname many_times = course.homeworks.index(bid) + 1 name = bid.name homework_count = bid.homeworks.count #已提交的作业数量 @@ -369,7 +369,7 @@ class CoursesService end #end open_anonymous_evaluation = bid.open_anonymous_evaluation - {:course_name => course.name,:id => bid.id, :course_teacher => author, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => student_questions_count, + {: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} end diff --git a/app/services/homework_service.rb b/app/services/homework_service.rb index dd2d2356e..c5a333125 100644 --- a/app/services/homework_service.rb +++ b/app/services/homework_service.rb @@ -26,7 +26,7 @@ class HomeworkService state = @bid.comment_status #end open_anonymous_evaluation = @bid.open_anonymous_evaluation - {:course_name => course.name,:id => @bid.id, :course_teacher => author, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => student_questions_count, + {: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