Answer:
He wrote it after he finished his travels, in the court of a Sultan in Morocco is the correct answer.
Step-by-step explanation:
Ibn Batuta was a Muslim explorer who traveled around the medieval world. He spent more than twenty years doing so, and as a result of these trips, he wrote "A Gift to Those Who Contemplate the Wonders of Cities and the Marvels of Traveling."
The first draft was dictated to Ibn Juzzay (Batuta had already worked with him) by recomendation of Abu Inan Faris, ruler of Morocco.