\documentclass[12pt,a4paper,twoside]{article}

\usepackage{amsmath}
\usepackage{epsfig}
\usepackage{bm}
\usepackage{relsize}
\usepackage{parskip}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{etoolbox}
\usepackage{graphicx}
\usepackage{type1cm}
\usepackage{eso-pic}
\usepackage{color}
\usepackage{textpos}
\usepackage{rotating}
\usepackage{upgreek}
\usepackage{geometry}

\geometry{verbose,asymmetric,a4paper,portrait,tmargin=23mm,bmargin=30mm,footskip=12mm,lmargin=31mm,rmargin=27mm,marginparsep=7mm}

\setlength{\parindent}{0mm}
\setlength{\marginparwidth}{10mm}
\linespread{1.2}
\setlength{\parskip}{8pt}

% Set a new conditional for warnings and set default to false
\newif\ifwarning
\warningfalse

\usepackage{fancyhdr,lastpage}
\pagestyle{fancy}
\fancyhf{}
\rfoot[]{{\bf Turn over}}
\renewcommand\headrulewidth{0pt} % Removes funny header line 

% Define the main question counter and sub-question counters &c.
\newcounter{QuestionNumber}
\newcounter{SubQuestionNumber}[QuestionNumber]
\newcounter{SubSubQuestionNumber}[SubQuestionNumber]

% Define the Exam. template version in case we need to track this later
\newcommand{\ExamTemplateVersion}{2.0}

% Define the desired no. marks and thresholdmarks per question, and set default to the usual 8 Threshold, 20 total
\newcounter{TargetQuestionMarks}
\setcounter{TargetQuestionMarks}{20}
\newcommand{\SetTargetQuestionMarks}[1]{\setcounter{TargetQuestionMarks}{#1}}
\newcounter{TargetQuestionThresholdMarks}
\setcounter{TargetQuestionThresholdMarks}{8}
\newcommand{\SetTargetQuestionThresholdMarks}[1]{\setcounter{TargetQuestionThresholdMarks}{#1}}

% Define mark counters that are reset every new question
\newcounter{QuestionMarks}[QuestionNumber]
\newcounter{QuestionThresholdMarks}[QuestionNumber]

\newcommand{\Question}{\raggedright \rfoot[]{{\bf continued}}\stepcounter{QuestionNumber}{\setlength{\parindent}{-7mm}\makebox[7mm][l]{\arabic{QuestionNumber}}}}
\newcommand{\SubQuestion}{\stepcounter{SubQuestionNumber}\setlength{\parindent}{0mm}\setlength{\hangindent}{7mm}\makebox[7mm][l]{(\alph{SubQuestionNumber})}}
\newcommand{\SubSubQuestion}{\stepcounter{SubSubQuestionNumber}\setlength{\parindent}{7mm}\setlength{\hangindent}{14mm}\makebox[7mm][l]{(\roman{SubSubQuestionNumber})}}
\newcommand{\Marks}[1]{\addtocounter{QuestionMarks}{#1}\marginpar[]{\makebox[8mm]{[#1]}}}
\newcommand{\ThresholdMarks}[1]{\addtocounter{QuestionThresholdMarks}{#1}\addtocounter{QuestionMarks}{#1}\marginpar[]{\makebox[8mm]{[#1]}$\ast$}}
\newcommand{\Notice}[1]{\begin{center}\bf #1 \end{center}}
\newcommand{\EndOfQuestion}{\rfoot[]{{{
% Check for incorrect threshold marks
\warningfalse
\ifnumequal{\value{QuestionThresholdMarks}}{\value{TargetQuestionThresholdMarks}}
{}
{
\ifwarning
\else
\textcolor{red}{\textbf{Wrong marks in Question \arabic{QuestionNumber}\\}}
\fi
\textcolor{red}{\arabic{QuestionThresholdMarks} THRESHOLD (target: \arabic{TargetQuestionThresholdMarks})\\}
\warningtrue
}
% Check for incorrect overall marks
\ifnumequal{\value{QuestionMarks}}{\value{TargetQuestionMarks}}
{}
{
\ifwarning
\else
\textcolor{red}{\textbf{Wrong marks in Question \arabic{QuestionNumber}\\}}
\fi
\textcolor{red}{\arabic{QuestionMarks} TOTAL MARKS (target: \arabic{TargetQuestionMarks})\\}
\warningtrue
}
% If we've found a problem with the marks, plaster a warning over the page
\ifwarning
\begin{textblock}{3}(-3,-6)
\begin{rotate}{45}
\fontsize{3cm}{3cm}\textsf{\textcolor{red}{INCORRECT}}
\end{rotate}
\end{textblock}
\begin{textblock}{3}(1,-3)
\begin{rotate}{45}
\fontsize{3cm}{3cm}\textsf{\textcolor{red}{MARKS}}
\end{rotate}
\end{textblock}
\else
% No warnings so typeset as normal
{\bf Turn over}
\fi
% Switch back to default
%\warningfalse
}}}}
\newcommand{\EndOfPaper}{\rfoot[]{}\vspace{\stretch{1}}{\bf \centerline{End of paper}}\vspace{\stretch{1}}\cfoot{Page \thepage\ of \pageref{LastPage}}}

\newcommand{\SubQuestionNote}{\setlength{\parindent}{7mm}\setlength{\hangindent}{7mm}}
\newcommand{\SubSubQuestionNote}{\setlength{\parindent}{14mm}\setlength{\hangindent}{14mm}}

\newcommand{\FrontPage}[3]{\linespread{1.0}\cfoot{}
\begin{minipage}[t][0.09\textheight][t]{\textwidth}\setlength{\parskip}{12pt}\begin{flushright}#1\end{flushright}\end{minipage} \newline \begin{minipage}[t][0.75\textheight][t]{\textwidth}\setlength{\parskip}{12pt}\begin{flushleft}#2\end{flushleft}\end{minipage} \newline
\begin{minipage}[t][0.15\textheight][b]{\textwidth}\setlength{\parskip}{12pt} #3 \end{minipage}
\newpage \setlength{\parskip}{8pt} \linespread{1.2} \cfoot{\bf Page \thepage\ of \pageref{LastPage}}}
