Preheat oven to 400°F. Coat a 9-by-13-inch baking dish with cooking spray.
Blanch all vegetables (if using beets, cook separately to avoid bleeding) in a large pot of boiling water for about 5 minutes. Drain. Pat Dry.
Heat 2 tablespoons oil in a medium saucepan over medium heat.
Add shallots and cook, stirring occasionally, until light brown, 3 to 4 minutes.
Add the flour and stir into a paste. Cook for 1-2 minutes.
Add the milk and thyme and simmer to slightly thicken.
Add ½ the cheese and simmer until melted.
Layer the ⅓ of the vegetables in the pan.
Top with remaining cheese.
Repeat two more times.
Pour the milk and cheese mixture over the grain.
Bake the gratin until for 20 minutes.
Remove from oven, top with parmesan and cook for another 5-10 minutes until bubbling and golden brown.
Cool for 10-15 minutes and serve.