Quiz app

27 views
Skip to first unread message

Lakshyaraj Dash

unread,
Nov 15, 2022, 8:15:06 PM11/15/22
to 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

unread,
Nov 16, 2022, 6:59:16 AM11/16/22
to 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

unread,
Nov 16, 2022, 7:31:13 AM11/16/22
to 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

unread,
Nov 16, 2022, 8:09:18 AM11/16/22
to 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

unread,
Nov 16, 2022, 9:01:32 AM11/16/22
to django...@googlegroups.com
Nice api
But it generates only one question.

Bhuvnesh Sharma

unread,
Nov 16, 2022, 9:31:37 AM11/16/22
to django...@googlegroups.com
Maybe the category you are sending request to contains only one matching question in db?

Lakshyaraj Dash

unread,
Nov 16, 2022, 10:05:09 AM11/16/22
to django...@googlegroups.com
Please tell which category has more than 5 questions. 

Bhuvnesh Sharma

unread,
Nov 16, 2022, 10:08:34 AM11/16/22
to 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.

Reply all
Reply to author
Forward
0 new messages