You don't need to know how to speak a language to get good grades on its written test unless it's expert-level tests like IELTS. Middle school foreign language class is just a kindergarten and elementary school level of native language class, after all. As long as your language logic part of your brain is developed enough from learning your own native language, it's far from impossible. The chokepoint would be the lexical range but that's not exactly something you need to concern about unless you're taking IELTS type shit.