"""Setup of rounds Categories are configured in session config like: ```primary = ['male', 'female'], secondary = ['work', 'family']``` Numbers in block config corresponds to 1st and 2nd element of corresponding pair """ import copy # All 4 randomizations of the test # primary 1 left round 1-4, then switch; secondary 1 left and fixed BLOCKS1 = { # e.g: male vs female 1: { 'title': "1", 'practice': True, 'left': {'primary': 1}, 'right': {'primary': 2}, 'round_nr': 1, }, # e.g: work vs family 2: { 'title': "2", 'practice': True, 'left': {'secondary': 1}, 'right': {'secondary': 2}, 'round_nr': 2, }, # e.g: male+work vs female+family 3: { 'title': "3", 'practice': False, 'left': {'primary': 1, 'secondary': 1}, 'right': {'primary': 2, 'secondary': 2}, 'round_nr': 3, }, 4: { 'title': "4", 'practice': False, 'left': {'primary': 1, 'secondary': 1}, 'right': {'primary': 2, 'secondary': 2}, 'round_nr': 4, }, # e.g: female vs male 5: { 'title': "5", 'practice': True, 'left': {'primary': 2}, 'right': {'primary': 1}, 'round_nr': 5, }, # e.g: female+work vs male+family 6: { 'title': "6", 'practice': False, 'left': {'primary': 2, 'secondary': 1}, 'right': {'primary': 1, 'secondary': 2}, 'round_nr': 6, }, 7: { 'title': "7", 'practice': False, 'left': {'primary': 2, 'secondary': 1}, 'right': {'primary': 1, 'secondary': 2}, 'round_nr': 7, }, } # primary 1 left round 1-4, then switch; secondary 2 left and fixed BLOCKS2 = { # e.g: male vs female 1: { 'title': "1", 'practice': True, 'left': {'primary': 1}, 'right': {'primary': 2}, 'round_nr': 1, }, # e.g: work vs family 2: { 'title': "2", 'practice': True, 'left': {'secondary': 2}, 'right': {'secondary': 1}, 'round_nr': 2, }, # e.g: male+work vs female+family 3: { 'title': "3", 'practice': False, 'left': {'primary': 1, 'secondary': 2}, 'right': {'primary': 2, 'secondary': 1}, 'round_nr': 3, }, 4: { 'title': "4", 'practice': False, 'left': {'primary': 1, 'secondary': 2}, 'right': {'primary': 2, 'secondary': 1}, 'round_nr': 4, }, # e.g: female vs male 5: { 'title': "5", 'practice': True, 'left': {'primary': 2}, 'right': {'primary': 1}, 'round_nr': 5, }, # e.g: female+work vs male+family 6: { 'title': "6", 'practice': False, 'left': {'primary': 2, 'secondary': 2}, 'right': {'primary': 1, 'secondary': 1}, 'round_nr': 6, }, 7: { 'title': "7", 'practice': False, 'left': {'primary': 2, 'secondary': 2}, 'right': {'primary': 1, 'secondary': 1}, 'round_nr': 7, }, } # primary 1 right round 1-4, then switch; secondary 1 left and fixed BLOCKS3 = { # e.g: male vs female 1: { 'title': "1", 'practice': True, 'left': {'primary': 2}, 'right': {'primary': 1}, 'round_nr': 1, }, # e.g: work vs family 2: { 'title': "2", 'practice': True, 'left': {'secondary': 1}, 'right': {'secondary': 2}, 'round_nr': 2, }, # e.g: male+work vs female+family 3: { 'title': "3", 'practice': False, 'left': {'primary': 2, 'secondary': 1}, 'right': {'primary': 1, 'secondary': 2}, 'round_nr': 3, }, 4: { 'title': "4", 'practice': False, 'left': {'primary': 2, 'secondary': 1}, 'right': {'primary': 1, 'secondary': 2}, 'round_nr': 4, }, # e.g: female vs male 5: { 'title': "5", 'practice': True, 'left': {'primary': 1}, 'right': {'primary': 2}, 'round_nr': 5, }, # e.g: female+work vs male+family 6: { 'title': "6", 'practice': False, 'left': {'primary': 1, 'secondary': 1}, 'right': {'primary': 2, 'secondary': 2}, 'round_nr': 6, }, 7: { 'title': "7", 'practice': False, 'left': {'primary': 1, 'secondary': 1}, 'right': {'primary': 2, 'secondary': 2}, 'round_nr': 7, }, } # primary 1 left round 1-4, then switch; secondary 2 left and fixed BLOCKS4 = { # e.g: male vs female 1: { 'title': "1", 'practice': True, 'left': {'primary': 2}, 'right': {'primary': 1}, 'round_nr': 1, }, # e.g: work vs family 2: { 'title': "2", 'practice': True, 'left': {'secondary': 2}, 'right': {'secondary': 1}, 'round_nr': 2, }, # e.g: male+work vs female+family 3: { 'title': "3", 'practice': False, 'left': {'primary': 2, 'secondary': 2}, 'right': {'primary': 1, 'secondary': 1}, 'round_nr': 3, }, 4: { 'title': "4", 'practice': False, 'left': {'primary': 2, 'secondary': 2}, 'right': {'primary': 1, 'secondary': 1}, 'round_nr': 4, }, # e.g: female vs male 5: { 'title': "5", 'practice': True, 'left': {'primary': 1}, 'right': {'primary': 2}, 'round_nr': 5, }, # e.g: female+work vs male+family 6: { 'title': "6", 'practice': False, 'left': {'primary': 1, 'secondary': 2}, 'right': {'primary': 2, 'secondary': 1}, 'round_nr': 6, }, 7: { 'title': "7", 'practice': False, 'left': {'primary': 1, 'secondary': 2}, 'right': {'primary': 2, 'secondary': 1}, 'round_nr': 7, }, } BLOCKS = [BLOCKS1, BLOCKS2, BLOCKS3, BLOCKS4] def configure(block, config): """Insert categories' names from config into block setup block: {'left': {'primary': 1, 'secondary': 1}, 'right': {'primary': 2, 'secondary': 2}} config: {'primary': ['male', 'female'], 'secondary': ['work', 'family']} result: {'left': {'primary': 'male', 'secondary': 'work'}, 'right': {'primary': 'female', 'secondary': 'family'}} """ result = copy.deepcopy(block) for side in ['left', 'right']: for cls, idx in block[side].items(): result[side][cls] = config[cls][idx - 1] return result