If your bowels are normal at other times and this happened at a time when you were stressed, then it really does sound like anxiety induced IBS type symptoms. You do not necessarily have to have diarrhea, but you can just have the constant belly pain that you described. When you are stressed, as during exams, your brain releases certain chemicals and unfortunately, these chemicals have an effect on the smooth muscle lining of your gut, which can then cause diarrhea, cramp like belly pain or constant pain and muscle spasms. I would suggest that you chill out if you can and once the stress has passed, I think you will probably find that your symptoms pass. However, if they don't then do go and see your doc to get checked over, but my guess would be IBS symptoms that have occurred due to anxiety/stress.
I think you probably need to eat some more fiber and it is not normal to pass undigested food in your stools all the time, however, certain foods can do this at times, like some vegetables such as sweetcorn and others. I would suggest taking Metamucil for a while to see if this helps. It is a water soluble fiber supplement and will help firm your stools up. Ensure you drink good amounts of water with it though and you may get a bloated belly and gas for a while until your system gets used to it.