\item In a statement file, several questions can be asked.
\item Questions are of one of the following types: "schoice", "mchoice", "num" or "string".
In the case of a "schoice" or "mchoice" type, the answer is coded as a string of characters 0 and 1.
\item Following the question text in the "itemize" environment, the keyword {\it\textcolor{vertmoyen}{\#\#ANSWER?\#\#}} must be placed to indicate that an answer is expected.
The "{\it\textcolor{vertmoyen}{?}}" indicates the question number.
\item The following command should finally be placed just before the end of the "question" environment in a chunk.\\
It generates spaces for the student to give his answer.\\
\vspace{3mm}
\centerline{\it answerlist(unlist(question))}
\end{itemize}
\end{frame}
\begin{frame}[fragile]
\frametitle{Question: innitialization}
{\tiny
<<eval = FALSE, message=FALSE, warning=FALSE>>=
question <- list()
response <- list()
sol <- c()
type <- c()
point <- c()
tol <- c()
@
}
\begin{beamerboxesrounded}%
[scheme=CommandeRouge, shadow=false]
{Explanation}
\begin{tabular}{ll}
{\it\textcolor{vertmoyen}{question}} & optional answers or an empty string (numerical answer)\\
{\it\textcolor{vertmoyen}{reponse}} & the decoded solution\\
{\it\textcolor{vertmoyen}{sol}} & the coded solution\\
{\it\textcolor{vertmoyen}{type}} & the types of questions\\
{\it\textcolor{vertmoyen}{point}} & the number of points for the solution\\
{\it\textcolor{vertmoyen}{tol}} & the tolerance for the numerical answers
The difference is that several options must be validated, i.e. "option 1" "option 3" "option 5".
\end{beamerboxesrounded}
\end{frame}
%\begin{frame}
% \frametitle{Your turn!!}
% \begin{columns}[T] % align columns
% \begin{column}{.48\textwidth}
% \begin{beamerboxesrounded}%
% [scheme=CommandeGrise, shadow=false]
% {Exercise}
% Create a "schoice" type question asking you to select the capital of a canton,
% whose name is drawn at random from a \href{https://www.travailler-en-suisse.ch/villes-et-cantons-suisses.html}{list of cantons}.
% \begin{itemize}
% \item The .R file has already been created, as well as the data file
% \item Modify the \textcolor{vertmoyen}{lines 44-45} in the file "formation\_qcm\_canton.Rnw"
% \end{itemize}
% \end{beamerboxesrounded}
% \end{column}%
% \hfill%
% \begin{column}{.48\textwidth}
% \begin{beamerboxesrounded}%
% [scheme=CommandeGrise, shadow=false]
% {Exercise}
% Create an "mchoice" question asking you to select the cantons where \href{https://fr.wikipedia.org/wiki/Canton_(Switzerland)}{French} is an official language.
% \begin{itemize}
% \item The .R file has already been created, as well as the data file
% \item Modify \textcolor{vertmoyen}{lines 51-52} in the file "formation\_qcm\_canton.Rnw"
% \end{itemize}
% \end{beamerboxesrounded}
% \end{column}%
% \end{columns}
%\end{frame}
\begin{frame}[fragile]
\frametitle{Question: num type}
{\tiny
<<eval = FALSE, message=FALSE, warning=FALSE>>=
question[[3]] <- ""
solution <- round(mean(x), nbdecimal)
sol <- c(sol, solution)
reponse[[3]] <- solution
type <- c(type, "num")
point <- c(point, 3L)
tol <- c(tol, precision)
@
}
\begin{beamerboxesrounded}%
[scheme=CommandeRouge, shadow=false]
{Explanation}
A numerical value is requested.\\
The number of points awarded for a correct answer is 3 pts.\\
The tolerance is set to the precision value.
\end{beamerboxesrounded}
\end{frame}
%\begin{frame}
% \frametitle{Your turn!}
% \begin{beamerboxesrounded}%
% [scheme=CommandeGrise, shadow=false]
% {Exercise}
% Create a "num" question asking you to calculate the $x$ percent of $y$, $x$ and $y$ being random.
%
% \begin{itemize}
% \item Create the script file *.R\\
% Help: the \textit{sample(1:100, 1)} command is used to obtain a random number between 1 and 100.
% \item Create the statement file *.Rnw\\
% Award 2 points for this question.
% \end{itemize}
%\end{beamerboxesrounded}
%\end{frame}
\begin{frame}[fragile]
\frametitle{Question: string type}
{\tiny
<<eval = FALSE, message=FALSE, warning=FALSE>>=
question[[4]] <- dat[2, selectedindex]
solution <- dat[1, selectedindex]
sol <- c(sol, solution)
reponse[[4]] <- solution
type <- c(type, "string")
point <- c(point, 1L)
tol <- c(tol, 0)
@
}
\begin{beamerboxesrounded}%
[scheme=CommandeRouge, shadow=false]
{Explanation}
A character string is expected.
The data has been generated in the *.R script (i.e. the "dat" matrix) as well as the line number (i.e. "selectedindex").
\end{beamerboxesrounded}
\end{frame}
%\begin{frame}
% \frametitle{Your turn!}
% \begin{beamerboxesrounded}%
% [scheme=CommandeGrise, shadow=false]
% {Exercise}
% Create a "string" question asking for the 3-letter code representing an ISO 3166-1 alpha-3 country, randomly selected from a list of countries.\\
% \vspace{3mm}
% A list is available at \\ \href{https://en.wikipedia.org/wiki/ISO\_3166-1\_alpha-3}{https://en.wikipedia.org/wiki/ISO\_3166-1\_alpha-3}
%
% \begin{itemize}
% \item Create the script file *.R\\
% Help: the \textit{sample(1:100, 1)} command is used to obtain a random number between 1 and 100.