Package: pyassignment
pyAssignmentA python module for authoring homework assignments and assessments.DescriptionThis is a rewrite of thepyHomeworkmodule, which was created to help
write homework assignments for physics classes. The rewrite is currently in progress.FeaturesBuild assignments and compute solutions in pure Python.Output assignment to LaTeX and build a PDF.Output assignment to a Blackboard quiz.Create problem set / Blackboard quiz pair. I.e. a Blackboard quiz that asks questions about
a problem set distributed as PDF.`pyErrorProp'integration. Tolerances for numerical solutions
can be automatically calculated using error propagation.InstallingTo installpyAssignment, code this repository and usepipto install.$gitclonehttps://github.com/CD3/pyAssignment
$cdpyAssignment
$pipinstall.pyAssignmentdepends on the following modules available on PyPi, which you will need to install withpip.pytestmarkdown-to-jsonnumpyPintPyLaTeXpyparsingPyYAMLIn addition to these, you will need to installmacro_expander$pipinstallgit+https://github.com/CD3/macro_expanderOptionally, if you want to do error propagation (which is very useful), you will need to installpyErrorProp$pipinstallgit+https://github.com/CD3/pyErrorPropYou will also need a LaTeX installation, such as texlive, withpdflatexto use the LaTeX writer.ExamplesMy primary use case forpyAssignmentis writing a Physics homework set. I want to create a PDF that contains
problems that the students must work, and then I want to create a Blackboard quiz for the students to complete
that asks questions about the problem set. The Blackboard quiz will typically contain some multiple choice questions
and several numerical answer questions, where the students must compute a numerical value for one of the problems
in the problem set and enter their answer into the quiz.The basic procedure for create this type of assignment is toCreate an object of theAssignmentclass.Add questions to the assignment with theadd_question()method of the assignment object.Add parts to a question with theadd_part()method of the question object.Add quiz questions for a question or part with theadd_question()method of the question object.Add an answer to the quiz question with theadd_answer()method of the quiz question object.Here is a basic working exampleimportos,sysfrompyAssignment.AssignmentimportAssignmentimportpyAssignment.Assignment.AnswersasAnswerfrompyAssignment.ActionsimportBuildProblemSetAndBlackboardQuizimportpintunits=pint.UnitRegistry()Q_=units.Quantityass=Assignment()ass.meta.title=r'Simple Assignment'withass.add_question()asq:q.text=r'''Calculate the weight of a 20 kg mass.'''withq.add_question()asqq:qq.text=r'''What is the mass?'''withqq.add_answer(Answer.Numerical)asa:a.quantity=(Q_(20,'kg')*Q_(9.8,'m/s^2')).to('N')basename=os.path.basename(__file__).replace(".py","")BuildProblemSetAndBlackboardQuiz(ass,basename)TheBuildProblemSetAndBlackboardQuizfunction is an "action". It takes an assignment object and creates a PDF containing
the assignment questions, and any parts that the questions might have. Questions contained in each question or part
are extracted and written to a text file that is suitable for uploading directly into a Blackboard quiz.
Both files are written to a sub-directory named_<BASENAME>, where<BASENAME>is the basename of the assignment file. For example, if the
assignment file is namedBasicAssignment.py, then the PDF and Blackboard quiz
file will be named_BasicAssignment/BasicAssignment.pdfand_BasicAssignment/BasicAssignment-quiz.txt, respectivly.Hereis the PDF that gets generated.Hereis the Blackboard quiz file that gets generated.A couple of things to note about the Blackboard quiz:pyAssignmentautomatically determines what problem number each quiz question corresponds to and inserts a statement
"For problem #X: " at the beginning of each question. This was actually the original motivation for creatingpyHomework.
I wanted a way to write quizzes for homework assignments that could be automatically graded and did not require me to
restate a bunch of information from the problem set. In order to do this, each quiz question needed to reference a specific
problem number. Doing this manually can be error-prone, as you can imagine...pyAssignmentautomatically detects the units for a numerical answer and inserts a statement "Give your answer in X." at
the end of each question text. Blackboard only accepts numerical values, its not possible to specify the units in your answer,
so the quiz question must indicate to the student what units their answer is to be expressed in. Otherwise, students
will say "Well, I computed the answer in Y. I think its the same thing as X, can you please check this?".pyAssignmentautomatically computes a tolerance for the numerical answer. If no estimate of error
is given (i.e. you don't specify uncertainties in your input values), thenpyAssignmentwill use 1%. It is also
possible to have the tolerance directly computed using error propagation (using the [pyErrorProp'](https://github.com/CD3/pyErrorProp) module). However,pyAssignment`
will always use at least a 1% tolerance, even if the actual uncertainty is compted to be less. This lets the students
safely round their answer to three significant figures when they enter it into Blackboard.