diff --git a/openapi.yaml b/openapi.yaml index 0dd61ad..4b1717a 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -13631,6 +13631,14 @@ paths: Metric needs `list_id` (an existing List) or `list` (a new List with its choices). - `new_field`: a new Field; `section_title` makes a heading. + **The Survey's own Outcome.** Give each `new_metric` the `outcome_id` of an existing Outcome + when one fits. A `new_metric` that leaves out `outcome_id` goes under an Outcome named after + the Survey, made only when a question needs it and shared by every such question (numbered if + your organisation already has an Outcome with that name, e.g. "Feedback Questionnaire (2)"). + The response gives its id as `automatic_outcome_id`, or null when none was needed. With + `automatic_outcome: false`, every `new_metric` needs `outcome_id`. Questions added later with + Change a Survey's questions may leave out `outcome_id` too, while the Survey has that Outcome. + Search the library first and reuse what fits: results recorded against a copy of a Metric don't add up with the original. If a new Metric, List or Field has the same or a near-identical name to one you could reuse, nothing is created and you get `409` with the @@ -13696,6 +13704,10 @@ paths: type: string intro_message: type: string + automatic_outcome: + type: boolean + default: true + description: A new_metric without outcome_id goes under an Outcome named after the Survey, made only if needed. With false, every new_metric needs outcome_id departments: type: array items: {type: string} @@ -25136,7 +25148,7 @@ components: type: integer new_metric: type: object - required: [name, metric_type, default_question, outcome_id] + required: [name, metric_type, default_question] properties: name: type: string @@ -25161,6 +25173,7 @@ components: items: {type: string} outcome_id: type: integer + description: The Outcome it measures. Leave it out to use an Outcome named after the Survey, made if needed (automatic_outcome) unit_id: type: integer description: Value only diff --git a/server.js b/server.js index d988877..68b69f1 100644 --- a/server.js +++ b/server.js @@ -2843,7 +2843,7 @@ function buildDocsPage() { ${endpointCard("POST", "/surveys", "Create a Survey with its questions", true, [ { name: "organisation_id", in: "body", type: "integer", required: true, desc: "The organisation (Charity) that will own it; you must be one of its editors" }, { name: "name", in: "body", type: "string", required: true, desc: "The Survey's name" }, - { name: "questions", in: "body", type: "array", required: true, desc: "In order, at most 50. Each has exactly one of metric_id, field_id, activity_tracker_id (reuse), new_metric {name, metric_type, default_question, outcome_id, list_id or list {name, choices}, unit_id} or new_field {field_name, field_data_type}; plus optional is_mandatory, choice, external_description, and, with intervals, by_interval and only_in_intervals" }, + { name: "questions", in: "body", type: "array", required: true, desc: "In order, at most 50. Each has exactly one of metric_id, field_id, activity_tracker_id (reuse), new_metric {name, metric_type, default_question, outcome_id (optional while automatic_outcome is on), list_id or list {name, choices}, unit_id} or new_field {field_name, field_data_type}; plus optional is_mandatory, choice, external_description, and, with intervals, by_interval and only_in_intervals" }, { name: "intervals", in: "body", type: "array", required: false, desc: "The Survey's Shared Intervals in order, at most 10, e.g. [\"Baseline\", \"Endpoint\"], for a Survey answered more than once. Projects it is added to later use them" }, { name: "questions[].by_interval", in: "body", type: "array", required: false, desc: "Adjust When: entries {interval, respondent, question} reword the question, {interval, respondent, hide: true} hide it. Leave out interval for every Interval and respondent (participant, colleague, observer, public) for everyone; where two cover the same place, the one naming more wins" }, { name: "questions[].only_in_intervals", in: "body", type: "array", required: false, desc: "Show the question only in these Intervals, e.g. [\"Endpoint\"]" }, @@ -2852,11 +2852,12 @@ function buildDocsPage() { { name: "scoring", in: "body", type: "object", required: false, desc: "Scoring and Verdicts: {questions, verdicts: [{name, from, to, description}]} adds up those questions' points into bands. Give new scale Metrics points per answer (new_metric.points); a reused Metric can be scored only if it already has points. Bands must cover every possible total with no gaps" }, { name: "question_grids", in: "body", type: "array", required: false, desc: "Question Grids: [{outcome_id, questions}] shows scale questions that measure the Outcome first and share one List as one table, headed by the Outcome's title. List every scale question of that Outcome; grid questions can't have display_if or skip_to" }, { name: "description / intro_message", in: "body", type: "string", required: false, desc: "Shown with the Survey" }, + { name: "automatic_outcome", in: "body", type: "boolean", required: false, desc: "Default true: a new_metric without outcome_id goes under an Outcome named after the Survey, made only when a question needs it (numbered if the name is taken, e.g. \"Feedback Questionnaire (2)\"). false: every new_metric needs outcome_id" }, { name: "departments / causes / sub_causes", in: "body", type: "array", required: false, desc: "Names, for the Explore filters" }, { name: "approved", in: "body", type: "boolean", required: false, desc: "Makerble staff only: show it to every organisation and approve its new Metrics and Lists" }, { name: "force", in: "body", type: "boolean", required: false, desc: "true to create new items even though near-identical ones exist (see 409)" } ], [ - { code: "201", cls: "response-2xx", desc: "Created: data is the Survey as Get a library item shows it, with its intervals and questions in order (each with any by_interval wording), plus approved" }, + { code: "201", cls: "response-2xx", desc: "Created: data is the Survey as Get a library item shows it, with automatic_outcome and automatic_outcome_id, its intervals and questions in order (each with any by_interval wording), plus approved" }, { code: "401", cls: "response-4xx", desc: "Missing or invalid token" }, { code: "403", cls: "response-4xx", desc: "You may not create Surveys, as in the Makerble app" }, { code: "404", cls: "response-4xx", desc: "The organisation, or an id in a question, isn't one you can use; the error names the question" },