What forced this implementation is the fact that there's no "de-cue" function in popcorn for a specific time.  All you can do is remove all cues, which is bad for us.

So, we have to assume that all cue'ed events will execute.  So, when we click on the question thumbnail, we execute `show_question` and move the time.  Then, `show_question` might (often does) execute again due to the cue event firing b/c of the time trigger.

So, I've set up an intermediate layer between the cue event and `show_question` that is keyed on time.  This is the `questionController`.  When a time is disabled in `questionController`, the `cue` event fires, but `show_question` will not be executed.

Then, to prevent the second `show_question` from executing, I have all `show_question` calls disable the time key at which they execute.  Then, that time key is automatically re-enabled .5 seconds later.  This re-enabling is implemented via another `cue` call which is not subject to a controller.

So, to answer your question specifically, the `show_question` has _already_ fired by the time the `enable` executes (they're both called via `cue`, and one is at an earlier time than the other, so any sane implementation would execute `show_question` first).  But, because it's "disabled", it's just a no-op.


On Jan 12, 2013, at 11:03 AM, Mike Wescott <notifications@github.com> wrote:

> In main/templates/exams/videotest.js:
> 
> > -                            firstQuestionId = questionsToShow;
> > -                            configureExamButton();
> > -                        } 
> > -                        $('#' + firstQuestionId).show(0, C2G.checkSubmitStatus);
> > -                        currentQuestionId = firstQuestionId;
> > -                        $('#exam-pane').fadeTo('fast', 1.0);
> > -                    };
> > -                };
> > -
> > -                window.popcornVideo.cue(cueSecond, showQuestion(questionsToShow));
> > -
> > +                C2G.videoSetup.questionController.install(cueSecond, C2G.videoSetup.showQuestion(questionsToShow, cueSecond));
> > +                window.popcornVideo.cue(cueSecond, C2G.videoSetup.questionController.execute_closure(cueSecond));
> > +                //We then set up a cue point 1 second after the original cue point
> > +                //when the original cue point is re-enabled.
> > +                window.popcornVideo.cue(parseFloat(cueSecond)+.5, C2G.videoSetup.questionController.enable_closure(cueSecond));
> Just making sure I understand completely. So with the enable_closure call, you effectively re-enable showQuestion to be called at that time, but does it execute because popcorn's cue method queues it up to execute as long as it's not blocked? In other words, it looks like what happens at "time + .5 seconds" is just that the showQuestion function simply becomes enabled, but it isn't explicitly invoked; does it still fire because it was basically just "on hold"?
> 
> —
> Reply to this email directly or view it on GitHub.
> 
>