mercredi 22 juillet 2020

How to stop the influence of other people being simultaneously on a website?

I do a Django survey and everything runs fine if only one person at a time answers it. In one of my functions (when loading one URL), there is a randomizer who randomizes the order of a list. However, if another person answers the survey and opens the url, the randomizer stars working and randomizes the order of the list not only for the second person, but for the first person, too.

How can I stop the effect of the second person on the first one? I dont want the first person to get a new order when another one answers the survey (and opens the url) at the same time.

def RandomDCE(request):
                # Create independent Counters for every Choice Set, so people
                # can use the "Back-Button" in the Browser without increasing the counter
                # "count" for every website-reload in the function
                global count, C1, C2, C3, C4, C5, C6, C7, C8   

                # Randomize the order of Choice Sets for each respondent
                if request.session['count%d' % (user_id)] == 0:
                    global number_list, number_list2, choiceblock
                    number_list = [2, 3, 4, 5, 6, 7, 8, 9]
                    number_list2 = [10, 11, 12, 13, 14, 15, 16, 17]
                    random.shuffle(number_list)
                    random.shuffle(number_list2)



Aucun commentaire:

Enregistrer un commentaire