2015-01-20 15:17:02 +08:00
|
|
|
|
module Mobile
|
|
|
|
|
module Entities
|
|
|
|
|
class Homework < Grape::Entity
|
|
|
|
|
def self.homework_expose(field)
|
|
|
|
|
expose field do |f,opt|
|
|
|
|
|
if f.is_a?(Hash) && f.key?(field)
|
|
|
|
|
f[field]
|
2015-01-21 11:28:09 +08:00
|
|
|
|
elsif f.is_a?(::Bid)
|
|
|
|
|
if f.respond_to?(field)
|
|
|
|
|
f.send(field)
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
end
|
2015-01-20 15:17:02 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
#作业id
|
|
|
|
|
homework_expose :id
|
|
|
|
|
#课程名称
|
|
|
|
|
homework_expose :course_name
|
|
|
|
|
#课程老师
|
|
|
|
|
homework_expose :course_teacher
|
|
|
|
|
#作业次数
|
|
|
|
|
homework_expose :homework_times
|
|
|
|
|
#作业名称
|
|
|
|
|
homework_expose :homework_name
|
|
|
|
|
#已提交的作业数量
|
|
|
|
|
homework_expose :homework_count
|
|
|
|
|
#学生提问数量
|
|
|
|
|
homework_expose :student_questions_count
|
|
|
|
|
#作业描述
|
|
|
|
|
homework_expose :description
|
|
|
|
|
#作业是否启用匿评功能 0:不启用,1启用
|
|
|
|
|
homework_expose :open_anonymous_evaluation
|
|
|
|
|
#作业状态 0:新建,1:已开启匿评,2:已关闭匿评
|
|
|
|
|
#只有作业启用了匿评功能且当前用户是课程老师且已提交的作品数量大于或等于2才能开启匿评
|
|
|
|
|
homework_expose :homework_state
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|