\documentclass[a4paper]{article}

\usepackage{automultiplechoice}
\usepackage{intcalc,ifthen}

\begin{document}
\newcounter{calculate}	
\setcounter{calculate}{0}

	\setdefaultgroupmode{withoutreplacement}
	

		
		\element{histoire}{
			
			\begin{question}{histoire-1}
				Question histoire1
				\begin{choices}
					\correctchoice{Correct}
					\wrongchoice{Wrong A}
					\wrongchoice{Wrong B}
				\end{choices}
			\end{question}
			
		}
		\element{histoire}{
			
			\begin{question}{histoire-2}
				Question histoire2
				\begin{choices}
					\correctchoice{Correct}
					\wrongchoice{Wrong A}
					\wrongchoice{Wrong B}
				\end{choices}
			\end{question}
			
		}
		\element{histoire}{
	
	\begin{question}{histoire-3}
		Question histoire3
		\begin{choices}
			\correctchoice{Correct}
			\wrongchoice{Wrong A}
			\wrongchoice{Wrong B}
		\end{choices}
	\end{question}
	
}
		\element{histoire}{
	
	\begin{question}{histoire-4}
		Question histoire4
		\begin{choices}
			\correctchoice{Correct}
			\wrongchoice{Wrong A}
			\wrongchoice{Wrong B}
		\end{choices}
	\end{question}
	
}	

	
		\element{chimie}{
	
	\begin{question}{chimie-1}
		Question chimie1
		\begin{choices}
			\correctchoice{Correct}
			\wrongchoice{Wrong A}
			\wrongchoice{Wrong B}
		\end{choices}
	\end{question}
	
}
\element{chimie}{
	
	\begin{question}{chimie-2}
		Question chimie2
		\begin{choices}
			\correctchoice{Correct}
			\wrongchoice{Wrong A}
			\wrongchoice{Wrong B}
		\end{choices}
	\end{question}
	
}
\element{chimie}{
	
	\begin{question}{chimie-3}
		Question chimie3
		\begin{choices}
			\correctchoice{Correct}
			\wrongchoice{Wrong A}
			\wrongchoice{Wrong B}
		\end{choices}
	\end{question}
	
}
\element{chimie}{
	
	\begin{question}{chimie-4}
		Question chimie4
		\begin{choices}
			\correctchoice{Correct}
			\wrongchoice{Wrong A}
			\wrongchoice{Wrong B}
		\end{choices}
	\end{question}
	
}	

		\element{biologie}{
	
	\begin{question}{biologie-1}
		Question biologie1
		\begin{choices}
			\correctchoice{Correct}
			\wrongchoice{Wrong A}
			\wrongchoice{Wrong B}
		\end{choices}
	\end{question}
	
}
\element{biologie}{
	
	\begin{question}{biologie-2}
		Question biologie2
		\begin{choices}
			\correctchoice{Correct}
			\wrongchoice{Wrong A}
			\wrongchoice{Wrong B}
		\end{choices}
	\end{question}
	
}
\element{biologie}{
	
	\begin{question}{biologie-3}
		Question biologie3
		\begin{choices}
			\correctchoice{Correct}
			\wrongchoice{Wrong A}
			\wrongchoice{Wrong B}
		\end{choices}
	\end{question}
	
}
\element{biologie}{
	
	\begin{question}{biologie-4}
		Question biologie4
		\begin{choices}
			\correctchoice{Correct}
			\wrongchoice{Wrong A}
			\wrongchoice{Wrong B}
		\end{choices}
	\end{question}
	
}
	
	\onecopy{15}{
		
		{\Large\bf TEST EXAM}
		\vspace{2ex}
		
		\namefield{\fbox{    
				\begin{minipage}{.5\linewidth}
					Name :
					
					\vspace*{.5cm}\dotfill
					
					\vspace*{.5cm}\dotfill
					\vspace*{1mm}
				\end{minipage}
		}}
		\vspace{2ex}
		
\cleargroup{tout}

\copygroupfrom[1]{histoire}{tout}{\thecalculate}	
\copygroupfrom[1]{chimie}{tout}{\thecalculate}
\copygroupfrom[1]{biologie}{tout}{\thecalculate}
\restituegroupe{tout}		

\ifthenelse{ \intcalcMod{\AMCStudentNumber}{5} = 0}
{\addtocounter{calculate}{1}}{\relax}

		
	}
	
\end{document}
