
% class examen
% auteur : Bruno Malenfant
% ---------------------------------------------------------------------------
% Cette classe formatte un examen.
% Elle va construire une liste des numéro avec
% leurs pointages et calculer le total.
% Elle permet aussi de gérer une version étudiante (sans
% les réponses) et une version enseignante.


\ProvidesClass{examen}[2008/06/28 v1.0 Classe pour les examens]
\NeedsTeXFormat{LaTeX2e}[2003/12/01]


% ---------------------------------------------------------------------------
% At Begin Of Class

\LoadClass{article}

\RequirePackage{ifthen}


\addtolength{\topmargin}{-0.8in}
\addtolength{\textheight}{1.2in} 
\addtolength{\oddsidemargin}{-50pt}
\addtolength{\textwidth}{100pt}
\addtolength{\parindent}{-\parindent}

\newcounter{total}

\makeatletter
\newboolean{reponseVisible}%
\newcommand\titreInt{Examen}%
\newcommand\titre[1]{%
\renewcommand\titreInt{#1}%
}%
\newcommand\coursInt{INF-XXXX}%
\newcommand\cours[1]{%
\renewcommand\coursInt{#1}%
}%
\newcommand\jourInt{aujourd'hui}%
\newcommand\jour[1]{%
\renewcommand\jourInt{#1}%
}%
\newcommand\sessionInt{Printemps}%
\newcommand\session[1]{%
\renewcommand\sessionInt{#1}%
}%
\newcommand\anneeInt{2000}
\newcommand\annee[1]{%
\renewcommand\anneeInt{#1}%
}%
\newcommand\universiteInt{Mon université}
\newcommand\universite[1]{%
\renewcommand\universiteInt{#1}%
}%
\newcommand\consigne[1]{%
\addtocontents{con}{\contentsline{consigne}{#1}}%
}%
\newcommand\numero[1]{%
\refstepcounter{section}%
\addtocontents{num}{\contentsline{numero}{\thesection}{#1}}%
\bigskip\hrule\bigskip%
{\bf Num\'ero \thesection. (#1 pts)}%
\sectionmark{#1}%
\@afterheading
}%
\renewcommand\thesubsection{\alph{subsection}}%
\newcommand\sousnumero[1]{%
\refstepcounter{subsection}%
\bigskip%
{\bf \hspace{2em}\thesubsection) (#1 pts)}%
\subsectionmark{#1}%
\@afterheading
}%

\newcommand\listofconsignes{%
%\begin{list}{$\cdot$}{\setlength\leftmargin{0.0cm}\setlength\itemindent{0.3cm}}%
\@starttoc{con}%
%\end{list}%
}%
\newcommand\l@consigne[1]{$\cdot$ #1 \par \medskip}%

\newcommand\listofnumber{\@starttoc{num}}%
\newcommand\l@numero[2]{\addtocounter{total}{#2}  \large{\##1\ \ \underline{\ \ \ \ \ \ \ \ }\ /\ #2} \par \bigskip }%

\newcommand\reponse[2]{%
\begin{minipage}[t][#1\baselineskip]{\linewidth}%
  \ifthenelse{\boolean{reponseVisible}}%
  {{\bf Réponse~:} \\ \\#2}%
  {\vspace{#1\baselineskip}}%
\end{minipage}%
}%
%\newcommand\reponse[2]{{\bf Réponse~:} \\ \\#2}%
%\newcommand\reponse[2]{\vspace{#1\baselineskip}}%
%\renewcommand\l@section{\@dottedtocline{1}{5.0em}{2.0em}}%
\newcommand\question{{\bf Question~:~}}
\newenvironment{objectifs}{\small \bf{ Objectif(s)~:} \begin{itemize} }{\end{itemize}\medskip}%
\makeatother

% ---------------------------------------------------------------------------

\AtBeginDocument{
\pagestyle{empty}

\vspace*{\stretch{1}}

\begin{tabular} {|p{10.9cm}|p{3.3cm}|} \hline
  \begin{tabular}{l}
  \\ {\universiteInt} \\
  \\ {\coursInt} \\
  \sessionInt\ \anneeInt \\
  \\
  \underline{\bf \titreInt} \\
  \jourInt\ \anneeInt \\
  \\
  CONSIGNES \\
  \fbox{
    \begin{minipage}{10cm}
      \smallskip
\listofconsignes
    \end{minipage}
  } \\ \\
  IDENTIFICATION \\
  \fbox{
    \begin{minipage}{10cm}
      \begin{center} \hfill \\ \hfill \\
        NOM~: \hrulefill \\ \hfill \\
        PRÉNOM~: \hrulefill \\ \hfill \\
        CODE PERMANENT~: \hrulefill \\ \hfill \\
        SIGNATURE~: \hrulefill \\ \hfill \\
        GROUPE~: \hrulefill \\ \hfill \\
        PROFESSEUR~: \hrulefill \\ \hfill \\
      \end{center}
    \end{minipage}
  }\\ \\
  \end{tabular}
 &
\begin{minipage}[c]{2.9cm}
\listofnumber
\begin{center}
\hrulefill \\
TOTAL\ \ \ \ \ \ \ \ \ \ \ \ \  \hfill \\ \hfill \\
  \large{\ \ \ \ \ \underline{\ \ \ \ \ \ \ \ }\ /\ \thetotal} \\ \hfill \\
\end{center}
\end{minipage}
 \\ \hline
 \multicolumn{2}{|l|}{commentaire~:} \\
 \multicolumn{2}{|l|}{} \\
 \multicolumn{2}{|l|}{} \\
 \multicolumn{2}{|l|}{} \\
 \multicolumn{2}{|l|}{} \\ \hline
\end{tabular}

\vspace*{\stretch{1}}

\clearpage

\pagestyle{myheadings} \markright{\hspace{\stretch{1}}\coursInt\ :\ \titreInt\hspace{\stretch{1}}}
}

