Beispiel #1
0
 def gen_check_page(accept):
     return Page(Label(),
                 Input('How much money does the proposer receive?',
                       prepend='$',
                       append='.00',
                       type='number',
                       required=True),
                 Input('How much money does the responder receive?',
                       prepend='$',
                       append='.00',
                       type='number',
                       required=True),
                 compile=[C.clear_response(),
                          C.random_proposal(accept)])
Beispiel #2
0
def household_residents(require=False):
    return Input(
        'How many people regularly live in your household, including yourself and children?',
        var='NHouseholdResidents',
        type='number',
        min=1,
        validate=V.require() if require else None,
        debug=D.send_keys(str(randint(1, 10)), p_exec=1 if require else .8))
Beispiel #3
0
def children(require=False):
    return Input('How many children do you have?',
                 var='NChildren',
                 type='number',
                 min=0,
                 validate=V.require() if require else None,
                 debug=D.send_keys(str(randint(0, 10)),
                                   p_exec=1 if require else .8))
Beispiel #4
0
def pig():
    return Input('''
        <p>A man buys a pig for $60, sells it for $70, buys it back for $80, 
        and sells it finally for $90. How much has he made?</p>
        ''',
                 var='CRT_Pig',
                 prepend='$',
                 type='number',
                 debug=_debug_functions(20, 10))
Beispiel #5
0
def age(require=False):
    return Input(
        'How old are you?',
        var='Age',
        type='number',
        min=0,
        max=100,
        validate=V.require() if require else None,
    )
Beispiel #6
0
def students():
    return Input('''
        <p>Jerry received both the 15th highest and the 15th lowest mark in 
        the class. How many students are in the class?</p>
        ''',
                 var='CRT_Students',
                 append='students',
                 type='number',
                 min=1,
                 debug=_debug_functions(29, 30))
Beispiel #7
0
def nurses():
    return Input('''
        <p>If it takes 2 nurses 2 minutes to measure the blood of 2 patients, 
        how many minutes would it take 200 nurses to measure the blood of 200 
        patients?</p>
        ''',
                 var='CRT_Nurses',
                 append='minutes',
                 extra_attrs=dict(type='number', min=0, step='any'),
                 debug=_debug_functions(2, 200))
Beispiel #8
0
def widgets():
    return Input('''
        <p>If it takes 5 machines 5 minutes to make 5 widgets, how many 
        minutes would it take 100 machines to make 100 widgets?</p>
        ''',
                 var='CRT_Widgets',
                 append='minutes',
                 type='number',
                 min=0,
                 step='any',
                 debug=_debug_functions(5, 100))
Beispiel #9
0
def gender(require=False):
    gender = Check('What is your gender?', ['Male', 'Female', 'Other'],
                   var='Gender',
                   validate=V.require() if require else None,
                   submit=_record_male)
    _debug_choices(gender, require)
    specify = Input('Please specify your gender.',
                    var='GenderSpecify',
                    data_rows=-1)
    show_on_event(specify, gender, 'Other')
    return gender, specify
Beispiel #10
0
def drinking_water():
    return Input('''
        <p>If John can drink one barrel of water in 6 days, and Mary can 
        drink one barrel of water in 12 days, how many days would it take 
        them to drink one barrel of water together?</p>
        ''',
                 var='CRT_DrinkingWater',
                 append='days',
                 type='number',
                 min=0,
                 step='any',
                 debug=_debug_functions(4, 9))
Beispiel #11
0
def soup_salad():
    return Input('''
        <p>Soup and salad cost $5.50 in total. The soup costs a dollar more 
        than the salad. How much does the salad cost?</p>
        ''',
                 var='CRT_SoupSalad',
                 prepend='$',
                 type='number',
                 min=0,
                 max=5.5,
                 step=.01,
                 debug=_debug_functions(2.25, 2.5))
Beispiel #12
0
def bat_ball():
    return Input('''
        <p>A bat and a ball cost $1.10 in total. The bat costs $1 more than 
        the ball.</p>
        <p>How many cents does the ball cost?</p>
        ''',
                 var='CRT_BatBall',
                 append='cents',
                 type='number',
                 min=0,
                 max=110,
                 debug=_debug_functions(5, 10))
Beispiel #13
0
def _verify1(q1, require):
    if q1.data != CORRECT_1:
        page = Page(Input('''
                Imagine we are throwing a five-sided die 50 times. On average, out of these 50 throws how many times would this five-sided die show an odd number (1, 3, or 5)?
                ''',
                          append='out of 50 throws',
                          type='number',
                          min=0,
                          max=50,
                          step=1,
                          required=require,
                          var='Berlin2a',
                          data_rows=-1,
                          submit=_verify2a,
                          debug=[D.send_keys(),
                                 D.send_keys('30', p_exec=.5)]),
                    name='Berlin 2a',
                    timer=('Berlin2aTime', -1),
                    debug=[D.debug_questions(),
                           D.forward()])
    else:
        page = Page(Input('''
                Imagine we are throwing a loaded die (6 sides). The probability that the die shows a 6 is twice as high as the probability of each of the other numbers. On average, out of these 70 throws how many times would the die show the number 6?
                ''',
                          append='out of 70 throws',
                          type='number',
                          min=0,
                          max=70,
                          required=require,
                          var='Berlin2b',
                          data_rows=-1,
                          submit=S(_verify2b, require),
                          debug=[D.send_keys(),
                                 D.send_keys('20', p_exec=.2)]),
                    name='Berlin 2b (or not 2b?)',
                    timer=('Berlin2bTime', -1),
                    debug=[D.debug_questions(),
                           D.forward()])
    q1.branch.pages.insert(q1.page.index + 1, page)
