\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}
\usepackage[color=black,opacity=1,angle=0,scale=1]{background}
\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{eulervm}
\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}
%-----------------------------------------------------------------------------
%-----------------------
\backgroundsetup{
contents={%
    \begin{tikzpicture}
        \draw[fill=white,,shade,
      top color=white,
      bottom color=white,
      rounded corners=3pt,
      blur shadow={shadow blur steps=5},double,thick] ($(current page.south west)+(1cm,1cm)$) rectangle ($(current page.north east)+(-1cm,-1cm)$);
 \node[fill=white,,shade,
      top color=white!40,
      bottom color=white!5,
      rounded corners=1pt, rotate=0, anchor=west, font=\small\scshape] at ($(current page.south)+(-0.9cm,0.4cm)$) {\shadowbox{
\RL{\sffamily صفحة \thepage\ من \numpages}}};
 \node[fill=white,,shade,
      top color=white!40,
      bottom color=white!5,
      rounded corners=1pt, rotate=0, anchor=west, font=\scshape] at ($(current page.south west)+(1.2cm,0.4cm)$) {
   \shadowbox{   \RL{  
      {\iflastpage{\sffamily انتهى الامتحان}{\sffamily
اقلب الورقة
}}}}};
   \node[fill=white,,shade,
      top color=white!40,
      bottom color=white!5,
      rounded corners=1pt, rotate=0, anchor=west, font=\small\scshape] at ($(current page.south west)+(18.3cm,0.4cm)$) {
  \shadowbox{    \RL{\sffamily\iflastpage{بالتوفيق}{ركز جيدا}}
      }};
    \end{tikzpicture}
}}
%

%---------------------------------------------------------------------------------------
\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}
\setlength{\headsep}{1pt}
\renewcommand{\thepartno}{\arabic{partno}}
\renewcommand{\thesubpart}{\Alph{subpart}}
\renewcommand\subpartlabel{\thesubpart)}
\renewcommand\partlabel{\thepartno)}
\renewcommand{\partshook}{\setlength{\topsep}{-0.2in}}

\baselineskip = 0.9cm
\pointpoints{نقطة}{نقاط}
\qformat{\textbf{\uline{\sffamily{  التـمرين   \thequestion :}}}\quad (\thepoints)\hfill}
\pagestyle{empty}
