The cause of the error is that \xdef tries to fully expand what it is given but not everything in LaTeX is expandable. In particular, "complicated" objects like tikzpicture environments are not likely to expand. You seem to be assuming that \xdef will just plug the "current value" of \Solution into \SolutionSet but what actually happens is that LaTeX tries to add a huge chunk of code to \SolutionSet and this just doesn't work.
As you say in the comments, "'don't use xdef' is not a solution" but I think that there is no easy way to fix what you are doing because the underlying approach is flawed (sorry!). Using tikz to typeset a list of questions and their solutions is certainly novel but it is not playing to the strengths of tikz, which is primarily for drawing graphics. Something like an enumerate environment is likely to be better for displaying exercises.
I suspect that you are using \tikz because you want to take advantage of \foreach but for what you want to do there are a whole host of expansion hurdles that you will have to solve and I don't think that you want to go there.
Instead, I recommend that you look at the \docsvlist command in the etoolbox package. This can be used to process a "list" of comma separated variables. The sort of exercise sets that you appear to be dealing with are easy to write as a comma separated list:
1+1 = 2,
1+2 = 3,
1+3 = 4,
2+2 = 4
This will also work with more complicated exercises but you should avoid commas and have only one equals sign - or change the syntax!
Given one of these "exercises" we will need to ply apart the exercise and solution. The modern LaTeX way of doing this is to use \SplitArgument
from xparse package but let's just use a plain TeX hack instead:
\def\printExercise#1=#2!!!{\item $#1=\space?$}
So, \printExercise 1+1 = 2!!! will set #1 equal to 1+1 and #2 to 2 with the result that \item $1+1=\space?$ will be added to the input stream. The \docsvlist command applies the command \do to each element of the list that it is given, so we just need to make \do give the exercise to \printExercise. We will also need a corresponding \printSolution macro. Hopefully, this is enough of an explanation for you to work out why the following code
\documentclass{article}
\usepackage{etoolbox}
\usepackage{enumitem}
\def\printExercise#1=#2!!!{\item $#1=\space?$}
\def\printSolution#1=#2!!!{\item $#1=#2$}
\newcommand\PrintExercises[1]{%
\section*{Exercises}
\renewcommand*\do[1]{\printExercise##1!!!}
\begin{enumerate}[label=(\arabic*)]
\docsvlist{#1}
\end{enumerate}
\section*{Solutions}
\renewcommand*\do[1]{\printSolution##1!!!}
\begin{enumerate}[label=(\arabic*)]
\docsvlist{#1}
\end{enumerate}
}
\begin{document}
\PrintExercises{% comma separated list of exercise: solution pairs
1+1 = 2,
1+2 = 3,
1+3 = 4,
2+2 = 4
}
\end{document}
produces something like the output that (I think), you are looking for:

In fact, since \printSolution is printing the "full exercise-solution equation", and not doing anything with #1 or #2, we can replace \renewcommand*\do[1]{\printSolution##1!!!} above with just \renewcommand*\do[1]{\item $##1$}. We only need a \printSolution macro for "more complicated" processing of the solution -- for example, if we wanted to just print the solution rather than the full equation.
The main trick here is to separate the data -- that is, the exercises and solutions -- from the surrounding LaTeX code that we need to display it. I think that it is always a good idea to keep related parts of the data, in this case the exercises and their solutions, as close together as possible.
\xdef? – David Carlisle Nov 03 '17 at 20:27\xdeffails here but works in so many of my other worksheets withTikZ, random numbers, etc. I keep asking for an alternative that actually works, but it seems nobody wants to offer one. I'm thinking of switching programming languages to get around this issue. What do you think of that as an alternative?? – WeCanLearnAnything Nov 03 '17 at 20:29