Beispiel #14
0
def sun_tea():
    return Input('''
        <p>Sally is making sun tea. Every hour, the concentration of the tea 
        doubles. If it takes 6 hours for the tea to be ready, how many hours 
        would it take for the tea to reach half of the final 
        concentration?</p>
        ''',
                 var='CRT_SunTea',
                 append='hours',
                 type='number',
                 min=0,
                 max=6,
                 step='any',
                 debug=_debug_functions(5, 3))
Beispiel #15
0
def lily_pads():
    return Input('''
        <p>In a lake, there is a patch of lily pads. Every day, the patch 
        doubles in size. If it takes 48 days for the patch to cover the 
        entire lake, how many days would it take for the patch to cover half 
        of the lake?</p>
        ''',
                 var='CRT_LilyPads',
                 append='days',
                 type='number',
                 min=0,
                 max=48,
                 step='any',
                 debug=_debug_functions(47, 24))
Beispiel #16
0
def religion(require=False):
    religion_q = Select(
        'Which religion or religious denomination do you belong to, if any?', [
            '', 'None', 'Roman Catholic', 'Protestant',
            ('Orthodox (Russian, Greek, etc.)', 'Orthodox'), 'Jewish',
            'Muslim', 'Hindu', 'Buddhist', 'Other'
        ],
        var='Religion',
        validate=V.require() if require else None)
    _debug_choices(religion_q, require)
    specify = Input(
        'Please specify your religion or religious denomination.',
        var='RelgionSpecify',
    )
    show_on_event(specify, religion_q, 'Other')
    return religion_q, specify
Beispiel #17
0
def race(require=False):
    race_q = Check('''
        Which race or ethnicity do you belong to?

        Check as many as apply.
        ''', [
        'White', 'Black',
        ('South Asian (Indian, Pakistani, etc.)', 'South Asian'),
        ('East Asian (Chinese, Japanese, etc.)', 'East Asian'),
        'Arabic or Central Asian', 'Other'
    ],
                   var='Race',
                   multiple=True,
                   validate=V.min_len(1) if require else None)
    _debug_choices(race_q, require)
    specify = Input('Please specify your race or ethnicity.',
                    var='RaceSpecify',
                    data_rows=-1)
    show_on_event(specify, race_q, 'Other')
    return race_q, specify
Beispiel #18
0
def berlin(require=False):
    """
    Add the Berlin Numeracy Test to a hemlock survey.

    Parameters
    ----------
    require : bool, default=False
        Indicates that responses are required.

    Returns
    -------
    Berlin page 1 : hemlock.Page
        The first page of the Berlin Numeracy Test.

    Notes
    -----
    Although this function returns only the first page of the test, it is all
    you need to add the full test to your survey. The submit function of the 
    page returned by this function adaptively generates additional pages of 
    the test.
    """
    return Page(Input('''
            Out of 1,000 people in a small town 500 are members of a choir. Out of these 500 members in the choir 100 are men. Out of the 500 inhabitants that are not in the choir 300 are men. What is the probability that a randomly drawn man is a member of the choir? Please enter the probability as a percent.
            ''',
                      append='%',
                      type='number',
                      min=0,
                      max=100,
                      step='any',
                      required=require,
                      var='Berlin1',
                      data_rows=-1,
                      submit=S(_verify1, require),
                      debug=[D.send_keys(),
                             D.send_keys('25', p_exec=.5)]),
                name='Berlin 1',
                timer=('Berlin1Time', -1),
                debug=[D.debug_questions(), D.forward()])
Beispiel #19
0
def _verify2b(q2b, require):
    if q2b.data == CORRECT_2B:
        _record_score(q2b, score=4)
    else:
        page = Page(Input('''
                In a forest 20% of mushrooms are red, 50% brown, and 30% white. A red mushroom is poisonous with a probability of 20%. A mushroom that is not red is poisonous with a probability of 5%. What is the probability that a poisonous mushroom in the forest is red?
                ''',
                          append='%',
                          type='number',
                          min=0,
                          max=100,
                          step='any',
                          required=require,
                          var='Berlin3',
                          data_rows=-1,
                          submit=_verify3,
                          debug=[D.send_keys(),
                                 D.send_keys('50', p_exec=.5)]),
                    name='Berlin 3',
                    timer=('Berlin3Time', -1),
                    debug=[D.debug_questions(),
                           D.forward()])
        q2b.branch.pages.insert(q2b.page.index + 1, page)