def intervention_logging(card, user_exercise):
    """
    Log a bunch of information about the added header text
    """
    event_log.log_event('x.intervention.full_header', card.growthHeader)
    event_log.log_event('x.intervention.exercise_name', card.exercise_name)
    problem_type = getattr(card, 'problem_type', 'UNDEFINED')
    event_log.log_event('x.intervention.problem_type', problem_type)
    total_done = getattr(user_exercise, 'total_done', -1)
    event_log.log_event('x.intervention.total_done', total_done)
    event_log.log_event('x.intervention.language',
            intl.request.locale_for_mo())
def add_header_text_to_cards(card, user_exercise):
    """
    Adds header text to a problem card based on exercise and
    A/B test bucket.
    """

    if not (card.exercise_name in target_exercises):
        card.growthHeader = ""
        return

    # get A/B test condition
    test_condition = experiments.CoreMetrics.ab_test(
        "growth mindset header",
        alternative_params={"no header": 5, "growth mindset": 1, "growth mindset + link": 1, "control statement": 2},
        core_categories="all",
    )

    if test_condition == "control statement":
        # nested experiments because only 4 conditions are supported in
        # GAE/Bingo
        test_subcondition = experiments.CoreMetrics.ab_test(
            "growth mindset header subtest",
            alternative_params={"positive statement": 1, "science statement": 1},
            core_categories="all",
        )
        test_condition += "." + test_subcondition

    if test_condition == "no header":
        card.growthHeader = ""
    elif test_condition == "growth mindset":
        message = random.choice(growth_messages)
        card.growthHeader = "<p><em>" + message + "</em></p>"
    elif test_condition == "growth mindset + link":
        message = random.choice(growth_messages)
        card.growthHeader = (
            "<p><em>" + message + "</em>"
            '&nbsp&nbsp&nbsp<FONT SIZE="-5">'
            '<a href=/brainworkout_1 target="_blank">'
            "LEARN MORE</a>"
            "</FONT></p>"
        )
    elif test_condition == "control statement.positive statement":
        message = random.choice(positive_messages)
        card.growthHeader = "<p><em>" + message + "</em></p>"
    elif test_condition == "control statement.science statement":
        message = random.choice(science_messages)
        card.growthHeader = "<p><em>" + message + "</em></p>"

    # TODO - this will record events even if the card is never
    # displayed -- for instance, because the student never goes past
    # the first card in a group of cards.  When interpreting these
    # results, will need to do the extra work of matching these up
    # against problemlog entries, and throwing out the ones which
    # don't match.
    event_log.log_event("x.mindset.test_condition", test_condition)
    event_log.log_event("x.mindset.exercise_name", card.exercise_name)
    problem_type = getattr(card, "problem_type", "UNDEFINED")
    event_log.log_event("x.mindset.problem_type", problem_type)
    total_done = getattr(user_exercise, "total_done", -1)
    event_log.log_event("x.mindset.total_done", total_done)
    event_log.log_event("x.mindset.message_text", card.growthHeader)
