예제 #1
0
def readyToEnd(request):
    if len(Round.objects.all()) != total_rounds:
        return redirect('/ready')

    readyList = set(Ready.objects.values_list('user_id', flat=True))
    if request.user.id not in readyList:
        Ready.objects.create(user=request.user)  #create new Ready User
        return render(request, 'facebook/readyToEnd.html')

    while (len(readyList) != Users_num):
        readyList = set(Ready.objects.values_list('user_id', flat=True))

    algo.UpdateScoreStatic(request.user.id)
    worker_id = Users_free.objects.filter(
        user_id=request.user.id).first().worker_id
    submitionCode = str(random.randint(0000, 9999))
    if len(submitionCode) == 3:
        submitionCode = submitionCode + "0"
    w = WorkersInfo(worker_id=worker_id, subCode=submitionCode)
    w.save()
    readyList = []
    time.sleep(1)
    return redirect('/end')
예제 #2
0
    print("HE DID: ", oper, success)
    AgentTimeEnd = timer()
    AgentTimeTook = (AgentTimeEnd - AgentTimeStart) / 60
    print(f"(Agent) Round Number {num_round}, took: {AgentTimeTook} Minutes")
    mylog = Log.objects.filter(id_user=agent_id).last()
    mylog.TimeTookInSec = AgentTimeTook
    mylog.save()
    print("Possible_Operators For The Current Round:\n")
    print(Possible_Operators)
    print('\n')

    endRound = timer()
    print(
        f"Round Number {num_round}, took: {(endRound-startRound-6)/60} Minutes"
    )

    # users_ready = set(Ready.objects.values_list('user_id', flat=True))
    print('----------------  # End Round----------------\n')

Ready.objects.create(user=AgentRequest.user)  #create new Ready User
users_ready = set(Ready.objects.values_list('user_id', flat=True))

while (len(users_ready) != Users_num):
    users_ready = set(Ready.objects.values_list('user_id', flat=True))

time.sleep(5)
Ready.objects.all().delete()
readyList = []

algo.UpdateScoreStatic(userid)
print("Simulrator Finished")