diff options
author | Palaparthy Adityachandra | 2020-11-18 18:45:21 +0530 |
---|---|---|
committer | GitHub | 2020-11-18 18:45:21 +0530 |
commit | 544c796a8b55e742975c6714b5bc0208a198df95 (patch) | |
tree | 3d1a43b712b0bbae35df087360403118066193e0 /yaksh/static | |
parent | a00348278009bcfdafaba9ba7e10383036b601f3 (diff) | |
parent | 5f02880d022053ed07ed218fd52d9e436f6455ee (diff) | |
download | online_test-544c796a8b55e742975c6714b5bc0208a198df95.tar.gz online_test-544c796a8b55e742975c6714b5bc0208a198df95.tar.bz2 online_test-544c796a8b55e742975c6714b5bc0208a198df95.zip |
Merge pull request #800 from adityacp/improve_video_tracking
Improve video tracking and lesson statistics
Diffstat (limited to 'yaksh/static')
-rw-r--r-- | yaksh/static/yaksh/js/show_toc.js | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/yaksh/static/yaksh/js/show_toc.js b/yaksh/static/yaksh/js/show_toc.js index 914ab1c..2bedc6a 100644 --- a/yaksh/static/yaksh/js/show_toc.js +++ b/yaksh/static/yaksh/js/show_toc.js @@ -27,10 +27,8 @@ $(document).ready(function() { var total_duration; player.on('ready loadedmetadata', event => { total_duration = parseInt(player.duration); + store_tracker_time(total_duration); $("#video_duration").val(get_time_in_hrs(total_duration)); - if (total_duration > 0) { - start_tracker((total_duration * 1000) / 4, player); - } }); player.on('timeupdate', event => { @@ -44,10 +42,17 @@ $(document).ready(function() { } else { if(player.fullscreen.active) player.fullscreen.exit(); + player.pause() url = $("#toc_"+content.id).val(); ajax_call(url, "GET", screen_lock=true); } } + if(markers.length > 0 && current_time >= markers[track_count]) { + track_count++; + var csrf = document.getElementById("track-form").elements[0].value; + ajax_call($("#track-form").attr("action"), $("#track-form").attr("method"), + $("#track-form").serialize(), csrf, screen_lock=false); + } }); player.on('ended', event => { var csrf = document.getElementById("track-form").elements[0].value; @@ -57,16 +62,11 @@ $(document).ready(function() { }); }); - -function start_tracker(slice_duration, player) { - setTimeout(function run() { - if(player && player.playing) { - var csrf = document.getElementById("track-form").elements[0].value; - ajax_call($("#track-form").attr("action"), $("#track-form").attr("method"), - $("#track-form").serialize(), csrf, screen_lock=false); - } - setTimeout(run, slice_duration); - }, slice_duration); +function store_tracker_time(duration) { + marker = duration / 4; + for(var i = marker; i <= duration - marker; i = i + marker) { + markers.push(i); + } } function show_topic(description, override) { |