Esempio n. 3
0
def add_header_text_to_cards(card, user_exercise):
    """
   Adds header text to a problem card based on exercise and
   A/B test bucket.
   """

    if not (card.exercise_name in target_exercises):
        card.growthHeader = ""     # card refers to the problem object. growthHeader is an attribute of the card.
        return

    # STOPSHIP. The new experiment starts with the KIND OF HEADER A/B test. 
    test_condition = experiments.CoreMetrics.ab_test("KIND OF HEADER",
            alternative_params={
                "no header": 5, # STOPSHIP. As before, unaffected users.
                "header": 1, # Text message is added but NO links to more info. 
                "learning support": 1, # Header has a clickable link to DropDown text or a webpage.
                },
            core_categories='all')

    if test_condition == "no header":
        card.growthHeader = ""
        
    
    elif test_condition == "header":
        test_subcondition = experiments.CoreMetrics.ab_test(
            "header type subtest",
            alternative_params={
                "mindset only": 1, #STOPSHIP mindset message, exactly as in previous expt            
                "explanation only": 1, #provides dropdown explanation strategy
                "mindset + explanation": 1}, #provides a mindset message, followed by an explanation strategy
            core_categories='all')
        test_condition += "." + test_subcondition
        

        if test_condition == "header.mindset only"
            message = random.choice(mindset_messages)
            card.growthHeader = "<p><em>" + message + "</em></p>" #show mindset message


        elif test_condition == "header.explanation only"
            card.growthHeader = wwh_strat #show explanation strategy
        
        elif test_condition == "header.mindset + explanation"
            message = random.choice(mindset_messages)
            card.growthHeader = "<p><em>" + message + "</em></p>" + wwh_strat  #show mindset message, followed by explanation strategy


    elif test_condition == "learning support":
        # STOPSHIP. People in the "learning support" condition are assigned to 1 of 2 sub-conditions.
        # "webpage link" provides a link to a webpage on KA with the LearningCoach study information (like brain workout page in mindset study).
        #       Right now this is just a placeholder exercise on our server with the LearningCoach at top.
        # "dropdown link" reveals text on dropdown that provides the LearningCoach study information
        #       through a nested series of dropdown text.

        test_subcondition = experiments.CoreMetrics.ab_test(
            "learning support subtest",
            alternative_params={
                "webpage link": 1, # provides a link to a webpage on KA with the LearningCoach study information               
                "dropdown link": 1}, # reveals text on dropdown that provides the LearningCoach study information
            core_categories='all')
        test_condition += "." + test_subcondition
        


    # STOPSHIP. "webpage link" provides a link to a webpage on KA with the LearningCoach study information (like brain workout page in mindset study).
    # Right now this is just a placeholder exercise on our server with the LearningCoach at top.
        if test_condition == "learning support.webpage link":
            card.growthHeader = ('<p><em>Click here to get tips for motivating yourself and learning more quickly:</em>'
                             '&nbsp&nbsp&nbsp<FONT SIZE="-5">'
                             '<a href="http://tiny.cc/kalearningcoach" target="_blank">' # This is a placeholder link to rough demo, actual link can be on KA like brain workout.
                             'GET TIPS</a>'
                             '</FONT></p>')
    # STOPSHIP. "dropdown link" reveals text on dropdown that provides the LearningCoach study information
    # through a nested series of dropdown text.                             
    # You can easily see what this complicated code does through demo at tiny.cc/kalearningcoach       
        elif test_condition == "learning support.dropdown link":
            message = random.choice(growth_messages) # These are assigned here and then used INSIDE of the LearningCoach
            card.growthHeader = create_learning_tutor(message, wwh_strat) #use the function above to generate a learning tutor with mindset message & what why how strategy.
                              


    



        
    # TODO - this will record events even if the card is never
    # displayed -- for instance, because the student never goes past
    # the first card in a group of cards.  When interpreting these
    # results, will need to do the extra work of matching these up
    # against problemlog entries, and throwing out the ones which
    # don't match.
    event_log.log_event('x.mindset.test_condition', test_condition)
    event_log.log_event('x.mindset.exercise_name', card.exercise_name)
    problem_type = getattr(card, 'problem_type', 'UNDEFINED')
    event_log.log_event('x.mindset.problem_type', problem_type)
    total_done = getattr(user_exercise, 'total_done', -1)
    event_log.log_event('x.mindset.total_done', total_done)
    event_log.log_event('x.mindset.message_text', card.growthHeader)
