Skip to content

Instantly share code, notes, and snippets.

@jnothman
Created March 27, 2012 04:15
Show Gist options
  • Save jnothman/2212483 to your computer and use it in GitHub Desktop.
Save jnothman/2212483 to your computer and use it in GitHub Desktop.
Links to show Coursera lecture quizzes only
/*
On the coursera lecture index, execute this Javascript (via greasemonkey script, bookmarklet, etc) to show 'quizzes' links next to each lecture. Clicking it will open the lecture, but instead of showing the video, will:
1. Pause it
2. Show the first quiz
3. Upon clicking "skip" or "continue" on the quiz, proceed to the next
4. Repeat from 3.
5. Continue showing the video
Having watched a downloaded video, you can now easily do the in-lecture quizzes separately.
(Note: attemptToShow can probably be replaced by some appropriate event handling. And I haven't worked out how to nicely avoid step 5, by closing the video on completion of the last quiz. Extensions welcome!)
*/
(function() {
function showQuizzes() {
var el = document.getElementById('fancybox-frame');
if (!el)
return false;
var w = el.contentWindow, player = w.QL_player;
if (!player || !player.cue_points_installed)
return false;
player.mediaelement_handle.pause();
w.quiz_cue_point_queue = player.cue_points.slice();
w.continue_to_next_quiz(player.mediaelement_handle);
return true;
}
function attemptToShow() {
if (!showQuizzes()) {
setTimeout(attemptToShow, 100);
}
}
$('<a href="#">quizzes</a>')
.click(function(ev) {
var ll = $(ev.target).closest('.item_row').find('.lecture-link');
ll.click();
attemptToShow();
})
.insertAfter($('.lecture-link'));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment