%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  This style file contains some macros for printing exams.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{german,version}
\usepackage{pstricks,graphics,pst-tree}
\usepackage{moreverb}
\usepackage{ntheorem}

\excludeversion{Beispiel}

\theoremstyle{break}
\theorembodyfont{\upshape}
\theorempostskipamount0.5cm

\newtheorem{Aufgabe}{Aufgabe}

\def\prginput#1
   {\psframebox[fillstyle=solid,fillcolor=white]{%
     \begin{minipage}{.98\textwidth}
       \verbatiminput{#1}%
     \end{minipage}
     }}

\newif\ifloesung\loesungfalse
\def\loesungOn{%
 \loesungtrue
 \newenvironment{loesung}
   {\vskip0.5cm \blue \textbf{L"osung}\ \ \sf}{}
 \def\nextone{\newpage}
 \def\xlsg##1{\strut{\blue ##1}}
 \def\lsg##1{\strut{\blue ##1}}}
\def\loesungOff{%
 \loesungfalse
 \def\nextone{\cleardoublepage\pageheader}
 \excludeversion{loesung}
 \excludeversion{lsg}
 \def\xlsg##1{\underline{\strut\white ##1\quad}}
 \def\lsg##1{\strut{\white ##1}}}

\newif\ifzpkt
\newif\iferwpkt
\newif\ifglobalzpkt
\newif\ifglobalerwpkt
\newtoks\pkt
\newtoks\zpkt
\newtoks\erwpkt

\newcounter{countpkte}
\newcounter{countzpkte}
\newcounter{erwpkte}

%  |\newtheoremlisttype{|\meta{name}|}{|\meta{start}|}{|\meta{line}%
%  |}{|\meta{end}|}|.
\newtheoremlisttype{punktliste}%
  {\begin{tabular}{|l|r@{}l|c|}\hline
            & \multicolumn{2}{l|}{Max.\ Punkte} & 
   \ifloesung{\lsg{Sch"atzung f"ur ``4''}}\else{Erreichte Punkte}\fi}%
  {\\\hline Aufgabe ##2 (##3) & 
     \the\pkt \addtocounter{countpkte}{\the\pkt}%
     & \ifzpkt +\the\zpkt\addtocounter{countzpkte}{\the\zpkt}\fi
     & \ifloesung{%
         \blue\iferwpkt \the\erwpkt\addtocounter{erwpkte}{\the\erwpkt}\fi}\fi
     \global\erwpktfalse\global\zpktfalse}%
  {\\\hline\hline
   Summe & \arabic{countpkte}
         & \ifglobalzpkt+\arabic{countzpkte}\fi
         &  \ifloesung\ifglobalerwpkt\blue\arabic{erwpkte}\fi\fi
         \\\hline\end{tabular}}
\makeatother
\parindent0cm