def add_header_text_to_cards(card, user_exercise):
    """
   Adds header text to a problem card based on exercise and
   A/B test bucket.
   """

    if not (card.exercise_name in target_exercises):
        card.growthHeader = ""     # card refers to the problem object. growthHeader is an attribute of the card.
        return

    # STOPSHIP. The new experiment starts with the KIND OF HEADER A/B test. 
    test_condition = experiments.CoreMetrics.ab_test("KIND OF HEADER",
            alternative_params={
                "no header": 5, # STOPSHIP. As before, unaffected users.
                "header": 1, # Text message is added but NO links to more info. 
                "learning support": 1, # Header has a clickable link to DropDown text or a webpage.
                },
            core_categories='all')

    if test_condition == "no header":
        card.growthHeader = ""
        
    elif test_condition == "header":
        message = random.choice(mindset_messages)
        card.growthHeader = "<p><em>" + message + "</em></p>"
        
    elif test_condition == "learning support":
        # STOPSHIP. People in the "learning support" condition are assigned to 1 of 2 sub-conditions.
        # "webpage link" provides a link to a webpage on KA with the LearningCoach study information (like brain workout page in mindset study).
        # Right now this is just a placeholder exercise on our server with the LearningCoach at top.
        # "dropdown link" reveals text on dropdown that provides the LearningCoach study information
        # through a nested series of dropdown text.

        test_subcondition = experiments.CoreMetrics.ab_test(
            "learning support subtest",
            alternative_params={
                "webpage link": 1, # provides a link to a webpage on KA with the LearningCoach study information               
                "dropdown link": 1}, # reveals text on dropdown that provides the LearningCoach study information
            core_categories='all')
        test_condition += "." + test_subcondition
        


    # STOPSHIP. "webpage link" provides a link to a webpage on KA with the LearningCoach study information (like brain workout page in mindset study).
    # Right now this is just a placeholder exercise on our server with the LearningCoach at top.
        if test_condition == "learning support.webpage link":
            card.growthHeader = ('<p><em>Click here to get tips for motivating yourself and learning more quickly:</em>'
                             '&nbsp&nbsp&nbsp<FONT SIZE="-5">'
                             '<a href="http://tiny.cc/kalearningcoach" target="_blank">' # This is a placeholder link to rough demo, actual link can be on KA like brain workout.
                             'GET TIPS</a>'
                             '</FONT></p>')
    # STOPSHIP. "dropdown link" reveals text on dropdown that provides the LearningCoach study information
    # through a nested series of dropdown text.                             
    # You can easily see what this complicated code does through demo at tiny.cc/kalearningcoach       
        elif test_condition == "learning support.dropdown link":
            message = random.choice(growth_messages) # These are assigned here and then used INSIDE of the LearningCoach
            card.growthHeader = ('<p><a href="#" class="show-subhint" data-subhint="help-me">'
                              'Click here to get tips for motivating yourself and learning more quickly</a></p>'
                              '<div class="subhint" id="help-me">'
                              '<a href="#" class="show-subhint" data-subhint="mindset-message">'
                              'I&#39;m feeling discouraged, I&#39;d like a motivational message.</a>'
                              '<div class="subhint" id="mindset-message"><p>' + message + '</p>'
                              '<p><a href="#" class="show-subhint" data-subhint="mindset-tellmore">Tell me more!</a></p>'
                              '<div class="subhint" id="mindset-tellmore">'
                              'Even if it&#39;s tough, the time you spend working help you form more '
                              'connections that will help you solve future problems.</div>'
                              '<p><a href="#" class="show-subhint" data-subhint="mindset-altmore">'
                              'How do you motivate yourself?</a></p>'                            
                              '<div class="subhint" id="mindset-altmore">'
                              'What would you tell another student to get motivated?</div>'
                              '</div>'
                              '<p><a href="#" class="show-subhint" data-subhint="learn-strat">'
                              'Would you like some suggestions for problem-solving strategies?</a></p>'
                              '<div class="subhint" id="learn-strat">'
                              '<a href="#" class="show-subhint" data-subhint="what-why-how">'
                              'Click here to learn about the'
                              ' "<span class="hint_purple" style="font-weight:bold">What? Why? How?</span> strategy</a>'
                              '<div class="subhint" id="what-why-how">'
                              'To use this strategy, ask yourself these'
                              ' "<span class="hint_purple" style="font-weight: bold">'
                              'What? Why? How?</span>"'
                              ' questions after each hint in a problem.'
                              '<br><span class="hint_purple" style="font-weight: bold">'
                              'What does this step mean to you?</span>'
                              '<br>'
                              '<span class="hint_purple" style="font-weight: bold">'
                              'Why is it helpful to take this step?</span>'
                              '<br><span class="hint_purple" style="font-weight: bold">'
                              'How do you know this step is right?</span>'
                              '<br>'
                              'As a reminder to ask yourself these questions, they'
                              'will sometimes appear in '
                              '<span class="hint_purple" style="font-weight: bold">'
                              'purple</span>.'
                              '<br><br>'
                              '<a href="#" class="show-subhint" data-subhint="encouragement" data-hidden-text="Hide Information">'
                              'What if I can’t do it?</a>'
                              '<div class="subhint" id="encouragement">'
                              'Many students are not sure what to say, or think '
                              'their answer isn’t good. That is fine, as long as you'
                              '<span style="font-weight: bold; font-style:italic">'
                              ' try</span>'
                              ' to think about the question, by typing or saying the answer to yourself.'
                              '</div></div></div></div>')
                              


    



        
    # TODO - this will record events even if the card is never
    # displayed -- for instance, because the student never goes past
    # the first card in a group of cards.  When interpreting these
    # results, will need to do the extra work of matching these up
    # against problemlog entries, and throwing out the ones which
    # don't match.
    event_log.log_event('x.mindset.test_condition', test_condition)
    event_log.log_event('x.mindset.exercise_name', card.exercise_name)
    problem_type = getattr(card, 'problem_type', 'UNDEFINED')
    event_log.log_event('x.mindset.problem_type', problem_type)
    total_done = getattr(user_exercise, 'total_done', -1)
    event_log.log_event('x.mindset.total_done', total_done)
    event_log.log_event('x.mindset.message_text', card.growthHeader)
