Quiz app

27 visualitzacions
Ves al primer missatge no llegit

Lakshyaraj Dash

no llegida,
15 de nov. 2022, 20:15:0615/11/22
a django...@googlegroups.com
Hello everyone,
I'm on my way to create a quiz app. I want that a loggedin user should get 5 questions randomly when he/she is visiting everytime.
Eg: 
On first visit
Q1. Who's the CEO of Facebook ?

On second visit
Q2. Who's the CEO of Google ?

Thanks and regards
Lakshyaraj Dash

Clive Bruton

no llegida,
16 de nov. 2022, 6:59:1616/11/22
a django...@googlegroups.com
Questions.objects.all().order_by('?')[:5]

ie get all the rows from the Questions table, in a random order, then
show me the first five.

https://docs.djangoproject.com/en/dev/topics/db/queries/#limiting-
querysets


-- Clive
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to django-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/
> d/msgid/django-users/CAF7qQgAAJinHYUKhY_M-
> Z0Y1ecrcHcWTyNHuHkSLdyV7QsFSqw%40mail.gmail.com.

Sebastian Jung

no llegida,
16 de nov. 2022, 7:31:1316/11/22
a django...@googlegroups.com
Hello Lakshyaraj,

I would create a app quiz with model quiz with a charfield. Then when get open 8 would get highesr id from model then randomizer and then get from database entity with this id. When you need 5 then get list of random 5 ids in this range and get all from database.

Then yoz render it back.

Write if yoz have Problems in implementation 

Bhuvnesh Sharma

no llegida,
16 de nov. 2022, 8:09:1816/11/22
a django...@googlegroups.com
Hi lakshayaraj,
Just in case you need api for the quiz app, you can checkout the open db i created for storing questions and answers. Link:-  http://quizry.in/ 

Thanks and Regards

Lakshyaraj Dash

no llegida,
16 de nov. 2022, 9:01:3216/11/22
a django...@googlegroups.com
Nice api
But it generates only one question.

Bhuvnesh Sharma

no llegida,
16 de nov. 2022, 9:31:3716/11/22
a django...@googlegroups.com
Maybe the category you are sending request to contains only one matching question in db?

Lakshyaraj Dash

no llegida,
16 de nov. 2022, 10:05:0916/11/22
a django...@googlegroups.com
Please tell which category has more than 5 questions. 

Bhuvnesh Sharma

no llegida,
16 de nov. 2022, 10:08:3416/11/22
a django...@googlegroups.com
Don't select any category or difficulty then you'll get random questions( you can select amount if you want) . Or if you want questions from a particular category you can also post new questions in that category which will be available once I approve those questions.

Respon a tots
Respon a l'autor
Reenvia
0 missatges nous