作业详情,课程作业列表接口返回数据格式修改(增加了作业作者相关信息)

This commit is contained in:
z9hang 2015-03-01 17:31:38 +08:00
parent 2f762973b4
commit 18271946d7
4 changed files with 14 additions and 7 deletions

View File

@ -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
#作业名称

View File

@ -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 {

View File

@ -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

View File

@ -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