def add_header_text_to_card(card, user_exercise):
    """
    Adds header text to a problem card based on
    A/B test buckets for the "intervention" set of experiments.
    """

    # use the same ab_test categories for all experiments
    core_categories = ["learning_dashboard", "exercises"]
    # the unique identifier for this user
    bingo_id = identity.identity()

    # get top level A/B test condition
    primary_condition = experiments.CoreMetrics.ab_test(
            "intervention top level",
            alternative_params={
                "no header": 4,
                "intervention": 1,
                "combination": 1},
            core_categories=core_categories)
    event_log.log_event('x.intervention.primary', primary_condition)

    if primary_condition == "no header":
        # student is in control condition
        card.growthHeader = ""
        intervention_logging(card, user_exercise)
        return

    # choose the frequency with which to insert a header
    # above exercises
    frequency_condition = experiments.CoreMetrics.ab_test(
            "intervention frequency",
            alternative_params={
                "0-10": 25,
                "10-25": 25,
                "25-75": 25,
                "75-100": 25},
            core_categories=core_categories)
    # by having continuous frequencies, we can smoothly plot effectiveness
    # vs. frequency later
    if frequency_condition == "0-10":
        frequency = hash_to_rand(bingo_id, 'freq') * 0.1
    elif frequency_condition == "10-25":
        frequency = hash_to_rand(bingo_id, 'freq') * 0.15 + 0.1
    elif frequency_condition == "25-75":
        frequency = hash_to_rand(bingo_id, 'freq') * 0.50 + 0.25
    elif frequency_condition == "75-100":
        frequency = hash_to_rand(bingo_id, 'freq') * 0.25 + 0.75
    event_log.log_event('x.intervention.frequency', frequency_condition)

    if frequency < random.random():
        # no header for this exercise
        card.growthHeader = ""
        event_log.log_event('x.intervention.frequency.skip', 'True')
        intervention_logging(card, user_exercise)
        return

    # choose what kind of psychological intervention to apply
    alternative_params = {
        "repeat experiment": 1,
        "whatwhyhow": 1,
        "individual explanation": 1}
    if primary_condition == "intervention":
        intervention_type_condition = experiments.CoreMetrics.ab_test(
                "intervention type",
                alternative_params=alternative_params,
                core_categories=core_categories)
    elif primary_condition == "combination":
        # in the combination condition, set the subexperiment at
        # random each time
        intervention_type_condition = random_weighted_choice(
                alternative_params)
    event_log.log_event('x.intervention.type', intervention_type_condition)

    if intervention_type_condition == 'repeat experiment':
        # repeat experiment means conditions which are duplicated from the
        # prior growth mindset experiment.
        # This is a nested ab test.
        # the positive statement had a small negative effect in the last
        # experiment, but it's good to have as a control, so we'll only
        # assign a small fraction of students to it this time
        alternative_params = {
            "growth mindset": 10,
            "growth mindset + link": 10,
            "science statement": 10,
            "positive statement": 1,
            }
        if primary_condition == "intervention":
            intervention_repeat_condition = experiments.CoreMetrics.ab_test(
                    "intervention repeat experiment",
                    alternative_params=alternative_params,
                    core_categories=core_categories)
        elif primary_condition == "combination":
            # in the combination condition, set the subexperiment at
            # random each time
            intervention_repeat_condition = random_weighted_choice(
                    alternative_params)
        event_log.log_event('x.intervention.repeat.type',
                intervention_repeat_condition)

        # set the message text for each condition
        if intervention_repeat_condition == "growth mindset":
            message_text = random.choice(growth_messages)
            card.growthHeader = "<p><em>" + message_text + "</em></p>"
        elif intervention_repeat_condition == "growth mindset + link":
            message_text = random.choice(growth_messages)
            message_text = (i18n._('<p><em>%(message)s</em>'
                                 '&nbsp&nbsp&nbsp<FONT SIZE="-5">'
                                 '<a href=/brainworkout_1 target="_blank">'
                                 'LEARN MORE</a>'
                                 '</FONT></p>', message=message_text))
        elif intervention_repeat_condition == "science statement":
            message_text = random.choice(science_messages)
            message_text = "<p><em>" + message_text + "</em></p>"
        elif intervention_repeat_condition == "positive statement":
            message_text = random.choice(positive_messages)
            message_text = "<p><em>" + message_text + "</em></p>"
    elif intervention_type_condition == 'whatwhyhow':
        # nearly identical to the whatwhyhow condition that was run in the
        # metacognitive experiment
        message_text = whatwhyhow_body
    elif intervention_type_condition == 'individual explanation':
        # more light weight explanation effect hints.
        # choose the target of address for the explanation.
        alternative_params = {
            "self": 1,
            "teacher": 1,
            "sal": 1,
            "friend": 1,
            }
        if primary_condition == "intervention":
            target_condition = experiments.CoreMetrics.ab_test(
                    "intervention repeat experiment",
                    alternative_params=alternative_params,
                    core_categories=core_categories)
        elif primary_condition == "combination":
            # in the combination condition, set the subexperiment at
            # random each time
            target_condition = random_weighted_choice(alternative_params)
        target_text = explanation_prompt_target_text[target_condition]
        question_text = random.choice(explanation_prompt_messages)
        message_text = target_text + question_text
        event_log.log_event('x.intervention.explanation.target',
                target_condition)
        event_log.log_event('x.intervention.explanation.question',
                question_text)

    # choose whether there's a dropdown
    dropdown_condition = experiments.CoreMetrics.ab_test(
            "intervention dropdown",
            alternative_params={
                "none": 1,
                "message": 1,
                "specific": 1
                },
            core_categories=core_categories)
    if intervention_type_condition == "whatwhyhow" and (
            dropdown_condition == 'none'):
        # whatwhyhow is a lot of text, and should always appear in a dropdown
        dropdown_condition = 'specific'
    event_log.log_event('x.intervention.dropdown', dropdown_condition)

    # choose the teaser text for the dropdown
    # TODO add bold+color to all dropdown text?
    if dropdown_condition == "message":
        dropdown_text = i18n._("[Click here for a message.]")
    elif dropdown_condition == "specific":
        if intervention_type_condition == 'repeat experiment':
            if intervention_repeat_condition == "science statement":
                dropdown_text = i18n._("[Click to learn a fun science fact.]")
            else:
                dropdown_text = i18n._(
                    "[Click to read a brief motivational message.]")
        elif intervention_type_condition == 'whatwhyhow':
            dropdown_text = i18n._('[Click to learn about the "<span class=' +
                '"hint_purple" style="font-weight: bold">What? Why? How?' +
                '</span>" strategy.]')
        elif intervention_type_condition == 'individual explanation':
            dropdown_text = i18n._("[Click for a learning strategy question.]")

    # combine the dropdown label and the message text
    if dropdown_condition == 'none':
        # just the message text
        card.growthHeader = message_text
    else:
        card.growthHeader = """
            <p>
                <a href="#" class="show-subhint"
                   data-subhint="intervention-learn-more"
                   data-hidden-text="Hide Information">
                    %s
                </a>
            </p>
            <div class="subhint" id="intervention-learn-more">
                %s
            </div>""" % (dropdown_text, message_text)

    intervention_logging(card, user_exercise)
