I'm using the exam class to make tests and am using an mdframed solution I found here to make an answer space with dotted lines to write their answers.
What I want is to have a way so that the boxes on each page finishes uniformly at the bottom of the page regardless of the length of the question above it. At the moment I manually specify the number of lines of dots and the vspace each question, and play with the numbers so that the box fills the space to \approx the bottom of the page, and the dotted lines go within \approx a couple of cm of the bottom.
I tried to use this approach with the vspace to get the box to go to the bottom of the page but even with extra \advance\spaceleft by -various pt type lines to try to adjust, the bottom of the box would always appear on the next page.
Can anyone suggest an approach that will make the vspace go to the bottom of the page so that all I have to do is manually specify the number of lines? Or even an additional bit to adjust the number of dotted lines automatically?
Example of current code that I would like to adapt to fill the space:
\documentclass[addpoints,12pt,a4paper,dvipsnames]{exam}
\usepackage{setspace}
\usepackage{lipsum}
\usepackage[top=2cm, bottom=2cm, left=2.5cm, right=2.5cm, headsep=1cm]{geometry}
\newcount\myloopcounter
\newdimen\spaceleft
\spaceleft=\textheight
\newdimen\spaceleftminus
\newdimen\spacetofill
\newcommand{\repeatit}[2][10]{%
\myloopcounter0% initialize the loop counter
\loop\ifnum\myloopcounter < #1 % Test if the loop counter is < #1
#2%
\advance\myloopcounter by 1 %
\repeat % start again
}
\renewcommand\subpartlabel{(\thesubpart)}
\renewcommand\partshook{\renewcommand\makelabel[1]{##1\hfill}}
\renewcommand\subpartshook{\renewcommand\makelabel[1]{##1\hfill}}
\makeatletter
\newcount\my@repeat@count
\newcommand{\myrepeat}[2]{%
\begingroup
\my@repeat@count=\z@
\@whilenum\my@repeat@count<#1\do{#2\advance\my@repeat@count\@ne}%
\endgroup
}
\makeatother
\usepackage{mdframed}
\newenvironment{mymdf}
{\mdfsetup{
innertopmargin=15pt,leftmargin=-20pt, rightmargin=-1.3cm, innerleftmargin=20pts
}
\begin{mdframed}%
}
{\end{mdframed}}
\renewcommand{\questionshook}{\setlength{\rightmargin}{1.1cm} \setlength{\labelsep}{6pt}}
\renewcommand{\partshook}{\setlength{\rightpointsmargin}{1.35cm} \setlength{\rightmargin}{0cm} \setlength{\itemsep}{0pt} \setlength{\topsep}{0pt} \setlength{\leftmargin}{0.7cm}}
\renewcommand{\subpartshook}{\setlength{\topsep}{0pt} \setlength{\itemsep}{0pt}}
\pointsdroppedatright
\setlength{\parskip}{12pt}
\begin{document}
\begin{questions}
\qformat{\textbf{\thequestion .} \hfill [Maximum mark: \totalpoints] \hspace{13.35cm} \vrule depth 1em width 0cm}
\question[1]
\lipsum[1-2]
\vspace{2mm}
\begin{mymdf}
\begin{spacing}{1.6}
\vspace{0.5cm}
\repeatit[6]{\myrepeat{129}{.}\}
\vspace{0.1cm}
\end{spacing}
\end{mymdf}
\newpage
\question[]
\lipsum[1][1-2]
\begin{parts}
\part[2] \lipsum[1][1] \droppoints
\part[3] \lipsum[1][1-2] \droppoints
\end{parts}
\vspace{0.3cm}
\begin{mymdf}
\begin{spacing}{1.6}
\vspace{0.5cm}
\repeatit[16]{\myrepeat{129}{.}\}
\vspace{0.1cm}
\end{spacing}
\end{mymdf}
\newpage
\question[1]
\lipsum[1]
\vspace{1cm}
\begin{mymdf}
\begin{spacing}{1.6}
\vspace{0.5cm}
\repeatit[8]{\myrepeat{129}{.}\}
\vspace{0.1cm}
\end{spacing}
\end{mymdf}
\end{questions}
\begin{center}
\vspace{0.1cm}
\textbf{END OF TEST}
\end{center}
\end{document}



