#1 by Sarah_Barati
I have two apps in Otree that I want to run in parallel. One app creates groups of 6 players, while the other creates groups of 4 players. In the first app, I assigned players to each app with a ratio of 60% to 40%, respectively. In each app, I attempted to set a group matrix based on the players assigned to that app to ensure that only the designated players are grouped together. This approach prevents null results and deadlocks at the wait pages. However, I encountered an issue: the player objects cannot be assigned directly to the group matrix; instead, the player IDs are assigned. As a result, I receive the following error message: Failed to create session: The matrix of integers either has duplicate or missing elements. How can I resolve this issue? this is the code I tried in the first app: def creating_session(subsession): if subsession.round_number == 1: players = subsession.get_players() total_players = len(players) split_indices = { 'quiz': int(total_players * 0.6), 'quiz_CP': total_players - int(total_players * 0.6), } group_assignment = ( ['quiz'] * split_indices['quiz'] + ['quiz_CP'] * split_indices['quiz_CP'] ) random.shuffle(group_assignment) for player, group in zip(players, group_assignment): player.participant.group_assignment = group print(f"Assigned {player.participant.code} to {group}") the code in the two apps to be played in parallel: def creating_session(subsession): players_in_app2 = [ p for p in subsession.get_players() if p.participant.group_assignment == 'quiz' ] print(f"Players assigned to app2: {[p.id_in_subsession for p in players_in_app2]}") group_matrix = [ players_in_app2[i:i + 6] for i in range(0, len(players_in_app2), 6) ] print(f"Group matrix for app2: {[[p.id_in_subsession for p in group] for group in group_matrix]}") subsession.set_group_matrix(group_matrix) the other one: def creating_session(subsession): players_in_app2 = [ p for p in subsession.get_players() if p.participant.group_assignment == 'quiz_CP' ] print(f"Players assigned to app2: {[p.id_in_subsession for p in players_in_app2]}") group_matrix = [ players_in_app2[i:i + 4] for i in range(0, len(players_in_app2), 4) ] print(f"Group matrix for app2: {[[p.id_in_subsession for p in group] for group in group_matrix]}") subsession.set_group_matrix(group_matrix) also for each page, I used the "is displayed" function to avoid seeing the app which is not assigned to that player. like below: @staticmethod def is_displayed(player): participant = player.participant return participant.group_assignment == 'quiz_CP'