def get_tip_string():
    """
    Generate the tip string to be used for the intervention experiments in the
    coach email.
    """

    # all A/B test weights are given as percentages

    # get A/B test condition
    # TODO(jascha) is 'coach' the core category we want?
    test_condition_top = experiments.CoreMetrics.ab_test(
        'coach email intervention',
        alternative_params={
            'control': 36,
            'single intervention': 44,
            'combination condition': 20,
            },
        core_categories=['retention','coach'])
    test_condition_text = test_condition_top

    if test_condition_top == 'control':
        test_condition_control = experiments.CoreMetrics.ab_test(
            'coach email intervention - control subtest',
            alternative_params={
                'no tip': 28,
                'site tip': 4,
                'positive encouragement': 4,
                },
            core_categories=['retention','coach'])
        test_condition_text += '.' + test_condition_control
        tip_text = tip_strings[test_condition_control]
    elif test_condition_top == 'single intervention':
        test_condition_intervention = experiments.CoreMetrics.ab_test(
            'coach email intervention - single intervention category',
            alternative_params={
                'growth mindset': 24,
                'explanation effect': 12,
                'long term goals': 4,
                'deliberate practice': 4,
                },
            core_categories=['retention','coach'])
        test_condition_text += '.' + test_condition_intervention
        if test_condition_intervention == 'growth mindset':
            test_condition_growth = experiments.CoreMetrics.ab_test(
                'coach email intervention - growth subtest',
                alternative_params={
                    'growth submessage': 12,
                    'growth framing': 12,
                    },
                core_categories=['retention','coach'])
            test_condition_text += '.' + test_condition_growth
            if test_condition_growth == 'growth submessage':
                test_condition_growth_submessage = \
                    experiments.CoreMetrics.ab_test(
                    'coach email intervention - growth subtest submessage',
                    alternative_params={
                        'growth neuroscience tip': 4,
                        'growth effort tip': 4,
                        'growth intelligence tip': 4,
                        },
                    core_categories=['retention','coach'])
                test_condition_text += '.' + test_condition_growth_submessage
                tip_text = tip_strings[test_condition_growth_submessage]
            elif test_condition_growth == 'growth framing':
                test_condition_growth_framing = experiments.CoreMetrics.ab_test(
                    'coach email intervention - growth subtest framing',
                    alternative_params={
                        'growth malleable': 4,
                        'growth malleable link': 4,
                        'growth malleable nonexpert': 4,
                        },
                    core_categories=['retention','coach'])
                test_condition_text += '.' + test_condition_growth_framing
                tip_text = tip_strings[test_condition_growth_framing]
        elif test_condition_intervention == 'explanation effect':
            test_condition_explanation = experiments.CoreMetrics.ab_test(
                'coach email intervention - explanation subtest',
                alternative_params={
                    'explanation short silent': 4,
                    'explanation short aloud': 4,
                    'explanation long aloud': 4,
                    },
                core_categories=['retention','coach'])
            test_condition_text += '.' + test_condition_explanation
            tip_text = tip_strings[test_condition_explanation]
        else:
            # long term goals or deliberate practice
            tip_text = tip_strings[test_condition_intervention]
    elif test_condition_top == 'combination condition':
        sig_index = hash_to_index(len(tip_strings), salt='combination')
        test_condition_text += '.' + str(sig_index)
        tip_text = tip_strings[tip_strings.keys()[sig_index]]

    # only show a message at all with 50% probability to allow comparisons of
    # on weeks and off weeks
    if hash_to_index(2, salt='display') == 0 and \
                            not test_condition_top == 'combination condition':
        test_condition_text += '.no display'
        tip_text = None

    # store the tip text in the KA logs
    event_log.log_event('x.intervention.email.test_condition',
                                                        test_condition_text)
    event_log.log_event('x.intervention.email.tip_text', tip_text)

    return tip_text
