count the number of question types in examdesign

In a previous question I asked how to count the total number of questions in an exam. Now I am curious how to count the number of questions types - e.g. multiple choice and short answer.

I borrowed from @samcarter's nice solution and defined unique counters for multiple choice, short answer and all questions using etoolbox. However, they do not work as planned. There are 5 total questions. The total question counter (thenumquestions) is correct, and so is the short answer question counter (thesa), but the multiple choice question counter (\themc) is counting all questions.

The trouble is that all questions are defined by \begin{question}, and I am trying to count those instances separately within each question type (\begin{multiplechoice} and \begin{shortanswer}).

I also tried to borrow from this solution to unique counting in the exam class by defining different environments for different questions, but it throws an error.

What am I doing wrong?

\documentclass[10pt]{examdesign}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\SectionFont{\large\bfseries\ttfamily}
\ContinuousNumbering
\Fullpages
\NoKey
\NumberOfVersions{1}

\let\namedata\relax

\usepackage{etoolbox}

\newcounter{numquestions}
\setcounter{numquestions}{0}

\newcounter{mc}
\setcounter{mc}{0}
\AtEndEnvironment{multiplechoice}{\setcounter{mc}{\value{mc}}}

\newcounter{sa}
\setcounter{sa}{0}

\usepackage{totcount}

\newtotcounter{s}
\setcounter{s}{0}
\newenvironment{mcquestion}[1]{
\stepcounter{s}
\begin{question}
#1
\end{question}
}

\begin{document}

\begin{examtop}
This exam is worth all the marbles. It contains  \themc\ MC questions and \thesa\ short answer questions. There are a total of \thenumquestions\ questions.\\
\end{examtop}

\begin{multiplechoice}[]

\begin{mcquestion}
Yes?
\choice[!]{Yes.}
\choice{No.}
\end{mcquestion}

\begin{question}
True?
\choice[!]{True.}
\choice{False.}
\choice{Maybe.}
\choice{Dunno.}
\end{question}

\begin{question}
False?
\choice{True.}
\choice[!]{False.}
\choice{Maybe.}
\choice{Dunno.}
\end{question}
\end{multiplechoice}

\begin{question}
What is love?
Baby don't hurt me.
\end{question}

\begin{question}
What is the meaning of life?
42.
\end{question}

\begin{question}
Are you sure?
Yes.
\end{question}

\end{document}


\documentclass[10pt]{examdesign}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath}
\SectionFont{\large\bfseries\ttfamily}
\ContinuousNumbering
\Fullpages
\NoKey
\NumberOfVersions{1}

\let\namedata\relax

\usepackage{etoolbox}

\newcounter{qcount}
\setcounter{qcount}{0}

\newcounter{mcount}
\setcounter{mcount}{0}

\newbool{insidemc}
\makeatletter
\renewenvironment{multiplechoice}[1][]
{\setbool{insidemc}{true}
\begin{section}
\def\@currentsectionname{multiplechoice}
\exam@definesectiontype{multiplechoice}
\exam@SetDefaultRearrangeBehavior
\exam@SetDefaultSectionTitle{\exam@notitle}
\exam@SetDefaultRecountState{\exam@DefaultNumberingBehavior}
\setkeys{section}{#1}%
\get@instructions \relax}
{\end{section}
\setbool{insidemc}{false}}
\makeatother

\newcounter{scount}
\setcounter{scount}{0}

\newbool{insides}
\makeatletter
{\setbool{insides}{true}
\begin{section}
\exam@SetDefaultRearrangeBehavior
\exam@SetDefaultSectionTitle{\exam@notitle}
\exam@SetDefaultRecountState{\exam@DefaultNumberingBehavior}
\setkeys{section}{#1}%
\get@instructions \relax}
{\end{section}
\setbool{insides}{false}}
\makeatother

\begin{document}

\begin{examtop}
This exam is worth all the marbles. It contains
\themcount\
MC questions and
\thescount\
short answer questions. There are a total of
\theqcount\
questions.\\
\end{examtop}

\begin{multiplechoice}[]

\begin{question}
Yes?
\choice[!]{Yes.}
\choice{No.}
\end{question}

\begin{question}
True?
\choice[!]{True.}
\choice{False.}
\choice{Maybe.}
\choice{Dunno.}
\end{question}

\begin{question}
False?
\choice{True.}
\choice[!]{False.}
\choice{Maybe.}
\choice{Dunno.}
\end{question}
\end{multiplechoice}

\begin{question}
What is love?
Baby don't hurt me.
\end{question}

\begin{question}
What is the meaning of life?
42.
\end{question}

\begin{question}
Are you sure?

• Cool - but why can't I do arithmetic with these counters? For example, if I define a counter called points, then I should be able to do something like \setcounter{points}{1*\value{mcount} + 2*\value{scount}} (using the calc package) and display it with thepoints. But this returns zero where it should return 9. – invictus Sep 26 '17 at 20:39
• @invictus You could look into \numexpr to do such calculations, but actually its not necessary, just use \newcounter{points} \addtocounter{points}{\themcount} \addtocounter{points}{\thescount} \addtocounter{points}{\thescount} \thepoints – user36296 Sep 26 '17 at 21:12