A ratio is just a mathematical way to show a relationship between things. I wrote it with a colon (:), but you can write it as a fraction or words "x to b."
Most of the time in math, the order of how the question is asked doesn't matter. When it's a ratio, it does matter. Because they ask about the yellow blocks first, that has to be the first part of the ratio.
There are 2 yellow blocks.
Next, it asks for the total. That will be the other part. Add all the total blocks together: 5+7+2+12= 26.
There are 26 total blocks.
Technically, we can simplify this down to 1:13, but it's not asking to simplify it, so let's just leave it as 2:26.