Moved some stuff to examples and added some missing pages

This commit is contained in:
Tom van Woudenberg 2024-02-27 10:19:04 +01:00
parent 2474bb4899
commit 699d085651
12 changed files with 397 additions and 6 deletions

View file

@ -37,8 +37,6 @@ parts:
- file: features/jupyterlite/including-jupyterlite
- file: features/custom_toc.md
- file: features/custom_download.md
- file: features/h5p_examples.md
- file: features/theory_questions.md
- file: features/h5p.md
- file: features/live_code.md
sections:
@ -49,8 +47,11 @@ parts:
- caption: Examples
chapters:
- file: examples/overview
- file: examples/h5p_examples.md
- file: examples/theory_questions.md
- file: examples/interactive_templates.md
sections:
- file: examples/example_gumbel.ipynb
- file: examples/example_quiz_interactive.ipynb
- file: examples/coding_theory_widgets.ipynb
- file: examples/parametric_questions.ipynb

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,61 @@
from grading import check
from math import isclose
tolerance = 0.001
# Using rel_tol is more reliable in the face of aliasing, but to fit the instructions give we use abs_total
check_float = lambda a, b: isclose(a, b, rel_tol=0, abs_tol=tolerance)
# We have to pass in the globals object since we need to have access to changes as well
@check
def check_example(glob):
mu, beta = glob["mu"], glob["beta"]
if (check_float(mu, -1.7461520011511888) and check_float(beta, 2.553428469837263)):
print(f"Part 1: you got the parameters right, well done! (checked with tolerance {tolerance})")
else:
print(f"Part 1: your parameters are incorrect. (checked with tolerance {tolerance})")
print(f" Other parts won't be graded until these are fixed. ")
return
function = glob["find_x_with_probability_p"]
test_inputs = [(1 - 0.001, 15.891029744351862), (1 - 0.2, 2.0838374640878863), (1 - 0.9, -3.875794191615308)]
failed = []
for x, out in test_inputs:
result = function(x)
if not check_float(result, out):
failed.append((x, out, result))
if len(failed) == 0:
print(f"Part 2: Well done, your inverse function is correct! (checked with tolerance {tolerance})")
else:
print(f"Part 2: Your function failed some tests. Keep in mind the tolerance is {tolerance}")
print(" --> Failed inputs:")
for case in failed:
print(f"{case[0]} gave {case[2]}, expected {case[1]}")
print(f" Other parts won't be graded until these are fixed.")
x = glob["x"]
if check_float(x, 15.891029744351862):
print(f"Part 3: you got the value of x right, well done! (checked with tolerance {tolerance})")
else:
print(f"Part 3: your value of x is incorrect. (checked with tolerance {tolerance})")
return
"""
Task 0:
x_1 = 4
p_1 = 1 - .1
x_2 = 10
p_2 = 1 - .01
Task 1:
beta = -(x_2 - x_1) / log(log(p_2) / log(p_1))
mu = x_1 + beta * log(-log(p_1))
Task 2:
x = mu - beta * log(-log(p))
Task 3:
x = find_x_with_probability_p(1 - 0.001)
"""

View file

@ -6,10 +6,6 @@ This page shows you how to combine theory with questions, so there's no coding i
```
## Truss structures
```{contents}
:local:
```
Truss structures are structures assembled of straight elements connected in nodes. These elements partly create triangles, which are of importance for its deformability. Of course, the structures you'll design shouldn't deform, so it's crucial to understand this topic.
### Examples truss structures

View file

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 261 KiB

After

Width:  |  Height:  |  Size: 261 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 93 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Before After
Before After