\documentclass[12pt]{exam} %Doc : https://mirrors.ircam.fr/pub/CTAN/macros/latex/contrib/exam/examdoc.pdf
\printanswers %Comment this line to hide the answers
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel} %Originally for french document, change to english or relevant language
\usepackage{amsmath,amssymb}
\usepackage{multicol}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{fadings}
\usetikzlibrary{calc}
\usepackage{tkz-tab}
\usepackage{pgfplots}
%Format Header and footer
\pagestyle{headandfoot}
\header{\footnotesize Class\\Id number}{\Large\textbf{Name}}{\footnotesize Year\\Teacher}
\headrule
\footrule
\setlength{\columnsep}{0.25cm}
%\setlength{\columnseprule}{1pt}
\footer{}{Page \thepage}{}
%\extrafootheight{-2cm}
% Change section command behaviour
\usepackage{titlesec}
\titleformat{\section}[frame]{\Huge\bfseries\filright}{}{2mm}{\centering Class n°\thesection~:\ }
% Add a watermark if answers are shown
\ifprintanswers
\usepackage{draftwatermark}
\SetWatermarkColor{red!30}
\SetWatermarkScale{5}
\SetWatermarkText{Solution} %Watermark text
\fi
%Format the name of each exercise
\qformat{\textbf{Exercice \thequestion~:}\hfill}
\extrawidth{1.5cm}
\title{Title}
\begin{document}
\section{Title of first class}
\begin{questions}
\question First question
\begin{itemize}
\item First sub question
\begin{solution}
Answer
\end{solution}
\item Second subquestion
\begin{solution}
Second answer
\end{solution}
\end{itemize}
\question Another way to have questions and subquestions
\begin{parts}
\part First subquestion
\part Second subquestion
\end{parts}
\begin{solution}
Answer for all subquestions
\end{solution}
\end{questions}
\newpage
\section{Title of second class}
\begin{questions}
\question First question
\begin{parts}
\part First subquestion
\begin{solution}
Answer
\end{solution}
\end{parts}
\end{questions}
\end{document}