Skip to content

Commit 245d11c

Browse files
committed
Update plans/_show,json.jbuilder to work with complete plan flag
- Add call for complete flag - Add questions and answers of a plan to the json if complete is set to true
1 parent 7ca5d12 commit 245d11c

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

app/views/api/v2/plans/_show.json.jbuilder

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
json.schema 'https://github.com/RDA-DMP-Common/RDA-DMP-Common-Standard/tree/master/examples/JSON/JSON-schema/1.0'
66

7-
presenter = Api::V2::PlanPresenter.new(plan: plan)
7+
presenter = Api::V2::PlanPresenter.new(plan: plan, complete: @complete)
88

99
# Note the symbol of the dmproadmap json object
1010
# nested in extensions which is the container for the json template object, etc.
@@ -68,5 +68,18 @@ unless @minimal
6868
json.title template.title
6969
end
7070
end
71+
72+
if @complete
73+
json.complete_plan do
74+
q_and_a = presenter.complete_plan_data
75+
next if q_and_a.blank?
76+
77+
json.array! q_and_a do |item|
78+
json.title item[:title]
79+
json.question item[:question]
80+
json.answer item[:answer]
81+
end
82+
end
83+
end
7184
end
7285
end

0 commit comments

Comments
 (0)