summaryrefslogtreecommitdiff
path: root/macros/generic/randomlist/test.tex
blob: 7e6f65519c778da841913a915537c91a4c8ecfb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[a4paper, margin=2.5cm, noheadfoot]{geometry}
\usepackage{amsmath}
\usepackage[seed=1]{randomlist}

\pagestyle{empty}
\setlength{\parindent}{0pt}

\NewList{Pupils}
\NewList{Triples}

\begin{document}
\ReadFileList{Pupils}{pupils.dat}
\ExtractFirstItem{Pupils}{NULL} % extract title line
\ReadFileList{Triples}{pythagoras.dat}
\ForEachFirstItem{Pupils}{Pupil}
{%
  \ReadFieldItem{\Pupil}{0}{Name}
  \ReadFieldItem{\Pupil}{1}{FName}
  \ReadFieldItem{\Pupil}{2}{Note}
  \ExtractRandomItem{Triples}{Triple}
  \ReadFieldItem{\Triple}{0}{Triplea}
  \ReadFieldItem{\Triple}{1}{Tripleb}
  \ReadFieldItem{\Triple}{2}{Triplec}
  \begin{center}
    \fbox{\huge\bfseries Test for \Name{} \FName}
  \end{center}
  \textbf{Exercise} \par
  \if A\Note
    The diagonal of a rectangle is \Triplec~in and a side of this
    rectangle is \Triplea~in. What is the length of the other side of
    the rectangle?
  \else
    Find the length of the diagonal of a rectangle that is \Triplea~in
    by \Tripleb~in.
  \fi
  \newpage
  \begin{center}
    \fbox{\huge\bfseries Answer to the test for \Name{} \FName}
  \end{center}
  \textbf{Exercise} \par
  \if A\Note
    Use Pythagorean theorem. We have:
    \[\text{diag}^2=\text{side1}^2+\text{side2}^2.\]
    Here:
    \[\Triplec^2=\Triplea^2+\text{side2}^2\]
    and then
    \[\text{side2}=\sqrt{\Triplec^2-\Triplea^2} = \Tripleb.\]
  \else
    Use Pythagorean theorem. We have:
    \[\text{diag}^2=\text{side1}^2+\text{side2}^2.\]
    Here:
    \[\text{diag}^2=\Triplea^2+\Tripleb^2\]
    and then
    \[\text{diag}=\sqrt{\Triplea^2+\Tripleb^2} = \Triplec.\]
  \fi
  \newpage
}
\end{document}