In the diffie helman algorithm a key is generated, A and B choose a random number a,b resp only they know. A prime number p and a generator g is given. The key is defined as $g^{a*b} \mod p$. I have to justify that $(a,b,g,p)=(3,4,15,31)$ is a bad choice, but the reason is not because the numbers are too small.
I have no idea how to solve this but I have thought about it for more than an hour.
I thought about maybe $15^x \mod p$ only is a subset of $\{0,...,30\}$ but I don't know what I should do with this information even if it was true.
Your intuition is correct.
$15$ is not a primitive root modulo $31$, and its order is $10$. On average, an attacker has to perform only $5$ guesses to recover one secret key (which is enough to break the system).
A better choice would have been, for example, $g = 17$.