Skip to content
Snippets Groups Projects

Validate uniqueness of export keys

All threads resolved!
2 files
+ 25
3
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -25,7 +25,6 @@ module Quby
validate_outcome_tables(questionnaire)
validate_markdown_fields(questionnaire) if questionnaire.validate_html
validate_raw_content_items(questionnaire) if questionnaire.validate_html
validate_scores(questionnaire)
# Some compilation errors are Exceptions (pure syntax errors) and some StandardErrors (NameErrors)
rescue Exception => exception # rubocop:disable Lint/RescueException
definition.errors.add(:sourcecode, {message: "Questionnaire error: #{definition.key}\n" \
@@ -81,6 +80,13 @@ module Quby
fail "Score #{score.key} does not have a score schema" unless score_schema
fail "Score label langer dan 100 tekens (geeft problemen oru accare)\n #{score_schema.label}" if score_schema.label&.length > 100
end
export_keys = questionnaire.score_schemas.flat_map { |_key, score_schema|
score_schema.subscore_schemas.map(&:export_key)
}
duplicate_export_keys = export_keys.tally.select { |key, count| count > 1 }.keys
fail "Score export keys not unique, duplicates: #{duplicate_export_keys}" if duplicate_export_keys.present?
end
def validate_question_options(questionnaire, question)
@@ -241,8 +247,6 @@ scores_schema tables to the resulting seed."
def validate_score_label_present(score)
fail "Score #{score.key} label must be passed in as an option." unless score.label.present?
end
def validate_subquestion_absence_in_select(question)
Loading