Hi Chris,num_waiting_players and all that needs to be defined by me, right? I cannot find any function in the readthedocs files called like that.And also the participant.wait_page_arrival needs to be defined by me first? How do I ensure that it takes the moment of arrival? Do I just set time.time() to a participant variable?Sorry, but often seemingly trivial information is missing for me (as I am not a programmer), which costs me hours to figure out.. :(Thanks and best-MiriamOn Tuesday, November 23, 2021 at 4:48:32 PM UTC+1 Miriam wrote:
Hi Chris,Thank you for your fast response. Just to make sure that I understand this code correctly..That sounds like what I need, yes! I will try that, thank you!Cheers,MiriamOn Tuesday, November 23, 2021 at 4:11:33 PM UTC+1 Chris @ oTree wrote:Take a look at waiting_too_long in otree-snippets. that app tries to group people into groups of 2, but if someone is waiting for more than X minutes they get put into a solo task.It sounds like what you want is a modification of that. For example, the below code tries to group people into groups of 4, but if at least 3 people have been waiting longer than 5 minutes, it groups them, and if 2 people have been waiting longer than 6 minutes, it groups them. Does this solve your use case?def waiting_seconds(player):participant = player.participantimport timereturn time.time() - participant.wait_page_arrivaldef num_waiting_minutes(waiting_players, num_minutes):count = 0for p in waiting_players:if waiting_seconds(p) >= num_minutes * 60:count += 1return countdef group_by_arrival_time_method(subsession, waiting_players):if len(waiting_players) >= 4:return waiting_players[:4]if num_waiting_minutes(waiting_players, 5) >= 3:return waiting_playersif num_waiting_minutes(waiting_players, 6) >= 2:return waiting_players# etc...
Upgrading Introduction_Game
Traceback (most recent call last):
File "/usr/local/bin/otree", line 8, in <module>
sys.exit(execute_from_command_line())
File "/usr/local/lib/python3.7/site-packages/otree/main.py", line 113, in execute_from_command_line
call_command(cmd, *argv[2:])
File "/usr/local/lib/python3.7/site-packages/otree/cli/base.py", line 32, in call_command
module.Command().outer_handle(args)
File "/usr/local/lib/python3.7/site-packages/otree/cli/base.py", line 10, in outer_handle
return self.handle(**vars(options))
File "/usr/local/lib/python3.7/site-packages/otree/cli/remove_self.py", line 49, in handle
make_noself(app_name)
File "/usr/local/lib/python3.7/site-packages/otree/cli/remove_self.py", line 251, in make_noself
write(black_format('\n'.join(lines2)))
File "/usr/local/lib/python3.7/site-packages/otree/cli/remove_self.py", line 285, in black_format
txt, mode=black.Mode(line_length=100, string_normalization=False)
File "/usr/local/lib/python3.7/site-packages/black/__init__.py", line 1057, in format_str
src_node = lib2to3_parse(src_contents.lstrip(), mode.target_versions)
File "/usr/local/lib/python3.7/site-packages/black/parsing.py", line 96, in lib2to3_parse
raise exc from None
black.parsing.InvalidInput: Cannot parse: 18:0: class Group(BaseGroup):
Take a look at waiting_too_long in otree-snippets. that app tries to group people into groups of 2, but if someone is waiting for more than X minutes they get put into a solo task.It sounds like what you want is a modification of that. For example, the below code tries to group people into groups of 4, but if at least 3 people have been waiting longer than 5 minutes, it groups them, and if 2 people have been waiting longer than 6 minutes, it groups them. Does this solve your use case?def waiting_seconds(player):participant = player.participantimport timereturn time.time() - participant.wait_page_arrivaldef num_waiting_minutes(waiting_players, num_minutes):count = 0for p in waiting_players:if waiting_seconds(p) >= num_minutes * 60:count += 1return countdef group_by_arrival_time_method(subsession, waiting_players):if len(waiting_players) >= 4:return waiting_players[:4]if num_waiting_minutes(waiting_players, 5) >= 3:return waiting_playersif num_waiting_minutes(waiting_players, 6) >= 2:return waiting_players# etc...
On Tuesday, November 23, 2021 at 6:15:48 AM UTC-8 Miriam wrote: