My teacher gave us a problem and I cannot understand how did she do it >_< it is about integral expression I am really weak at mathematics even I focus it takes time for me to understand the topic but she is very fast when teaching I hope you can help me I didn't even have any idea what is integral expression she gave us this problem

consider the integral expression in x

P=x^3 + x^2 + ax + 1

where a is a rational number, At a=? the value of P is a rational number for any x which satisfies the equation x^2 + 2x -2=0, and in this case the value of P =?

and the answer is a=-4 p=-1

how she do it and what is integral expression I am very sorry >_<