Skip to content

Commit

Permalink
Add appearance column and fill with data from qtype
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex committed Feb 4, 2025
1 parent c992e30 commit 827c142
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/models/forms/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def to_xls
"hint::#{language_name(locale)} (#{locale})")
end

questions.row(0).push("name", "required", "relevant", "choice_filter", "constraint")
questions.row(0).push("name", "required", "appearance", "relevant", "choice_filter", "constraint")

locales.each do |locale|
questions.row(0).push("constraint message::#{language_name(locale)} (#{locale})")
Expand Down Expand Up @@ -148,6 +148,7 @@ def to_xls
else # is this a question?
# convert question types to ODK style
qtype_converted = QTYPE_TO_XLS[q.qtype_name]
appearance_to_push = QTYPE_TO_APPEARANCE[q.qtype_name] || ""

# if we have any relevant conditions or constraints, save them now
conditions_to_push = conditions_to_xls(q.display_conditions, q.display_if)
Expand Down Expand Up @@ -210,7 +211,7 @@ def to_xls
end

questions.row(row_index + l_index).push(name_to_push,
q.required.to_s, conditions_to_push, choice_filter, constraints_to_push, *constraint_msg_to_push)
q.required.to_s, appearance_to_push, conditions_to_push, choice_filter, constraints_to_push, *constraint_msg_to_push)

# define the choice_filter cell for the following row, e.g, "state=${selected_state}"
choice_filter = "#{level_name}=${#{name_to_push}}"
Expand All @@ -230,7 +231,7 @@ def to_xls
q.question.hint_translations&.dig(locale.to_s))
end

questions.row(row_index).push(q.code, q.required.to_s,
questions.row(row_index).push(q.code, q.required.to_s, appearance_to_push,
conditions_to_push, choice_filter, constraints_to_push, *constraint_msg_to_push)
end
else # no option set present
Expand All @@ -242,7 +243,7 @@ def to_xls
q.question.hint_translations&.dig(locale.to_s))
end

questions.row(row_index).push(q.code, q.required.to_s,
questions.row(row_index).push(q.code, q.required.to_s, appearance_to_push,
conditions_to_push, choice_filter, constraints_to_push, *constraint_msg_to_push)
end
end
Expand Down

0 comments on commit 827c142

Please sign in to comment.