Skip to content

Conversation

@momo3404
Copy link
Collaborator

@momo3404 momo3404 commented Feb 6, 2026

Changes proposed in this PR:

  • Add the complete flag to the V2 API to enable accessing all questions and answers belonging to a plan in the API response.
  • Per the V2 API Documentation: "The idea is to have a flag which defaults to false and thereby is compliant with the RDA metadata standard, but can be passed in with a value of true to include the questions and answers of the plan."
  • The flag is optional and works with the api/v2/plans and api/v2/plans/[plan_id] endpoints. For example: api/v2/plans/12345?complete=true.
  • The schema the flag returns is as follows:
  •       "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>"
              },
            ]
    
  • Questions with no answers are not included in the response.

- Edit plan query to check for user role to prevent eager loading
- Add set_complete_param function that sets complete flag according to its value if its set to true in the API call
@github-actions
Copy link

github-actions bot commented Feb 6, 2026

</tr>
1 Error
🚫

Please include a CHANGELOG entry.

You can find it at [CHANGELOG.md](https://github.com/DMPRoadmap/roadmap/blob/main/CHANGELOG.md).

Generated by 🚫 Danger

Comment on lines +72 to +77
if @complete
json.complete_plan do
q_and_a = presenter.complete_plan_data
next if q_and_a.blank?

json.array! q_and_a do |item|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to you, but this might be a tiny bit easier to read:

if @complete && presenter.complete_plan_data.present?
  json.complete_plan do
    json.array! presenter.complete_plan_data do |item|

- Edit initialize to include complete flag, which is set to false as default
- If flag is true in call, call fetch_all_q_and_a
- Add fetch_all_q_and_a function that fetches questions and answers

Update plan_presenter
@momo3404 momo3404 force-pushed the momo/add-complete-flag branch from 20ba138 to 6261caf Compare February 9, 2026 21:48
- Add complete flag data to extension in json
@momo3404 momo3404 force-pushed the momo/add-complete-flag branch from d7b2d27 to 3771771 Compare February 9, 2026 21:49
next unless q.present?

{
title: "Question #{q.number || q.id}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we end up agreeing on the unique identifier (i.e. q.id) for this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we agreed that it wasn't possible as is to have a unique identifier for a question that would remain unchanged if the question was edited, and that it was shippable as is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, maybe I'm misunderstanding, but it might be possible.
When I create a plan, it has a plan.template associated with it. And that template has several questions associated with it. That template should always be associated with that plan, and those questions should always be associated with that template.
If an admin were to update a template question, a new template would be created. However, no plans with the prior template or prior questions would be affected.

Despite all that, we're running out of time. :P You can leave this to ship as-is for now if you'd like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants