Gathering Iterables

Thomas J. Kennedy

Contents:

1 The Problem

This assignment deals with the same problem as Assembling Classes.

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 assignment will focus on QuestionPool You will need your copy of EssayQuestion code from the previous assignment.

1.1 Input

There is no input to this program.

1.2 Output

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

2 Your Tasks

Start by grabbing a completed copy of EssayQuestion from the previous assignment

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

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

  1. title - an str that stores a short name describing the QuestionPool.

  2. questions - a list of EssayQuestion objects. The starting value must be an empty list.

Your QuestionPool 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 QuestionPool objects by comparing the questions contained in each pool. For two pools to be equal… they must have matching titles and contain matching questions in the same order.

  3. __iter__ - provides an iterator that allows access to the contained EssayQuestion objects.

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

    QuestionPool(
        title="...",
        questions=[
            EssayQuestion(
                question_text="...",
                feedback_correct="...",
                feedback_incorrect="...",
                points=...
            ),
            EssayQuestion(
                question_text="...",
                feedback_correct="...",
                feedback_incorrect="...",
                points=...
            ),
            EssayQuestion(
                question_text="...",
                feedback_correct="...",
                feedback_incorrect="...",
                points=...
            )
        ]
    )
    

    The ellipses 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 four (4) files in this assignment:

You will be working in question_pool.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 question_pool.py as a file upload through Canvas.

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