Online Quiz Platform: by Group 5
Online Quiz Platform: by Group 5
Online Quiz Platform: by Group 5
BY GROUP 5
outline
define the structures for User and Quiz, which store
information about users and quizzes, respectively.
Create empty vectors users and quizzes to store user
and quiz objects.
• Implement the registerUser() function
• Implement the authenticateUser
• Implement the createQuiz()
• .Implement the takeQuiz()
• Implement the showLeaderboard()
• the main function,
problem statement
The problem statement for this project revolves around the need for a quiz platform that
provides users with the ability to register, create quizzes, and take quizzes.
1User Registration:
- Users need a platform where they can create an account and register their details
securely. This allows them to access personalized features, save their progress, and
track their performance over time.
2. Quiz Creation:
- Educators, trainers, and content creators require a user-friendly platform to create
quizzes tailored to their specific needs. They need the ability to add questions, define
correct answers, and customize the quiz format. This empowers them to design
engaging and interactive assessments for their audience.
3. Quiz Taking:
- Users, such as students or learners, need a platform where they can access a wide
range of quizzes and assessments. They should be able to select quizzes based on
their interests or educational requirements. Taking quizzes provides an opportunity to
test their knowledge, reinforce learning, and receive immediate feedback on their
performance.
Goals
1. User Class:
- Properties: username, password, score
- Methods: getters and setters for properties
2. Quiz Class:
- Properties: quizName, questions (stored as a map with question as key and correct answer as value)
- Methods: getters and setters for properties
3. QuizPlatform Class:
- Properties: users (stored as a vector of User objects), quizzes (stored as a vector of Quiz objects)
- Methods:
- User Registration: Allows a user to register by entering a username and password. The User object is created and added to the
users vector.
- User Authentication: Checks if the entered username and password match any of the registered users in the users vector.
- Quiz Creation: Allows an authenticated user to create a quiz by entering a quiz name, number of questions, and the questions
with their correct answers. The Quiz object is created and added to the quizzes vector.
- Quiz Taking: Allows an authenticated user to select a quiz from the available quizzes and answer the questions. The user's
score is calculated based on the number of correct answers and displayed at the end.
- Leaderboard Display: Displays the users and their scores in descending order based on their scores.
implementation
The implementation includes functions for user
registration, authentication, quiz creation, quiz taking,
and leaderboard display.
The implementation consists of the following functions:
• registerUser(): Handles the user registration process.
• loginUser(): Handles the user login process.
• createQuiz(): Manages the creation of a new quiz.
• takeQuiz(): Guides the user through taking a quiz.
• calculateScore(): Calculates the user's score.
Algorithm
1. User Authentication Algorithm:
```
function authenticateUser(username, password):
for user in users:
if user.username == username and user.password == password:
return true
return false
```
for i in range(numQuestions):
question = promptUserForQuestion()
correctAnswer = promptUserForCorrectAnswer()
quiz.questions[question] = correctAnswer
quizzes.push_back(quiz)
```
3. Quiz Taking Algorithm:
function takeQuiz(selectedQuiz):
score = 0
if userAnswer == correctAnswer:
score += 1
displayScore(score)
function displayLeaderboard():
sort(users by score in descending order)
3. createQuiz(): This function has a time complexity of O(m), where m is the number of
questions in the quiz. It prompts the user to enter each question and its answer,
resulting in a linear time complexity.
4. takeQuiz(): This function has a time complexity of O(k), where k is the number of
questions in the selected quiz. It iterates over each question in the quiz and prompts
the user for an answer, resulting in a linear time complexity.
5. showLeaderboard(): This function has a time complexity of O(n log n), where n is
the number of users. It sorts the `users` vector based on the score using `std::sort`,
which has an average time complexity of O(n log n).
performance analysis
space complexity
1. space complexity of the `users` vector is O(n), where n is
the number of registered users. It stores user objects.