def make_param(ans_str, att_str, variable_list={}):
    """
    input: answer string, attemp string,
    optional input: variable dictionary {'variable_name':value to test, 'variable_name2':value}
    return: list of dict with format
        'user_id':d['user_id'],'answer':d['answer'], 'attempt':d['attempt'],
        'ans_tree':eval_tree,'att_tree':eval_tree_att
    """

    parse_tree = webwork_parser.parse_webwork(ans_str)
    if parse_tree[0] == None:
        print 'parse_tree empty'
        return {}
    eval_tree = Eval_parsed.eval_parsed(parse_tree[0], variable_list)
    if eval_tree == None:
        print 'eval_tree empty'
        return {}

    parse_tree_att = webwork_parser.parse_webwork(att_str)
    if parse_tree_att[0] == None:
        print 'parse_tree empty'
        return {}
    eval_tree_att = Eval_parsed.eval_parsed(parse_tree_att[0], variable_list)
    if eval_tree_att == None:
        print 'eval_tree empty'
        return {}

    params = {'answer':ans_str, 'attempt':att_str, 'ans_tree':eval_tree, 'att_tree':eval_tree_att}

    return params
def make_params(problem_id, part_id, problem_part_collection, variable_list={}):
    """return list of dict with format
    'user_id':d['user_id'],'answer':d['answer'], 'attempt':d['attempt'],
    'ans_tree':eval_tree,'att_tree':eval_tree_att"""
    params = []
    count = 0
    for d in problem_part_collection[problem_id,part_id]:
        print '\r',count,
        count += 1
        if d['answer']:
            parse_tree = webwork_parser.parse_webwork(d['answer'])
            if parse_tree[0] == None:
                print 'parse_tree empty'
                continue
            eval_tree = Eval_parsed.eval_parsed(parse_tree[0], variable_list)
            if eval_tree == None:
                print 'eval_tree empty'
                continue

            parse_tree_att = webwork_parser.parse_webwork(d['attempt'])
            if parse_tree_att[0] == None:
                print 'parse_tree empty'
                continue
            eval_tree_att = Eval_parsed.eval_parsed(parse_tree_att[0], variable_list)
            if eval_tree_att == None:
                print 'eval_tree empty'
                continue

            params += [{'user_id':d['user_id'], 'user_var':d['var'], 'timestamp':d['timestamp'], 'answer':d['answer'], 'attempt':d['attempt'],
                        'ans_tree':eval_tree, 'att_tree':eval_tree_att}]
        else:
            print 'no answer'
    return params