Skip to content
Snippets Groups Projects

Add dsl for outcome schemas (tables) for roqua

Merged Jorn van de Beek requested to merge jb_roqua_outcome_schema into main
All threads resolved!
Files
2
@@ -21,7 +21,7 @@ module Quby
respondent_types: questionnaire.respondent_types,
tags: questionnaire.tags.to_h.keys,
charts: charts,
outcome_schema: outcome_schema,
outcome_tables_schema: outcome_tables_schema,
}
end
@@ -75,9 +75,17 @@ module Quby
}
end
def outcome_schema
# configuration for outcome tables.
# tables:
# <outcome_table_name:Symbol>: # each entry is a table.
# score_keys: Set[<schema.key:Symbol>] # rows in the table
# subscore_keys: Set[<subschema.key:Symbol>] # columns in the table
# headers:
# <subscore_key:Symbol>: <subscore.label:String> # headers for each subscore key for all tables.
def outcome_tables_schema
# hash of tables, with the score keys (rows) and subscore keys (columns) used for each
tables = Hash.new{ |hash, key| hash[key] = {score_keys: [], subscore_keys: []} }
tables = Hash.new{ |hash, key| hash[key] = {score_keys: Set.new, subscore_keys: Set.new } }
# hash of `subscore_key: subscore_label` pairs used in tables
headers = {}
@@ -89,12 +97,9 @@ module Quby
end
end
tables.values.each { |table| table[:score_keys].uniq! }
tables.values.each { |table| table[:subscore_keys].uniq! }
{
headers: headers,
tables: tables.values,
tables: tables,
}
end
end
Loading