Gathering Iterables
Thomas J. Kennedy
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…
multiple variants
feedback for correct answers
feedback for incorrect answers
possible points
Our goal is to work with question pools (i.e., groups of related questions). We want to build a few classes…
The two builder classes will be handled by another team. (i.e., they will be provided). Your work will focus on
EssayQuestion
andQuestionPool
. We will pretend thatEssayQuestion
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:
-
implement the
QuestionPool
class from scratch with a basic class -
implement the
QuestionPool
class with the@dataclass
decorator
Your implementation must result in an QuestionPool
class with the following data members:
-
title
- anstr
that stores a short name describing theQuestionPool
. -
questions
- alist
ofEssayQuestion
objects. The starting value must be an emptylist
.
Your QuestionPool
implementation must provide the following methods:
-
__init__
- the standard constructor. It must accept a singlestr
parameter (title) which serves as the question text. -
__eq__
- compares twoQuestionPool
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. -
__iter__
- provides an iterator that allows access to the containedEssayQuestion
objects. -
__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:
essay_question.py
question_pool.py
test/test_essay_question.py
test/test_question_pool.py
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…
- test 000 - code passes
test_all_fields_present
- test 001 - code passes
test_default_values
- test 002 - code passes
test_eq_identity
- test 003 - code passes
test_eq_are_equal
- test 004 - code passes
test_eq_not_equal
- test 005 - code passes
test_iter_empty
- test 006 - code passes
test_iter
- test 007 - code passes
test_repr
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.