def add_header_text_to_cards(card, user_exercise):
    """
   Adds header text to a problem card based on exercise and
   A/B test bucket.
   """

    if not (card.exercise_name in target_exercises):
        card.growthHeader = ""  # card refers to the problem object. growthHeader is an attribute of the card.
        return

    # STOPSHIP. The new experiment starts with the KIND OF HEADER A/B test.
    test_condition = experiments.CoreMetrics.ab_test(
        "KIND OF HEADER",
        alternative_params={
            "no header": 5,  # STOPSHIP. As before, unaffected users.
            "header": 1,  # Text message is added but NO links to more info. 
            "learning support":
            1,  # Header has a clickable link to DropDown text or a webpage.
        },
        core_categories='all')

    if test_condition == "no header":
        card.growthHeader = ""

    elif test_condition == "header":
        message = random.choice(mindset_messages)
        card.growthHeader = "<p><em>" + message + "</em></p>"

    elif test_condition == "learning support":
        # STOPSHIP. People in the "learning support" condition are assigned to 1 of 2 sub-conditions.
        # "webpage link" provides a link to a webpage on KA with the LearningCoach study information (like brain workout page in mindset study).
        # Right now this is just a placeholder exercise on our server with the LearningCoach at top.
        # "dropdown link" reveals text on dropdown that provides the LearningCoach study information
        # through a nested series of dropdown text.

        test_subcondition = experiments.CoreMetrics.ab_test(
            "learning support subtest",
            alternative_params={
                "webpage link":
                1,  # provides a link to a webpage on KA with the LearningCoach study information               
                "dropdown link": 1
            },  # reveals text on dropdown that provides the LearningCoach study information
            core_categories='all')
        test_condition += "." + test_subcondition

        # STOPSHIP. "webpage link" provides a link to a webpage on KA with the LearningCoach study information (like brain workout page in mindset study).
        # Right now this is just a placeholder exercise on our server with the LearningCoach at top.
        if test_condition == "learning support.webpage link":
            card.growthHeader = (
                '<p><em>Click here to get tips for motivating yourself and learning more quickly:</em>'
                '&nbsp&nbsp&nbsp<FONT SIZE="-5">'
                '<a href="http://tiny.cc/kalearningcoach" target="_blank">'  # This is a placeholder link to rough demo, actual link can be on KA like brain workout.
                'GET TIPS</a>'
                '</FONT></p>')
    # STOPSHIP. "dropdown link" reveals text on dropdown that provides the LearningCoach study information
    # through a nested series of dropdown text.
    # You can easily see what this complicated code does through demo at tiny.cc/kalearningcoach
        elif test_condition == "learning support.dropdown link":
            message = random.choice(
                growth_messages
            )  # These are assigned here and then used INSIDE of the LearningCoach
            card.growthHeader = (
                '<p><a href="#" class="show-subhint" data-subhint="help-me">'
                'Click here to get tips for motivating yourself and learning more quickly</a></p>'
                '<div class="subhint" id="help-me">'
                '<a href="#" class="show-subhint" data-subhint="mindset-message">'
                'I&#39;m feeling discouraged, I&#39;d like a motivational message.</a>'
                '<div class="subhint" id="mindset-message"><p>' + message +
                '</p>'
                '<p><a href="#" class="show-subhint" data-subhint="mindset-tellmore">Tell me more!</a></p>'
                '<div class="subhint" id="mindset-tellmore">'
                'Even if it&#39;s tough, the time you spend working help you form more '
                'connections that will help you solve future problems.</div>'
                '<p><a href="#" class="show-subhint" data-subhint="mindset-altmore">'
                'How do you motivate yourself?</a></p>'
                '<div class="subhint" id="mindset-altmore">'
                'What would you tell another student to get motivated?</div>'
                '</div>'
                '<p><a href="#" class="show-subhint" data-subhint="learn-strat">'
                'Would you like some suggestions for problem-solving strategies?</a></p>'
                '<div class="subhint" id="learn-strat">'
                '<a href="#" class="show-subhint" data-subhint="what-why-how">'
                'Click here to learn about the'
                ' "<span class="hint_purple" style="font-weight:bold">What? Why? How?</span> strategy</a>'
                '<div class="subhint" id="what-why-how">'
                'To use this strategy, ask yourself these'
                ' "<span class="hint_purple" style="font-weight: bold">'
                'What? Why? How?</span>"'
                ' questions after each hint in a problem.'
                '<br><span class="hint_purple" style="font-weight: bold">'
                'What does this step mean to you?</span>'
                '<br>'
                '<span class="hint_purple" style="font-weight: bold">'
                'Why is it helpful to take this step?</span>'
                '<br><span class="hint_purple" style="font-weight: bold">'
                'How do you know this step is right?</span>'
                '<br>'
                'As a reminder to ask yourself these questions, they'
                'will sometimes appear in '
                '<span class="hint_purple" style="font-weight: bold">'
                'purple</span>.'
                '<br><br>'
                '<a href="#" class="show-subhint" data-subhint="encouragement" data-hidden-text="Hide Information">'
                'What if I can’t do it?</a>'
                '<div class="subhint" id="encouragement">'
                'Many students are not sure what to say, or think '
                'their answer isn’t good. That is fine, as long as you'
                '<span style="font-weight: bold; font-style:italic">'
                ' try</span>'
                ' to think about the question, by typing or saying the answer to yourself.'
                '</div></div></div></div>')

    # TODO - this will record events even if the card is never
    # displayed -- for instance, because the student never goes past
    # the first card in a group of cards.  When interpreting these
    # results, will need to do the extra work of matching these up
    # against problemlog entries, and throwing out the ones which
    # don't match.
    event_log.log_event('x.mindset.test_condition', test_condition)
    event_log.log_event('x.mindset.exercise_name', card.exercise_name)
    problem_type = getattr(card, 'problem_type', 'UNDEFINED')
    event_log.log_event('x.mindset.problem_type', problem_type)
    total_done = getattr(user_exercise, 'total_done', -1)
    event_log.log_event('x.mindset.total_done', total_done)
    event_log.log_event('x.mindset.message_text', card.growthHeader)