def update(db_conn, user, card, response):

    # TODO-3 split up into smaller methods

    if not card.has_assessment():
        return {
            'response': Response({}),
            'feedback': '',
        }

    errors = card.validate_response(response)
    if errors:
        return {'errors': errors}

    score, feedback = card.score_response(response)
    response = Response({
        'user_id': user['id'],
        'card_id': card['entity_id'],
        'unit_id': card['unit_id'],
        'response': response,
        'score': score,
    })

    card_parameters = CardParameters.get(db_conn, entity_id=card['entity_id'])
    previous_response = Response.get_latest(db_conn,
                                            user_id=user['id'],
                                            unit_id=card['unit_id'])

    now = time()
    time_delta = now - (int(previous_response['created'].strftime("%s"))
                        if previous_response else now)

    learned = (previous_response['learned']
               if previous_response else init_learned)
    guess_distribution = card_parameters.get_distribution('guess')
    slip_distribution = card_parameters.get_distribution('slip')

    updates = formula_update(score, time_delta,
                             learned, guess_distribution, slip_distribution)

    response['learned'] = updates['learned']
    response, errors = response.save(db_conn)
    if errors:
        return {'errors': errors, 'feedback': feedback}

    card_parameters.set_distribution('guess', updates['guess_distribution'])
    card_parameters.set_distribution('slip', updates['slip_distribution'])
    card_parameters, errors = card_parameters.save(db_conn)
    if errors:
        return {'errors': errors, 'feedback': feedback}

    return {'response': response, 'feedback': feedback}
:type target:pants.build_graph.target.Target
dataset/ETHPy150Open heiskr/sagefy/server/modules/sequencer/index.py/update--crossover with--dataset/ETHPy150Open pantsbuild/pants/src/python/pants/backend/project_info/tasks/export.py/ExportTask._source_roots_for_target