Ou encore 
 enter code here
     \newif\ifcorrige
     %\corrigetrue    % decommenter pour afficher les réponses
    \newcounter{nbrlignespointilles}
    \newcommand{\lpointilles}[1]{%
    \setcounter{nbrlignespointilles}{0}
    \loop 
    \ifnum\value{nbrlignespointilles}<#1
    \stepcounter{nbrlignespointilles}%
    \dotfill\par
    \repeat}
    \newcounter{nbrlignestotal}
    \newcounter{lignesparag}
    \newcommand{\lpointilles}[1]{%
    \setcounter{nbrlignespointilles}{0}
    \loop 
    \ifnum\value{nbrlignespointilles}<#1
    \stepcounter{nbrlignespointilles}%
    \dotfill\par
    \repeat}
    \ifcorrige
    \newenvironment{reponse}[1]
    {%  
    	\parindent=0pt
    	\blue
    	\par
        \setcounter{nbrlignestotal}{#1}
    }
    {%
        \par\setcounter{lignesparag}{\prevgraf}%
\par%
        \lpointilles{\number\numexpr \value{nbrlignestotal}-\value{lignesparag}}%
\value{nbrlignestotal}-\prevgraf}%
    }
     \else
     \newenvironment{reponse}[1]
    {%
    \parindent=0pt
    \lpointilles{#1}%
    \comment}
    {\endcomment
    \par}
    \fi