The quizzing Package is about creating, managing, and conducting interactive quizzes for users, divided into two sub-packages: question_bank and doquiz.
Project description
quizzing Package
Author: Huan He, Qijia Zheng
The quizzing Package is about creating, managing, and conducting interactive quizzes for users, divided into two sub-packages: question_bank and doquiz.
question_bank Sub-package
question_loader Module
This module is responsible for loading, classifying, and analyzing quiz questions. It provides utilities to organize questions and perform statistical analysis on them. This module uses inheritance.
Methods
-
load_questions_from_file(filepath): Load questions from a JSON or CSV file and return them as a list of dictionaries.
Parameters:
filepath: The file path of the JSON or CSV file containing questions. -
classify_questionsby_by_category(questions): Classify questions by category and calculate questions numbers. Returns a dictionary with:classification: Questions grouped by their categories.stats: A count of questions per category.
Parameters:
questions: A list of question dictionaries.
-
classify_questionsby_by_difficulty(questions): Classify questions by difficulty and calculate questions numbers. Returns a dictionary with:classification: Questions grouped by their difficulties.stats: A count of questions per difficulty.
Parameters:
questions: A list of question dictionaries.
-
get_random_questions(category, difficulty, number): Retrieve a specified number of random questions from the given category and difficulty.
Parameters:
questions: A list of available questions.
category: The category to filter questions by.
difficulty: The difficulty to filter questions by.number: The number of questions to retrieve.
question_manager Module
This module is responsible for managing the question bank, including adding, removing, and updating questions.
Methods
-
add_question(question): Add a new question to the question bank.
Parameters:
question: A dictionary representing the question to add. -
remove_question(question_id): Remove a question from the question bank by its unique identifier.
Parameters:
question_id: The ID of the question to be removed. -
update_question(question_id, updated_data): Update the details of an existing question, such as its text or answer options.
Parameters:
question_id: The ID of the question to update.
updated_data: A dictionary containing the updated question information. -
get_question_by_id(question_id): Retrieve a specific question from the question bank by its unique identifier. Parameters:question_id: The ID of the question to retrieve. Returns: The question matching the ID or None if not found. -
list_all_questions(): List all the questions currently stored in the question bank. Returns: A list of all available questions.
do_quiz Sub-package
quiz_session Module
This module is responsible for managing the whole quiz session, including starting a quiz, submitting answers, calculating scores and ending the quiz.
Attributes
score: The current score of the quiz session.questions: A list to store questions for this quiz.current_question_index: Index of the current question to be answered.wrong_answers: A list to store the incorrect questions, user's answers and the correct answers.
Methods
-
__init__(): Initialize a new instance of the class with basic attributes. -
start_quiz(questions): Start a new quiz session and reset the state of quiz. The questions used for the quiz are generated from question manager.
Parameters:
questions: A list of questions selected for this quiz. -
submit_answer(answer): Submit the user's answer for the current question and checks if the user's answer is correct. If correct, add one score, otherwise add the question with the user's answer towrong_answers. After these, addcurrent_question_indexby one moving to next question.
Parameters:
answer: The answer given by the user. -
end_quiz(): End the quiz and return the total score achieved duiring the session. -
get_wrong_answers(): Check whether users get the full scores. If so, sent them congratulation message, otherwise show them the details of questions they answerd wrong.
quiz_timer Module
This module is designed to manage time tracking during the quiz session. It allows us to start a timer, check the remaining time for quiz and end the timer.
Attributes
start_time: The timestamp when the timer is started.duration: Users need to complete the exam within that time.
Methods
-
__init__(): Initialize a new instance of the class with basic attributes. -
start_timer(duration): Record the current time as start time and set duration for the timer.
Parameters:
duration: Total time for the timer. -
check_time_remaining(): Calculate the elapsed time since started and return the remaining time by subtracting it from the duration. Returns 0 if the timer has expired. -
end_timer(): End the timer and reset the start time.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quizzing-0.0.1.tar.gz.
File metadata
- Download URL: quizzing-0.0.1.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5238e980b2d443851f3347e1ddd378eb07289ae5eb6925f063b7d4be4b42ea90
|
|
| MD5 |
3f39267ba3a59075bae474d01d9de7c6
|
|
| BLAKE2b-256 |
9a436f49e37e05e1eee0d20ddfb48e6f2f1f6e0e076a053ee3b9dc7d7b9edac6
|
File details
Details for the file quizzing-0.0.1-py3-none-any.whl.
File metadata
- Download URL: quizzing-0.0.1-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
630e5aa5d3d14d67736cab38044ee8ea0c2a95a37fdad7e49fb66b320d59471c
|
|
| MD5 |
47bc44e51a548d8a531aa5c3644e0d54
|
|
| BLAKE2b-256 |
d5b6a38916f7a00d19f069bd5a4a56bd88607cc658cfb3bc0552ce08eda77943
|