From d6c8d7a99c7eda671c7d7e82d7feb7ac657e08dc Mon Sep 17 00:00:00 2001 From: Ken Holstein Date: Thu, 8 Feb 2018 18:46:07 -0500 Subject: [PATCH] Delete student_doing_well__moving_average.js --- .../student_doing_well__moving_average.js | 176 ------------------ 1 file changed, 176 deletions(-) delete mode 100644 Test_Rig/Detectors/student_doing_well__moving_average.js diff --git a/Test_Rig/Detectors/student_doing_well__moving_average.js b/Test_Rig/Detectors/student_doing_well__moving_average.js deleted file mode 100644 index 9457b0b..0000000 --- a/Test_Rig/Detectors/student_doing_well__moving_average.js +++ /dev/null @@ -1,176 +0,0 @@ -//detector template - -//add output variable name below -var variableName = "student_doing_well" - -//initializations (do not touch) -var detector_output = {name: variableName, - category: "Dashboard", - value: "0, none", - history: "", - skill_names: "", - step_id: "", - transaction_id: "", - time: "" - }; -var mailer; - -//declare any custom global variables that will be initialized -//based on "remembered" values across problem boundaries, here -// (initialize these at the bottom of this file, inside of self.onmessage) -var attemptWindow; - -//declare and/or initialize any other custom global variables for this detector here -var attemptWindow = Array.apply(null, Array(windowSize)).map(Number.prototype.valueOf,0); -var windowSize = 10; -var threshold = 8; -var stepCounter = {}; - - -function is_first_attempt(e){ - - var currStep = e.data.tutor_data.selection; - - if(currStep in stepCounter){ - stepCounter[currStep] += 1; - return false; - } - else{ - stepCounter[currStep] = 1; - return true; - } - -} - -function receive_transaction( e ){ - //e is the data of the transaction from mailer from transaction assembler - - if(e.data.actor == 'student' && e.data.tool_data.selection !="done" && e.data.tool_data.action != "UpdateVariable"){ - isFirstAttempt = is_first_attempt(e); - } - - //set conditions under which transaction should be processed - //(i.e., to update internal state and history, without - //necessarily updating external state and history) - if(e.data.actor == 'student' && e.data.tool_data.selection !="done" && isFirstAttempt == true && e.data.tool_data.action != "UpdateVariable"){ - //do not touch - rawSkills = e.data.tutor_data.skills - var currSkills = [] - for (var property in rawSkills) { - if (rawSkills.hasOwnProperty(property)) { - currSkills.push(rawSkills[property].name + "/" + rawSkills[property].category) - } - } - detector_output.skill_names = currSkills; - detector_output.step_id = e.data.tutor_data.step_id; - - //custom processing (insert code here) - attemptCorrect = (e.data.tutor_data.action_evaluation.toLowerCase() == "correct") ? 1 : 0; - attemptWindow.shift(); - attemptWindow.push(attemptCorrect); - detector_output.history = JSON.stringify(attemptWindow); - - var sumCorrect = attemptWindow.reduce(function(pv, cv) { return pv + cv; }, 0); - console.log(attemptWindow); - - } - - //set conditions under which detector should update - //external state and history - if(e.data.actor == 'student' && e.data.tool_data.selection !="done" && isFirstAttempt == true && e.data.tool_data.action != "UpdateVariable"){ - detector_output.time = new Date(e.data.tool_data.tool_event_time); - detector_output.transaction_id = e.data.transaction_id; - - //custom processing (insert code here) - if (sumCorrect >= threshold){ - detector_output.value = "1"; - } - else{ - detector_output.value = "0"; - } - - if (offlineMode==false){ - mailer.postMessage(detector_output); - } - postMessage(detector_output); - console.log("output_data = ", detector_output); - } -} - - -self.onmessage = function ( event ) { - //console.log(variableName, " self.onmessage:", e, e.data, (e.data?e.data.commmand:null), (e.data?e.data.transaction:null), e.ports); - switch( event.data.command ) - { - case "offlineMode": - //console.log(event.data.message); - offlineMode = true; - receive_transaction({data: event.data.message}); - break; - case "offlineNewProblem": - console.log("new problem!"); - stepCounter = {}; - break; - case "offlineNewStudent": - console.log("new student!"); - detector_output.category = event.data.studentId; - detector_output.history = ""; - detector_output.value = "0, > 0 s"; - attemptWindow = Array.apply(null, Array(windowSize)).map(Number.prototype.valueOf,0); - stepCounter = {}; - break; - case "connectMailer": - mailer = e.ports[0]; - mailer.onmessage = receive_transaction; - break; - case "initialize": - for (initItem in event.data.initializer){ - if (event.data.initializer[initItem].name == variableName){ - detector_output.history = event.data.initializer[initItem].history; - detector_output.value = event.data.initializer[initItem].value; - } - } - - //optional: In "detectorForget", specify conditions under which a detector - //should NOT remember their most recent value and history (using the variable "detectorForget"). - //(e.g., setting the condition to "true" will mean that the detector - // will always be reset between problems... and setting the condition to "false" - // means that the detector will never be reset between problems) - // - // - // - detectorForget = false; - // - // - - if (detectorForget){ - detector_output.history = ""; - detector_output.value = 0; - } - - - //optional: If any global variables are based on remembered values across problem boundaries, - // these initializations should be written here - // - // - if (detector_output.history == "" || detector_output.history == null){ - attemptWindow = Array.apply(null, Array(windowSize)).map(Number.prototype.valueOf,0); - } - else{ - attemptWindow = JSON.parse(detector_output.history); - } - - if (offlineMode==false){ - detector_output.time = new Date(event.data.tool_data.tool_event_time); - mailer.postMessage(detector_output); - postMessage(detector_output); - console.log("output_data = ", detector_output); - } - - break; - default: - break; - - } - -} \ No newline at end of file