Skip to content

Commit

Permalink
prepend option set name to level
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex committed Jan 17, 2025
1 parent e723d96 commit 1a717e5
Showing 1 changed file with 8 additions and 3 deletions.
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

0 comments on commit 1a717e5

Please sign in to comment.