What I interpret you as asking is this: you can just store all the scores for the quiz, ever, and calculate the average when some user asks for it, but you're wondering if you can provide the same data without having to store all the scores.
If I understand correctly, you can calculate a "running average" (called a "cumulative moving average" here) like this: let the $n$-th score be $s_n$. The average of the first $n$ scores is:
$$
\overline{s_n} = \frac{s_0 + s_1 + \dots + s_n}{n}
$$
Now you've got a new score, $s_{n+1}$. The new average should be:
$$
\overline{s_{n+1}} = \frac{s_0 + s_1 + \dots + s_n + s_{n+1}}{n + 1}
$$
Doing some algebra, we can try to rearrange this to involve values we know:
$$
\begin{aligned}
\overline{s_{n+1}} &= \frac{s_0 + s_1 + \dots + s_n + s_{n+1}}{n + 1}\\
&= \frac{s_0 + s_1 + \dots + s_n}{n + 1} + \frac{s_{n+1}}{n+1}\\
\end{aligned}
$$
The right-hand term we can calculate. The left-hand term is almost $\overline{s_n}$, but it has that pesky $n + 1$ in the denominator. So we multiply by $\frac{n+1}{n}$ to get rid of it.
$$
\frac{s_0 + s_1 + \dots + s_n}{n + 1} \cdot \frac{n + 1}{n} = \frac{s_0 + s_1 + \dots + s_n}{n} = \overline{s_n}
$$
Rearranging that:
$$
\frac{s_0 + s_1 + \dots + s_n}{n + 1} = \overline{s_n} \cdot \frac{n}{n+1}
$$
And substituting back in:
$$
\begin{aligned}
\overline{s_{n+1}} &= \overline{s_n}\cdot \frac{n}{n+1} + \frac{s_{n+1}}{n+1}\\
\overline{s_{n+1}} &= \frac{n\overline{s_n} + s_{n+1}}{n+1}\\
\end{aligned}
$$
So that's your formula for the new average, in terms of the old average, $n$, and the new score.
Now, what I just found with algebra can also be found with common sense. We think, if we think of the new score as an "average" (of a data set with one element) then we're asking: how do I combine two averages to make a new one?
Seems like that should be some kind of weighted sum. We should weight the old average by $n$, since it was around for $n$ scores, (treat is as a big fat data point) and weight the new average by just $1$, since it was around for one score. Then just divide by the total number of scores.
(You might do a similar calculation to figure out your new GPA given your current GPA, your new grades, and the number of classes you've taken so far).
Best Answer
Notice that sum is the current average times the current number of elements...
Suppose that $a(n)$ is the average of the first $n$ elements of the set and $e$ is the $n+1^{\text{st}}$ element. Then $$ a(n+1) = \frac{n a(n) + e}{n+1} \text{.} $$ Of course, all this does is reconstruct sum, update it with the new element and then divide to get the new running average.