Change a question to a described end state
limesurvey_update_question_from_specChange one existing question to the end state given as a question spec (typically the spec of limesurvey_get_survey_spec at level question, changed).
Instructions
Change one existing question to the end state given as a question spec (typically the spec of limesurvey_get_survey_spec at level question, changed). The tool compares the end state with the question and picks the mode: none (nothing differs, nothing is written); texts (only question, help and subquestion texts: written in place with set_question_properties questionl10ns, also at an active survey); columns (code, mandatory, relevance, preg, other, same_default, same_script, encrypted, question_theme_name, modulename, inactive survey only: written in place, the question ID stays); replace (anything else: subquestions, answers and answer texts, attributes, defaults, type, script; inactive survey only): the end state is imported as a new question, moved to the place of the old one and read back completely; only if it matches is the old question deleted, otherwise the new one is deleted again and the old one keeps everything. Texts the end state does not change are written back as LimeSurvey stores them. dry_run true only reads (write scope none) and returns { survey_id, question_id, survey_active, mode (none, texts, columns, replace, or rejected when an active survey would need more than texts), changes [{ path, kind (text, column, structure), current, desired, and for a subquestion or answer its code and, on scale 1, scale_id }], changes_total, risks [{ code, blocking, acknowledgeable, detail, locations }], plan, fingerprint }. The real run needs expected_fingerprint (of get_survey_spec or the dry run; STALE_SPEC if the question changed since) and confirm_destructive_action true, and returns the same plus applied, verification { ok, differences } and, after a replacement, the new question_id and old_question_id. Blocking risks stop the call with UPDATE_QUESTION_BLOCKED before anything is written: qid_bound_links (every replacement: URL parameters, archived responses, quota memberships of the old ID), quota_members, other_default, removals, translation_gaps (import_question fills missing translations of the survey) and unreadable_texts (texts of the question that cannot be read in a language get the base-language text; both acknowledged with fill_translation_gaps) and answer_code_references can be acknowledged; code_references (the old code or removed fields such as CODE_SQ, CODE_SQcomment, CODE_other named anywhere, the end state of the question included; free texts are searched inside {...} only), sgqa_references and data_uri cannot. Each risk lists at most a part of its locations (locations_total). Errors: SPEC_INVALID, STALE_SPEC, SURVEY_ACTIVE (with the changes that need an inactive survey), UPDATE_QUESTION_BLOCKED, QUESTION_SURVEY_MISMATCH, REPLACE_QUESTION_FAILED (failed_step, rolled_back, manual_cleanup, differences), UPDATE_QUESTION_FAILED (texts and columns; the old values are written back and read back, manual_cleanup names what is not back), VERIFY_READ_FAILED (written: true; only the read-back failed). Texts of the survey, groups and questions alone go with limesurvey_update_survey_texts; a new question with limesurvey_add_question_from_spec. Needs the write scope content (dry run: none).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dry_run | No | true: only show mode, changes, risks and plan; nothing is written (default false). | |
| question | Yes | The end state of the question as a question spec, for example the spec of limesurvey_get_survey_spec at level question, changed. | |
| survey_id | Yes | Numeric LimeSurvey survey ID. | |
| acknowledge | No | Confirmed risks of the dry run: qid_bound_links, quota_members, other_default, removals, fill_translation_gaps (for the risks translation_gaps and unreadable_texts) and answer_code_references. | |
| question_id | Yes | ID of the main question of this survey to change. | |
| expected_fingerprint | No | The fingerprint of the question as read (limesurvey_get_survey_spec or a dry run); required unless dry_run is true. | |
| confirm_destructive_action | No | Must be true for a real run (dry_run not true): a replacement deletes the old question. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes | ||
| workflow | Yes |