Logo: Relish

  1. Sign in

Project: Lombard

Survey creation

As a
I want to write out the survey in the DSL
So that I can give it to survey participants

Scenarios
Basic questions
Given
I parse
survey "Simple survey" do
  section "Basic questions" do
    label "These questions are examples of the basic supported input types"

    question_1 "What is your favorite color?", :pick => :one, :display_order => 1
    answer "red"
    answer "blue"
    answer "green"
    answer :other

    q_2b "Choose the colors you don't like", :pick => :any, :display_order => 2
    a_1 "orange"
    a_2 "purple"
    a_3 "brown"
    a :omit
  end
end
Then
there should be 1 survey with:
title
Simple survey
And
there should be 3 questions with:
reference_identifier text pick display_type
nil These questions are examples of the basic supported input types none label
1 What is your favorite color? one default
2b Choose the colors you don't like any default
And
there should be 8 answers with:
reference_identifier text response_class
nil red answer
nil blue answer
nil green answer
nil Other answer
1 orange answer
2 purple answer
3 brown answer
nil Omit answer
More complex questions
Given
the survey
survey "Complex survey" do
  section "Complicated questions" do
    grid "Tell us how you feel today" do
    a "-2"
    a "-1"
    a "0"
    a "1"
    a "2"
    q "down|up" , :pick => :one
    q "sad|happy", :pick => :one
    q "limp|perky", :pick => :one
    end

    q "Choose your favorite utensils and enter frequency of use (daily, weekly, monthly, etc...)", :pick => :any
    a "spoon", :string
    a "fork", :string
    a "knife", :string
    a :other, :string

    repeater "Tell us about the cars you own" do
    q "Make", :pick => :one, :display_type => :dropdown
    a "Toyota"
    a "Ford"
    a "GMChevy"
    a "Ferrari"
    a "Tesla"
    a "Honda"
    a "Other weak brand"
    q "Model"
    a :string
    q "Year"
    a :string
    end
  end
end
Then
there should be 1 survey with:
title
Complex survey
And
there should be 2 question groups with:
text display_type
Tell us how you feel today grid
Tell us about the cars you own repeater
And
there should be 7 questions with:
text pick display_type
Make one dropdown
And
there should be 28 answers with:
text response_class
-2 answer
Other string
Dependencies and validations
Given
the survey
survey "dependency test" do
  section "section 1" do
    q_copd_sh_1 "Have you ever smoked cigarettes?",:pick=>:one,:help_text=>"NO means less than 20 packs of cigarettes or 12 oz. of tobacco in a lifetime or less than 1 cigarette a day for 1 year."
    a_1 "Yes"
    a_2 "No"
    q_copd_sh_1a "How old were you when you first started smoking cigarettes?", :help_text=>"age in years"
    a :integer
    dependency :rule => "A"
    condition_A :q_copd_sh_1, "==", :a_1
    q_copd_sh_1b "Do you currently smoke cigarettes?",:pick=>:one, :help_text=>"as of 1 month ago"
    a_1 "Yes"
    a_2 "No"
    dependency :rule => "B"
    condition_B :q_copd_sh_1, "==", :a_1
    q_copd_sh_1c "On the average of the entire time you smoked, how many cigarettes did you smoke per day?"
    a :integer
    dependency :rule => "C"
    condition_C :q_copd_sh_1, "==", :a_1
    q_copd_sh_1bb "How many cigarettes do you smoke per day now?"
    a_2 "integer"
    dependency :rule => "D"
    condition_D :q_copd_sh_1b, "==", :a_1
    q_copd_sh_1ba "How old were you when you stopped?"
    a "Years", :integer
    dependency :rule => "E"
    condition_E :q_copd_sh_1b, "==", :a_2
  end
end
Then
there should be 5 dependencies
And
question "copd_sh_1a" should have a dependency with rule "A"
And
question "copd_sh_1ba" should have a dependency with rule "E"
Dependencies on questions inside of a group
Given
the survey
survey "Phone Screen Questions" do
  section "Phone Screen", :display_order => 1 do
    q_diabetes "Diabetes", :pick => :one, :display_order => 1
    a_yes "Yes"
    a_no "No"

    q_high_blood_preassure "High blood pressure?", :pick => :one, :display_order => 2
    a_yes "Yes"
    a_no "No"

    group do
    dependency :rule => "A"
    condition_A :q_diabetes, "==", :a_yes
    label "It looks like you are not eligible for this specific study at the time"
    end

    group "Eligible" do
    dependency :rule => "A"
    condition_A :q_diabetes, "==", :a_no

    label "You're Eligible!"

    label "You need medical clearance"
    dependency :rule => "A"
    condition_A :q_high_blood_preassure, "==", :a_yes

    label "You don't need medical clearance"
    dependency :rule => "A"
    condition_A :q_high_blood_preassure, "==", :a_no
    end
  end
end
Then
there should be 4 dependencies
And
2 dependencies should depend on questions
And
2 dependencies should depend on question groups
Dependencies with "a"
Given
the survey
survey "Dependencies with 'a'" do
  section "First" do
    q_data_collection "Disease data collection", :pick => :one, :display_order => 1
    a_via_chart_review "Via chart review"
    a_via_patient_interview "Via patient interview/questionnaire"

    q_myocardial_infaction "Myocardinal Infarction", :pick => :one, :display_order => 2
    dependency :rule => "A"
    condition_A :q_data_collection, "==", :a_via_chart_review
    a_yes "Yes"
    a_no "No"
  end
end
And
there should be 1 dependency with:
rule
A
And
there should be 1 resolved dependency_condition with:
rule_key
A
Dependencies with "q"
Given
the survey
survey "Dependencies with 'q'" do
  section "First" do
    q_rawq_collection "Your rockin rawq collection", :pick => :one, :display_order => 1
    a_rawqs "Rawqs"
    a_doesnt_rawq "Doesn't rawq"

    q_do_you_rawq "Do you rawq with your rockin rawq collection?", :pick => :one, :display_order => 2
    dependency :rule => "A"
    condition_A :q_rawq_collection, "==", :a_rawqs
    a_yes "Yes"
    a_no "No"
  end
end
And
there should be 1 dependency with:
rule
A
And
there should be 1 resolved dependency_condition with:
rule_key
A

Last published over 5 years ago by wminsinger.