\RequirePackage{calc}
\RequirePackage{fltpoint}
\RequirePackage{boites}
\RequirePackage{lastpage}


\newcounter{probleme}
\stepcounter{probleme}
\newcounter{problemequestion}
\newcounter{tempstotal}
\newcounter{maxtempstotal}
\newcommand{\SetTempsTotal}[1]{\setcounter{maxtempstotal}{#1}}

\newcounter{heures}
\newcounter{minutes}
\newcommand{\duree}{%
  \setcounter{heures}{\themaxtempstotal/60}%
  \setcounter{minutes}{\themaxtempstotal - \theheures * 60}%
  \theheures{}h\ifnum\c@minutes=0\else
     \ifnum\theminutes<10 0\theminutes\else\theminutes\fi\fi}

\newcommand{\point}[1]{{\large\color{red}(#1)}}

\AtEndDocument{%
  \ifnum\c@maxtempstotal=\c@tempstotal
  \else
    \@latex@warning{Vous devriez relancer LaTeX pour afficher le temps total correct.}
  \fi
  \if@filesw\immediate\write\@auxout{\string\SetTempsTotal{\the\c@tempstotal}}\fi
}

\newcounter{bareme}
\newcommand{\listofexercises}{{\large\@starttoc{loe}}}
\newcommand{\ecaption}[1]{\addcontentsline{loe}{exo}{#1}}
\newcommand{\l@exo}[2]{\par\noindent#1 \hfill #2}

\newcommand{\entete}[2]{
 \fpRegSet{toto}{#2}
  \fpRegSet{titi}{2}
  \fpRegSet{tutu}{9}
  \fpRegMul{toto}{titi}
  \fpRegDiv{toto}{tutu}
  \fpRegRound{toto}{-1}
  \fpRegGet{toto}{\bareme}
  \ecaption{%
    \hbox to 9cm{Exercice \theprobleme{} (\emph{#1})\hfill}  %
    \hbox to 2cm{[#2 mn]\hfill} [\bareme / 20]}
}

\newcommand{\Probleme}[2]{
  \entete{#1}{#2}
  \section*{Exercice \theprobleme{} (\emph{#1}) \hfill [#2 mn]}
  \stepcounter{probleme}
  \setcounter{problemequestion}{1}
}

\newcommand{\ProblemeSimple}[2]{
  \entete{#1}{#2}
  \section*{Exercice \theprobleme{} (\emph{#1}) \hfill [#2 mn : \hbox to 2cm{\dotfill}]}
  \stepcounter{probleme}
  \setcounter{problemequestion}{1}
  \addtocounter{tempstotal}{#2}%
}

\newcommand{\PbQuestion}[1]{
  \subsection*{Question \theproblemequestion{} \hfill [#1 mn : \hbox to 2cm{\dotfill}]}
  \stepcounter{problemequestion}
  \addtocounter{tempstotal}{#1}%
}

\newcommand{\CartoucheNom}{
  \begin{center}
    \fbox{
      \begin{minipage}{15cm}
        \rule{0mm}{8mm} {\Large\textbf{Nom :}}
        
        \rule[-4mm]{0mm}{13mm} {\Large\textbf{Prénom :}}
      \end{minipage}
    }
  \end{center}
}

\AtBeginDocument{%
  \lhead{\small\@code{} -- \textsc{\@matiere}}
  \chead{}
  \rhead{\small\@numero{}}
  \lfoot{\scriptsize ENST Bretagne -- Majeure Informatique}
  \cfoot{\textrm{\thepage{} sur {\color{black}\pageref{LastPage}}}}
  \rfoot{\scriptsize \@date}
  \colorlet{background}{gray!30}
  \colorlet{backgroundCorrection}{blue!10}
}
