SCM

Forum: support

Monitor Forum | Start New Thread Start New Thread
RE: Please critique this easy sample. [ Reply ]
By: Achim Zeileis on 2014-07-08 23:39
[forum:41162]
Ben,

your example seems fine. I have made some small edits, see the modified version below.

1. Yes, with this code you can generate arbitrarily many random variations and upload them into your e-learning system (Moodle, OLAT, ...).

2. The solution contained unnecessary \text{} statments and also the ~ was not needed. Hence I omitted these. Only the \cdot command _needs_ to be inside math mode but as the numbers are displayed somewhat more nicely in math mode, I have kept the dollars for them.

3. Yes, as the tolerance is set to 0, the solution needs to be exact.

hth,
Z

<<echo=FALSE, results=hide>>=
ok <- FALSE
while(!ok) {
n <- sample(seq(750, 2500, by = 50), 1)
p <- sample(seq(1, 99, by = 1), 1)
ok <- abs(n*p/100 - round(n*p/100)) < 10^(-3)
}
sol <- p/100 * n
@

\begin{question}
What is $\Sexpr{p}$\% of $\Sexpr{n}$?
\end{question}

\begin{solution}
$\Sexpr{p}$\% of $\Sexpr{n}$ is $\Sexpr{p/100} \cdot \Sexpr{n} = \Sexpr{sol}$.
\end{solution}

%% \extype{num}
%% \exsolution{\Sexpr{sol}}
%% \exname{percentages}
%% \extol{0}

Please critique this easy sample. [ Reply ]
By: Ben Greenspan on 2014-07-08 17:09
[forum:41161]
Hi,

I am trying to create an easy sample problem.

I have several questions:
1. Can I upload the sample exercise to generate a new question for each student?
2. The solution is a mixture of math and text. Can I simplify the code?
3. The students should submit an exact solution. Is the code correct?

Please critique the code below.

Thank you.

<<echo=FALSE, results=hide>>=
## DATA GENERATION
n <- sample(seq(750,2500,by=50),1)
p <- sample(seq(1,99,by=1),1)
while( abs(n*p/100 - round(n*p/100)) > 10^(-3) ) {
n <- sample(seq(750,2500,by=50),1)
p <- sample(seq(1,99,by=1),1)
}
@
\begin{question}
What is $\Sexpr{p}\%$ of $\Sexpr{n}$?
\end{question}
\begin{solution}
$\Sexpr{p}\%~\text{of}~$\Sexpr{n}$~\text{is}~$\Sexpr{p/100}*\Sexpr{n}=\Sexpr{p/100*n}$\text{.}
\end{solution}
%% META-INFORMATION
%% \extype{num}
%% \exsolution{\Sexpr{p/100*n}}
%% \exname{percentages}
%% \extol{0}

Thanks to:
Vienna University of Economics and Business Powered By FusionForge