Skip to content
Snippets Groups Projects
Commit b562af20 authored by Jorn van de Beek's avatar Jorn van de Beek
Browse files

Revert "Add dsl for outcome schemas (tables) for roqua"

This reverts commit 4c9ea0b6.
parent 4c9ea0b6
No related branches found
No related tags found
No related merge requests found
Pipeline #78215 passed
......@@ -14,10 +14,6 @@ module Quby
attribute :only_for_export?, Types::Bool
# [Optional] The key of the variable definition used to calculate the subscore result.
attribute :calculation_key?, Types::Symbol
# [Optional] The name of the outcome table where this subscore should be shown. Used for cases where scores
# differ in subscores too much to be shown as one table. Any name can be used, as long as they match between
# subscores that should be shown in the same table.
attribute :outcome_table?, Types::Symbol
end
end
end
......
......@@ -21,7 +21,6 @@ module Quby
respondent_types: questionnaire.respondent_types,
tags: questionnaire.tags.to_h.keys,
charts: charts,
outcome_schema: outcome_schema,
}
end
......@@ -74,30 +73,6 @@ module Quby
end
}
end
def outcome_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: []} }
# hash of `subscore_key: subscore_label` pairs used in tables
headers = {}
questionnaire.score_schemas.values.each do |schema|
schema.subscore_schemas.each do |subschema|
next unless subschema.outcome_table
tables[subschema.outcome_table][:subscore_keys] << subschema.key
tables[subschema.outcome_table][:score_keys] << schema.key
headers[subschema.key] = subschema.label
end
end
tables.values.each { |table| table[:score_keys].uniq! }
tables.values.each { |table| table[:subscore_keys].uniq! }
{
headers: headers,
tables: tables.values,
}
end
end
end
end
......
require 'spec_helper'
describe Quby::Compiler::Outputs::RoquaSerializer do
it 'generates outcome schemas' do
questionnaire = dsl("test") do
title "Test Quest"
score_schema :score1, 'Score 1' do
subscore :value, 'Waarde', export_key: :score1, outcome_table: :values do
1
end
subscore :int, 'Interpretatie', export_key: :score1_i do
'Wah'
end
end
score_schema :score2, 'Score 2' do
subscore :value, 'Waarde', export_key: :score2, outcome_table: :values do
2
end
end
score_schema :score3, 'Score 3' do
subscore :mean, 'Gemiddelde', export_key: :score3, outcome_table: :means do
1
end
end
end
serializer = described_class.new(questionnaire)
expect(serializer.as_json).to \
include({
outcome_schema: {
tables: [{:score_keys => [:score1, :score2], :subscore_keys => [:value]},
{:score_keys => [:score3], :subscore_keys => [:mean]}],
headers: {mean: "Gemiddelde", value: "Waarde"}
}
})
end
def dsl(key, &block)
Quby::Compiler::DSL.build(key, nil, &block)
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment