parent
5bd404322b
commit
9c560e56b6
@ -1,9 +1,32 @@
|
||||
module Mobile
|
||||
module Entities
|
||||
class Exercise < Grape::Entity
|
||||
include Redmine::I18n
|
||||
include ApplicationHelper
|
||||
include ApiHelper
|
||||
def self.exercise_expose(field)
|
||||
expose field do |f,opt|
|
||||
if f.is_a?(Hash) && f.key?(field)
|
||||
if field == :created_on
|
||||
format_time(f[field])
|
||||
else
|
||||
f[field]
|
||||
end
|
||||
elsif f.is_a?(::Exercise)
|
||||
if f.respond_to?(field)
|
||||
f.send(field)
|
||||
else
|
||||
case field
|
||||
when :coursename
|
||||
f.course.nil? ? "" : f.course.name
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
expose :exercise_name
|
||||
expose :exercise_description
|
||||
expose :coursename #所属班级名
|
||||
exercise_expose :coursename #所属班级名
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in new issue