Module Documentation
This page contains documentation of everything QuizBot has to offer.
Quiz
With this module, you can create quizzes with questions different kinds.
- class quizbot.quiz.quiz.Quiz(author='')[source]
Bases:
objectAn Instance of the class Quiz has a list of questions, which defines the Quiz. You can choose whether
the order of the questions is random
the result of the entered answer is shown after the question
the result of the entered answer of every question is shown after the quiz
- __init__(author='') None[source]
Initializes an instance of the class Quiz.
- Parameters:
author – Author of the quiz
Questions
With this module, you can create questions different kinds.
- class quizbot.quiz.question_factory.Question(question, correct_answer)[source]
Bases:
objectGeneral class for questions.
- __init__(question, correct_answer)[source]
Initialize a question by the question and the correct answer. Additionally, it initializes the user answer as an empty string.
- Parameters:
question – Question of the question-instance as string.
correct_answer – Correct answer of the question in (question specific) type.
- Raises:
AssertionError – If the question or the correct answer is empty.
- class quizbot.quiz.question_factory.QuestionBool(question, correct_answer)[source]
Bases:
QuestionSubclass for questions with a boolean value as answer. Inherits by question.
- __init__(question, correct_answer)[source]
Initialize a question by the question and the correct answer. Additionally, it initializes the user answer as an empty string.
- Parameters:
question – Question of the question-instance as string.
correct_answer – Correct answer of the question as boolean value (True or False).
- Raises:
AssertionError – If the question or the correct answer is not a boolean value.
- class quizbot.quiz.question_factory.QuestionChoice(question, correct_answer)[source]
Bases:
QuestionSubclass for questions with multiple possible and correct answers. Inherits by question.
- __init__(question, correct_answer)[source]
Initialize a question by the question and the correct answer. Additionally, it initializes the user answer as an empty string, the randomness as False and the list of possible answers as a list of correct answers.
- Parameters:
question – Question of the question-instance as string.
correct_answer – Correct answers of the question as string (seperated by comma).
- Raises:
AssertionError – If the question is empty or the count of correct answers is smaller than one.
- class quizbot.quiz.question_factory.QuestionChoiceSingle(question='', correct_answer='')[source]
Bases:
QuestionChoiceSubclass for questions with multiple possible and correct answers. Inherits by question_choice.
- __init__(question='', correct_answer='')[source]
Initialize a question by the question and the correct answer. Additionally, it initializes the user answer as an empty string, the randomness as False and the list of possible answers as an empty list.
- Parameters:
question – Question of the question-instance as string.
correct_answer – Correct answers of the question as list.
- Raises:
AssertionError – If the question is empty or the count of correct answers doesn’t equal one.
- class quizbot.quiz.question_factory.QuestionNumber(question, correct_answer)[source]
Bases:
QuestionSubclass for questions with an integer as answer. Inherits from question.
- __init__(question, correct_answer)[source]
Initialize a question by the question and the correct answer. Additionally, it initializes the user answer as an empty string.
- Parameters:
question – Question of the question-instance as string.
correct_answer – Correct answer of the question as number.
- Raises:
AssertionError – If the question or the correct answer is not a number.
Attempt
With this module you can create one attemp of a quiz.
- class quizbot.quiz.attempt.Attempt(quiz: Quiz)[source]
Bases:
objectAn Instance of the class Attempt has a quiz and a list of the left questions.
- __init__(quiz: Quiz) None[source]
Initializes an instance of the class Attempt. It shuffeles the question if the quiz specifies it.
- Parameters:
quiz – Quiz which wants the user to attempt.
Bot
Telegram bot to create and attempt to quizzes.
- async quizbot.bot.bot.post_init(application)[source]
Set bot commands visible in the Telegram command menu.
Create quiz
Module with methods to create a quiz with a telegram bot
- async quizbot.bot.create_quiz.cancel(update, context)[source]
Cancels a creation ofa quiz by deleting the users’ entries.
- async quizbot.bot.create_quiz.enter_answer(update, context)[source]
After entering the correct answer it tries to process it. If it fails, it asks for the correct answer again. Otherwise, it asks for additional possible answers, if the question is an instance of QuestionChoice. Otherwise, it adds the question to the quiz and asks for the type of the next question.
- async quizbot.bot.create_quiz.enter_password(update, context)[source]
Hashes the password and saves the quiz to the database.
- async quizbot.bot.create_quiz.enter_password_choice(update, context)[source]
After choosing whether to set a password, either asks for the password or saves the quiz without one.
- async quizbot.bot.create_quiz.enter_possible_answer(update, context)[source]
After entering additional possible answers, it asks whether the order of the answers should be random.
- async quizbot.bot.create_quiz.enter_question(update, context)[source]
Asks for the correct answer to the question after entering the question itself.
- async quizbot.bot.create_quiz.enter_quiz_name(update, context)[source]
After entering the name of the quiz, it looks up if the quiz name is occupied. If unique, asks whether the user wants to set a password.
- async quizbot.bot.create_quiz.enter_randomness_question(update, context)[source]
After entering whether the order if the answers should be random, it adds the question to the quiz. After that, it asks for the type of next question.
- async quizbot.bot.create_quiz.enter_randomness_quiz(update, context)[source]
After entering whether the order if the questions should be random, it asks if the result of the question be displayed after the question itself.
- async quizbot.bot.create_quiz.enter_result_after_question(update, context)[source]
After entering whether the result of the question should be displayed after the question itself, it asks if the result of every question be displayed after the quiz.
- async quizbot.bot.create_quiz.enter_result_after_quiz(update, context)[source]
After entering whether the result of every question should be displayed after the quiz, it asks for the name of the quiz?
Attempt quiz
Module with methods to attempt to a quiz with a telegram bot
- async quizbot.bot.attempt_quiz.ask_question(update, context)[source]
Formats the keyboard and prints the current question.
- async quizbot.bot.attempt_quiz.cancel(update, context)[source]
Cancels an attempt to a quiz by deleting the users’ entries.
- async quizbot.bot.attempt_quiz.enter_answer(update, context)[source]
It processes the answer to a question and asks a new question, if possible. Otherwise, it prints results.
- async quizbot.bot.attempt_quiz.enter_password(update, context)[source]
Verifies the password for a password-protected quiz. If correct, starts the attempt. If wrong, reprompts.
Edit quiz
Module with methods to rename and remove a quiz with a telegram bot
- async quizbot.bot.edit_quiz.cancel_edit(update, context)[source]
Cancels the process of deletion or renaming.
- async quizbot.bot.edit_quiz.enter_name_remove(update, context)[source]
Deltes a quiz after entering its’ name.
- async quizbot.bot.edit_quiz.enter_new_name(update, context)[source]
After entering the new name of the quiz, it renames it.