学生作业模型
This commit is contained in:
parent
2fe18787a2
commit
426d382ee5
|
@ -0,0 +1,45 @@
|
|||
module Mobile
|
||||
module Entities
|
||||
class StudentWork < Grape::Entity
|
||||
include ApplicationHelper
|
||||
include ApiHelper
|
||||
def self.student_work_expose(f)
|
||||
expose f do |u,opt|
|
||||
if u.is_a?(Hash) && u.key?(f)
|
||||
u[f]
|
||||
elsif u.is_a?(::StudentWork)
|
||||
if u.respond_to?(f)
|
||||
if f == :created_at
|
||||
format_time(u.send(:created_at))
|
||||
else
|
||||
u.send(f)
|
||||
end
|
||||
|
||||
else
|
||||
case f
|
||||
when :student_id
|
||||
u.user.user_extensions.student_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
expose :user, using: Mobile::Entities::User do |c, opt|
|
||||
if c.is_a?(::StudentWork)
|
||||
c.user
|
||||
end
|
||||
end
|
||||
student_work_expose :student_id
|
||||
student_work_expose :id
|
||||
student_work_expose :name
|
||||
student_work_expose :description
|
||||
student_work_expose :final_score
|
||||
student_work_expose :teacher_score
|
||||
student_work_expose :student_score
|
||||
student_work_expose :teacher_asistant_score
|
||||
student_work_expose :created_at
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue