See the attached notebook for an example of what you are trying to do. The gist of the reason why your code is not working correctly is that SelectionEvaluate is placing the calculation in the evaluation queue to be executed after the code that contains the SelectionEvaluate. So the % is not referring to the result of the SelectionEvaluate. It's best to be a bit more detailed in the process of getting at the result in the tagged cell and explicitly assigning that expression to a parameter, then checking the parameter against the desired response.
Here is an example of such code and an example notebook that uses it is attached (the cell with the student's answer has the CellTag "testtag)--the code assumes that it is being executed in the notebook itself and that there is only one cell with the given CellTag:
Module[{nb, answer},
nb = EvaluationNotebook[];
NotebookFind[nb, "testtag", All, CellTags];
SelectionMove[nb, All, CellContents];
answer = ToExpression@NotebookRead[nb];
If[answer === 1 + x, "Yes!", "No... :-( "]
]
Note also that I use === rather than ==. The latter might not evaluate to either True or False but the former always will. Also remember that two expressions may be the same but if the pattern on the left hand side is expressed differently than the right hand side then the === will possibly yield False. E.g.,
2 (1 + x) === 2 + 2 x
yields
False
Attachments: