# Using conditionals inside mcexam

I want to write exams where the questions and answers are randomized, and mcexam lets me do almost everything I want. However, I would also like each question to be picked randomly from a group of questions. For instance, I may want one question on the exam about the product rule, so from a group of 5 questions, one of them is randomly selected to be on the exam. I'm currently using pgfmath and I thought it was working great, but then I realized that sometimes it takes bits and parts of the questions and pieces them together.

In the code there are two questions to be picked from: "Which is not a fruit?" and "What color is an emerald?" What's happening is the output will have "Which is not a fruit?" but then the answer choices are the ones for "What color is an emerald?" or vice versa. Why is this happening and is there something I can do to fix this? I am not overly familiar with latex. Thanks!

\documentclass[12pt]{article}
\usepackage{pgfmath}
\usepackage{tikz,framed}
\usepackage[output=exam
,numberofversions=1
,version=1
,seed=6
,randomizequestions=true
,writeRfile=false
]{mcexam}

\begin{document}
\begin{mcquestions}

\question

\pgfmathrandom{2}  % store 1 or 2 in \pgfmathresult
\ifnum\pgfmathresult=2
{
Which is not a fruit?
}
\else
{   What color is an emerald?
}
\fi

\question
This is the second question, needed in order to run.