Q:

Am I using etoolbox correctly for string comparison?

I have a little environment to enumerate question statements. Sometimes, I want the label to not be a number but some string instead. In that case, I do not want the counter to be incremented.
% question environment
\newcounter{QuestionCounter}
\stepcounter{QuestionCounter}
\newenvironment{question}[1][\arabic{QuestionCounter}] {
  \vspace*{0.5\baselineskip}
  \noindent\textbf{Question #1. }\ignorespaces
  \ifdefstrequal{#1}{\value{QuestionCounter}}
  {\stepcounter{QuestionCounter}}
  {}}{}

The concerning if-statement here being,
\ifdefstrequal{#1}{\value{QuestionCounter}}
{\stepcounter{QuestionCounter}}
{}

How can I compare the value (expansion?) of the argument #1 and the value of the counter \value{QuestionCounter}? I have tried \ifdefstrequal{\value{#1}}{\value{QuestionCounter}} because I thought \ifdefstrequal first two arguments need to be macros.
Thanks!

A:

No, it's incorrect usage. And you'd need to do test with full expansion.
I'd do it in a different way: if the optional argument is missing (or empty), the counter is stepped and used for numbering the question.
\documentclass{article}

\newcounter{QuestionCounter}
\newenvironment{question}[1][]
 {%
  \par\addvspace{0.5\baselineskip}%
  \if\relax\detokenize{#1}\relax
    \stepcounter{QuestionCounter}%
    \thisquestion{\arabic{QuestionCounter}}%
  \else
    \thisquestion{#1}%
  \fi
 }{%
  \par\addvspace{0.5\baselineskip}%
 }
\newcommand{\thisquestion}[1]{%
  \noindent\textbf{Question #1. }\ignorespaces
}

\begin{document}

\begin{question}
Is this a numbered question?
\end{question}

\begin{question}[foo]
Is this a numbered question?
\end{question}

\begin{question}
Is this a numbered question?
\end{question}

\end{document}

