To answer the question, we need to make some assumptions. The least plausible is that if the student has not memorized the answer, she will get $0$ on the question. We also assume that the questions to be memorized, and the questions on the test, are all equally likely to be chosen, and independent.
If $k\ge 8$, the student will get a perfect score, which we call $4$. So now we need to deal with $0\le k\le 7$. The arguments for $k\le 4$ and $5\le k\le 7$ are a little different.
Case $k\le 4$: For any $i$ from $0$ to $4$, we compute the probability $p_i$ that exactly $i$ of the memorized questions are on the test. There are $\binom{12}{8}$ equally likely ways to choose the $8$ questions.
There are $\binom{k}{i}$ ways to choose $i$ memorized questions and for each of these ways there are $\binom{12-k}{8-i}$ ways to choose the rest of the $8$ questions from the $12-k$ unmemorized. Thus
$$p_i=\frac{\binom{k}{i}\binom{12-k}{8-i}}{\binom{12}{8}}.$$
We are using the convention that if $a\lt b$ then $\binom{a}{b}=0$.
Finally, the expected score is $\sum_{1}^4 ip_i$.
Cases $5\le k\le 7$: We do a sample case, say $k=6$. Then $p_0=p_1=0$.
The probabilities $p_2$ and $p_3$ are calculated just as in the case $k\le 4$. But $p_4$ is different, since it is possible for the teacher to choose more than $4$ questions the student has memorized. The fix is easy, $p_4=1-p_2-p_3$.