Khan/khan-exercises — pull request #122815 by Merbs (2013-11-21 02:41:31+00:00)
Title: Fix for "not showing" bug

I believe it's a pernicious scoping problem because:
- it occurs rarely
- when it does occur, the competing exercise never reaches
`debugLog("loading and rendering " + exid)` on line 1113
- despite not reaching the above, it manages to set `typeOverride` on
line 1077

That is, there are two, almost simultaneous renders (say A and B). A sets its local `var typeOverride` then A sets the global `exerciseId`, then B sets its local `var typeOverride`, then B sets the global `exerciseId`, then A calls `startLoadingExercise(exerciseId,...)` with the global `exerciseId`, which was the one set by B.

The only time the global `exerciseId` should be set is in `setUserExercise`.

The real solution is to change the variable names so that global and local variables are confused with each other.

If you're interested, I can write more at length about it, but this was the gist.