Skip to main content

A python module for authoring and assessing homework assignments.

Project description

pyAssignment

A python module for authoring homework assignments and assessments.

Description

This is a rewrite of the pyHomework module, which was created to help write homework assignments for physics classes. The rewrite is currently in progress.

Features

  • Build 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.

Installing

To install pyAssignment, code this repository and use pip to install.

$ git clone https://github.com/CD3/pyAssignment
$ cd pyAssignment
$ pip install .

pyAssignment depends on the following modules available on PyPi, which you will need to install with pip.

  • pytest
  • markdown-to-json
  • numpy
  • Pint
  • PyLaTeX
  • pyparsing
  • PyYAML

In addition to these, you will need to install macro_expander

$ pip install git+https://github.com/CD3/macro_expander

Optionally, if you want to do error propagation (which is very useful), you will need to install pyErrorProp

$ pip install git+https://github.com/CD3/pyErrorProp

You will also need a LaTeX installation, such as texlive, with pdflatex to use the LaTeX writer.

Examples

My primary use case for pyAssignment is 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 to

  1. Create an object of the Assignment class.
  2. Add questions to the assignment with the add_question() method of the assignment object.
  3. Add parts to a question with the add_part() method of the question object.
  4. Add quiz questions for a question or part with the add_question() method of the question object.
  5. Add an answer to the quiz question with the add_answer() method of the quiz question object.

Here is a basic working example

import os,sys
from pyAssignment.Assignment import Assignment
import pyAssignment.Assignment.Answers as Answer
from pyAssignment.Actions import BuildProblemSetAndBlackboardQuiz
import pint

units = pint.UnitRegistry()
Q_ = units.Quantity

ass = Assignment()
ass.meta.title = r'Simple Assignment'

with ass.add_question() as q:
  q.text = r'''Calculate the weight of a 20 kg mass.'''

  with q.add_question() as qq:
    qq.text = r'''What is the mass?'''
    with qq.add_answer(Answer.Numerical) as a:
      a.quantity = (Q_(20,'kg')*Q_(9.8,'m/s^2')).to('N')


basename = os.path.basename(__file__).replace(".py","")
BuildProblemSetAndBlackboardQuiz(ass,basename)

The BuildProblemSetAndBlackboardQuiz function 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 named BasicAssignment.py, then the PDF and Blackboard quiz file will be named _BasicAssignment/BasicAssignment.pdf and _BasicAssignment/BasicAssignment-quiz.txt, respectivly.

Here is the PDF that gets generated.

Here is the Blackboard quiz file that gets generated.

A couple of things to note about the Blackboard quiz:

  1. pyAssignment automatically 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 creating pyHomework. 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...
  2. pyAssignment automatically 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?".
  3. pyAssignment automatically 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), then pyAssignment will 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.

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

pyassignment-2.0.6.tar.gz (59.2 kB view details)

Uploaded Source

Built Distribution

pyassignment-2.0.6-py3-none-any.whl (39.3 kB view details)

Uploaded Python 3

File details

Details for the file pyassignment-2.0.6.tar.gz.

File metadata

  • Download URL: pyassignment-2.0.6.tar.gz
  • Upload date:
  • Size: 59.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.1 CPython/3.10.12 Linux/6.2.0-36-generic

File hashes

Hashes for pyassignment-2.0.6.tar.gz
Algorithm Hash digest
SHA256 3db5510141654b556774dbba025385b641a38815b5314fb407e8138fab135788
MD5 27c11859c5a4fd73baa087fd44570074
BLAKE2b-256 7b921f2879347955be68272a2f217772ab048bec352a84d355c58e92ce66f05a

See more details on using hashes here.

File details

Details for the file pyassignment-2.0.6-py3-none-any.whl.

File metadata

  • Download URL: pyassignment-2.0.6-py3-none-any.whl
  • Upload date:
  • Size: 39.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.1 CPython/3.10.12 Linux/6.2.0-36-generic

File hashes

Hashes for pyassignment-2.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 6f1d20efbd50a0132aad2b00fe80f62f5296e9746b2a367c27e98e21ca9e8d0d
MD5 4928cb4b7c09d222430f5075fae84550
BLAKE2b-256 caed9d6b8a0465339efdfe44f769def7a287b7046b220dff1c56faccadc4d88a

See more details on using hashes here.

Supported by

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