\usepackage{amsmath,amsfonts,amssymb,mathtools}
\usepackage{fmtcount}
\usepackage{etoolbox}
\usepackage[margin=1.8cm]{geometry}
\usepackage{setspace}
\usepackage{listings}
\usepackage{tikz}
\usepackage{fancybox}
\usepackage[tikz]{bclogo}
\usetikzlibrary{patterns,snakes}
 \usepackage{multicol}
\usetikzlibrary{shapes,calc,snakes,arrows,shadows}
\usetikzlibrary{shadows.blur}
\usetikzlibrary{shapes.symbols}
\definecolor{blue}{rgb}{0.1,0.5,0.4}
\usepackage{moreenum}
\usepackage{yagusylo}
\usepackage{wasysym}
\usepackage{pifont}
\usepackage{polyglossia}
\usepackage{mathpple}
\usepackage{ulem}
%===============================================================
\setdefaultlanguage[calendar=gregorian,,locale=algeria]{arabic}
\newfontfamily\arabicfont[Script=Arabic,Scale=1.1]{Amiri}
\newfontfamily\arabicfontsf[Script=Arabic,Scale=1.2]{Aljazeera}
\newfontfamily\arabicfonttt[Script=Arabic,Scale=1.1]{Simplified Arabic}
%-----------------------------------------------------------------------------
%---------------------------------------------------------------------------------------
\renewcommand{\thequestion}{\words{question}}
\newcommand\words[1]{\expandafter\xwords\csname c@#1\endcsname}
\def\xwords#1{\ifcase#1\or
الأول\or
الثاني\or
الثالث\or
الرابع\or
الخامس\or
السادس\or
السابع\or
الثامن\or
التاسع\or
العاشر\or
\else
I need more words\fi}
%***
%------------------------------------------------------------------------------
\singlespacing
\parindent 0ex
%------------------------------
\pointsinmargin
%\pointsinrightmargin
\marginpointname{ن}
\pointformat{\fbox{\bfseries\boldmath\themarginpoints}}
\setlength{\marginpointssep}{1.8cm}
\setlength{\rightpointsmargin}{4.5cm}
\renewcommand{\thepartno}{\arabic{partno}}
\renewcommand{\thesubpart}{\Alph{subpart}}
\renewcommand\subpartlabel{\thesubpart)}
\renewcommand\partlabel{\thepartno)}
\renewcommand{\partshook}{\setlength{\topsep}{-0.2in}}
\setlength{\headsep}{1pt}
\baselineskip = 0.9cm
\pointpoints{نقطة}{نقاط}
\qformat{\textbf{\uline{\sffamily{  التـمرين   \thequestion :}}}\quad (\thepoints)\hfill}
%---------------------------------------
\runningheadrule
\firstpagefootrule
%\footer{}{Page \thepage\ of \numpages}{}
\footer{}{\sffamily صفحه \thepage\ من \numpages}
\runningheadrule
\runningfootrule
%\cfoot{}
\lfoot{
{\iflastpage{\sffamily انتهى الامتحان}{\sffamily اقلب الورقة%
}}}

\rfoot{
{\iflastpage{\sffamily بالتوفــيق}{\sffamily ركز جيدا%
}}}