# Is there a way to add reusable metadata to the exam class?

Assuming I want to build a large pool of questions I can reuse for exams and tests, how can I extend the question section in the exam class to enable adding references to

• where the work/solution can be found in textbooks/online
• what section of work / major concepts are being address in the particular question, ideally encapsulating questions from similar sections of work together, and
• difficulty level of the particular question

I have mostly worked with templates and standard classes, and have not extended any standard template, so please be gentle with your answer.

\question[12] Did you need this?

\begin{solution}
Once upon a midnight dreary, while I pondered, weak and weary,
Over many a quaint and curious volume of forgotten lore--- While I
nodded, nearly napping, suddenly there came a tapping, As of some
one gently rapping, rapping at my chamber door. ‘‘\,’Tis some
visitor,’’ I muttered, ‘‘tapping at my chamber door--- Only this
and nothing more.’’
\end{solution}


Would be great to be able to add variables or modifiers / metadata for

1. Reference
2. major concepts and
3. difficulty level.

Maybe the best place to do this would be inside the solution section?

• It would be nice if you could always add a MWE (minimal working example), so that one doesn't have to compose one but could instead just copy it from your question – Tom Bombadil Sep 19 '12 at 11:07
• I've never used but TeXoMaker allows you to build exercises data base to be composed with latex. – Ignasi Sep 21 '12 at 17:33
• Hmm, I really don't understand what you mean by "reusable metadata". I was thinking of putting some macros to either question or solution, and probably using makeindex/biblatex for adding keywords and references. Probably you could elaborate a little on how you would like things to work. Probably you could hack together a picture of what you would like to achieve? And buddy, I'm still waiting for that MWE ;-) – Tom Bombadil Sep 21 '12 at 22:33

As I still don't know what you want, here's what I think you might want (<- good example for bad kerning, ay?).

## Code

\documentclass[answers]{exam}
\usepackage{pifont}
\usepackage{xifthen}
\usepackage{tikz}
\usepackage{makeidx}
\usepackage[columns=1]{idxlayout}
\makeindex

