A most straightforward solution would be to use the adjustbox package and define answer command as :
\newcommand{\answer}[1]{\adjustbox{minipage=linewidth,phantom,frame}{#1}}
and removing the phantom option when the answer should be displayed. Of course, the frame is for demonstration purpose and must likely be removed.
Edit: I just read in the comments that the switch must be given as argument, so \answer can be defined as:
\newcommand\answer[2][phantom]{\adjustbox{minipage=\textwidth,frame,#1}{#2}}
with an optional argument, set by default to phantom to hide the content,
and simply omitted to show it.
Nevertheless, as a teacher, I would find much more convenient to make a global change, for example with a simple \newif that could be used as follows.
\documentclass{book}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{adjustbox}
\newcommand{\question}[1]{#1\par}
\newif\ifhideanswer
\newcommand\answer[1]{%
\ifhideanswer
\adjustbox{minipage=\textwidth,phantom}{#1}
\else
\adjustbox{minipage=\linewidth}{#1}
\fi
}
\begin{document}
\hideanswerfalse
\question{What is your idea?}
\answer{%
\tikz{\draw[fill=red,line width=1pt] circle(1ex);}
\lipsum[1]
}
\lipsum[2]
\rule{\textwidth}{1pt} \bigskip
\hideanswertrue
\question{What is your idea?}
\answer{
\tikz{\draw[fill=red,line width=1pt] circle(1ex);}
\lipsum[1]
}
\lipsum[2]
\end{document}
producing the attached image.
