Skip to main content

An package able to make a quiz.

Project description

Quiz Python Package Description

Group members: Zetian Zhao(skywalker007-cpu), Haoxiang Xu

Table of Contents

Build Status

Description

The Quiz Python package is a package that allows users to create quizzes and take them. The package includes three classes: Quiz, Question, and Response. The Quiz class is the main class of the package and is used to create a quiz object. The Question class represents a question in the quiz, and the Response class represents a response from a student to a question in the quiz. The package also includes three subclasses of the Question class: MultipleChoiceQuestion, ShortAnswerQuestion, and TrueFalseQuestion.

Installation

To install the Quizzing package, you can use the following command:

pip install git+

Usage

  • Import the Quizzing package:

    from quizzing import Quizzing
    
  • Create a quiz object:

    quiz = Quiz()
    # OR
    quiz = Quiz(questions, responses, API_KEY)
    
    • questions Optional (List[Question]): A dictionary of Question objects that represent the questions in the quiz.
    • responses Optional (List[Response]): A dictionary of Response objects that represent the responses to the quiz.
    • API_KEY Optional (str): The API key used to access the OpenAI API for marking the responses.

List of Classes

Quiz

  • Description: This class is the main class of the package. It is used to create a quiz object. The class has a list of Question objects and a dictionary of Response objects. The class also has a method to take the quiz and submit responses, and a method to mark the quiz using the OpenAI API.

Included Variables

  • questions: A nested dictionary of Question objects that each key-value pair represent the question ID and the question object.
  • responses: A dictionary of Response objects that each key-value pair represent the student ID and their response to the quiz.
  • API_KEY (str): The API key used to access the OpenAI API for marking the responses.

Included Methods

  • __init__(self, questions: List[Question], responses: dict[str, Response], API_KEY: str): The constructor method for the Quiz class. It initializes the questions, responses, and API_KEY variables.
  • __str__(self): A method that returns a string that list the questions.
  • add_question(self, question: Question): A method that adds a Question object to the questions list. (unable to add a question if the quiz has already started, and will show "quiz is already started, and you cannot add question anymore!" to the user for notification.)
  • remove_question(self, question: Question): A method that removes a Question object from the questions list. (unable to add a question if the quiz has already started, and will return corresponding string for notification.)
  • add_response(self, response: Response): A method that adds a Response object after user reply to the question during the quiz to the responses list. (unable to add a response if there is no quiz happening, and will return corresponding string for notification.)
  • take_quiz(self, student_id): A method that allows the user to take the quiz and submit responses. (unable to take the quiz if there's no questions, and will return corresponding string for notification.)
  • mark_quiz(self, student_id, type): A method that marks the quiz using the OpenAI API and returns the results (format - gained score/total score). (unable to mark the quiz if the quiz has not been taken, and will return corresponding string for notification.)
    • type: auto(AI) or manual(human)

Question

  • Description: This class represents a question in the quiz, and data format is following a dictionary format, which the values are question id, question text, correct answer, score, and type of the question with corresponding key.

Included Variables

  • question_id: The ID of the question.
  • description: The text of the question.
  • answer: The correct answer to the question.
  • score: The score of the question.

Included Methods

  • __init__(self, question: str, score: int): The constructor method for the Question class. It initializes the question and score variables.
  • __str__(self): A method that returns a string representation of the question.

SubClasses (extend from Question)

  • MultipleChoiceQuestion: A subclass of Question that represents a multiple-choice question, and has an additional options variable.
    • extra attribute: options in the __init__ function: A list of options for the multiple-choice question.
  • ShortAnswerQuestion: A subclass of Question that represents a short answer question.
    • extra attribute: notice in the __init__ function: A notice for user when they do the short answer question. For example, "Please write your answer in one sentence."
  • TrueFalseQuestion: A subclass of Question that represents a true/false question.
    • extra attribute: options in the __init__ function: A list of options that only contain true/false.

Response

  • Description: This class represents a response from a student to a question in the quiz.

Included Variable

  • student_id: The ID of the student who submitted the response.
  • response: a JSON format object that contains the student's response to the question.

Included Methods

  • __init__(self, student_id: str, response: List[str]): The constructor method for the Response class. It initializes the student_id and response variables.
  • __str__(self): A method that returns a string representation of the response.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quizzingpackage-0.0.1.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

QuizzingPackage-0.0.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file quizzingpackage-0.0.1.tar.gz.

File metadata

  • Download URL: quizzingpackage-0.0.1.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for quizzingpackage-0.0.1.tar.gz
Algorithm Hash digest
SHA256 63b1c1fe41f78b033dd66b131ebf8ce00dbfb4cb05359207ecafb414854bad4a
MD5 eafbc2857803ddea4bac762ca38d33f4
BLAKE2b-256 5f0fdaee402326321468794118620ec1394fa9bde766d53ce76b603f6cddc557

See more details on using hashes here.

File details

Details for the file QuizzingPackage-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for QuizzingPackage-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ba00f07246d29a21a82bf67d06efb657b772e29f3d45e86068c6cd423753bc90
MD5 a17f72a6b1c3fe48963c750d961522fa
BLAKE2b-256 8e9eaec237dc0b5b5399a958b09b673dbe9fe200426377a9e9e72a53f18ba1cd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page