How do I know if someone is asking for people to solve a question from their test, as it is against the rules to help someone with a question in their test.

So for example, a while ago, I answered a question where there's a screenshot on someone's computer. I thought it was some kind of homework, but it turned out it was an assessment the person was taking.

The result was me losing 100s of points (I think as a punishment) and getting my answer deleted.

TLDR: How do I make sure that I'm helping someone with a question on their assignment, not on their test?