See ADDENDUM for OP's follow-on.
EDITED to make a separate environment, benumerate
.
Here, inside the benumerate
environment, the optional argument to \item
indicates the difficulty level.
Here is a brief description of what the new/revised macros do, since they may require some alteration if fonts are changed, as desired by the OP.
\difbox
: creates the "difficulty-box" under the item number. The size and color of the gray box are provided by a \rule
and \color
macro. It calls on \makeballs
to set the proper number of circles in the gray box.
\makeballs
: the recursive macro that places a set of sequential \bullet
s as the circles in the box.
benumerate
: the environment that accomplishes all this, by redefining a few things and calling on enumerate
.
\item
: inside benumerate
, \item
is redefined to take the difficulty level as the optional argument (default 1
), which it saves before calling on the usual \item
.
\labelenumi
: the label redefinition inside benumerate
, which stacks the \difbox
1pt
below the enumeration label (which has been set in bold, sans font of an altered color).
EDITED to \smash
the \labelenumi
, since the low-hanging box was affecting line spacing of the item content.
\documentclass{article}
\usepackage{stackengine,xcolor,lipsum}
\let\svitem\item
\newcommand\difbox[1]{\stackengine{0pt}{\color{gray!30}\rule{5ex}{1.15ex}}{%
\color{cyan!60!black}$\mkern1mu\makeballs{#1}$}{O}{c}{F}{F}{L}}
\def\makeballs#1{\ifnum#1>0\relax{\bullet}%
\expandafter\makeballs\the\numexpr#1-1\relax\fi}
\newenvironment{benumerate}
{\renewcommand\item[1][1]{\def\difficulty{##1}\svitem}%
\def\labelenumi{\smash{\stackunder[1pt]{\color{cyan!60!black}%
\bfseries\sffamily\theenumi}{\difbox{\difficulty}}}}%
\enumerate}{\endenumerate}
\begin{document}
\begin{benumerate}
\setcounter{enumi}{32}
\item[2] \lipsum[4]
\item[3] \lipsum[4]
\item[4] \lipsum[3]
\end{benumerate}
\end{document}
ADDENDUM
To handle the OP's follow on extension request, the solution is trivial. After the invocation of \makeballs{#1}
in the difbox
macro, add \textcolor{red}{\makeballs{\the\numexpr4-#1\relax}}
.
\documentclass{article}
\usepackage{stackengine,xcolor,lipsum}
\let\svitem\item
\newcommand\difbox[1]{\stackengine{0pt}{\color{gray!30}\rule{5ex}{1.15ex}}{%
\color{cyan!60!black}$\mkern1mu\makeballs{#1}%
\textcolor{red}{\makeballs{\the\numexpr4-#1\relax}}$}{O}{c}{F}{F}{L}}
\def\makeballs#1{\ifnum#1>0\relax{\bullet}%
\expandafter\makeballs\the\numexpr#1-1\relax\fi}
\newenvironment{benumerate}
{\renewcommand\item[1][1]{\def\difficulty{##1}\svitem}%
\def\labelenumi{\smash{\stackunder[1pt]{\color{cyan!60!black}%
\bfseries\sffamily\theenumi}{\difbox{\difficulty}}}}%
\enumerate}{\endenumerate}
\begin{document}
\begin{benumerate}
\setcounter{enumi}{32}
\item[2] \lipsum[4]
\item[3] \lipsum[4]
\item[4] \lipsum[3]
\end{benumerate}
\end{document}