"You rested while I cooked."
Translation:Du vilade medan jag lagade mat.
Not 100 % sure, but I think när translates to when and describes a punctual event. E.g: When I came home, I realized I had forgotten to buy eggs (när). In contrast to that, medan translates to during/while, which is used when refering to two events occuring at the same time, which is the case in the provided sentence. As I said, I'm not 100 % sure on that. I usually learn stuff like this by observations, which can sometimes be misleading. So if anyone knows better, feel free to correct me.
Well, they're both correct. Assuming the options were identical except for du/ni, you need to pick both.
But that said, the multiple-choice questions are generated automatically, so I'm afraid we can't see what you were given, nor how the system decides to correct you.
Ah, I see what you mean. When I said multiple choice, it's the one where there are three possible answers and you choose the correct one. On the second attempt, I selected "ni..." and was marked correct, which is why I was surprised when I clicked on the discussion button to ask what the difference was (which you have now explained, thanks), it said "du...".
I now understand the difference between the two, and that both can be correct in slightly different contexts