An application that would let you create, edit and attempt quizzes (intended for tech quizzes), along with keeping a profile. .Here’s a breakdown of the project:
The project is divided into 2 applications:
- users: For handling user’s profile.
- quiz: For handling quizzes.
- Profile: A model for storing a user’s data (built-in User Model), bio, and profile pictures. I used Cloudinary for saving user’s uploads on the cloud.
- Quizzer: Stores quiz’s title, author (Foreign Key to User), private(For keeping quizzes unpublished), Reattempt( Boolean value for allowing multiple attempts), bg_pic (background picture for quiz modal, stored in the cloud with Cloudinary field), tags (Used taggit for creating a taggable object). Questions of the quiz, number of attempters, tags are retrieved using class methods.
- Questions: Stores question text, options(limited to 4), points(for particular question), answer( created a custom RangeField for limiting values to 4) and obviously a foreign key to Quizzer model, quizz.
- QuizScore: Stores user’s(Foreign Key to User) score(Integer Field) of the quiz(Foreign Key to Quizzer).
- AnonymousUsersData: stores user’s name, the score for quizzes attempted by shareable quizzes.
- QuizForm: A model form for taking Quizzer fields.[tags limited to 3 or more]
- QuestionsFormset: A formset for taking multiple Questions model inputs.
- UserRegsitrationForm: Form for registering users, used built-in UserCreationForm.
- UserUpdateForm: Form for updating user’s data (name and address).
- ProfileUpdateForm: Form for updating user’s profile (bio and pic).
- / : Home Page for all quizzes.
- /register/ : Registration Page.
- /login/ : Login Page.
- /profile/ : Logged In user’s profile.
- /profile/<str:view_user>/ : For viewing other‘s profile.
- /quiz/add/ : Adding quizzes.
- /quiz/edit/<str:quiz_tit>/ : For editing quiz.
- /quiz/shared/<slug:username>/<slug:quiz_name>/<str:id>/ : Url pattern for shared quizzes.
- /quiz/<str:slug>/ : Page for attempting quiz.
- /api-auth/: Api Views for all the pages.
- ShareQuizzView: The view let’s anonymous users to attempt shared quizzes and adds the user’s data to AnonymousUsersData models.
- add_quiz_form: Adds quizzes via QuizForm and QuestionsFormset, at least one is required, needs the user to be logged in.
- edit_quiz_form: formsets are used for editing the quizzes, allows authors to edit quizzes by their title.
- QuizzView: allows attempting public quizzes by the users, redirects if reattempts are not allowed or quiz doesnot exists, and updates or adds the score of the quiz to the user’s profile data.
- Quizzes: Lists the quizzes which are public by other users, and are not yet attempted by the user. Search feature is available
- register: Register users with built-in registration form. Signals are used to create profiles of the registered users.
- profile: Allows users to update their name, bio, pic and created quizzes, including private and public quizzes with a share option. Lists all the user’s public and attempted quizzes with their score.
- Secret Keys are stored using decouple, which lets you read values from environment variable. Since the application is hosted on heroku, secret key’s are stored in heroku’s environment variables.
2. taggit was used to store tags, widget_tweaks for adding attributes to jinja tags, cloudinary for storing user’s upload.
3. whitenoise used for storing static files, dj_database_url for updating database to heroku’s default database.
4. Factory Boy used for generating fake quizzes and users.
python manage.py setup_test_data command (present at QuizCreator/quiz/management/commands/) generates fake data.
Github Link: https://github.com/AtufaShireen/QuizCreator.
Project Link: https://quizzier.herokuapp.com/.