Skip to content

Commit

Permalink
added explainable detectors; updated time-elapsed script in detectors…
Browse files Browse the repository at this point in the history
… that should have time elapsed persist across problem boundaries
  • Loading branch information
d19fe8 committed Jun 30, 2017
1 parent f27b81f commit d07c8c2
Show file tree
Hide file tree
Showing 3 changed files with 207 additions and 112 deletions.
53 changes: 30 additions & 23 deletions HTML/Assets/Detectors/Lumilo/Critical_Struggle/critical_struggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,50 +325,50 @@ 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);
}

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);
console.log("output_data = ", detector_output);
}
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);
console.log("output_data = ", detector_output);
}
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);
console.log("output_data = ", detector_output);
}
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);
Expand Down Expand Up @@ -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);
Expand All @@ -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();

Expand Down Expand Up @@ -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);
}
}
Expand Down
127 changes: 82 additions & 45 deletions HTML/Assets/Detectors/Lumilo/Struggle/struggle__moving_average.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ){
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
Loading

0 comments on commit d07c8c2

Please sign in to comment.