Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

12522: Add constraint rejection messages to XLSForm export #1031

Merged
merged 4 commits into from
Jan 24, 2025

Conversation

plastichotsprings
Copy link
Collaborator

@plastichotsprings plastichotsprings commented Jan 10, 2025

This PR adds support to the XLSForm export feature for constraint messages.

If there are multiple constraint rules for a particular question, the method combines all provided messages into one string (per locale/translation), separated by a semicolon, in order to match the XLSForm standard format.

This PR also slightly rearranges the column orders to put the constraint messages column beside the constraint column for better readability.

image

@plastichotsprings plastichotsprings changed the title 12522: Add rejection messages to questions with constraints 12522: Add constraint rejection messages to XLSForm export Jan 16, 2025
Copy link
Member

@cooperka cooperka left a comment

Choose a reason for hiding this comment

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

tested and verified importing into Central 🙌 nice work

Screenshot

if constraint_message.present?
constraint_msg_to_push[locale_index] += constraint_message
# Add semicolon concatenator, unless at the end
constraint_msg_to_push[locale_index] += "; " unless c_index + 1 == q.constraints.length
Copy link
Member

Choose a reason for hiding this comment

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

this works perfectly fine, just sharing a helpful alternative: [1, 2, 3].join("; ")


constraint_msg_to_push.each do |message|
questions.row(row_index).push(message)
end
Copy link
Member

Choose a reason for hiding this comment

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

rather than having a separate each loop here, it may be possible to combine these:

[].push(1, 2, *[3, 4]) is equivalent to [].push(1, 2, 3, 4), with the * "splat" operator deconstructing the array

@plastichotsprings plastichotsprings merged commit abb53a1 into main Jan 24, 2025
1 check passed
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