'Populates DragAndDrop variables from user_answer and correct_answer.
If correct_answer is dict, converts it to list.
Correct answer in dict form is simpe structure for fast and simple
grading. Example of correct answer dict example::
correct_answer = {\'name4\': \'t1\',
\'name_with_icon\': \'t1\',
\'5\': \'t2\',
\'7\': \'t2\'}
It is draggable_name: dragable_position mapping.
Advanced form converted from simple form uses \'exact\' rule
for matching.
Correct answer in list form is designed for advanced cases::
correct_answers = [
\'draggables\': [\'1\', \'2\', \'3\', \'4\', \'5\', \'6\'],
\'targets\': [
\'s_left\', \'s_right\', \'s_sigma\', \'s_sigma_star\', \'p_pi_1\',  \'p_pi_2\'],
\'rule\': \'anyof\'},
\'draggables\': [\'7\', \'8\', \'9\', \'10\'],
\'targets\': [\'p_left_1\', \'p_left_2\', \'p_right_1\', \'p_right_2\'],
\'rule\': \'anyof\'
Advanced answer in list form is list of dicts, and every dict must have
3 keys: \'draggables\', \'targets\' and \'rule\'. \'Draggables\' value is
list of draggables ids, \'targes\' values are list of targets ids, \'rule\'
value one of \'exact\', \'anyof\', \'unordered_equal\', \'anyof+number\',
\'unordered_equal+number\'
Advanced form uses "all dicts must match with their rule" logic.
Same draggable cannot appears more that in one dict.
Behavior is more widely explained in sphinx documentation.
Args:
user_answer: json
correct_answer: dict or list'

def __init__(self, correct_answer, user_answer):

    self.correct_groups = []
    self.correct_positions = []
    self.user_groups = []
    self.user_positions = []
    if isinstance(correct_answer, dict):
        tmp = []
        for (key, value) in correct_answer.items():
            tmp.append({'draggables': [key], 'targets': [value], 'rule': 'exact'})
        correct_answer = tmp
    user_answer = json.loads(user_answer)
    self.excess_draggables = dict(((users_draggable.keys()[0], True) for users_draggable in user_answer))
    user_answer = flat_user_answer(user_answer)
    for answer in correct_answer:
        user_groups_data = []
        user_positions_data = []
        for draggable_dict in user_answer:
            draggable_name = draggable_dict.keys()[0]
            if (draggable_name in answer['draggables']):
                user_groups_data.append(draggable_name)
                user_positions_data.append(draggable_dict[draggable_name])
                self.excess_draggables[draggable_name] = False
        self.correct_groups.append(answer['draggables'])
        self.correct_positions.append({answer['rule']: answer['targets']})
        self.user_groups.append(user_groups_data)
        self.user_positions.append({'user': user_positions_data})
