diff --git a/HTML/Assets/Detectors/Lumilo/Critical_Struggle/critical_struggle.js b/HTML/Assets/Detectors/Lumilo/Critical_Struggle/critical_struggle.js index a4bde8d..c06de40 100644 --- a/HTML/Assets/Detectors/Lumilo/Critical_Struggle/critical_struggle.js +++ b/HTML/Assets/Detectors/Lumilo/Critical_Struggle/critical_struggle.js @@ -325,10 +325,10 @@ function clone(obj) { } -function secondsSince(initTime){ +function secondsSince(initTime){ var currTime = new Date(); diff = currTime.getTime() - initTime.getTime(); - console.log("time elapsed: ", diff/1000); + console.log("time elapsed: ", diff/1000) return (diff / 1000); } @@ -336,7 +336,7 @@ function checkTimeElapsed(initTime) { var timeDiff = secondsSince(initTime); if( timeDiff > (300-seedTime) ){ detector_output.history = JSON.stringify([attemptWindow, skillLevelsAttempts, initTime, onboardSkills]); - detector_output.value = "1, > 5 min" + detector_output.value = "1, > 5 min, " + elaborationString; detector_output.time = new Date(); mailer.postMessage(detector_output); postMessage(detector_output); @@ -344,7 +344,7 @@ function checkTimeElapsed(initTime) { } else if( timeDiff > (120-seedTime) ){ detector_output.history = JSON.stringify([attemptWindow, skillLevelsAttempts, initTime, onboardSkills]); - detector_output.value = "1, > 2 min" + detector_output.value = "1, > 2 min, " + elaborationString; detector_output.time = new Date(); mailer.postMessage(detector_output); postMessage(detector_output); @@ -352,15 +352,15 @@ function checkTimeElapsed(initTime) { } else if( timeDiff > (60-seedTime) ){ detector_output.history = JSON.stringify([attemptWindow, skillLevelsAttempts, initTime, onboardSkills]); - detector_output.value = "1, > 1 min" + detector_output.value = "1, > 1 min, " + elaborationString; detector_output.time = new Date(); mailer.postMessage(detector_output); postMessage(detector_output); console.log("output_data = ", detector_output); } - else if( timeDiff > (45-seedTime) ){ + else if( timeDiff > (45-seedTime) ){ detector_output.history = JSON.stringify([attemptWindow, skillLevelsAttempts, initTime, onboardSkills]); - detector_output.value = "1, > 45 s" + detector_output.value = "1, > 45 s, " + elaborationString; detector_output.time = new Date(); mailer.postMessage(detector_output); postMessage(detector_output); @@ -368,7 +368,7 @@ function checkTimeElapsed(initTime) { } else{ detector_output.history = JSON.stringify([attemptWindow, skillLevelsAttempts, initTime, onboardSkills]); - detector_output.value = "1, > " + seedTime.toString() + " s" + detector_output.value = "1, > " + seedTime.toString() + " s, " + elaborationString; detector_output.time = new Date(); mailer.postMessage(detector_output); postMessage(detector_output); @@ -454,19 +454,11 @@ function receive_transaction( e ){ var isWheelSpinning = detect_wheel_spinning(e, onboardSkills, stepCounter[currStep]); - if (isWheelSpinning){ - elaborationString = "not improving on some skills"; - } - else if (help_model_output == "ask teacher for help/try step"){ - elaborationString = "hints aren't helping"; - } - else{ - elaborationString = ""; - } - + attemptWindow.shift(); attemptWindow.push( (help_model_output == "ask teacher for help/try step" || isWheelSpinning) ? 1 : 0 ); var sumAskTeacherForHelp = attemptWindow.reduce(function(pv, cv) { return pv + cv; }, 0); + console.log(attemptWindow); console.log(help_model_output); console.log(isWheelSpinning); @@ -483,21 +475,36 @@ function receive_transaction( e ){ detector_output.transaction_id = e.data.transaction_id; //custom processing (insert code here) - if (detector_output.value=="0, > 0 s" && (sumAskTeacherForHelp >= threshold)){ + + // elaboration string + if (sumAskTeacherForHelp>=threshold){ + if (isWheelSpinning){ + elaborationString = "slow to master some skills"; + } + else{ + elaborationString = "hints aren't helping"; + } + } + else{ + elaborationString = ""; + } + + + if (detector_output.value.split(',')[0]=="0" && (sumAskTeacherForHelp >= threshold)){ initTime = new Date(); detector_output.history = JSON.stringify([attemptWindow, skillLevelsAttempts, initTime, onboardSkills]); - detector_output.value = "1, > " + seedTime.toString() + " s"; + detector_output.value = "1, > " + seedTime.toString() + " s, " + elaborationString; detector_output.time = new Date(); intervalID = setInterval( function() { checkTimeElapsed(initTime);} , 3000); } - else if (detector_output.value!="0, > 0 s" && (sumAskTeacherForHelp >= threshold)){ + else if (detector_output.value.split(',')[0]!="0" && (sumAskTeacherForHelp >= threshold)){ detector_output.history = JSON.stringify([attemptWindow, skillLevelsAttempts, initTime, onboardSkills]); detector_output.time = new Date(); } else{ - detector_output.value = "0, > 0 s"; + detector_output.value = "0, > 0 s, " + elaborationString; detector_output.history = JSON.stringify([attemptWindow, skillLevelsAttempts, initTime, onboardSkills]); detector_output.time = new Date(); @@ -568,7 +575,7 @@ self.onmessage = function ( e ) { initTime = new Date(all_history[2]); onboardSkills = all_history[3]; - if(detector_output.value!="0, > 0 s"){ + if(detector_output.value.split(',')[0]!="0"){ intervalID = setInterval( function() { checkTimeElapsed(initTime);} , 3000); } } diff --git a/HTML/Assets/Detectors/Lumilo/Struggle/struggle__moving_average.js b/HTML/Assets/Detectors/Lumilo/Struggle/struggle__moving_average.js index 8501388..ec3dd8c 100644 --- a/HTML/Assets/Detectors/Lumilo/Struggle/struggle__moving_average.js +++ b/HTML/Assets/Detectors/Lumilo/Struggle/struggle__moving_average.js @@ -20,12 +20,66 @@ var mailer; //based on "remembered" values across problem boundaries, here // (initialize these at the bottom of this file, inside of self.onmessage) var attemptWindow; +var intervalID; //declare and/or initialize any other custom global variables for this detector here var attemptCorrect; var windowSize = 7; var threshold = 1; -var timerId; var timerId2; var timerId3; var timerId4; var timerId5; +var initTime; +var elaborationString; +var seedTime = 25; + +function secondsSince(initTime){ + var currTime = new Date(); + diff = currTime.getTime() - initTime.getTime(); + console.log("time elapsed: ", diff/1000) + return (diff / 1000); +} + +function checkTimeElapsed(initTime) { + var timeDiff = secondsSince(initTime); + if( timeDiff > (300-seedTime) ){ + detector_output.history = JSON.stringify([attemptWindow, initTime]); + detector_output.value = "1, > 5 min, " + elaborationString; + detector_output.time = new Date(); + mailer.postMessage(detector_output); + postMessage(detector_output); + console.log("output_data = ", detector_output); + } + else if( timeDiff > (120-seedTime) ){ + detector_output.history = JSON.stringify([attemptWindow, initTime]); + detector_output.value = "1, > 2 min, " + elaborationString; + detector_output.time = new Date(); + mailer.postMessage(detector_output); + postMessage(detector_output); + console.log("output_data = ", detector_output); + } + else if( timeDiff > (60-seedTime) ){ + detector_output.history = JSON.stringify([attemptWindow, initTime]); + detector_output.value = "1, > 1 min, " + elaborationString; + detector_output.time = new Date(); + mailer.postMessage(detector_output); + postMessage(detector_output); + console.log("output_data = ", detector_output); + } + else if( timeDiff > (45-seedTime) ){ + detector_output.history = JSON.stringify([attemptWindow, initTime]); + detector_output.value = "1, > 45 s, " + elaborationString; + detector_output.time = new Date(); + mailer.postMessage(detector_output); + postMessage(detector_output); + console.log("output_data = ", detector_output); + } + else{ + detector_output.history = JSON.stringify([attemptWindow, initTime]); + detector_output.value = "1, > " + seedTime.toString() + " s, " + elaborationString; + detector_output.time = new Date(); + mailer.postMessage(detector_output); + postMessage(detector_output); + console.log("output_data = ", detector_output); + } +} function receive_transaction( e ){ @@ -63,58 +117,35 @@ function receive_transaction( e ){ detector_output.transaction_id = e.data.transaction_id; //custom processing (insert code here) - if (detector_output.value=="0, > 0 s" && (sumCorrect <= threshold)){ - detector_output.history = JSON.stringify(attemptWindow); - detector_output.value = "1, > 25 s" + + // elaboration string + if (sumCorrect<=threshold){ + elaborationString = "lots of errors"; + } + else{ + elaborationString = ""; + } + + + if (detector_output.value.split(',')[0]=="0" && (sumCorrect <= threshold)){ + initTime = new Date(); + detector_output.history = JSON.stringify([attemptWindow, initTime]); + detector_output.value = "1, > " + seedTime.toString() + " s, " + elaborationString; detector_output.time = new Date(); - timerId = setTimeout(function() { - detector_output.history = JSON.stringify(attemptWindow); - detector_output.value = "1, > 45 s" - detector_output.time = new Date(); - mailer.postMessage(detector_output); - postMessage(detector_output); - console.log("output_data = ", detector_output); }, - 20000) - timerId2 = setTimeout(function() { - detector_output.history = JSON.stringify(attemptWindow); - detector_output.value = "1, > 1 min" - detector_output.time = new Date(); - mailer.postMessage(detector_output); - postMessage(detector_output); - console.log("output_data = ", detector_output); }, - 35000) - timerId3 = setTimeout(function() { - detector_output.history = JSON.stringify(attemptWindow); - detector_output.value = "1, > 2 min" - detector_output.time = new Date(); - mailer.postMessage(detector_output); - postMessage(detector_output); - console.log("output_data = ", detector_output); }, - 95000) - timerId4 = setTimeout(function() { - detector_output.history = JSON.stringify(attemptWindow); - detector_output.value = "1, > 5 min" - detector_output.time = new Date(); - mailer.postMessage(detector_output); - postMessage(detector_output); - console.log("output_data = ", detector_output); }, - 275000) + intervalID = setInterval( function() { checkTimeElapsed(initTime);} , 3000); } - else if (detector_output.value!="0, > 0 s" && (sumCorrect <= threshold)){ - detector_output.history = JSON.stringify(attemptWindow); + else if (detector_output.value.split(',')[0]!="0" && (sumCorrect <= threshold)){ + detector_output.history = JSON.stringify([attemptWindow, initTime]); detector_output.time = new Date(); } else{ - detector_output.value = "0, > 0 s"; - detector_output.history = JSON.stringify(attemptWindow); + detector_output.value = "0, > 0 s, " + elaborationString; + detector_output.history = JSON.stringify([attemptWindow, initTime]); detector_output.time = new Date(); - clearTimeout(timerId); - clearTimeout(timerId2); - clearTimeout(timerId3); - clearTimeout(timerId4); + clearInterval(intervalID); } mailer.postMessage(detector_output); @@ -166,7 +197,13 @@ self.onmessage = function ( e ) { attemptWindow = Array.apply(null, Array(windowSize)).map(Number.prototype.valueOf,1); } else{ - attemptWindow = JSON.parse(detector_output.history); + var all_history = JSON.parse(detector_output.history); + attemptWindow = all_history[0]; + initTime = new Date(all_history[1]); + + if(detector_output.value.split(',')[0]!="0"){ + intervalID = setInterval( function() { checkTimeElapsed(initTime);} , 3000); + } } break; diff --git a/HTML/Assets/Detectors/Lumilo/System_Misuse/system_misuse.js b/HTML/Assets/Detectors/Lumilo/System_Misuse/system_misuse.js index 32414ca..48315cc 100644 --- a/HTML/Assets/Detectors/Lumilo/System_Misuse/system_misuse.js +++ b/HTML/Assets/Detectors/Lumilo/System_Misuse/system_misuse.js @@ -19,6 +19,9 @@ var mailer; //based on "remembered" values across problem boundaries, here // (initialize these at the bottom of this file, inside of self.onmessage) var attemptWindow; +var initTime; +var lastTrigger; +var intervalID; //declare and/or initialize any other custom global variables for this detector here... var stepCounter = {}; @@ -29,7 +32,7 @@ var help_variables = {"lastAction": "null", "lastHintLength": "", "lastSenseOfWhatToDo": false }; -var timerId; var timerId2; var timerId3; var timerId4; var timerId5; +var elaborationString; // //[optional] single out TUNABLE PARAMETERS below var windowSize = 7; //arbitrary: need to tune @@ -39,8 +42,61 @@ var newStepThreshold = 1; //currently arbitrary var familiarityThreshold = 0.4; var senseOfWhatToDoThreshold = 0.6; var hintIsHelpfulPlaceholder = true; //currently a dummy value (assumption that hint is always helpful...) +var seedTime = 25; + +function secondsSince(initTime){ + var currTime = new Date(); + diff = currTime.getTime() - initTime.getTime(); + console.log("time elapsed: ", diff/1000) + return (diff / 1000); +} + +function checkTimeElapsed(initTime) { + var timeDiff = secondsSince(initTime); + if( timeDiff > (300-seedTime) ){ + detector_output.history = JSON.stringify([attemptWindow, initTime]); + detector_output.value = "1, > 5 min, " + elaborationString; + detector_output.time = new Date(); + mailer.postMessage(detector_output); + postMessage(detector_output); + console.log("output_data = ", detector_output); + } + else if( timeDiff > (120-seedTime) ){ + detector_output.history = JSON.stringify([attemptWindow, initTime]); + detector_output.value = "1, > 2 min, " + elaborationString; + detector_output.time = new Date(); + mailer.postMessage(detector_output); + postMessage(detector_output); + console.log("output_data = ", detector_output); + } + else if( timeDiff > (60-seedTime) ){ + detector_output.history = JSON.stringify([attemptWindow, initTime]); + detector_output.value = "1, > 1 min, " + elaborationString; + detector_output.time = new Date(); + mailer.postMessage(detector_output); + postMessage(detector_output); + console.log("output_data = ", detector_output); + } + else if( timeDiff > (45-seedTime) ){ + detector_output.history = JSON.stringify([attemptWindow, initTime]); + detector_output.value = "1, > 45 s, " + elaborationString; + detector_output.time = new Date(); + mailer.postMessage(detector_output); + postMessage(detector_output); + console.log("output_data = ", detector_output); + } + else{ + detector_output.history = JSON.stringify([attemptWindow, initTime]); + detector_output.value = "1, > " + seedTime.toString() + " s, " + elaborationString; + detector_output.time = new Date(); + mailer.postMessage(detector_output); + postMessage(detector_output); + console.log("output_data = ", detector_output); + } +} +//############## function is_gaming(e){ return false; @@ -333,58 +389,47 @@ function receive_transaction( e ){ detector_output.transaction_id = e.data.transaction_id; //custom processing (insert code here) - if (detector_output.value=="0, > 0 s" && (sumAskTeacherForHelp >= threshold)){ - detector_output.history = JSON.stringify([attemptWindow]); - detector_output.value = "1, > 25 s" + + if(isGaming){lastTrigger="isGaming"} + else if(isAbusingHints){lastTrigger="isAbusingHints"} + else{lastTrigger="isNotDeliberate?"} + + // elaboration string + if (sumAskTeacherForHelp>=threshold){ + if (lastTrigger=="isGaming"){ + elaborationString = "frequent guessing, not trying?"; + } + else if (lastTrigger=="isAbusingHints"){ + elaborationString = "abusing hints?"; + } + else{ + elaborationString = "fast attempts in a row, not deliberate?"; + } + } + else{ + elaborationString = ""; + } + + + if (detector_output.value.split(',')[0]=="0" && (sumAskTeacherForHelp >= threshold)){ + initTime = new Date(); + detector_output.history = JSON.stringify([attemptWindow, initTime]); + detector_output.value = "1, > " + seedTime.toString() + " s, " + elaborationString; detector_output.time = new Date(); - timerId = setTimeout(function() { - detector_output.history = JSON.stringify([attemptWindow]); - detector_output.value = "1, > 45 s" - detector_output.time = new Date(); - mailer.postMessage(detector_output); - postMessage(detector_output); - console.log("output_data = ", detector_output); }, - 20000) - timerId2 = setTimeout(function() { - detector_output.history = JSON.stringify([attemptWindow]); - detector_output.value = "1, > 1 min" - detector_output.time = new Date(); - mailer.postMessage(detector_output); - postMessage(detector_output); - console.log("output_data = ", detector_output); }, - 35000) - timerId3 = setTimeout(function() { - detector_output.history = JSON.stringify([attemptWindow]); - detector_output.value = "1, > 2 min" - detector_output.time = new Date(); - mailer.postMessage(detector_output); - postMessage(detector_output); - console.log("output_data = ", detector_output); }, - 95000) - timerId4 = setTimeout(function() { - detector_output.history = JSON.stringify([attemptWindow]); - detector_output.value = "1, > 5 min" - detector_output.time = new Date(); - mailer.postMessage(detector_output); - postMessage(detector_output); - console.log("output_data = ", detector_output); }, - 275000) + intervalID = setInterval( function() { checkTimeElapsed(initTime);} , 3000); } - else if (detector_output.value!="0, > 0 s" && (sumAskTeacherForHelp >= threshold)){ - detector_output.history = JSON.stringify([attemptWindow]); + else if (detector_output.value.split(',')[0]!="0" && (sumAskTeacherForHelp >= threshold)){ + detector_output.history = JSON.stringify([attemptWindow, initTime]); detector_output.time = new Date(); } else{ - detector_output.value = "0, > 0 s"; - detector_output.history = JSON.stringify([attemptWindow]); + detector_output.value = "0, > 0 s, " + elaborationString; + detector_output.history = JSON.stringify([attemptWindow, initTime]); detector_output.time = new Date(); - clearTimeout(timerId); - clearTimeout(timerId2); - clearTimeout(timerId3); - clearTimeout(timerId4); + clearInterval(intervalID); } @@ -445,6 +490,12 @@ self.onmessage = function ( e ) { // var all_history = JSON.parse(detector_output.history); attemptWindow = all_history[0]; + initTime = new Date(all_history[1]); + lastTrigger = all_history[2]; + + if(detector_output.value.split(',')[0]!="0"){ + intervalID = setInterval( function() { checkTimeElapsed(initTime);} , 3000); + } } break; default: