Assembling Classes

Thomas J. Kennedy

Contents:

1 The Problem

Developing questions for quizzes, exams and similar assessments is often difficult. Questions need to have…

Our goal is to work with question pools (i.e., groups of related questions). We want to build a few classes…

Question Pool Class Hierarchy

The two builder classes will be handled by another team. (i.e., they will be provided). Your work will focus on EssayQuestion and QuestionPool. We will pretend that EssayQuestion is the only type of question.

This will be a two-part exercise. This assignment will focus on EssayQuestion and the next assignment will focus on QuestionPool.

1.1 Input

There is no input to this program.

1.2 Output

There is no main function in this program. the EssayQuestion class will evaluated with a test suite within tests/test_essay_quesion.py.

2 Your Tasks

Your task is to create the EssayQuestion class as documented in the UML Class diagram within the The Problem section. You may either:

Your implementation must result in an EssayQuestion class with the following data members:

  1. question_text - an str that contains the actual question text.

  2. feedback_correct - an optional str that provides feedback for correct answers. The default value must be None.

  3. feedback_incorrect - an optional str that provides feedback for incorrect answers. The default value must be None.

  4. points - an optional int that provides the default point value for the question. The default value must be 0.

Your EssayQuestion implementation must provide the following methods:

  1. __init__ - the standard constructor. It must accept a single str parameter (title) which serves as the question text.

  2. __eq__ - compares two EssayQuestion objects by comparing question text and no other fields.

  3. __repr__ - generates debugging output. Your implementation must generate output in the following form…

    EssayQuestion(
        question_text="...",
        feedback_correct="...",
        feedback_incorrect="...",
        points=...
    )
    

    The ellipses are placeholders for the actual values.

  4. __str__ - generates production output. Your implementation must generate output in the following form…

    Points: [points]
    
    [Question Text]
    
    Feedback:
    
        Correct:
            [feedback]  
    
        Incorrect:
            [feedback]  
    

    The items denoted be square brackets are placeholders for the actual values.

3 Mechanics

The test code can be run with…

python3.11 -m pytest -v tests

4 Files

There are two (2) files in this assignment:

You will be working in essay_question.py. Do not modify the other files.

You can access the starting files on GitHub. You may either clone the starting repository (through Git) or download a zip file.

5 Grading

Your grade will be based on the following criteria…

6 Submitting

You will submit your completed copy of essay_question.py as a file upload through Canvas.

Do not alter any of the other source code files, nor change the module interface.