I am trying to make a re-useable latex document for setting exam questions together with the answer keys. Because the intended future users will not be familiar with Latex, I have made some templates using \newcommand which can be used by them, and it does all the formatting for them. The new command can be used in this manner.
\questiontext{Enter your question text here}{Enter your answer here}
However, I would just like to make the two arguments in the \newcommand print at different parts of the document but correspond to each other.
The code below shows the MWE of what I have now, and what I would like to have.
\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage{tabularx}
\usepackage{xifthen}% provides \isempty test
\newcounter{questionnumber}[section]
\newcounter{questionpartnumber}[questionnumber]
\newcommand{\questiontext}[2]{
\stepcounter{questionnumber}
\ifthenelse{\isempty{#1}}{\noindent\textbf{\arabic{questionnumber}.}\\}
{\begin{tabularx}{\textwidth}{p{0.5cm} p{12.5cm} @{\extracolsep{\fill}}r}
\textbf{\arabic{questionnumber}.} & \noindent\parbox[t]{\hsize}{#1} & \ifx\empty#2\else[#2]\fi\\\\
\end{tabularx}}
}
\newcommand{\questiontextwoscore}[1]{
\stepcounter{questionnumber}
\ifthenelse{\isempty{#1}}{\noindent\textbf{\arabic{questionnumber}.}\\}
{\begin{tabularx}{\textwidth}{p{0.5cm} p{12.5cm} @{\extracolsep{\fill}}r}
\textbf{\arabic{questionnumber}.} & \noindent\parbox[t]{\hsize}{#1}\\\\
\end{tabularx}}
}
\begin{document}
\section{Questions (Wrong)}
\questiontext{Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.}{5}
\questiontext{Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.}{500}
\questiontext{Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.}{123}
% what i want
\section{Questions (Right)}
\questiontextwoscore{Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.}
\questiontextwoscore{Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.}
\questiontextwoscore{Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.}
\section{Answers}
\questiontextwoscore{5}
\questiontextwoscore{500}
\questiontextwoscore{123}
\end{document}
My current output is in Section 1, what I am looking for ideally, is in Sections 2 and 3.
To summarize, is there a way to make a latex commands which takes in two arguments, prints all of argument 1 sequentially, then prints all of argument 2 sequentially.
Thanks!