\newcommand{\difflevel}[3][]% [some words], diff from 1 to 5, short question title
{ \ifthenelse{#2=1}{\xdef\mycolor{blue!50!gray}}{}
\ifthenelse{#2=2}{\xdef\mycolor{green!50!gray}}{}
\ifthenelse{#2=3}{\xdef\mycolor{yellow!50!gray}}{}
\ifthenelse{#2=4}{\xdef\mycolor{orange!50!gray}}{}
\ifthenelse{#2=5}{\xdef\mycolor{red!50!gray}}{}
\pgfmathtruncatemacro{\dingnum}{201+#2}
\tikz{\node[text width=\textwidth,inner sep=2pt] {\textcolor{\mycolor}{\ding{\dingnum}} #1};}
%\index{Difficulty!1!#3@\ding{\dingnum}}
\index{Difficulty!\ding{\dingnum}!#3}
}

\newenvironment{usefulstuff}{\textbf{Important concepts\\}}{}

\newcommand{\usefulconcept}[3]% label, linked text, further info
{   \tikz{\node[text width=\textwidth,inner sep=2pt] {$\bullet$ \hyperref[#1]{\textbf{#2}} #3};}
}

\begin{document}

\begin{questions}

\question[12] Did you need this?
\begin{solution}\\
\difflevel[A particularly easy question]{1}{The first bogus question}
\begin{usefulstuff}
\usefulconcept{th.pythagoras}{The Pythagorean theorem}{is important here as there is a right angle in the triangle}
\end{usefulstuff}
Once upon a midnight dreary, while I pondered, weak and weary,
Over many a quaint and curious volume of forgotten lore--- While I
nodded, nearly napping, suddenly there came a tapping, As of some
one gently rapping, rapping at my chamber door. ‘‘\,’Tis some
visitor,’’ I muttered, ‘‘tapping at my chamber door--- Only this
and nothing more.’’
\end{solution}

\question[12] Did you need this?
\begin{solution}\\
\difflevel[Quite easy, if you listened in the lecture]{2}{The second bogus question}
Once upon a midnight dreary, while I pondered, weak and weary,
Over many a quaint and curious volume of forgotten lore--- While I
nodded, nearly napping, suddenly there came a tapping, As of some
one gently rapping, rapping at my chamber door. ‘‘\,’Tis some
visitor,’’ I muttered, ‘‘tapping at my chamber door--- Only this
and nothing more.’’
\end{solution}

\question[12] Did you need this?
\begin{solution}\\
\difflevel[A little challenge, but you'll have to think carefully]{3}{The bogus question between second and fourth}
Once upon a midnight dreary, while I pondered, weak and weary,
Over many a quaint and curious volume of forgotten lore--- While I
nodded, nearly napping, suddenly there came a tapping, As of some
one gently rapping, rapping at my chamber door. ‘‘\,’Tis some
visitor,’’ I muttered, ‘‘tapping at my chamber door--- Only this
and nothing more.’’
\end{solution}

\question[12] Did you need this?
\begin{solution}\\
\difflevel[Quite a challenge]{4}{The bogus question after the third}
Once upon a midnight dreary, while I pondered, weak and weary,
Over many a quaint and curious volume of forgotten lore--- While I
nodded, nearly napping, suddenly there came a tapping, As of some
one gently rapping, rapping at my chamber door. ‘‘\,’Tis some
visitor,’’ I muttered, ‘‘tapping at my chamber door--- Only this
and nothing more.’’
\end{solution}

\question[12] Did you need this?
\begin{solution}\\
\difflevel[The question that will determine weather you're a PRO]{5}{The bogus question number five}
\begin{usefulstuff}
\usefulconcept{th.thales}{The theorem of Thales}{will be usefull as there's a semi circle involved.}
\end{usefulstuff}
Once upon a midnight dreary, while I pondered, weak and weary,
Over many a quaint and curious volume of forgotten lore--- While I
nodded, nearly napping, suddenly there came a tapping, As of some
one gently rapping, rapping at my chamber door. ‘‘\,’Tis some
visitor,’’ I muttered, ‘‘tapping at my chamber door--- Only this
and nothing more.’’
\end{solution}

\question[12] Did you need this?
\begin{solution}\\
\difflevel[A particularly easy question]{1}{The 6$^{th}$ bogus question}
Once upon a midnight dreary, while I pondered, weak and weary,
Over many a quaint and curious volume of forgotten lore--- While I
nodded, nearly napping, suddenly there came a tapping, As of some
one gently rapping, rapping at my chamber door. ‘‘\,’Tis some
visitor,’’ I muttered, ‘‘tapping at my chamber door--- Only this
and nothing more.’’
\end{solution}

\question[12] Did you need this?
\begin{solution}\\
\difflevel[The question that will determine weather you're a PRO]{5}{The bogus question number seven}
Once upon a midnight dreary, while I pondered, weak and weary,
Over many a quaint and curious volume of forgotten lore--- While I
nodded, nearly napping, suddenly there came a tapping, As of some
one gently rapping, rapping at my chamber door. ‘‘\,’Tis some
visitor,’’ I muttered, ‘‘tapping at my chamber door--- Only this
and nothing more.’’
\end{solution}

\question[12] Did you need this?
\begin{solution}\\
\difflevel[A little challenge, but you'll have to think carefully]{3}{The bogus question between seventh and 9$^{th}$}
\begin{usefulstuff}
\usefulconcept{th.pythagoras}{Quantum mechanics}{need to be used as something really strange is going on.}
\end{usefulstuff}
Once upon a midnight dreary, while I pondered, weak and weary,
Over many a quaint and curious volume of forgotten lore--- While I
nodded, nearly napping, suddenly there came a tapping, As of some
one gently rapping, rapping at my chamber door. ‘‘\,’Tis some
visitor,’’ I muttered, ‘‘tapping at my chamber door--- Only this
and nothing more.’’
\end{solution}

\end{questions}

\clearpage

{\fontsize{20}{24}\selectfont\noindent Important Concepts}
\begin{description}
\item[Pythagorean theorem]\label{th.pythagoras}\index{Concept!Theorem!Pythagorean theorem} $a^2+b^2=c^2$
\item[Thales' theorem]\label{th.thales}\index{Concept!Theorem!Thales' theorem} if A, B and C are points on a circle where the line AC is a diameter of the circle, then the angle ABC is a right angle.
\item[Quantum mechanics]\label{pt.quantum}\index{Concept!Theory!Quantum mechanic} Tiny particles behave unexpectedly
\end{description}

\clearpage

\printindex

\end{document}


## Result

• That is perfect, thanks. Is the difflevel then available for access later, as a variable? – Forkrul Assail Sep 25 '12 at 11:28
• What do you mean? Something like \ref{question1} resulting in Question 1 (difficulty)? – Tom Bombadil Sep 25 '12 at 15:40
• What I mean is will -> \difflevel[A particularly easy question]{1}{The first bogus question} be query-able later so that I could for instance, cherry-pick questions with a certain difficulty - in your example a difficulty value of 1. Let's say I traverse my set of questions (random selection), and can then see the difficulty level / value of a given question. I hope this makes sense. – Forkrul Assail Sep 25 '12 at 16:02
• No, this is not possible at the moment. I'll think about a solution tomorrow. – Tom Bombadil Sep 25 '12 at 22:41

Some days ago ExSheets was uploaded to CTAN. After a quick reading it looks promising. It allows to add meta-data to the exercises and use them for filtering questions.

Part of manual abstract:

ExSheets provides means to create exercises or questions and their corresponding solutions. The questions can be divided into classes and/or topics and can be printed selectively. Meta-data to questions can be added and recovered.

• Here is an example code that uses \DeclareQuestionProperty (=meta-data): bitbucket.org/cgnieder/exsheets/wiki/Home – clemens Oct 13 '12 at 21:32
• Thanks so much for the reference. I'll definitely give it a try. – Forkrul Assail Oct 14 '12 at 19:24
• @cgnieder: Thank you for the package! I'll start to use it. – Ignasi Oct 15 '12 at 7:14
• @cgnieder: I don't know what's the problem but the link to the wiki doesn't work for me. It says You do not have access to the wiki. – Ignasi Oct 15 '12 at 7:16
• @Ignasi it should work now. I had mistakenly set it to private... – clemens Oct 15 '12 at 7:44