def get_question_objects(content):
    question_objs = {
        # 'Question text': question_obj
    }

    for section in content.sections:
        for question in get_questions(section.questions):
            question_objs[question.get_source('question')] = question

    return question_objs
def test_get_questions_unpacks_multiquestions():

    section = ContentSection.create(section=get_section(
        questions=['checkboxes', 'boolean'],
        multiquestions=['checkboxes', 'boolean']
    ))
    assert section.id == 'options'

    # should be a flat list with 4 entries
    questions = get_questions(section.questions)
    assert len(questions) == 4
def test_get_questions_unpacks_multiquestions():

    section = ContentSection.create(section=get_section(
        questions=['checkboxes', 'boolean'],
        multiquestions=['checkboxes', 'boolean']
    ))
    assert section.id == 'options'

    # should be a flat list with 4 entries
    questions = get_questions(section.questions)
    assert len(questions) == 4
def test_get_questions_sets_multiquestion_names_and_hints():

    section = ContentSection.create(section=get_section(
        multiquestions=['checkboxes', 'boolean']
    ))
    assert section.id == 'options'

    # hint and name of multiquestion should be preserved in nested_questions
    for question in get_questions(section.questions):
        if question.get('id').startswith('multiquestion_'):
            assert question.get('parent').get('name') == 'Options'
            assert question.get('parent').get('hint') == 'Please indicate your preferred options'
def test_get_questions_sets_multiquestion_names_and_hints():

    section = ContentSection.create(section=get_section(
        multiquestions=['checkboxes', 'boolean']
    ))
    assert section.id == 'options'

    # hint and name of multiquestion should be preserved in nested_questions
    for question in get_questions(section.questions):
        if question.get('id').startswith('multiquestion_'):
            assert question.get('multiquestion_name') == 'Options'
            assert question.get('multiquestion_hint') == 'Please indicate your preferred options'