Page MenuHomec4science

en_Howto_questions.Rnw
No OneTemporary

File Metadata

Created
Sun, Aug 3, 22:14

en_Howto_questions.Rnw

% !TeX root = ../teach.Moodle.Latex.R
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%
%% Pastille %%
%% Questions %%
%% %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Conception : Questions}
\begin{frame}
\frametitle{Questions: principles}
\begin{itemize}
\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
\end{tabular}
\end{beamerboxesrounded}
\end{frame}
\begin{frame}[fragile]
\frametitle{Question: schoice type}
{\tiny
<<eval = FALSE, message=FALSE, warning=FALSE>>=
question[[1]] <- paste("option",1:5)
solution <- mchoice2string(c(rep(F,4),T))
sol <- c(sol, solution)
reponse[[1]] <- question[[1]][string2mchoice(solution)]
type <- c(type,"schoice")
point <- c(point, 1L)
tol <- c(tol, 0)
@
}
\begin{beamerboxesrounded}%
[scheme=CommandeRouge, shadow=false]
{Explanation}
\begin{tabular}{ll}
{\it\textcolor{vertmoyen}{question}} & contains "option1", ..., "option5"\\
{\it\textcolor{vertmoyen}{solution}} & designates "option5" as the solution (T), \\
& the others being false (F),\\
& then encodes it as a string "00001"\\
{\it\textcolor{vertmoyen}{sol}} & adds the coded solution\\
{\it\textcolor{vertmoyen}{reponse}} & adds the decoded solution\\
{\it\textcolor{vertmoyen}{type}} & indicates the type of question, i.e. "schoice"\\
{\it\textcolor{vertmoyen}{point}} & gives the number of points for this solution, i.e. 1 pt\\
{\it\textcolor{vertmoyen}{tol}} & no tolerance necessary
\end{tabular}
\end{beamerboxesrounded}
\end{frame}
\begin{frame}[fragile]
\frametitle{Question: mchoice type}
{\tiny
<<eval = FALSE, message=FALSE, warning=FALSE>>=
question[[2]] <- paste("option",1:5)
solution <- mchoice2string(c(T,F,T,F,T))
sol <- c(sol, solution)
reponse[[2]] <- question[[2]][string2mchoice(solution)]
type <- c(type, "mchoice")
point <- c(point, sum(string2mchoice(solution)))
tol <- c(tol, 0)
@
}
\begin{beamerboxesrounded}%
[scheme=CommandeRouge, shadow=false]
{Explanation}
Similar to a question of the type "schoice".\\
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.
% \item Create the statement file *.Rnw\\
% Award 1 point for this question.
% \end{itemize}
%\end{beamerboxesrounded}
%\end{frame}

Event Timeline