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

12624: xlsform export bug fix: duplicate column header error #1032

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions app/models/forms/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ def to_xls
# is the option set multilevel?
if os.level_names.present?
os.level_names.each_with_index do |level, l_index|
level_name = vanillify(level.values[0])
# prepend option set name so that level names are unique
# this avoids duplicate header errors
level_name = os_name + "_" + vanillify(level.values[0])

# Append level name to qtype
type_to_push = "#{qtype_converted} #{level_name}"
Expand Down Expand Up @@ -381,7 +383,8 @@ def options_to_xls(option_sets, locales)
if node.level.present?
# per XLSform style, option sets with levels need to have the
# list_name replaced with the level name to distinguish each row.
listname_to_push = node.level_name
# prepend unique identifier to avoid duplicate header errors
listname_to_push = vanillify(os.name) + "_" + node.level_name

# Only attempt to access node ancestors if they exist
if node.ancestry_depth > 1
Expand Down Expand Up @@ -418,7 +421,9 @@ def options_to_xls(option_sets, locales)
# omit last entry (lowest level)
if os.level_names.present?
os.level_names[0..-2].each do |level|
header_row.push(vanillify(level.values[0]))

# prepend unique identifier
header_row.push(vanillify(os.name) + '_' + vanillify(level.values[0]))

# increment column counter
column_counter += 1
Expand Down
Loading