mirror of
https://github.com/TeachBooks/manual.git
synced 2026-11-12 22:35:51 +00:00
Added missing grading.py file
This commit is contained in:
parent
41f5701aab
commit
ebfede3879
2 changed files with 17 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
|||
#from grading import check
|
||||
from grading import check
|
||||
from math import isclose
|
||||
|
||||
tolerance = 0.001
|
||||
|
|
|
|||
16
book/examples/grading.py
Normal file
16
book/examples/grading.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
from IPython.display import display
|
||||
import ipywidgets as widgets
|
||||
|
||||
def check(f):
|
||||
def wrapper(*args, **kwargs):
|
||||
output = widgets.Output()
|
||||
button = widgets.Button(description="Check Answer(s)")
|
||||
@output.capture(clear_output=True,wait=True)
|
||||
def _inner_check(button):
|
||||
try:
|
||||
f(*args, **kwargs)
|
||||
except:
|
||||
print("Something went wrong, have you filled all the functions and run the cells?")
|
||||
button.on_click(_inner_check)
|
||||
display(button, output)
|
||||
return wrapper
|
||||
Loading…
Add table
Add a link
Reference in a new issue