This allowed the water to run right out of the pipe and down the side of the foundation, ultimately running into the basement and the floor drain. I am thankful that the previous owner at least managed the water so it didn't collect in the basement and cause mold issues, but now the overall cost of the job will far exceed what it would have cost if they had found the source of the problem years ago.
This picture is from my foundation. Digging a 7' hole in clay is not fun! This was caused by a downspout from a gutter system that was not installed properly. We purchased our home in July of 2015 when the weather was nice and the landscaping was lush and green. The plants along the side of the house however blocked the signs of this damage from the home inspector. As I was walking around the house the following spring I noticed that the previous owner had patched the crack in the foundation that was above grade and never worried about what was looming underneath. Before the picture, I chipped off what little patch was covering the crack above ground. As you can see the crack has now spread all the way to the footer of the foundation and has even eroded into bigger holes in a few places. On the inside of the house the "repair" that was done was jack-hammering a trench in the floor of the basement to allow the water to flow from the gap along the wall to the floor drain. This was basically putting a band-aid on the issue and not really finding the source of the problem.
All of that could have been avoided if the downspout from the gutter was pitched and connected properly. The pitch of the pipe that was installed to bring the water away from the house was too low for the length of it. On top of the pitch being too low, it was ran through the middle of a bush. As the bush grew, it decreased the pitch of the downspout even further and exaggerated the issue already present. The pitch itself though was not what caused the problem. The real problem started because whoever installed the gutter downspout essentially crumpled the bottom pipe into the top pipe.
I can't repair your foundation but I can properly install downspouts so you don't end up with foundation damage.