<commit_before>(function(ADL){
    
    var debug = true;
    var log = function(message)
    {
        if (!debug) return false;
        try
        {
            console.log(message);
            return true;
        }
        catch(e){return false;}
    } 

    function PopcornVideo(player, comp) {
        var myplayer = player;
        var playerID = player.media.id;
        var firstQuartileHit = false;
        var halfwayHit = false;
        var thirdQuartileHit = false;
        var isTracking = true;
        var competency = comp;

        // Youtube videos don't have children
        var objectURI = player.media.children[0].src ? player.media.children[0].src : player.media.src;
        var videoActivity = {"id":objectURI, "definition":{"name": {"en-US":playerID}}};
        
        // Edit the actor inside of the wrapper or just include it here
        var actor = ADL.XAPIWrapper.lrs.actor ? ADL.XAPIWrapper.lrs.actor :
            {"account":{"name":"tester", "homePage":"uri:testaccount"}};

        var compContext = competency ? {"contextActivities":{"parent" : [{"id": "compID:" + competency}]}} : null 

        // Play event
        myplayer.on("play", function(){
            var currentTime = myplayer.currentTime()
            // This if is a youtube workaround - when replaying youtube vids the roundTime is the same as the duration
            if (currentTime == Math.round(myplayer.duration())){
                log('youtube video ' + playerID + ' launched weird')
                startstuff(true)
            }
            // Playing after pause
            else if (currentTime != 0){
                log('video ' + playerID + ' resumed')
                startstuff(false)
            }
            // Normal start when vid is launched
            else{
                log('video ' + playerID + ' launched')
                startstuff(true)
            }
        });

        // Every second event
        myplayer.on("timeupdate", function(){
            var currentTime = myplayer.roundTime()
            // If stmt to catch specific times - the hits get reset to false when video ends
            if (!firstQuartileHit && currentTime == Math.round(myplayer.duration() * .25)){
                log('video ' + playerID + ' first point')
                firstQuartileHit = true
                middleStuff("firstquartile", currentTime)
            }
            else if (!halfwayHit && currentTime == Math.round(myplayer.duration() * .5)){
                log('video ' + playerID + ' half point')
                halfwayHit = true
                middleStuff("halfway", currentTime)
            }
            else if (!thirdQuartileHit && currentTime == Math.round(myplayer.duration() * .75)){
                log('video ' + playerID + ' third point')
                thirdQuartileHit = true
                middleStuff("thirdquartile", currentTime)
            }
        });

        // Pause event
        myplayer.on("pause", function(){
            var currentTime = myplayer.roundTime()
            // If stmt is a youtube workaround - youtube vids pause right before they end
            if (currentTime != Math.round(myplayer.duration())){
                log('video ' + playerID + ' paused')
                pauseStuff(currentTime)
            }
         });

        // Seeked event
        myplayer.on("seeked", function(){
            var currentTime = myplayer.roundTime()
            // If try to replay movie, instead of playing it fires seeked
            if (currentTime != 0){
                log('seeked ' + playerID + ' to ' + currentTime)
                seekStuff(currentTime)
            }
            // Youtube workaround - videos seek to 0 when replayed or launched
            else{
                log('seeked to 0s so really launched ' + playerID)
                startstuff(true)
                // Reset video quartile states
                firstQuartileHit = halfwayHit = thirdQuartileHit = false;
            }
        });

        // Ended event
        myplayer.on("ended", function(){
            log('video ' + playerID + ' ended')
            endStuff(myplayer.duration())
        });    

        function startstuff(launched){
            var stmt = {"actor":actor, "object": videoActivity}
            if (compContext){
                stmt["context"] = compContext
            }

            if (launched){
                stmt["verb"] = ADL.verbs.launched
            }
            else{
                var resumeTime = "PT" + myplayer.roundTime() + "S";
                stmt["verb"] = ADL.verbs.resumed
                stmt["result"] = {"extensions":{"resultExt:resumed":resumeTime}}
            }
            report(stmt);
        }

        function middleStuff(quartile, benchTime) {
            var benchObj = {"id":objectURI + "#" + quartile, "definition":{"name":{"en-US":playerID + "#" + quartile}}};
            var bench = "PT" + benchTime + "S";
            var extKey = "resultExt:" + quartile
            var result = {"extensions":{}};
            

            var stmt = {"actor":actor,
                    "verb":ADL.verbs.progressed,
                    "object":benchObj,
                    "result":result}
            var context = {}
            if (compContext){
                context = compContext
                context["contextActivities"]["grouping"] = [{"id": objectURI}]
            }
            else{
                context = {"contextActivities":{"grouping" : [{"id": objectURI}]}};
            }
            stmt["context"] = context
            result["extensions"][extKey] = bench
            report(stmt);
        }

        function pauseStuff(pauseTime){
            var paused = "PT" + pauseTime + "S";
            var stmt = {"actor":actor, 
                    "verb":ADL.verbs.suspended,
                    "object":videoActivity, 
                    "result":{"extensions":{"resultExt:paused":paused}}}

            if (compContext){
                stmt["context"] = compContext
            }
            report(stmt);
        }

        function seekStuff(seekTime){
            var seeked = "PT" + seekTime + "S";
            var stmt = {"actor":actor, 
                    "verb":ADL.verbs.interacted,
                    "object":videoActivity, 
                    "result":{"extensions":{"resultExt:seeked": seeked}}}
            <commit_msg>changed stmt structure for comps<commit_after>(function(ADL){
    
    var debug = true;
    var log = function(message)
    {
        if (!debug) return false;
        try
        {
            console.log(message);
            return true;
        }
        catch(e){return false;}
    } 

    function PopcornVideo(player, comp) {
        var myplayer = player;
        var playerID = player.media.id;
        var firstQuartileHit = false;
        var halfwayHit = false;
        var thirdQuartileHit = false;
        var isTracking = true;
        var competency = comp;

        // Youtube videos don't have children
        var objectURI = player.media.children[0].src ? player.media.children[0].src : player.media.src;
        var videoActivity = {"id":objectURI, "definition":{"name": {"en-US":playerID}}};
        
        // Edit the actor inside of the wrapper or just include it here
        var actor = ADL.XAPIWrapper.lrs.actor ? ADL.XAPIWrapper.lrs.actor :
            {"account":{"name":"tester", "homePage":"uri:testaccount"}};

        var compContext = competency ? {"contextActivities":{"other" : [{"id": "compID:" + competency}]}} : null 

        // Play event
        myplayer.on("play", function(){
            var currentTime = myplayer.currentTime()
            // This if is a youtube workaround - when replaying youtube vids the roundTime is the same as the duration
            if (currentTime == Math.round(myplayer.duration())){
                log('youtube video ' + playerID + ' launched weird')
                startstuff(true)
            }
            // Playing after pause
            else if (currentTime != 0){
                log('video ' + playerID + ' resumed')
                startstuff(false)
            }
            // Normal start when vid is launched
            else{
                log('video ' + playerID + ' launched')
                startstuff(true)
            }
        });

        // Every second event
        myplayer.on("timeupdate", function(){
            var currentTime = myplayer.roundTime()
            // If stmt to catch specific times - the hits get reset to false when video ends
            if (!firstQuartileHit && currentTime == Math.round(myplayer.duration() * .25)){
                log('video ' + playerID + ' first point')
                firstQuartileHit = true
                middleStuff("firstquartile", currentTime)
            }
            else if (!halfwayHit && currentTime == Math.round(myplayer.duration() * .5)){
                log('video ' + playerID + ' half point')
                halfwayHit = true
                middleStuff("halfway", currentTime)
            }
            else if (!thirdQuartileHit && currentTime == Math.round(myplayer.duration() * .75)){
                log('video ' + playerID + ' third point')
                thirdQuartileHit = true
                middleStuff("thirdquartile", currentTime)
            }
        });

        // Pause event
        myplayer.on("pause", function(){
            var currentTime = myplayer.roundTime()
            // If stmt is a youtube workaround - youtube vids pause right before they end
            if (currentTime != Math.round(myplayer.duration())){
                log('video ' + playerID + ' paused')
                pauseStuff(currentTime)
            }
         });

        // Seeked event
        myplayer.on("seeked", function(){
            var currentTime = myplayer.roundTime()
            // If try to replay movie, instead of playing it fires seeked
            if (currentTime != 0){
                log('seeked ' + playerID + ' to ' + currentTime)
                seekStuff(currentTime)
            }
            // Youtube workaround - videos seek to 0 when replayed or launched
            else{
                log('seeked to 0s so really launched ' + playerID)
                startstuff(true)
                // Reset video quartile states
                firstQuartileHit = halfwayHit = thirdQuartileHit = false;
            }
        });

        // Ended event
        myplayer.on("ended", function(){
            log('video ' + playerID + ' ended')
            endStuff(myplayer.duration())
        });    

        function startstuff(launched){
            var stmt = {"actor":actor, "object": videoActivity}
            if (compContext){
                stmt["context"] = compContext
            }

            if (launched){
                stmt["verb"] = ADL.verbs.launched
            }
            else{
                var resumeTime = "PT" + myplayer.roundTime() + "S";
                stmt["verb"] = ADL.verbs.resumed
                stmt["result"] = {"extensions":{"resultExt:resumed":resumeTime}}
            }
            report(stmt);
        }

        function middleStuff(quartile, benchTime) {
            var benchObj = {"id":objectURI + "#" + quartile, "definition":{"name":{"en-US":playerID + "#" + quartile}}};
            var bench = "PT" + benchTime + "S";
            var extKey = "resultExt:" + quartile
            var result = {"extensions":{}};
            

            var stmt = {"actor":actor,
                    "verb":ADL.verbs.progressed,
                    "object":benchObj,
                    "result":result}
            var context = {}
            if (compContext){
                context = compContext
            }
            context["contextActivities"]["parent"] = [{"id": objectURI}];

            stmt["context"] = context
            result["extensions"][extKey] = bench
            report(stmt);
        }

        function pauseStuff(pauseTime){
            var paused = "PT" + pauseTime + "S";
            var stmt = {"actor":actor, 
                    "verb":ADL.verbs.suspended,
                    "object":videoActivity, 
                    "result":{"extensions":{"resultExt:paused":paused}}}

            if (compContext){
                stmt["context"] = compContext
            }
            report(stmt);
        }

        function seekStuff(seekTime){
            var seeked = "PT" + seekTime + "S";
            var stmt = {"actor":actor, 
                    "verb":ADL.verbs.interacted,
                    "object":videoActivity, 
                    "result":{"extensions":{"resultExt:seeked": seeked}}}
            
{'fraction_non_alphanumeric': 0.11929214725865066, 'fraction_numerical': 0.001738031284563122, 'mean_word_length': 1.5625506072874493, 'pattern_counts': {'":': 72, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6764261', 'n_tokens_mistral': 3390, 'n_tokens_neox': 3149, 'n_words': 787}