Exemplo n.º 1
0
    def handle(self, *args, **options):
        fake = Factory.create()

        min_number = int(options['min_number'])
        max_number = int(options['max_number'])

        users = User.objects.all()[1:]
        questions = Question.objects.all()
        is_correct = (True, False)
        counter = 1
        for q in questions:
            for i in range(0, randint(min_number, max_number)):
                ans = Answer()

                ans.text = fake.paragraph(nb_sentences=randint(2, 4),
                                          variable_nb_sentences=True)
                ans.user = choice(users)
                ans.question = q
                ans.rating = randint(0, 1500)
                ans.is_correct = choice(is_correct)
                ans.id = counter
                counter += 1
                ans.save()
                self.stdout.write('in question [%d] add ans [%d]' %
                                  (q.id, ans.id))
Exemplo n.º 2
0
    def handle(self, *args, **options):
        fake = Factory.create()

        min_number = int(options['min_number'])
        max_number = int(options['max_number'])

        users = User.objects.all()[1:]
        questions = Question.objects.all()

        for q in questions:
            for i in range(0, randint(min_number, max_number)):
                ans = Answer()
                ans.text = fake.paragraph(nb_sentences=randint(2, 10),
                                          variable_nb_sentences=True)
                ans.auth = choice(users)
                ans.question = q
                ans.save()