summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-09-12 20:29:14 +0000
committerKarl Berry <karl@freefriends.org>2021-09-12 20:29:14 +0000
commitbe52c14bbe48645b8bda2d8366e1b7981d2aad3d (patch)
tree76d1d1f81acf17db3e37cca59deb7a094f8e5a36
parentfb50ed521936ee0f9fc10cdbc1f0c5d7b7fab36f (diff)
mcexam (12sep21)
git-svn-id: svn://tug.org/texlive/trunk@60481 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/mcexam/README.md4
-rw-r--r--Master/texmf-dist/doc/latex/mcexam/mcexam.pdfbin229715 -> 222389 bytes
-rw-r--r--Master/texmf-dist/doc/latex/mcexam/mcexam.tex13
-rw-r--r--Master/texmf-dist/doc/latex/mcexam/mcexam_example.r118
-rw-r--r--Master/texmf-dist/doc/latex/mcexam/mcexam_example.tex20
-rw-r--r--Master/texmf-dist/doc/latex/mcexam/mcexam_example_dataset.r42
-rw-r--r--Master/texmf-dist/tex/latex/mcexam/mcexam.sty8
7 files changed, 72 insertions, 133 deletions
diff --git a/Master/texmf-dist/doc/latex/mcexam/README.md b/Master/texmf-dist/doc/latex/mcexam/README.md
index 1170e6f689a..369ed487079 100644
--- a/Master/texmf-dist/doc/latex/mcexam/README.md
+++ b/Master/texmf-dist/doc/latex/mcexam/README.md
@@ -1,9 +1,9 @@
-mcexam package v0.4
+mcexam package v0.5
The mcexam package is a LaTeX package that automatically randomly permutes the order of questions and answer options in different versions of a multiple choice exam/test. Next to the exam versions themselves, the package also allows printing a concept version of the exam, a key table with the correct answers or points, and a document with solutions and explanation per exam version. The package also allows writing an R code which processes the results of the exam and calculates the grades.
---------------
-Jorre Vannieuwenhuyze 2017
+Jorre Vannieuwenhuyze 2021
jorre_v[ad]zoho.com
Permission is granted to copy, distribute and/or modify this software under the terms of the LaTeX Project Public License, version 1.3c or later.
diff --git a/Master/texmf-dist/doc/latex/mcexam/mcexam.pdf b/Master/texmf-dist/doc/latex/mcexam/mcexam.pdf
index c5ec1775362..3e32e95caed 100644
--- a/Master/texmf-dist/doc/latex/mcexam/mcexam.pdf
+++ b/Master/texmf-dist/doc/latex/mcexam/mcexam.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/mcexam/mcexam.tex b/Master/texmf-dist/doc/latex/mcexam/mcexam.tex
index c97e86f3a87..bd450a06684 100644
--- a/Master/texmf-dist/doc/latex/mcexam/mcexam.tex
+++ b/Master/texmf-dist/doc/latex/mcexam/mcexam.tex
@@ -218,7 +218,7 @@ The package also defines the \verb$\mcexamoptions{key=value,...}$ command which
\subsection{The questions}
-The most important parts of the exam are, of course, the questions. Within the body of your script file, you place the questions within the \verb$mcquestions$-environment which works similar to list-environments. Each question is preceded by a \verb$\question$ command similar to the \verb$\item$ command :
+The most important parts of the exam are, of course, the questions. Within the body of your script file, you place the questions within the \verb$mcquestions$-environment which works similar to list-environments. Each question is preceded by a \verb$\question$ command similar to the \verb$\item$ command:
\begin{code}
\begin{mcquestions}
\question This is the first question.
@@ -314,7 +314,7 @@ By default, all answers are randomly shuffled within the \verb$mcanswerslist$ an
\item \verb$permutenone$:
This option doesn't permute the answers and sorts the answers in each version in the same order as they are given in the script file.
\item \emph{User specific}:
- If none of the above options satisfies your needs, you can still enter the possible permutations manually. You achieve this by making a comma separated list of all allowed permutations where each permutation itself is a comma separated list of all answer numbers within two curly braces. For example, if your question contains three answers you can give the option \verb$[{1,2,3},{2,3,1}]$. With this option, the package will either put the answers in the order `answer 1, answer 2, answer 3' or in the order `answer 2, answer 3, answer 1'. The package will throw errors if only one permutation is given, if a permutation does not contain all answer numbers, if a permutations contains answer numbers more than once, or if a permutation contains invalid answer numbers. The package will not throw errors if a permutation is given more than once. For example, \verb$[{1,2,3},{1,2,3},{2,3,1}]$ will not give errors, it just means that the order `1,~2,~3' is twice more likely to appear than the order `2,~3,~1'.
+ If none of the above options satisfies your needs, you can still enter the possible permutations manually. You achieve this by making a comma separated list of all allowed permutations where each permutation itself is a comma separated list of all answer numbers within two curly braces. For example, if your question contains three answers you can give the option \verb$[{1,2,3},{2,3,1}]$. With this option, the package will either put the answers in the order `answer 1, answer 2, answer 3' or in the order `answer 2, answer 3, answer 1'. The package will throw errors if only one permutation is given, if a permutation does not contain all answer numbers, if a permutation contains answer numbers more than once, or if a permutation contains invalid answer numbers. The package will not throw errors if a permutation is given more than once. For example, \verb$[{1,2,3},{1,2,3},{2,3,1}]$ will not give errors, it just means that the order `1,~2,~3' is twice more likely to appear than the order `2,~3,~1'.
\end{itemize}
Putting all together, in your script file you can write something like this:
@@ -684,18 +684,13 @@ in the preamble of your script file.
\item[2017/12/26 v0.4:] Added \texttt{pgffor} package to fix bug.
+\item[2021/09/12 v0.5:] Fixed bugs with randomization of answers.
+
\end{description}
-\subsection{Planned modifications}
-\begin{itemize}
- \item Add an error message when you only have one question and the option randomizequestions=true. Now, you should change this option explicitly to randomizequestions=false for one question.
- \item Find an alternative for longtable which is now the default for tables in the package. Longtable doesn't work with twocolumn.
- \item Add a function to reproduce the questions in another permutation/version within the same document.
- \item Add the option to continue the question counter over several mcquestions environments.
-\end{itemize}
diff --git a/Master/texmf-dist/doc/latex/mcexam/mcexam_example.r b/Master/texmf-dist/doc/latex/mcexam/mcexam_example.r
deleted file mode 100644
index 736cd501616..00000000000
--- a/Master/texmf-dist/doc/latex/mcexam/mcexam_example.r
+++ /dev/null
@@ -1,118 +0,0 @@
-mcprocessanswers <- function(ID,versions,answers,path=getwd()) {
-
-tol <- .Machine$double.eps^0.5
-if(! is.numeric(answers)) stop("non-numeric value(s) in answers, mcprocessanswers stopped")
-if(min(answers > tol)==0) stop("non-positive value(s) in answers, mcprocessanswers stopped")
-if(min(abs(answers - round(answers)) < tol)==0) stop("non-integer value(s) in answers, mcprocessanswers stopped")
-if(! is.numeric(versions)) stop("non-numeric value(s) in versions, mcprocessanswers stopped")
-if(min(versions > tol)==0) stop("non-positive value(s) in versions, mcprocessanswers stopped")
-if(min(abs(versions - round(versions)) < tol)==0) stop("non-integer value(s) in versions, mcprocessanswers stopped")
-if(min(versions-4< tol)==0) stop("value(s) in versions too large, maximum possible value is 4, mcprocessanswers stopped")
-
-questiondictionary=list(c(11,3,14,15,16,17,12,2,6,4,7,8,5,9,10,13,1),c(8,10,3,4,5,15,11,16,2,12,7,6,17,9,1,13,14),c(7,11,8,9,10,3,1,15,4,2,12,17,16,13,14,5,6),c(13,12,3,4,5,9,2,11,16,17,14,15,1,6,7,8,10))
-
-randomizedanswersdictionary=list(
- list(c(3,1,2,4,5),c(3,4,1,2),c(4,1,2,3),c(1,2,3,4,5),c(2,1,3,4),c(2,1,4,3),c(4,1,3,2),c(4,3,2,1),c(3,4,1,2),c(4,3,2,1),c(4,2,1,3),c(4,3,1,2),c(4,3,2,1),c(4,3,2,1),c(2,4,1,3),c(1,2,3,4),c(1,2))
- ,list(c(4,3,1,2,5),c(3,4,2,1),c(1,2,3,4),c(5,4,3,2,1),c(1,2,3,4),c(3,4,1,2),c(2,1,3,4),c(4,3,2,1),c(2,1,3,4),c(4,3,2,1),c(3,1,2,4),c(4,2,3,1),c(4,2,3,1),c(1,2,3,4),c(3,4,2,1),c(2,1,3,4),c(1,2))
- ,list(c(3,2,1,4,5),c(3,1,2,4),c(3,4,1,2),c(5,4,3,2,1),c(2,1,3,4),c(1,2,3,4),c(4,1,2,3),c(1,2,3,4),c(3,4,1,2),c(2,1,3,4),c(1,4,3,2),c(3,2,4,1),c(1,3,2,4),c(4,3,2,1),c(1,4,3,2),c(2,1,3,4),c(1,2))
- ,list(c(2,4,1,3,5),c(2,3,1,4),c(4,1,2,3),c(1,2,3,4,5),c(2,1,3,4),c(4,3,2,1),c(2,4,3,1),c(1,2,3,4),c(3,2,4,1),c(4,1,2,3),c(1,4,2,3),c(3,2,4,1),c(1,2,3,4),c(1,2,3,4),c(1,4,3,2),c(1,2,3,4),c(1,2))
- )
-
-correctiondictionary=list(c(1,0,0,0,0),c(0,0,1,0),c(1,0,0,0),c(0,1,0,0,0),c(0,1,0,0),c(0,0,0,1),c(1,0,0,0),c(0,0,1,0),c(1,0,0,0),c(0,1,0,0),c(0,0,1,0),c(1,0,0,0),c(0,0,1,0),c(0,0,0,1),c(0,1,0,0),c(0,1,0,0),c(1,0))
-
-Nversions=4;
-Nquestions=17;
-Nanswers=c(5,4,4,5,4,4,4,4,4,4,4,4,4,4,4,4,2);
-Nstudents=nrow(answers);
-
-Q <- matrix(NA,nrow=Nstudents,ncol=Nquestions);
-P <- matrix(NA,nrow=Nstudents,ncol=Nquestions);
-for ( student in 1:Nstudents ){
- for (question in 1:Nquestions){
- R <- randomizedanswersdictionary[[versions[student]]][[question]];
- Q[student,question] <- R[answers[student,questiondictionary[[versions[student]]][question]]];
- P[student,question] <- correctiondictionary[[question]][Q[student,question]];
- P[student,question] <- ifelse(is.na(P[student,question]),0,P[student,question]);
- }}
-Points=apply(P,1,sum);
-outputdata <- data.frame(ID=ID,versions=versions,originalQuestion=Q,pointsQuestion=P,total=Points);
-
-p <- apply(P,2,mean);
-p.cor <- apply(P,2,mean) - (1-apply(P,2,mean))/(Nanswers-unlist(lapply(correctiondictionary,sum)));
-r.cor <- NULL;
-for (i in 1:Nquestions){
- r.cor[i] <- ifelse(var(P[,i])==0,0,cor(P[,i],apply(P[,-i],1,sum)));
- }
-
-Nquestions.cor <- sum(apply(P,2,var)>0);
-alpha <- (Nquestions.cor/(Nquestions.cor-1))*(1-(sum(apply(P,2,var))/var(Points)));
-
-outputfilename=file.path(path,"mcexam_example.ana");
-write("\\makeatletter",outputfilename) ;
-
-formatnumber <- function(x) {
- y <- gsub("(?<![0-9.])0+","", sprintf("%.3f",x),perl = TRUE)
- n <- nchar(y)
- y <- gsub(" ","\\\\phantom{-}",y)
- y <- paste0(strrep("\\phantom{0}",max(n)-n),y)
- y
- };
-write(c(
- "\\gdef\\mc@questionAnalysisTable{",
- " \\begin{setmcquestionanalysistable}",
- " \\begin{longtable}{cccc}",
- " & \\mc@babel@Proportion & \\mc@babel@Corrected & \\mc@babel@Item@rest \\\\",
- " & \\mc@babel@correct & \\mc@babel@proportion & \\mc@babel@correlation \\\\",
- " \\hline",
- " \\mc@babel@Question \\\\",
- " \\endhead",
- " \\hline",
- " \\endfoot",
- " \\hline",
- paste0(" \\multicolumn{4}{l}{\\mc@babel@Number@of@students\\ = ",Nstudents,"}\\\\"),
- paste0(" \\multicolumn{4}{l}{Cronbach's alpha = ",sprintf("%.3f",alpha),"}\\\\"),
- " \\endlastfoot ",
- paste0(" \\setcounter{mc@counter}{",1:ncol(answers),"}\\mcquestionlabelfmt{mc@counter}& "
- ,formatnumber(p)," & ",formatnumber(p.cor)," & ",formatnumber(r.cor)," \\\\"),
- " \\end{longtable}",
- " \\end{setmcquestionanalysistable}",
- " }"
- ),outputfilename,append=TRUE) ;
-
-versions.factor <- factor(versions);
-levels(versions.factor) <- 1:Nversions;
-for (i in 1:Nquestions) {
- X <- factor(Q[,i],1:Nanswers[i]);
- props <- cbind(prop.table(table(X,versions.factor,useNA="ifany"),2),prop.table(table(X,useNA="ifany")));
- dims <- dim(props);
- props <- lapply(props,function(x) ifelse(is.na(x),"N.A.",gsub(" ","\\\\phantom{0}",paste0(sprintf("%5.1f",x*100),"\\%"))));
- dim(props) <- dims;
- props <- apply(props, 1, paste, collapse=" & ");
- labels <- paste0(" \\setcounter{mc@counter}{",1:Nanswers[i],"}\\mcanswerlabelfmt{mc@counter}");
- labels <- ifelse(is.na(labels[1:dims[1]])," invalid",labels[1:dims[1]])
-write(c(
- paste0("\\csgdef{mc@answerAnalysisTable",i,"}{"),
- paste0(" \\begin{tabular}{c",strrep("c",Nversions),"c}"),
- paste0(" \\multicolumn{1}{r}{\\mc@babel@Version}&"
- ,paste(paste0("\\setcounter{mc@counter}{",1:Nversions,
- "}\\mcversionlabelfmt{mc@counter}"),collapse="&")
- ," & \\mc@babel@total \\\\"),
- " \\hline",
- " \\mc@babel@Answer \\\\",
- paste0(labels," & ",props,"\\\\"),
- " \\hline",
- paste0(" \\multicolumn{",Nversions+2,"}{l}{\\mc@babel@Proportion@correct\\ = ",
- sprintf("%.3f",p[i]),"}\\\\"),
- paste0(" \\multicolumn{",Nversions+2,"}{l}{\\mc@babel@Corrected@proportion\\ = ",
- sprintf("%.3f",p.cor[i]),"}\\\\"),
- paste0(" \\multicolumn{",Nversions+2,"}{l}{\\mc@babel@Item@rest@correlation\\ = ",
- sprintf("%.3f",r.cor[i]),"}\\\\"),
- " \\end{tabular}",
- " }"
- ),outputfilename,append=TRUE) ;
- }
-
-write("\\makeatother",outputfilename,append=TRUE) ;
-
-outputdata ;
- }
diff --git a/Master/texmf-dist/doc/latex/mcexam/mcexam_example.tex b/Master/texmf-dist/doc/latex/mcexam/mcexam_example.tex
index dbd3e4866cc..700d59520f6 100644
--- a/Master/texmf-dist/doc/latex/mcexam/mcexam_example.tex
+++ b/Master/texmf-dist/doc/latex/mcexam/mcexam_example.tex
@@ -39,7 +39,24 @@
-
+
+
+% solution counter starting at 3
+%\newcounter{temp}
+%\setlist[setmcquestions]{
+%label=\protect\setcounter{temp}{\arabic{*}}
+% \protect\addtocounter{temp}{2}
+% \arabic{temp}.
+%,ref=\protect\setcounter{temp}{\arabic{*}}
+% \protect\addtocounter{temp}{2}
+% \arabic{temp}.
+%,itemsep=2\baselineskip
+%,topsep=2\baselineskip }
+
+
+
+
+
\begin{document}
@@ -77,6 +94,7 @@
+
\begin{mcquestions}
diff --git a/Master/texmf-dist/doc/latex/mcexam/mcexam_example_dataset.r b/Master/texmf-dist/doc/latex/mcexam/mcexam_example_dataset.r
new file mode 100644
index 00000000000..9fa54e062da
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/mcexam/mcexam_example_dataset.r
@@ -0,0 +1,42 @@
+### mcexam_example_dataset.r
+### This code contains some test data for the example of mcexam. First run
+### mcexam_example.tex through LaTeX, then process this file with R. Next,
+### you can make an analysis version of the exam in LaTeX. Make sure the
+### working directory is the folder where mcexam_example.tex resorts.
+###
+### Copyright (c) 2017 Jorre Vannieuwenhuyze.
+###
+### Permission is granted to copy, distribute and/or modify this
+### software under the terms of the LaTeX Project Public License
+### (LPPL), version 1.3c or any later version.
+###
+### This software is provided 'as is', without warranty of any kind,
+### either expressed or implied, including, but not limited to, the
+### implied warranties of merchantability and fitness for a
+### particular purpose.
+
+rm(list = ls())
+
+ID <- c(1,2,3,4,5,6,7,8,9,10)
+versions <- c(1,1,1,2,2,2,2,3,3,3)
+answers <- rbind(c(1,2,1,4,2, 3,4,3,1,1, 2,2,2,5,2, 1,3) #17
+ ,c(1,1,2,4,3, 2,2,3,1,2, 2,3,2,5,2, 2,3) #9
+ ,c(1,2,1,3,2, 3,4,2,1,1, 2,2,3,5,1, 1,3) #8
+ ,c(3,2,5,4,2, 4,1,3,4,1, 2,3,1,1,2, 2,3) #11
+ ,c(2,2,5,3,2, 3,1,2,4,2, 2,3,1,1,1, 2,3) #0
+ ,c(3,2,5,4,2, 4,1,3,3,1, 2,2,1,1,2, 1,4) #7
+ ,c(3,2,5,4,2, 3,1,3,4,2, 2,3,2,1,1, 2,1) #2
+ ,c(2,1,4,2,1, 1,3,5,4,1, 1,3,1,4,3, 2,4) #6
+ ,c(2,1,3,3,1, 1,3,5,4,1, 1,2,1,4,3, 2,4) #11
+ ,c(1,1,3,3,2, 1,2,5,4,3, 2,3,4,3,3, 1,3) #4
+ )
+
+source("mcexam_example.r")
+data <- mcprocessanswers(ID,versions,answers)
+
+
+
+
+
+
+ \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/mcexam/mcexam.sty b/Master/texmf-dist/tex/latex/mcexam/mcexam.sty
index f28c975ced2..c2359ac17ae 100644
--- a/Master/texmf-dist/tex/latex/mcexam/mcexam.sty
+++ b/Master/texmf-dist/tex/latex/mcexam/mcexam.sty
@@ -46,7 +46,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{mcexam}[2017/12/26 v0.4 LaTeX package for creating randomized Multiple Choice questions]
+\ProvidesPackage{mcexam}[2021/09/12 v0.5 LaTeX package for creating randomized Multiple Choice questions]
% package option: output
\newbool{mc@concept}
@@ -1057,10 +1057,11 @@
\foreach \a in {1,...,\csuse{mc@totalNumberOfAnswersQ\q}}{
\csxdef{mc@answerTempnum\a}{\a}
}
+ \numdef\@numberofpermuteanswers{\csuse{mc@totalNumberOfAnswersQ\q}}
\numdef\@numberofswaps{\csuse{mc@totalNumberOfAnswersQ\q}-1}
\foreach \v in {1,...,\mc@totalNumberOfVersions}{
\foreach \x in {1,...,\@numberofswaps}{
- \pgfmathrandominteger{\r}{\x}{\csuse{mc@totalNumberOfAnswersQ\q}}
+ \pgfmathrandominteger{\r}{\x}{\@numberofpermuteanswers}
\letcs\@temp{mc@answerTempnum\x}
\global\csletcs{mc@answerTempnum\x}{mc@answerTempnum\r}
\global\cslet{mc@answerTempnum\r}{\@temp}
@@ -1137,6 +1138,7 @@
\def\mc@randomizeAnswers@userdefined{
+ \numdef\@numberofpermuteanswers{\csuse{mc@totalNumberOfUserPermutationsQ\q}}
\numdef\@numberofswaps{\csuse{mc@totalNumberOfUserPermutationsQ\q}-1}
\gdef\mc@cntr{0}
\renewcommand*{\do}[1]{
@@ -1147,7 +1149,7 @@
\foreach \v in {1,...,\mc@totalNumberOfVersions}{
\ifnumequal{\mc@cntr}{0}{
\foreach \p in {1,...,\@numberofswaps}{
- \pgfmathrandominteger{\r}{\p}{\csuse{mc@totalNumberOfUserPermutationsQ\q}}
+ \pgfmathrandominteger{\r}{\p}{\@numberofpermuteanswers}
\letcs\@temp{mc@userPermutationQ\q P\p}
\global\csletcs{mc@userPermutationQ\q P\p}{mc@userPermutationQ\q P\r}
\global\cslet{mc@userPermutationQ\q P\r}{\@temp}