And Hashem said to Moshe, 'Come up to Me to the mountain and I shall give you the Tablets of stone, and the Torah, and the mitzvah which I have written to instruct you.
It is written in Gemara Berachos (5a) Rebbi Levi the son of Chama said in the name of Raish Lakish: What is the meaning of the possuk, "And Hashem said to Moshe, 'Come up to Me to the mountain and I shall give you the Tablets of stone, and the Torah, and the mitzvah which I have written to instruct you.'"? "The Tablets of Stone" are referring to the Ten Commandments. "And the Torah" is referring to the rest of Neviim and Kesuvim. "And the mitzvah" is referring to the Mishnayos. "Which I have written" is referring to the Neviim (Prophets) and Kesuvim (Writings). "To instruct you" is referring to the Gemara.
In other words, from this Gemara it seems that at the time that Moshe climbed Har Sinai to receive the Ten Commandments he also received, separately, the whole rest of the Torah; the rest of Chumash, all of the Neveiim and Kesuvim, the Mishnayos and even the Gemara.
Zera Shimshon asks that there is another Gemara that seems to contradict this Gemara. In Nedarim (22b) it is written Rebbi Ada the son of Rebbi Chanina said; Had the Jewish people not sinned with the Golden Calf, Hashem would have given to Moshe only the Chumash and the Book of Yehoshua because the division of Eretz Yisroel among all of the tribes is written there. From this Gemara it seems that Hashem gave the Neviim, Kesuvim, Mishnayos and Gemara only after Bnei Yisroel sinned and not at the time that Moshe climbed Har Sinai to receive the Ten Commandments! When was the rest of the Torah given, on Har Sinai or after Bnei Yisroel sinned with the Golden Calf?
Zera Shimshon answers that the incident of the Golden Calf was not the only sin Bnei Yisroel committed at the time of the giving of the Torah. It is written in the Medrash that the fact that after they heard the first two commandments from Hashem and they then asked Moshe to relate to them the rest instead of hearing them directly from Hashem is also considered as a sin. If they would have heard all of the Ten Commandments from Hashem Himself and not through Moshe, they would not have been subject to forgetfulness, the yetzer hara or subjugated by foreign nations. Zera Shimshon understood from this that they also would have understood all of the Torah, the words of the Neviim, the Kesuvim, the mishnayos and all the wisdom of the gemara from the Ten Commandments! However, since they asked that Moshe tell them the Ten Commandments their hearts became hard like stone and Hashem had to now explain each part of the Torah by itself to them.
However, that their request to hear the rest of the Ten Commandments from Moshe is considered something wrong is not at all simple. In Parshas V'eschanan (Devarim 5/25) when Moshe recounts the whole incident of the Giving of the Torah and Moshe mentions that Bnei Yisroel asked Moshe to continue telling them the mitzvos instead of Hashem, Hashem replied, "haiteevu kahl asher deebairu", "and they did well in all that they spoke". If they lost so much by this request how could Hashem say "and they did well in all that they spoke"? From this possuk it seems that their request to hear from Moshe was not only not an avairo but it was even commendable! On the other hand, from the Medrash in our parsha it seems it was an avairo. How can we reconcile these two sources?
Zera Shimshon explains that their request to hear from Moshe was inherently not commendable and not an aveiro but was dependent on their intentions. One possible way to understand their request is that were scared if they would hear the whole Torah directly from Hashem then even though that they would have no yetzer hara and therefore no inclination to do sin, there would still be the possibility to choose sin (See Michtav M'Eliyahu vol. 2 p.138). They were afraid if this would be the case they would sin and they would not be able to argue that they were at least partially forced by the yetzer hara. If this would be so, they would be held completely responsible for what they did and be deserving of the death penalty even for the littlest sin. If this was their intentions then their request was commendable and showed yiras Hashem. On the other hand, their request might have been simply because they wanted to sin and it would easier for them if they would hear the mitzvos from Moshe instead of from Hashem.
To test their true intentions, after they requested that Moshe will relate to them the rest of the mitzvos, Hashem gave them back the yetzer hara that left them after hearing the first two Commandments to see what will be. If they will sin mistakably then retroactively their request was made with good faith and when Moshe would come down with the Ten Comandents they would be freed from the yetzer hara and they would be able to understand the whole Torah. However, if they would sin deliberately then their original request will be judged as something bad and they would stay with their hardened heart unable to understand the whole Torah from the Ten Commandments. Then, among the other things that will happen, Hashem will have to teach us Neviim, Kesuvim, Mishnayos and Gemara separately.
According to the above we can now explain that there is no contradiction between the Gemara in Berachos and the Gemara in Nedarim.
The possuk, "Come up to Me to the mountain and I shall give you the Tablets of stone, and the Torah, and the mitzvah which I have written to instruct you." is written after Bnei Yisroel requested Moshe to continue instead of Hashem and at that time the yetzer hara and the inability to understand the whole Torah from the Ten Commandments returned to them. Therefore there is an allusion that Hashem gave in addition to the Ten Commandments, Neviim, Kesuvim, Mishna and Gemara. However, this was not unchangeable. It was only taken away from them to see what their intentions were by their request.
The Gemara in Nedarim that says if Bnei Yisroel didn't sin with the Golden Calf then there would no need to teach all the parts of the Torah separately is also true, since retroactively it would be shown that they had the right intentions and their hearts that became stone would be loosened. It is only because they did sin at the Golden Calf was the verdict made permanent and Hashem gave us each part of the Torah piece by piece!