[DRAFT] Add question and answer flag to V2 API#3590
[DRAFT] Add question and answer flag to V2 API#3590momo3404 wants to merge 11 commits intoapi_v2_dmponlinefrom
Conversation
- This optional parameter is added to the plans endpoints in the V2 API
- This function fetches all questions and answers belonging to a plan.
Generated by 🚫 Danger |
| if @question_and_answer | ||
| json.questions_and_answers do | ||
| outputs.each do |output| | ||
| presenter = Api::V2::ResearchOutputPresenter.new(output: output) | ||
| q_and_a = presenter.send(:fetch_all_q_and_a, plan: plan) | ||
| next if q_and_a.blank? | ||
|
|
||
| json.set! output.id.to_s do | ||
| json.array! q_and_a do |item| | ||
| json.title item[:title] | ||
| json.question item[:question] | ||
| json.answer item[:answer] | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
There was a problem hiding this comment.
I'm looking at the comment at the top of this file:
# Note the symbol of the dmproadmap json object
# nested in extensions which is the container for the json template object, etc.
# A JSON representation of a Data Management Plan in the
# RDA Common Standard format
With the exception of json.extension, I think all of the keys here map onto the RDA-DMP-Common-Standard structure. Maybe this additional data should also be placed inside of json.extension?
There was a problem hiding this comment.
We'll probably have to get Marcus to sign off on what the schema should look like in the end, but I agree additional data like this should be inside the extension category. I moved it there.
There was a problem hiding this comment.
Marcus signed off on putting it into extension, and he also said the flag should be titled complete and the JSON should have complete_plan, like this:
"complete_plan": [
{
"title": "Question 1",
"question": "<p>What considerations will you take into account with respect to ethical, legal, or commercial issues?</p>\r\n<p><br>Describe any applicable ethical, legal, or commercial considerations related to your project and data. This includes research involving Indigenous communities and knowledges, human subjects, legal and commercial considerations/agreements, partnerships or data with a high level of risk associated with it.</p>",
"answer": "<p>test</p>"
},
{
"title": "Question 2",
"question": "<p>What data will you collect or otherwise bring into your project under this plan?</p>\r\n<p><br>Describe the data that will be collected, generated, and/or acquired.</p>",
"answer": "<p>test</p>"
},
]
I added those changes to this PR.
- Moved 'fetch_all_q_and_a' from research_output_present to plan_presenter - Moved q_and_a json to be inside extensions
- This removes the plan id from the questions and answers json
Changes proposed in this PR:
completeflag to the V2 API to enable accessing all questions and answers belonging to a plan in the API response.api/v2/plansandapi/v2/plans/[plan_id]endpoints. For example:api/v2/plans/12345?complete=true.