\documentclass[11pt,a4paper]{article}
\usepackage{amsfonts,amsmath,amssymb,amsthm}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{mathptmx}
\usepackage{fancybox}
\usepackage{graphicx}
\usepackage{ifthen}
\usepackage{tikz}
\usepackage{hyperref}
\hypersetup{
  colorlinks=true,
  linkcolor=blue,
  urlcolor=blue,
  pdftitle={Exercices de mathématiques},
  pdfauthor={Noham Rivoirard}
}
\usepackage{geometry}
\geometry{top=2cm, bottom=2cm, left=2cm, right=2cm}

% Modified to extract number of stars and title
\newcommand{\exercice}[1]{%
  \def\exoargs{#1}%
  \expandafter\parseexoargs\exoargs,,,,,\@nil%
}

\def\parseexoargs#1,#2,#3,#4,#5,#6\@nil{%
  \def\exoref{#1}%
  \def\exoauthor{#2}%
  \def\exodate{#3}%
  \def\exostars{#4}%
  \def\exotitle{#5}%
}

\newcommand{\finexercice}{}
\newcommand{\noindication}{}
\newcommand{\nocorrection}{}
\newcounter{exo}
\newcommand{\currentexonum}{} % mémoire temporaire

% Modified to include variable number of stars and optional title
\newcommand{\enonce}[2]{%
\refstepcounter{exo}%
\expandafter\edef\csname exoNum@\exoref\endcsname{\theexo}%
\hypertarget{exo7:\exoref}{}\label{exo7:\exoref}%
 {\bf Exercice \arabic{exo}}~\printStars{\exostars}\ \ 
 \ifthenelse{\equal{\exotitle}{}}{#2}{\textbf{\exotitle} -- #2}\vspace{1mm}\hrule\vspace{1mm}%
}   

% Command to print stars using TikZ foreach
\newcommand{\printStars}[1]{%
  \foreach \i in {1,...,#1} {%
    \includegraphics[height=1em]{assets/Icone_etoile.png}%
  }%
}

\newcommand{\finenonce}[1]{%
\ifthenelse{\equal{\ref{ind7:#1}}{\ref{bidon}}\and\equal{\ref{cor7:#1}}{\ref{bidon}}}{}{\par{\footnotesize
\ifthenelse{\equal{\ref{ind7:#1}}{\ref{bidon}}}{}{\hyperlink{ind7:#1}{\texttt{Indication} $\blacktriangledown$}\qquad}
\ifthenelse{\equal{\ref{cor7:#1}}{\ref{bidon}}}{}{\hyperlink{cor7:#1}{\texttt{Correction} $\blacktriangledown$}}}}%
\hfill{\scriptsize\texttt{[#1]}}\vspace{1mm}\hrule\vspace*{7mm}%
}
\newcommand{\indication}[1]{%
\hypertarget{ind7:#1}{}\label{ind7:#1}%
{\bf Indication pour \hyperlink{exo7:#1}{l'exercice \csname exoNum@#1\endcsname\ $\blacktriangle$}}\vspace{1mm}\hrule\vspace{1mm}}
\newcommand{\correction}[1]{%
\hypertarget{cor7:#1}{}\label{cor7:#1}%
{\bf Correction de \hyperlink{exo7:#1}{l'exercice \csname exoNum@#1\endcsname\ $\blacktriangle$}}\vspace{1mm}\hrule\vspace{1mm}}
\newcommand{\finindication}{\vspace{1mm}\hrule\vspace*{7mm}}
\newcommand{\fincorrection}{\vspace{1mm}\hrule\vspace*{7mm}}
\newcommand{\finenonces}{\newpage}
\newcommand{\finindications}{\newpage}
\newcommand{\fiche}[1]{} \newcommand{\finfiche}{}
\newcommand{\addcommand}[1]{}

% Bibmath commands
\newcommand{\mcm}{\mathcal{M}}
\newcommand{\mcc}{\mathcal{C}}
\newcommand{\mcmn}{\mathcal{M}}
\newcommand{\mcmnr}{\mathcal{M}_n(\mtr)}
\newcommand{\mcmnk}{\mathcal{M}_n(\mtk)}
\newcommand{\mcsn}{\mathcal{S}_n}
\newcommand{\mcs}{\mathcal{S}}
\newcommand{\mcd}{\mathcal{D}}
\newcommand{\mcsns}{\mathcal{S}_n^{++}}
\newcommand{\glnk}{GL_n(\mtk)}
\newcommand{\mnr}{\mathcal{M}_n(\mtr)}\DeclareMathOperator{\ch}{ch}
\DeclareMathOperator{\sh}{sh}
\DeclareMathOperator{\vect}{vect}\DeclareMathOperator{\card}{card}
\DeclareMathOperator{\comat}{comat}\DeclareMathOperator{\imv}{Im}
\DeclareMathOperator{\rang}{rg}
\DeclareMathOperator{\Fr}{Fr}
\DeclareMathOperator{\diam}{diam}
\DeclareMathOperator{\supp}{supp}
\newcommand{\veps}{\varepsilon}
\newcommand{\mcu}{\mathcal{U}}
\newcommand{\mcun}{\mcu_n}
\newcommand{\dis}{\displaystyle}
\newcommand{\croouv}{[\![}
\newcommand{\crofer}{]\!]}
\newcommand{\rab}{\mathcal{R}(a,b)}
\newcommand{\pss}[2]{\langle #1,#2\rangle}

% End of preamble
\usepackage{graphics}
\usepackage[all]{xy}

\pagestyle{empty}
\begin{document}
