I want to create a template to standardise the question papers in my institution. I had previously asked this question but did not receive any answer. Recently, I tried the way as shown in the MWE below. There, I faced the following problems:
- In my attempt, the counters for different knowledge-levels for questions and its parts are working fine. However, the marks counter for individual knowledge-levels are misbehaving after some time. After compiling the MWE, I see that at Qn 16.a, the marks counter value for Analysing has not increased, and more surprisingly, the Evaluating marks counter value has decreased! The rests are all messed up Qn 17 onwards.
- The marks counter values are flushed outside the
questionenvironment. As a result, I cannot use the command\printRBTtablesuccessfully at the end. - In the last row of the
tabularinside the\printRBTtable, the command\FPevalis not working, however,\fpevalis working fine.
Please indicate the problem here. I am also open to any alternate solution which solves the linked question.
\documentclass[a5paper, 11pt]{exam}
\usepackage{fp}
\usepackage{array, siunitx}
%
\newcounter{rem}
\newcounter{und}
\newcounter{app}
\newcounter{ana}
\newcounter{eva}
\newcounter{cre}
%
\edef\rem{0}
\edef\und{0}
\edef\app{0}
\edef\ana{0}
\edef\eva{0}
\edef\cre{0}
\edef\x{0}
%
\newcommand{\rqn}[1]{\question[#1]\emph{(Remembering)}%
\let\x\rem%
\FPeval{\rem}{clip(\x+#1)}%
\refstepcounter{rem}
}
\newcommand{\rpart}[1]{\part[#1]\emph{(Remembering)}%
\let\x\rem%
\FPeval{\rem}{clip(\x+#1)}%
\refstepcounter{rem}
}
\newcommand{\rsubpart}[1]{\subpart[#1]\emph{(Remembering)}%
\let\x\rem%
\FPeval{\rem}{clip(\x+#1)}%
\refstepcounter{rem}
}
%
\newcommand{\uqn}[1]{\question[#1]\emph{(Understanding)}%
\let\x\und%
\FPeval{\und}{clip(\x+#1)}%
\refstepcounter{und}
}
\newcommand{\upart}[1]{\part[#1]\emph{(Understanding)}%
\let\x\und%
\FPeval{\und}{clip(\x+#1)}%
\refstepcounter{und}
}
\newcommand{\usubpart}[1]{\subpart[#1]\emph{(Understanding)}%
\let\x\und%
\FPeval{\und}{clip(\x+#1)}%
\refstepcounter{und}
}
%
\newcommand{\aqn}[1]{\question[#1]\emph{(Applying)}%
\let\x\app%
\FPeval{\app}{clip(\x+#1)}%
\refstepcounter{app}
}
\newcommand{\apart}[1]{\part[#1]\emph{(Applying)}%
\let\x\app%
\FPeval{\app}{clip(\x+#1)}%
\refstepcounter{app}
}
\newcommand{\asubpart}[1]{\subpart[#1]\emph{(Applying)}%
\let\x\app%
\FPeval{\app}{clip(\x+#1)}%
\refstepcounter{app}
}
%
\newcommand{\bqn}[1]{\question[#1]\emph{(Analysing)}%
\let\x\ana%
\FPeval{\ana}{clip(\x+#1)}%
\refstepcounter{ana}
}
\newcommand{\bpart}[1]{\part[#1]\emph{(Analysing)}%
\let\x\ana%
\FPeval{\ana}{clip(\x+#1)}%
\refstepcounter{ana}
}
\newcommand{\bsubpart}[1]{\subpart[#1]\emph{(Analysing)}%
\let\x\ana%
\FPeval{\ana}{clip(\x+#1)}%
\refstepcounter{ana}
}
%
\newcommand{\evqn}[1]{\question[#1]\emph{(Evaluating)}%
\let\x\eva%
\FPeval{\eva}{clip(\x+#1)}%
\refstepcounter{eva}
}
\newcommand{\evpart}[1]{\part[#1]\emph{(Evaluating)}%
\let\x\eva%
\FPeval{\eva}{clip(\x+#1)}%
\refstepcounter{eva}
}
\newcommand{\evsubpart}[1]{\subpart[#1]\emph{(Evaluating)}%
\let\x\eva%
\FPeval{\eva}{clip(\x+#1)}%
\refstepcounter{eva}
}
%
\newcommand{\cqn}[1]{\question[#1]\emph{(Creating)}%
\let\x\eva%
\FPeval\cre{clip(\x+#1)}%
\refstepcounter{cre}
}
\newcommand{\cpart}[1]{\part[#1]\emph{(Creating)}%
\let\x\eva%
\FPeval\cre{clip(\x+#1)}%
\refstepcounter{cre}
}
\newcommand{\csubpart}[1]{\subpart[#1]\emph{(Creating)}%
\let\x\eva%
\FPeval\cre{clip(\x+#1)}%
\refstepcounter{cre}
}
%
\newcommand{\printRBTtable}[1]{%
\begin{center}%
\def\arraystretch{#1}%
\begin{tabular}{|l|S|S|}%
\hline%
\multicolumn{1}{|c|}{\small\textbf{Knowledge levels}} & \multicolumn{1}{c}{\small\textbf{Number of questions}} & \multicolumn{1}{|c|}{\small\textbf{Marks}}\\%
\hline%
Remembering & \therem & \rem\\%
\hline%
Understanding & \theund & \und\\%
\hline%
Applying & \theapp & \app\\%
\hline%
Analysing & \theana & \ana\\%
\hline
Evaluating & \theeva & \eva\\%
\hline
Creating & \thecre & \cre\\%
\hline%
\textbf{Total} & \fpeval{\therem+\theund+\theapp+\theana+\theeva+\thecre} & \fpeval{\rem+\und+\app+\ana+\eva+\cre} \\%
\hline
\end{tabular}
\end{center}
}
%
\begin{document}
%
\subsubsection*{\centering{GROUP -- A\\ \small Answer any FIVE questions.\normalsize}}\vspace{1ex}
%
\begin{questions}
%
%Qn 1
%
\uqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 2
%
\evqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 3
%
\aqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 4
%
\rqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 5
%
\uqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 6
%
\uqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 7
%
\aqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 8
%
\rqn{2}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%
\subsubsection*{\centering{GROUP -- B\\ \small Answer any FOUR questions.\normalsize}}\vspace{1ex}
%
%
%
%Qn 9
%
\evqn{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 10
%
\uqn{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 11
%
\aqn{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 12
%
\bqn{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 13
%
\bqn{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%Qn 14
%
\uqn{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%
%
\subsubsection*{\centering{GROUP -- C\\ \small Answer any TWO questions.\normalsize}}\vspace{1ex}
%
%
%
%Qn 15
%
\question
\begin{parts}
%15.a
\bpart{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%15.b
\evpart{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
\end{parts}\vspace{2ex}
%
%Qn 16
%
\question
\begin{parts}
%Qn 16.a
\bpart{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%16.b
\apart{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
\end{parts}\vspace{2ex}
%
% Qn 17
%
\question
\begin{parts}
%17.a
\evpart{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%17.b
\evpart{5}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
\end{parts}\vspace{2ex}
%
%Qn 18
%
\question
\begin{parts}
%18.a
\apart{3}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
%18.b
\bpart{7}\droppoints
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre
\end{parts}\vspace{5ex}
%
\printRBTtable{1.25}
%
%
\end{questions}
\printRBTtable{1.25}
%
%
%
%
\begin{center}
\vspace{3ex}
\rule{6cm}{0.4pt}
\end{center}
\end{document}
EDIT:
It only occurred to me after the comment from cfr that the attached MWE is too large. To minimise the effort to comprehend my process, here is a step-by-step description of the code snippets.
- I declared six counters for different k-levels to count the number of questions in each level.
\newcounter{rem}. - I declared six variables for different k-levels to sum the total marks against each level.
\edef\rem{0}. - Declared a temporary variable
\edef\x{0}. - For each k-level, defined three macros
\rqn,\rpartand\rsubpartto account forquestion,partandsubpartrespectively. - Each of the above macros did the followings:
took the total marks of the question as an argument.
printed the corresponding k-level at the beginning of the question.
\newcommand{\rqn}[1]{\question[#1]\emph{(Remembering)}stored the previous value of corresponding k-level marks variable in the temporary variable
\x, added the marks of the current question to\xand stored it into the same k-level marks variable.\let\x\rem% \FPeval{\rem}{clip(\x+#1)}increased the corresponding k-level question counter.
\refstepcounter{rem}Snippet for entire macro:
\newcommand{\rqn}[1]{\question[#1]\emph{(Remembering)}%
\let\x\rem%
\FPeval{\rem}{clip(\x+#1)}%
\refstepcounter{rem}
}
I have prepared the entire QP with different combinations of the defined macros, and after each question, printed the present value of the total marks corresponding to each k-level:
R:\rem, U:\und, A1:\app, A2: \ana, E: \eva, C: \cre.Finally, I have printed the
\printRBTtableinside and outside of thequestionsenvironment.
\edef\x{}is a really, really bad idea. How certain are you you're not overwriting something important? In any case, I'd recommend looking atexpl3and handle this as integers. As far as I can tell, you don't need anything else or are you dealing with fractional marks? I used to usefp. It worked, but life is so much easier now ;). – cfr Mar 21 '24 at 07:36fppackage from here and used\edeffrom its documentation. It will be very helpful for me if you please suggest any alternate idea to execute the task in an answer. There may happen to exist fractional marks, but for the time being, I am happy with integers only. – Subhajit Paul Mar 21 '24 at 08:47\edefby\def, but the same result continued. – Subhajit Paul Mar 21 '24 at 08:50fpwas a good recommendation. You can still use it. It's just there are better options available these days. – cfr Mar 21 '24 at 21:55\defand\edefdefine things locally.\begin{parts}forms a group. Hence the original definitions are restored at the end of that group. So the points for evaluation or whatever increase inside the group and then get reset to whatever they were at the start. You'd need\gdefor\xdeffor global effect. But, again, be careful with these. It would be better in your preamble to use\newcommand\x{0}. Then you can say\edef\x{}relatively safely. – cfr Mar 21 '24 at 22:05