microsoft / pybryt

Python library for pedagogical auto-assessment
https://microsoft.github.io/pybryt
MIT License
63 stars 19 forks source link

Student-set initial conditions #159

Closed chrispyles closed 2 years ago

chrispyles commented 2 years ago

Introduce an InitialCondition class which is essentially a placeholder for a value that can be used in annotations but which isn’t set until the student’s submission is executed. you would write annotations like this:

ic = pybryt.InitialCondition(name="foo")

pybryt.Value(2 + ic)
pybryt.Value(2 * ic)
pybryt.Value(ic.apply(lambda v: v ** 0.5))

The InitialCondition class can be transformed as needed with arithmetic operators and functions but all results would be derived from the same root value. Then, in the student’s submission, there would be a block like

pybryt.set_initial_conditions({
    "foo": foo,  # key matches the 'name' of the InitialCondition
    "bar": bar,
})

that records the values of the initial conditions in the memory footprint so that they can be used to check the annotations.