Skip to content

Commit 8f3beaf

Browse files
committed
Update _show,json.jbuilder to include questions and answers
1 parent 62c4498 commit 8f3beaf

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,24 @@ unless @minimal
5757

5858
outputs = plan.research_outputs.any? ? plan.research_outputs : [plan]
5959

60+
if @question_and_answer
61+
json.questions_and_answers do
62+
outputs.each do |output|
63+
presenter = Api::V2::ResearchOutputPresenter.new(output: output)
64+
q_and_a = presenter.send(:fetch_all_q_and_a, plan: plan)
65+
next if q_and_a.blank?
66+
67+
json.set! output.id.to_s do
68+
json.array! q_and_a do |item|
69+
json.title item[:title]
70+
json.question item[:question]
71+
json.answer item[:answer]
72+
end
73+
end
74+
end
75+
end
76+
end
77+
6078
json.dataset outputs do |output|
6179
json.partial! "api/v2/datasets/show", output: output
6280
end

0 commit comments

Comments
 (0)